private void configureStartAndEndSteps(final Traversal.Admin<?, ?> whereTraversal) { ConnectiveStrategy.instance().apply(whereTraversal); //// START STEP to WhereStartStep final Step<?, ?> startStep = whereTraversal.getStartStep(); if (startStep instanceof ConnectiveStep || startStep instanceof NotStep) { // for conjunction- and not-steps ((TraversalParent) startStep).getLocalChildren().forEach(this::configureStartAndEndSteps); } else if (StartStep.isVariableStartStep(startStep)) { // as("a").out()... traversals final String label = startStep.getLabels().iterator().next(); this.scopeKeys.add(label); TraversalHelper.replaceStep(startStep, new WhereStartStep(whereTraversal, label), whereTraversal); } else if (!whereTraversal.getEndStep().getLabels().isEmpty()) { // ...out().as("a") traversals TraversalHelper.insertBeforeStep(new WhereStartStep(whereTraversal, null), (Step) startStep, whereTraversal); } //// END STEP to WhereEndStep final Step<?, ?> endStep = whereTraversal.getEndStep(); if (!endStep.getLabels().isEmpty()) { if (endStep.getLabels().size() > 1) throw new IllegalArgumentException("The end step of a where()-traversal can only have one label: " + endStep); final String label = endStep.getLabels().iterator().next(); this.scopeKeys.add(label); endStep.removeLabel(label); whereTraversal.addStep(new WhereEndStep(whereTraversal, label)); } }
} else if (startStep instanceof WhereTraversalStep) { // necessary for GraphComputer so the projection is not select'd from a path final WhereTraversalStep<?> whereStep = (WhereTraversalStep<?>) startStep; TraversalHelper.insertBeforeStep(new MatchStartStep(matchTraversal, this.pullOutVariableStartStepToParent(whereStep)), (Step) whereStep, matchTraversal); // where(as('a').out()) -> as('a').where(out()) } else if (startStep instanceof WherePredicateStep) { // necessary for GraphComputer so the projection is not select'd from a path final WherePredicateStep<?> whereStep = (WherePredicateStep<?>) startStep; TraversalHelper.insertBeforeStep(new MatchStartStep(matchTraversal, whereStep.getStartKey().orElse(null)), (Step) whereStep, matchTraversal); // where('a',eq('b')) --> as('a').where(eq('b')) whereStep.removeStartKey(); } else {
final Step barrier = (Step) TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, computerTraversal).orElse(null); if (MessagePassingReductionStrategy.insertElementId(barrier)) // out().count() -> out().id().count() TraversalHelper.insertBeforeStep(new IdStep(computerTraversal), barrier, computerTraversal); if (!(MessagePassingReductionStrategy.endsWithElement(null == barrier ? computerTraversal.getEndStep() : barrier))) { Traversal.Admin newChildTraversal = new DefaultGraphTraversal<>();
TraversalHelper.insertBeforeStep(new RangeGlobalStep<>(traversal, 0L, highRange), curr, traversal);
final String generatedLabel = PathProcessorStrategy.generateLabel(); if (selectOneStep.getPreviousStep() instanceof EmptyStep) { TraversalHelper.insertBeforeStep(new IdentityStep<>(traversal), selectOneStep, traversal); index++;
TraversalHelper.insertBeforeStep(this.sqlgStep, step, this.traversal); return true;
TraversalHelper.insertBeforeStep(this.sqlgStep, step, this.traversal); return true;
private void configureStartAndEndSteps(final Traversal.Admin<?, ?> whereTraversal) { ConnectiveStrategy.instance().apply(whereTraversal); //// START STEP to WhereStartStep final Step<?, ?> startStep = whereTraversal.getStartStep(); if (startStep instanceof ConnectiveStep || startStep instanceof NotStep) { // for conjunction- and not-steps ((TraversalParent) startStep).getLocalChildren().forEach(this::configureStartAndEndSteps); } else if (StartStep.isVariableStartStep(startStep)) { // as("a").out()... traversals final String label = startStep.getLabels().iterator().next(); this.scopeKeys.add(label); TraversalHelper.replaceStep(startStep, new WhereStartStep(whereTraversal, label), whereTraversal); } else if (!whereTraversal.getEndStep().getLabels().isEmpty()) { // ...out().as("a") traversals TraversalHelper.insertBeforeStep(new WhereStartStep(whereTraversal, null), (Step) startStep, whereTraversal); } //// END STEP to WhereEndStep final Step<?, ?> endStep = whereTraversal.getEndStep(); if (!endStep.getLabels().isEmpty()) { if (endStep.getLabels().size() > 1) throw new IllegalArgumentException("The end step of a where()-traversal can only have one label: " + endStep); final String label = endStep.getLabels().iterator().next(); this.scopeKeys.add(label); endStep.removeLabel(label); whereTraversal.addStep(new WhereEndStep(whereTraversal, label)); } }
} else if (startStep instanceof WhereTraversalStep) { // necessary for GraphComputer so the projection is not select'd from a path final WhereTraversalStep<?> whereStep = (WhereTraversalStep<?>) startStep; TraversalHelper.insertBeforeStep(new MatchStartStep(matchTraversal, this.pullOutVariableStartStepToParent(whereStep)), (Step) whereStep, matchTraversal); // where(as('a').out()) -> as('a').where(out()) } else if (startStep instanceof WherePredicateStep) { // necessary for GraphComputer so the projection is not select'd from a path final WherePredicateStep<?> whereStep = (WherePredicateStep<?>) startStep; TraversalHelper.insertBeforeStep(new MatchStartStep(matchTraversal, whereStep.getStartKey().orElse(null)), (Step) whereStep, matchTraversal); // where('a',eq('b')) --> as('a').where(eq('b')) whereStep.removeStartKey(); } else {
final Step barrier = (Step) TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, computerTraversal).orElse(null); if (MessagePassingReductionStrategy.insertElementId(barrier)) // out().count() -> out().id().count() TraversalHelper.insertBeforeStep(new IdStep(computerTraversal), barrier, computerTraversal); if (!(MessagePassingReductionStrategy.endsWithElement(null == barrier ? computerTraversal.getEndStep() : barrier))) { Traversal.Admin newChildTraversal = new DefaultGraphTraversal<>();
TraversalHelper.insertBeforeStep(new RangeGlobalStep<>(traversal, 0L, highRange), curr, traversal);
final String generatedLabel = PathProcessorStrategy.generateLabel(); if (selectOneStep.getPreviousStep() instanceof EmptyStep) { TraversalHelper.insertBeforeStep(new IdentityStep<>(traversal), selectOneStep, traversal); index++;