Hi, I have a toy java DSL at
https://github.com/danielmartincraig/technic-dsl which models gears which drive other gears. This DSL aims to be declarative and idempotent - client code doesn't need to concern itself with whether or not a vertex already exists, a vertex will be created if it doesn't already exist. Here's a sample which creates 2 linked vertices:
g.gear("driverGear").drives(__.gear("followerGear")).next();
I have defined a gear(String gearId) traversal start step that looks like this:
public GraphTraversal<Vertex, Vertex> gear(String gearId) {
GraphTraversalSource clone = this.clone();
clone.getBytecode().addStep(GraphTraversal.Symbols.V);
GraphTraversal<Vertex, Vertex> traversal = new DefaultGraphTraversal<>(clone);
traversal.asAdmin().addStep(new GraphStep<>(traversal.asAdmin(), Vertex.class, true));
traversal = traversal.has(T.id, gearId);
traversal = traversal.fold().coalesce(__.unfold(), __.addV("gear").property(T.id, gearId));
return traversal;
}
So I'm concerned that this step as implemented will do a full scan because it starts with a V() and then does a .has(T.id, gearID). How can I do the equivalent of a V(gearID) instead?