-
Notifications
You must be signed in to change notification settings - Fork 836
Fix TraversalParent implementations for Placeholder steps #3209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9b292c6
6b7445d
5a23a28
3c94201
9b6b08e
271d783
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ | |
import org.apache.tinkerpop.gremlin.process.traversal.GValueManager; | ||
import org.apache.tinkerpop.gremlin.process.traversal.Step; | ||
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; | ||
import org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchStep; | ||
import org.apache.tinkerpop.gremlin.process.traversal.step.branch.LocalStep; | ||
import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement; | ||
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; | ||
|
||
|
@@ -31,14 +33,30 @@ | |
import java.util.Set; | ||
|
||
/** | ||
* Indicates that a step can contain child Traversals. Any step which implements this interface should override at least | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Likely out of scope for this PR but I feel it would be helpful in general for TinkerPop to have more custom annotations. In this case there could be a custom annotation like
And then there could also be an
Then when adding new steps or adding child traversals to an existing step, all you would need to do is add the custom annotation and you wouldn't have to 'remember' to do the boilerplate logic. If you agree with this suggestion it's possible to use an annotation for these affected classes only and then slowly migrate towards 100% usage of the annotation in future PRs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's definitely a compelling idea and would be an improvement over the status quo. I'm not sure about half starting it here in this PR though. I would rather such a change be made all at once, as I'm worried there are a few steps which will be difficult to adapt to the annotation model, and may require tweaking the design. The steps which come to mind which may be difficult are the ones like AddEdge which currently shove all of their arguments into a I think this might make for a good JIRA. I don't think it's prohibitively large to tackle all at once as a standalone task. There's only about 60 implementations of TraversalParent when you factor out abstract classes and such, and there's really only a handful of unique patterns within those, they are mostly simple and repetitive. |
||
* one of getGlobalChildren() or getLocalChildren(). All TraversalParents should call integrateChild() for all child | ||
Cole-Greer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
* traversals as they are added to the step, and TraversalParents should override {@link Step::setTraversal()}, and | ||
* call integrateChild() again for all child traversals. | ||
* | ||
* @author Marko A. Rodriguez (http://markorodriguez.com) | ||
*/ | ||
public interface TraversalParent extends PopContaining, AutoCloseable { | ||
|
||
/** | ||
* Gets a list of all "global" child traversals for this step. A "global" traversal is one which evaluates across | ||
* all of its parents incoming traversers at once. This is typically used in cases where the child traversal | ||
* represents a branch of traversal flow. See {@link BranchStep} as an example. | ||
*/ | ||
public default <S, E> List<Traversal.Admin<S, E>> getGlobalChildren() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
/** | ||
* Gets a list of all "local" child traversals for this step. A "local" traversal is one which is evaluated | ||
* independently for each incoming traverser to the parent step. This is typically used in cases where the child | ||
* is used to process or augment each traverser individually. See {@link LocalStep} or {@link ByModulating} as | ||
* examples. | ||
*/ | ||
public default <S, E> List<Traversal.Admin<S, E>> getLocalChildren() { | ||
return Collections.emptyList(); | ||
} | ||
|
andreachild marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There needs to be a revisit for cloning of GValues, GValueManager, and StepPlaceholders. I consider this out of scope for this PR and intend to address this soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that there are fields in the parent class
AbstractLambdaTraversal
which are not cloned by this current logic such asbypassTraversal
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated this method to include a call to
super.clone()
. I will do a further followup of cloning of GValues/StepPlaceholders in a followup PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the call to
super.clone
should go inside the try blockThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still leaving this scope to a followup on cloning, although
AbstractLambdaTraversal.clone()
does not throwCloneNotSupportedException
so adding it to the try does not have any effect. There's actually no way forGValue
orGValueManager
to throwCloneNotSupportedException
either given the current implementation, so in the followup this will be corrected and the try-catch will go away altogether.