mirror of https://gitee.com/bigwinds/arangodb
Adjust the stage to the now non-void pointered index implementation.
This commit is contained in:
parent
dae95de667
commit
cd6cc35def
|
@ -51,7 +51,7 @@ static int internalCounter = 0;
|
|||
static int first = 0;
|
||||
static int second = 0;
|
||||
static int third = 0;
|
||||
auto integerEdgeEnumerator = [] (int& start, std::vector<int>& result, void*& next, size_t&, bool&) {
|
||||
auto integerEdgeEnumerator = [] (int& start, std::vector<int>& result, int*& next, size_t&, bool&) {
|
||||
if (result.size() >= 3) {
|
||||
next = nullptr;
|
||||
} else if (next == nullptr) {
|
||||
|
@ -125,23 +125,23 @@ BOOST_FIXTURE_TEST_SUITE (PathEnumeratorTest, PathEnumeratorSetup)
|
|||
|
||||
BOOST_AUTO_TEST_CASE (test_fullPathEnumerator) {
|
||||
int startVertex = 1;
|
||||
PathEnumerator<int, int> it(integerEdgeEnumerator, integerVertexEnumerator, startVertex);
|
||||
TraversalPath<int, int> path;
|
||||
PathEnumerator<int, int, int> it(integerEdgeEnumerator, integerVertexEnumerator, startVertex);
|
||||
TraversalPath<int, int, int> path;
|
||||
for (int k = 1; k < 4; k++) {
|
||||
path = it.next();
|
||||
BOOST_CHECK_EQUAL(path.edges.size(), 1);
|
||||
BOOST_CHECK_EQUAL(path.vertices.size(), 2);
|
||||
BOOST_CHECK_EQUAL(path.edges.size(), (size_t)1);
|
||||
BOOST_CHECK_EQUAL(path.vertices.size(), (size_t)2);
|
||||
BOOST_CHECK_EQUAL(path.edges[0], k);
|
||||
for (int i = 1; i < 4; i++) {
|
||||
path = it.next();
|
||||
BOOST_CHECK_EQUAL(path.edges.size(), 2);
|
||||
BOOST_CHECK_EQUAL(path.vertices.size(), 3);
|
||||
BOOST_CHECK_EQUAL(path.edges.size(), (size_t)2);
|
||||
BOOST_CHECK_EQUAL(path.vertices.size(), (size_t)3);
|
||||
BOOST_CHECK_EQUAL(path.edges[0], k);
|
||||
BOOST_CHECK_EQUAL(path.edges[1], i);
|
||||
for (int j = 1; j < 4; j++) {
|
||||
path = it.next();
|
||||
BOOST_CHECK_EQUAL(path.edges.size(), 3);
|
||||
BOOST_CHECK_EQUAL(path.vertices.size(), 4);
|
||||
BOOST_CHECK_EQUAL(path.edges.size(), (size_t)3);
|
||||
BOOST_CHECK_EQUAL(path.vertices.size(), (size_t)4);
|
||||
BOOST_CHECK_EQUAL(path.edges[0], k);
|
||||
BOOST_CHECK_EQUAL(path.edges[1], i);
|
||||
BOOST_CHECK_EQUAL(path.edges[2], j);
|
||||
|
@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE (test_fullPathEnumerator) {
|
|||
}
|
||||
}
|
||||
path = it.next();
|
||||
BOOST_CHECK_EQUAL(path.edges.size(), 0);
|
||||
BOOST_CHECK_EQUAL(path.edges.size(), (size_t)0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -157,7 +157,7 @@ std::unordered_map<int, std::string const> const AstNode::TypeNames{
|
|||
{ static_cast<int>(NODE_TYPE_DISTINCT), "distinct" },
|
||||
{ static_cast<int>(NODE_TYPE_TRAVERSAL), "traversal" },
|
||||
{ static_cast<int>(NODE_TYPE_DIRECTION), "direction" },
|
||||
{ static_cast<int>(NODE_TYPE_COLLECTION_LIST), "collection list" }
|
||||
{ static_cast<int>(NODE_TYPE_COLLECTION_LIST), "collection list" },
|
||||
{ static_cast<int>(NODE_TYPE_OPERATOR_NARY_AND), "n-ary and" },
|
||||
{ static_cast<int>(NODE_TYPE_OPERATOR_NARY_OR), "n-ary or" }
|
||||
};
|
||||
|
|
|
@ -58,6 +58,7 @@ bool ConditionFinder::before (ExecutionNode* en) {
|
|||
case EN::UPDATE:
|
||||
case EN::UPSERT:
|
||||
case EN::RETURN:
|
||||
case EN::TRAVERSAL:
|
||||
// in these cases we simply ignore the intermediate nodes, note
|
||||
// that we have taken care of nodes that could throw exceptions
|
||||
// above.
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "Aql/WalkerWorker.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include <iostream> /// TODO: remove me.
|
||||
|
||||
using namespace triagens::aql;
|
||||
using namespace triagens::basics;
|
||||
|
|
|
@ -1990,6 +1990,7 @@ struct SortToIndexNode final : public WalkerWorker<ExecutionNode> {
|
|||
case EN::REMOTE:
|
||||
case EN::ILLEGAL:
|
||||
case EN::LIMIT: // LIMIT is criterion to stop
|
||||
case EN::TRAVERSAL:
|
||||
return true; // abort.
|
||||
|
||||
case EN::SORT: // pulling two sorts together is done elsewhere.
|
||||
|
@ -2684,6 +2685,7 @@ int triagens::aql::distributeFilternCalcToClusterRule (Optimizer* opt,
|
|||
case EN::SORT:
|
||||
case EN::INDEX:
|
||||
case EN::ENUMERATE_COLLECTION:
|
||||
case EN::TRAVERSAL:
|
||||
//do break
|
||||
stopSearching = true;
|
||||
break;
|
||||
|
@ -2779,6 +2781,7 @@ int triagens::aql::distributeSortToClusterRule (Optimizer* opt,
|
|||
case EN::REMOTE:
|
||||
case EN::LIMIT:
|
||||
case EN::INDEX:
|
||||
case EN::TRAVERSAL:
|
||||
case EN::ENUMERATE_COLLECTION:
|
||||
// For all these, we do not want to pull a SortNode further down
|
||||
// out to the DBservers, note that potential FilterNodes and
|
||||
|
@ -3050,8 +3053,9 @@ class RemoveToEnumCollFinder final : public WalkerWorker<ExecutionNode> {
|
|||
case EN::RETURN:
|
||||
case EN::NORESULTS:
|
||||
case EN::ILLEGAL:
|
||||
case EN::LIMIT:
|
||||
case EN::LIMIT:
|
||||
case EN::SORT:
|
||||
case EN::TRAVERSAL:
|
||||
case EN::INDEX: {
|
||||
// if we meet any of the above, then we abort . . .
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "Aql/TraversalBlock.h"
|
||||
#include "Utils/ShapedJsonTransformer.h"
|
||||
#include "Utils/SingleCollectionReadOnlyTransaction.h"
|
||||
#include <iostream> /// TODO: remove me.
|
||||
|
||||
using namespace std;
|
||||
using namespace triagens::basics;
|
||||
|
@ -238,7 +239,7 @@ AqlValue TraversalBlock::edgeToAqlValue (
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AqlValue TraversalBlock::pathToAqlValue (
|
||||
const TraversalPath<EdgeInfo, VertexId>& p
|
||||
const TraversalPath<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>& p
|
||||
) {
|
||||
// This json is freed by the AqlValue. No unique_ptr here.
|
||||
Json* path = new Json(Json::Object, 2);
|
||||
|
|
|
@ -272,7 +272,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AqlValue pathToAqlValue (
|
||||
const basics::TraversalPath<EdgeInfo, VertexId>& p
|
||||
const basics::TraversalPath<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>& p
|
||||
);
|
||||
|
||||
};
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "Aql/TraversalNode.h"
|
||||
#include "Aql/ExecutionPlan.h"
|
||||
#include "Aql/Ast.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace triagens::basics;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
|||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.0.2. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -114,10 +114,10 @@ extern int Aqldebug;
|
|||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 17 "arangod/Aql/grammar.y" /* yacc.c:1915 */
|
||||
#line 17 "arangod/Aql/grammar.y" /* yacc.c:1909 */
|
||||
|
||||
triagens::aql::AstNode* node;
|
||||
struct {
|
||||
|
@ -127,10 +127,8 @@ union YYSTYPE
|
|||
bool boolval;
|
||||
int64_t intval;
|
||||
|
||||
#line 131 "arangod/Aql/grammar.hpp" /* yacc.c:1915 */
|
||||
#line 131 "arangod/Aql/grammar.hpp" /* yacc.c:1909 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
|
|
@ -32,18 +32,10 @@
|
|||
#include "Utils/transactions.h"
|
||||
#include "Utils/V8ResolverGuard.h"
|
||||
#include "Utils/CollectionNameResolver.h"
|
||||
#include "V8/v8-conv.h"
|
||||
#include "V8/v8-utils.h"
|
||||
#include "V8Server/v8-vocbaseprivate.h"
|
||||
#include "V8Server/v8-wrapshapedjson.h"
|
||||
#include "V8Server/v8-vocindex.h"
|
||||
#include "V8Server/v8-collection.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/KeyGenerator.h"
|
||||
#include "VocBase/VocShaper.h"
|
||||
|
||||
#include <v8.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace triagens::basics;
|
||||
using namespace triagens::basics::traverser;
|
||||
|
@ -768,7 +760,7 @@ void DepthFirstTraverser::_defInternalFunctions () {
|
|||
auto direction = _opts.direction;
|
||||
auto edgeCols = _edgeCols;
|
||||
if (direction == TRI_EDGE_ANY) {
|
||||
_getEdge = [edgeCols] (VertexId& startVertex, std::vector<EdgeInfo>& edges, void*& last, size_t& eColIdx, bool& dir) {
|
||||
_getEdge = [edgeCols] (VertexId& startVertex, std::vector<EdgeInfo>& edges, TRI_doc_mptr_copy_t*& last, size_t& eColIdx, bool& dir) {
|
||||
std::vector<TRI_doc_mptr_copy_t> tmp;
|
||||
TRI_ASSERT(eColIdx < edgeCols.size());
|
||||
// TODO fill Statistics
|
||||
|
@ -827,7 +819,7 @@ void DepthFirstTraverser::_defInternalFunctions () {
|
|||
}
|
||||
};
|
||||
} else {
|
||||
_getEdge = [edgeCols, direction] (VertexId& startVertex, std::vector<EdgeInfo>& edges, void*& last, size_t& eColIdx, bool&) {
|
||||
_getEdge = [edgeCols, direction] (VertexId& startVertex, std::vector<EdgeInfo>& edges, TRI_doc_mptr_copy_t*& last, size_t& eColIdx, bool&) {
|
||||
std::vector<TRI_doc_mptr_copy_t> tmp;
|
||||
TRI_ASSERT(eColIdx < edgeCols.size());
|
||||
// Do not touch the bool parameter, as long as it is default the first encountered nullptr is final
|
||||
|
@ -858,13 +850,13 @@ void DepthFirstTraverser::_defInternalFunctions () {
|
|||
}
|
||||
|
||||
void DepthFirstTraverser::setStartVertex (VertexId& v) {
|
||||
_enumerator.reset(new PathEnumerator<EdgeInfo, VertexId>(_getEdge, _getVertex, v));
|
||||
_enumerator.reset(new PathEnumerator<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>(_getEdge, _getVertex, v));
|
||||
_done = false;
|
||||
}
|
||||
|
||||
size_t DepthFirstTraverser::skip (size_t amount) {
|
||||
size_t skipped = 0;
|
||||
TraversalPath<EdgeInfo, VertexId> p;
|
||||
TraversalPath<EdgeInfo, VertexId, TRI_doc_mptr_copy_t> p;
|
||||
for (size_t i = 0; i < amount; ++i) {
|
||||
p = next();
|
||||
if (p.edges.size() == 0) {
|
||||
|
@ -879,14 +871,14 @@ bool DepthFirstTraverser::hasMore () {
|
|||
return !_done;
|
||||
}
|
||||
|
||||
const TraversalPath<EdgeInfo, VertexId>& DepthFirstTraverser::next () {
|
||||
const TraversalPath<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>& DepthFirstTraverser::next () {
|
||||
TRI_ASSERT(!_done);
|
||||
if (_pruneNext) {
|
||||
_pruneNext = false;
|
||||
_enumerator->prune();
|
||||
}
|
||||
TRI_ASSERT(!_pruneNext);
|
||||
const TraversalPath<EdgeInfo, VertexId>& p = _enumerator->next();
|
||||
const TraversalPath<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>& p = _enumerator->next();
|
||||
size_t countEdges = p.edges.size();
|
||||
if (countEdges == 0) {
|
||||
_done = true;
|
||||
|
|
|
@ -262,7 +262,7 @@ namespace triagens {
|
|||
struct TraverserOptions {
|
||||
|
||||
private:
|
||||
std::function<bool (const TraversalPath<EdgeInfo, VertexId>& path)> pruningFunction;
|
||||
std::function<bool (const TraversalPath<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>& path)> pruningFunction;
|
||||
|
||||
public:
|
||||
TRI_edge_direction_e direction;
|
||||
|
@ -282,14 +282,14 @@ namespace triagens {
|
|||
{ };
|
||||
|
||||
void setPruningFunction (
|
||||
std::function<bool (const TraversalPath<EdgeInfo, VertexId>& path)> callback
|
||||
std::function<bool (const TraversalPath<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>& path)> callback
|
||||
) {
|
||||
pruningFunction = callback;
|
||||
usesPrune = true;
|
||||
}
|
||||
|
||||
bool shouldPrunePath (
|
||||
const TraversalPath<EdgeInfo, VertexId>& path
|
||||
const TraversalPath<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>& path
|
||||
) {
|
||||
if (!usesPrune) {
|
||||
return false;
|
||||
|
@ -328,13 +328,16 @@ namespace triagens {
|
|||
/// @brief internal cursor to enumerate the paths of a graph
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::unique_ptr<PathEnumerator<EdgeInfo, VertexId>> _enumerator;
|
||||
std::unique_ptr<PathEnumerator<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>> _enumerator;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief internal function to extract an edge
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::function<void(VertexId&, std::vector<EdgeInfo>&, void*&, size_t&, bool&)> _getEdge;
|
||||
std::function<void(VertexId&, std::vector<EdgeInfo>&,
|
||||
TRI_doc_mptr_copy_t*&,
|
||||
size_t&, bool&)>
|
||||
_getEdge;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief internal function to extract vertex information
|
||||
|
@ -384,7 +387,7 @@ namespace triagens {
|
|||
/// @brief Get the next possible path in the graph.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const TraversalPath<EdgeInfo, VertexId>& next ();
|
||||
const TraversalPath<EdgeInfo, VertexId, TRI_doc_mptr_copy_t>& next ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Prune the current path prefix. Do not evaluate it any further.
|
||||
|
|
|
@ -87,6 +87,7 @@ GraphFactory* GraphFactory::factory () {
|
|||
}
|
||||
|
||||
Graph const& GraphFactory::byName (TRI_vocbase_t* vocbase, std::string name) {
|
||||
_cache.clear(); //// TODO: clear cache from js graph management.
|
||||
auto outit = _cache.find(vocbase->_id);
|
||||
if (outit == _cache.end()) {
|
||||
// database not yet found.
|
||||
|
|
|
@ -1235,7 +1235,7 @@ namespace triagens {
|
|||
// --SECTION-- struct TraversalPath
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
template <typename edgeIdentifier, typename vertexIdentifier>
|
||||
template <typename edgeIdentifier, typename vertexIdentifier, typename edgeItem>
|
||||
struct TraversalPath {
|
||||
std::vector<edgeIdentifier> edges;
|
||||
std::vector<vertexIdentifier> vertices;
|
||||
|
@ -1246,7 +1246,7 @@ namespace triagens {
|
|||
// --SECTION-- class PathIterator
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
template <typename edgeIdentifier, typename vertexIdentifier>
|
||||
template <typename edgeIdentifier, typename vertexIdentifier, typename edgeItem>
|
||||
class PathEnumerator {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -1262,14 +1262,14 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief List of the last path is used to
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
TraversalPath<edgeIdentifier, vertexIdentifier> _traversalPath;
|
||||
TraversalPath<edgeIdentifier, vertexIdentifier, edgeItem> _traversalPath;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief The pointers returned for edge indexes on this path. Used to continue
|
||||
/// the search on respective levels.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::stack<void*> _lastEdges;
|
||||
std::stack<edgeItem*> _lastEdges;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief The boolean value indicating the direction for 'any' search
|
||||
|
@ -1290,7 +1290,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Function to get the next edge from index.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::function<void (vertexIdentifier&, std::vector<edgeIdentifier>&, void*&, size_t&, bool&)> _getEdge;
|
||||
std::function<void (vertexIdentifier&, std::vector<edgeIdentifier>&, edgeItem*&, size_t&, bool&)> _getEdge;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1305,7 +1305,7 @@ namespace triagens {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
PathEnumerator (
|
||||
std::function<void(vertexIdentifier&, std::vector<edgeIdentifier>&, void*&, size_t&, bool&)> getEdge,
|
||||
std::function<void(vertexIdentifier&, std::vector<edgeIdentifier>&, edgeItem*&, size_t&, bool&)> getEdge,
|
||||
std::function<vertexIdentifier (edgeIdentifier&, vertexIdentifier&)> getVertex,
|
||||
vertexIdentifier& startVertex
|
||||
) : _getEdge(getEdge),
|
||||
|
@ -1329,7 +1329,7 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Get the next Path element from the traversal.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const TraversalPath<edgeIdentifier, vertexIdentifier>& next () {
|
||||
const TraversalPath<edgeIdentifier, vertexIdentifier, edgeItem>& next () {
|
||||
if (_lastEdges.size() == 0) {
|
||||
_traversalPath.edges.clear();
|
||||
_traversalPath.vertices.clear();
|
||||
|
|
Loading…
Reference in New Issue