[
https://issues.apache.org/jira/browse/TINKERPOP-2256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
stephen mallette closed TINKERPOP-2256.
---------------------------------------
Resolution: Done
Assignee: stephen mallette
Fix Version/s: 3.5.0
3.4.3
3.3.8
> processAllStarts of AggregateStep should only be called when barrier is empty
> -----------------------------------------------------------------------------
>
> Key: TINKERPOP-2256
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2256
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Reporter: Wang Xiyu
> Assignee: stephen mallette
> Priority: Minor
> Fix For: 3.3.8, 3.4.3, 3.5.0
>
>
> Currently the function processNextStart , hasNextBarrier, nextBarrier of
> AggregateStep all call AggregateStep.processAllStarts:
> {code:java}
> protected Traverser.Admin<S> processNextStart() {
> this.processAllStarts();
> return this.barrier.remove();
> }{code}
> Every time we get a traverser from AggregateStep,
> AggregateStep.processAllStarts will be called. Then processAllStarts calls
> this.starts.hasNext().
> {code:java}
> @Override
> public void processAllStarts() {
> if (this.starts.hasNext()) {
> final BulkSet<Object> bulkSet = new BulkSet<>();
> while (this.starts.hasNext()) {
> final Traverser.Admin<S> traverser = this.starts.next();
> bulkSet.add(TraversalUtil.applyNullable(traverser,
> this.aggregateTraversal), traverser.bulk());
> traverser.setStepId(this.getNextStep().getId()); // when
> barrier is reloaded, the traversers should be at the next step
> this.barrier.add(traverser);
> }
> this.getTraversal().getSideEffects().add(this.sideEffectKey,
> bulkSet);
> }
> }
> {code}
> It results in a lot of hasNext call.
> As document says "The step uses [eager
> evaluation|http://en.wikipedia.org/wiki/Eager_evaluation] in that no objects
> continue on until all previous objects have been fully aggregated." maybe we
> can limit the AggregateStep.processAllStarts only be called once.
>
>
>
> We found this when we run DSL like this :
> {code:java}
> g.V().has('name','wxy').repeat(both("knows").simplePath()).emit().times(2).aggregate("friends"){code}
> and the plan is like this :
> {code:java}
> GraphStep(vertex,[name.eq(wxy)]),
> RepeatStep([VertexStep(BOTH,[knows],vertex), PathFilterStep(simple),
> RepeatEndStep],until(loops(2)),emit(true)), AggregateStep(friends)
> {code}
> Then we found thousands of calls to GraphStep(vertex,[name.eq(wxy)]).hasNext.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)