Rusi Popov created TINKERPOP-2799:
-------------------------------------

             Summary: AdjacentToIncidentStrategy replaces the PropertyType of 
ProeprtiesStep from VALUE to PROPERTY
                 Key: TINKERPOP-2799
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2799
             Project: TinkerPop
          Issue Type: Bug
          Components: structure
    Affects Versions: 3.6.1
            Reporter: Rusi Popov


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:
{code:java}
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);
}
{code}
For example:
* the traversal {code} g.V().has("1"){code}  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:
{code}
newStep = new PropertiesStep(traversal, PropertyType.PROPERTY, 
ps.getPropertyKeys());
{code}
with
{code}
newStep = new PropertiesStep(traversal, ps.getReturnType(), 
ps.getPropertyKeys());
{code}


Test:
{code:java}
  @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()));
  }
{code}
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to