mirror of https://gitee.com/bigwinds/arangodb
Moved String->VertexId conversion into the general traverser. It is required outside of V8Server
This commit is contained in:
parent
430eb2fd07
commit
aa8e1daaf7
|
@ -63,34 +63,6 @@ static VertexId ExtractToId (TRI_doc_mptr_copy_t const& ptr) {
|
|||
TRI_EXTRACT_MARKER_TO_KEY(&ptr));
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Helper to transform a vertex _id string to VertexId struct.
|
||||
/// NOTE: Make sure the given string is not freed as long as the resulting
|
||||
/// VertexId is in use
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VertexId triagens::arango::traverser::IdStringToVertexId (
|
||||
CollectionNameResolver const* resolver,
|
||||
string const& vertex
|
||||
) {
|
||||
size_t split;
|
||||
char const* str = vertex.c_str();
|
||||
|
||||
if (! TRI_ValidateDocumentIdKeyGenerator(str, &split)) {
|
||||
throw TRI_ERROR_ARANGO_INVALID_KEY_GENERATOR;
|
||||
}
|
||||
|
||||
string const collectionName = vertex.substr(0, split);
|
||||
auto cid = resolver->getCollectionIdCluster(collectionName);
|
||||
|
||||
if (cid == 0) {
|
||||
throw TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||
}
|
||||
return VertexId(cid, const_cast<char *>(str + split + 1));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Expander for Multiple edge collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -84,12 +84,6 @@ namespace triagens {
|
|||
namespace arango {
|
||||
namespace traverser {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Helper function to convert an _id string into a VertexId
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
VertexId IdStringToVertexId (triagens::arango::CollectionNameResolver const* resolver,
|
||||
std::string const& vertex);
|
||||
|
||||
// A collection of shared options used in several functions.
|
||||
// Should not be used directly, use specialization instead.
|
||||
struct BasicOptions {
|
||||
|
|
|
@ -29,9 +29,36 @@
|
|||
|
||||
#include "Traverser.h"
|
||||
#include "Basics/json-utilities.h"
|
||||
#include "VocBase/KeyGenerator.h"
|
||||
|
||||
using TraverserExpression = triagens::arango::traverser::TraverserExpression;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Helper to transform a vertex _id string to VertexId struct.
|
||||
/// NOTE: Make sure the given string is not freed as long as the resulting
|
||||
/// VertexId is in use
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
triagens::arango::traverser::VertexId triagens::arango::traverser::IdStringToVertexId (
|
||||
CollectionNameResolver const* resolver,
|
||||
std::string const& vertex
|
||||
) {
|
||||
size_t split;
|
||||
char const* str = vertex.c_str();
|
||||
|
||||
if (! TRI_ValidateDocumentIdKeyGenerator(str, &split)) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD);
|
||||
}
|
||||
|
||||
std::string const collectionName = vertex.substr(0, split);
|
||||
auto cid = resolver->getCollectionIdCluster(collectionName);
|
||||
|
||||
if (cid == 0) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
|
||||
}
|
||||
return VertexId(cid, const_cast<char *>(str + split + 1));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief transforms the expression into json
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -42,48 +42,6 @@ namespace triagens {
|
|||
namespace arango {
|
||||
namespace traverser {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- struct TraverserExpression
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class TraverserExpression {
|
||||
public:
|
||||
|
||||
bool isEdgeAccess;
|
||||
triagens::aql::AstNodeType comparisonType;
|
||||
triagens::aql::AstNode const* varAccess;
|
||||
triagens::basics::Json* compareTo;
|
||||
|
||||
TraverserExpression (
|
||||
bool pisEdgeAccess,
|
||||
triagens::aql::AstNodeType pcomparisonType,
|
||||
triagens::aql::AstNode const* pvarAccess
|
||||
) : isEdgeAccess(pisEdgeAccess),
|
||||
comparisonType(pcomparisonType),
|
||||
varAccess(pvarAccess),
|
||||
compareTo(nullptr) {
|
||||
}
|
||||
|
||||
virtual ~TraverserExpression () {
|
||||
if (compareTo != nullptr) {
|
||||
delete compareTo;
|
||||
}
|
||||
}
|
||||
|
||||
void toJson (triagens::basics::Json& json,
|
||||
TRI_memory_zone_t* zone) const;
|
||||
|
||||
bool matchesCheck (TRI_doc_mptr_t& element,
|
||||
TRI_document_collection_t* collection,
|
||||
CollectionNameResolver* resolver) const;
|
||||
|
||||
private:
|
||||
|
||||
bool recursiveCheck (triagens::aql::AstNode const*,
|
||||
DocumentAccessor&) const;
|
||||
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- struct VertexId
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -126,6 +84,55 @@ namespace triagens {
|
|||
// EdgeId and VertexId are similar here. both have a key and a cid
|
||||
typedef VertexId EdgeId;
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Helper function to convert an _id string into a VertexId
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
VertexId IdStringToVertexId (triagens::arango::CollectionNameResolver const* resolver,
|
||||
std::string const& vertex);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- struct TraverserExpression
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class TraverserExpression {
|
||||
public:
|
||||
|
||||
bool isEdgeAccess;
|
||||
triagens::aql::AstNodeType comparisonType;
|
||||
triagens::aql::AstNode const* varAccess;
|
||||
triagens::basics::Json* compareTo;
|
||||
|
||||
TraverserExpression (
|
||||
bool pisEdgeAccess,
|
||||
triagens::aql::AstNodeType pcomparisonType,
|
||||
triagens::aql::AstNode const* pvarAccess
|
||||
) : isEdgeAccess(pisEdgeAccess),
|
||||
comparisonType(pcomparisonType),
|
||||
varAccess(pvarAccess),
|
||||
compareTo(nullptr) {
|
||||
}
|
||||
|
||||
virtual ~TraverserExpression () {
|
||||
if (compareTo != nullptr) {
|
||||
delete compareTo;
|
||||
}
|
||||
}
|
||||
|
||||
void toJson (triagens::basics::Json& json,
|
||||
TRI_memory_zone_t* zone) const;
|
||||
|
||||
bool matchesCheck (TRI_doc_mptr_t& element,
|
||||
TRI_document_collection_t* collection,
|
||||
CollectionNameResolver* resolver) const;
|
||||
|
||||
private:
|
||||
|
||||
bool recursiveCheck (triagens::aql::AstNode const*,
|
||||
DocumentAccessor&) const;
|
||||
|
||||
};
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class TraversalPath
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue