Github user jorgebay commented on a diff in the pull request:
https://github.com/apache/tinkerpop/pull/857#discussion_r184057436
--- Diff:
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
---
@@ -63,15 +64,17 @@ public void apply(final Traversal.Admin<?, ?>
traversal) {
throw new VerificationException("The parent of a reducing
barrier can not be repeat()-step: " + step, traversal);
}
- // The ProfileSideEffectStep must be the last step, 2nd last step
when accompanied by the cap step,
- // or 3rd to last when the traversal ends with a RequirementsStep.
+ // The ProfileSideEffectStep must be one of the following
+ // (1) the last step
+ // (2) 2nd last step when accompanied by the cap step or none step
(i.e. iterate() to nothing)
+ // (3) 3rd to last when the traversal ends with a RequirementsStep.
final Step<?, ?> endStep = traversal.asAdmin().getEndStep();
if (TraversalHelper.hasStepOfClass(ProfileSideEffectStep.class,
traversal) &&
!(endStep instanceof ProfileSideEffectStep ||
(endStep instanceof SideEffectCapStep &&
endStep.getPreviousStep() instanceof ProfileSideEffectStep) ||
- (endStep instanceof RequirementsStep && (
- endStep.getPreviousStep() instanceof
SideEffectCapStep ||
- endStep.getPreviousStep()
instanceof ProfileSideEffectStep)))) {
+ (endStep instanceof NoneStep &&
endStep.getPreviousStep() instanceof SideEffectCapStep &&
endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) ||
--- End diff --
I think we can save some `instanceof` checks if we introduce a method
similar to `TraversalHelper.hasStepOfClass(ProfileSideEffectStep.class,
traversal)` but instead of returning a boolean, it returns the step instance.
Then, from the `ProfileSideEffectStep` instance itself, it's easier to do the
checks.
---