Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
3.6.1
-
None
-
None
Description
When applying the default strategies, specifically org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.AdjacentToIncidentStrategy its optimizeStep() method replaces the ProeprtyType.VALUE type of the PropertiesStep instance with PropertyType.PROPERTY.
Source code:
private static void optimizeStep(final Traversal.Admin traversal, final Step step) { final Step newStep; if (step instanceof VertexStep) { final VertexStep vs = (VertexStep) step; newStep = new VertexStep<>(traversal, Edge.class, vs.getDirection(), vs.getEdgeLabels()); } else if (step instanceof PropertiesStep) { final PropertiesStep ps = (PropertiesStep) step; newStep = new PropertiesStep(traversal, PropertyType.PROPERTY, ps.getPropertyKeys()); <<<<<<<<<< } else { return; } TraversalHelper.replaceStep(step, newStep, traversal); }
For example:
- the traversal
g.V().has("1")
contains a PropertiesStep with PropertyType.VALUE type
- after applying the strategies it already contains a PropertiesStep with PropertyType.PROPERTY type
This seems to me incorrect.
Suggestion
- in org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.AdjacentToIncidentStrategy.optimizeStep(Admin, Step) method replace the line:
newStep = new PropertiesStep(traversal, PropertyType.PROPERTY, ps.getPropertyKeys());
with
newStep = new PropertiesStep(traversal, ps.getReturnType(), ps.getPropertyKeys());
Test:
@Test public void g_V_has_X_1_X() { Traversal transfrormed; transfrormed = g.V().has("1"); transfrormed.asAdmin().applyStrategies(); assertThat(transfrormed.toString(), equalTo(expected.V().has("1").toString())); }