Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions arangod/Graph/Enumerators/WeightedTwoSidedEnumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,13 @@ class WeightedTwoSidedEnumerator {
return _haveSeenOtherSide;
}

auto setForbiddenVertices(std::shared_ptr<VertexSet> forbidden) -> void
requires HasForbidden<PathValidatorType>
{
auto setForbiddenVertices(std::shared_ptr<VertexSet> forbidden)
-> void requires HasForbidden<PathValidatorType> {
_validator.setForbiddenVertices(std::move(forbidden));
};

auto setForbiddenEdges(std::shared_ptr<EdgeSet> forbidden) -> void
requires HasForbidden<PathValidatorType>
{
auto setForbiddenEdges(std::shared_ptr<EdgeSet> forbidden)
-> void requires HasForbidden<PathValidatorType> {
_validator.setForbiddenEdges(std::move(forbidden));
};

Expand Down Expand Up @@ -395,22 +393,19 @@ class WeightedTwoSidedEnumerator {
*/
auto stealStats() -> aql::TraversalStats;

auto setForbiddenVertices(std::shared_ptr<VertexSet> forbidden) -> void
requires HasForbidden<PathValidatorType>
{
auto setForbiddenVertices(std::shared_ptr<VertexSet> forbidden)
-> void requires HasForbidden<PathValidatorType> {
_left.setForbiddenVertices(forbidden);
_right.setForbiddenVertices(std::move(forbidden));
};

auto setForbiddenEdges(std::shared_ptr<EdgeSet> forbidden) -> void
requires HasForbidden<PathValidatorType>
{
auto setForbiddenEdges(std::shared_ptr<EdgeSet> forbidden)
-> void requires HasForbidden<PathValidatorType> {
_left.setForbiddenEdges(forbidden);
_right.setForbiddenEdges(std::move(forbidden));
};

private:
[[nodiscard]] auto searchDone() const -> bool;
private : [[nodiscard]] auto searchDone() const -> bool;
// Ensure that we have fetched all vertices in the _results list. Otherwise,
// we will not be able to generate the resulting path
auto fetchResults() -> void;
Expand Down
8 changes: 6 additions & 2 deletions arangod/Graph/PathManagement/PathValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,13 @@ auto PathValidator<ProviderType, PathStore, vertexUniqueness, edgeUniqueness>::
return true;
}

auto collectionName = step.getCollectionName();
auto collectionNameResult = step.getVertex().collectionName();
if (collectionNameResult.fail()) {
THROW_ARANGO_EXCEPTION(collectionNameResult.result());
}

if (std::find(allowedCollections.begin(), allowedCollections.end(),
collectionName) != allowedCollections.end()) {
collectionNameResult.get()) != allowedCollections.end()) {
// found in allowed collections => allowed
return true;
}
Expand Down
16 changes: 1 addition & 15 deletions arangod/Graph/Providers/BaseStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <velocypack/HashedStringRef.h>
#include "Basics/ResultT.h"
#include "Basics/Exceptions.h"

#include <numeric>

Expand Down Expand Up @@ -56,21 +57,6 @@ class BaseStep {

double getWeight() const { return _weight; }

[[nodiscard]] ResultT<std::pair<std::string, size_t>> extractCollectionName(
arangodb::velocypack::HashedStringRef const& idHashed) const {
size_t pos = idHashed.find('/');
if (pos == std::string::npos) {
// Invalid input. If we get here somehow we managed to store invalid
// _from/_to values or the traverser did a let an illegal start through
TRI_ASSERT(false);
return Result{TRI_ERROR_GRAPH_INVALID_EDGE,
"edge contains invalid value " + idHashed.toString()};
}

std::string colName = idHashed.substr(0, pos).toString();
return std::make_pair(std::move(colName), pos);
}

private:
size_t _previous;
size_t _depth;
Expand Down
8 changes: 0 additions & 8 deletions arangod/Graph/Steps/ClusterProviderStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ class ClusterProviderStep : public arangodb::graph::BaseStep {
// beware: returns a *copy* of the edge id
[[nodiscard]] EdgeType getEdgeIdentifier() const { return _edge.getID(); }

[[nodiscard]] std::string getCollectionName() const {
auto collectionNameResult = extractCollectionName(_vertex.getID());
if (collectionNameResult.fail()) {
THROW_ARANGO_EXCEPTION(collectionNameResult.result());
}
return collectionNameResult.get().first;
}

friend auto operator<<(std::ostream& out, ClusterProviderStep const& step)
-> std::ostream&;

Expand Down
13 changes: 0 additions & 13 deletions arangod/Graph/Steps/SingleServerProviderStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,6 @@ class SingleServerProviderStep : public arangodb::graph::BaseStep {
// beware: will return a *copy* of the edge id
EdgeType getEdgeIdentifier() const { return _edge.getID(); }

std::string getCollectionName() const {
/*
* Future optimization: When re-implementing the documentFastPathLocal
* method to support string refs or either string views, we can improve this
* section here as well.
*/
auto collectionNameResult = extractCollectionName(_vertex.getID());
if (collectionNameResult.fail()) {
THROW_ARANGO_EXCEPTION(collectionNameResult.result());
}
return collectionNameResult.get().first;
};

friend auto operator<<(std::ostream& out,
SingleServerProviderStep const& step) -> std::ostream&;

Expand Down
1 change: 1 addition & 0 deletions arangod/Graph/Types/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target_sources(arango_graph PRIVATE
VertexRef.cpp
UniquenessLevel.cpp
ValidationResult.cpp)
4 changes: 4 additions & 0 deletions arangod/Graph/Types/VertexRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "Basics/ResultT.h"

#include <velocypack/HashedStringRef.h>

#include <compare>
Expand Down Expand Up @@ -57,6 +59,8 @@ class VertexRef {

operator velocypack::HashedStringRef() { return _vertex; }

[[nodiscard]] auto collectionName() const -> ResultT<std::string_view>;

private:
RefType _vertex;
};
Expand Down
8 changes: 0 additions & 8 deletions tests/Mocks/MockGraphProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,6 @@ class MockGraphProvider {
return _edge.getID();
}

std::string getCollectionName() const {
auto collectionNameResult = extractCollectionName(_vertex.getID());
if (collectionNameResult.fail()) {
THROW_ARANGO_EXCEPTION(collectionNameResult.result());
}
return collectionNameResult.get().first;
};

void setLocalSchreierIndex(size_t index) {
TRI_ASSERT(index != std::numeric_limits<size_t>::max());
TRI_ASSERT(!hasLocalSchreierIndex());
Expand Down