private static boolean legalCurrentStep(final Step<?, ?> step) { return !(step instanceof EmptyStep || step instanceof ProfileSideEffectStep || step instanceof HasNextStep || step instanceof ComputerAwareStep.EndStep || (step instanceof StartStep && !StartStep.isVariableStartStep(step)) || GraphStep.isStartStep(step)); }
private static Set<Scoping.Variable> getVariableLocations(final Set<Scoping.Variable> variables, final Traversal.Admin<?, ?> traversal) { if (variables.size() == 2) return variables; // has both START and END so no need to compute further final Step<?, ?> startStep = traversal.getStartStep(); if (StartStep.isVariableStartStep(startStep)) variables.add(Scoping.Variable.START); else if (startStep instanceof WherePredicateStep) {
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)); } }
matchTraversal.addStep(0, new WhereTraversalStep<>(matchTraversal, notTraversal)); this.configureStartAndEndSteps(matchTraversal); } else if (StartStep.isVariableStartStep(startStep)) { final String label = startStep.getLabels().iterator().next(); this.matchStartLabels.add(label);
private static boolean legalCurrentStep(final Step<?, ?> step) { return !(step instanceof EmptyStep || step instanceof ProfileSideEffectStep || step instanceof HasNextStep || step instanceof ComputerAwareStep.EndStep || (step instanceof StartStep && !StartStep.isVariableStartStep(step)) || GraphStep.isStartStep(step)); }
private static Set<Scoping.Variable> getVariableLocations(final Set<Scoping.Variable> variables, final Traversal.Admin<?, ?> traversal) { if (variables.size() == 2) return variables; // has both START and END so no need to compute further final Step<?, ?> startStep = traversal.getStartStep(); if (StartStep.isVariableStartStep(startStep)) variables.add(Scoping.Variable.START); else if (startStep instanceof WherePredicateStep) {
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)); } }
matchTraversal.addStep(0, new WhereTraversalStep<>(matchTraversal, notTraversal)); this.configureStartAndEndSteps(matchTraversal); } else if (StartStep.isVariableStartStep(startStep)) { final String label = startStep.getLabels().iterator().next(); this.matchStartLabels.add(label);