コード例 #1
0
        public override TraversalBranch Next(TraversalContext metadata)
        {
            TraversalBranch branch        = NextBranchFromCurrentSelector(metadata, false);
            Entry           state         = StateForCurrentSelector;
            AtomicInteger   previousDepth = state.Depth;

            if (branch != null && branch.Length() == previousDepth.get())
            {               // Same depth as previous branch returned from this side.
                return(branch);
            }

            if (branch != null)
            {
                _totalDepth.set(CurrentSide(), branch.Length());
            }
            if ((_stopDescentOnResult && (metadata.NumberOfPathsReturned > 0)) || (_totalDepth.get() > (_maxDepth + 1)))
            {
                NextSelector();
                return(null);
            }

            if (branch != null)
            {
                previousDepth.set(branch.Length());
                state.Branch = branch;
            }
            BranchSelector  otherSelector = NextSelector();
            Entry           otherState    = StateForCurrentSelector;
            TraversalBranch otherBranch   = otherState.Branch;

            if (otherBranch != null)
            {
                otherState.Branch = null;
                return(otherBranch);
            }

            otherBranch = otherSelector.Next(metadata);
            if (otherBranch != null)
            {
                return(otherBranch);
            }
            else
            {
                return(branch);
            }
        }
コード例 #2
0
        internal BidirectionalTraverserIterator(Resource resource, MonoDirectionalTraversalDescription start, MonoDirectionalTraversalDescription end, SideSelectorPolicy sideSelector, Org.Neo4j.Graphdb.traversal.BranchCollisionPolicy collisionPolicy, PathEvaluator collisionEvaluator, int maxDepth, IEnumerable <Node> startNodes, IEnumerable <Node> endNodes) : base(resource)
        {
            this._sides[Direction.OUTGOING] = new Side(start);
            this._sides[Direction.INCOMING] = new Side(end);
            this._uniqueness = MakeSureStartAndEndHasSameUniqueness(start, end);

            // A little chicken-and-egg problem. This happens when constructing the start/end
            // selectors and they initially call evaluate() and isUniqueFirst, where the selector is used.
            // Solved this way for now, to have it return the start side to begin with.
            this._selector = FixedSide(Direction.OUTGOING);
            BranchSelector startSelector = start.BranchOrdering.create(new AsOneStartBranch(this, startNodes, start.InitialState, start.UniquenessConflict), start.Expander);

            this._selector = FixedSide(Direction.INCOMING);
            BranchSelector endSelector = end.BranchOrdering.create(new AsOneStartBranch(this, endNodes, end.InitialState, start.UniquenessConflict), end.Expander);

            this._selector          = sideSelector.Create(startSelector, endSelector, maxDepth);
            this._collisionDetector = collisionPolicy.Create(collisionEvaluator, _uniqueness.checkFull);
        }
コード例 #3
0
 internal MonoDirectionalTraverserIterator(Resource resource, UniquenessFilter uniqueness, PathExpander expander, BranchOrderingPolicy order, PathEvaluator evaluator, IEnumerable <Node> startNodes, InitialBranchState initialState, UniquenessFactory uniquenessFactory) : base(resource)
 {
     this._uniqueness = uniqueness;
     this._evaluator  = evaluator;
     this._selector   = order.Create(new AsOneStartBranch(this, startNodes, initialState, uniquenessFactory), expander);
 }
コード例 #4
0
 public AlternatingSelectorOrderer(BranchSelector startSelector, BranchSelector endSelector) : base(startSelector, endSelector)
 {
 }
コード例 #5
0
 public LevelSelectorOrderer(BranchSelector startSelector, BranchSelector endSelector, bool stopDescentOnResult, int maxDepth) : base(startSelector, endSelector)
 {
     this._stopDescentOnResult = stopDescentOnResult;
     this._maxDepth            = maxDepth;
 }