[
https://issues.apache.org/jira/browse/TINKERPOP-2799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17605264#comment-17605264
]
Stephen Mallette commented on TINKERPOP-2799:
---------------------------------------------
> AdjacentToIncidentStrategy its optimizeStep() method replaces the
> ProeprtyType.VALUE type of the PropertiesStep instance with
> PropertyType.PROPERTY.
This is precisely the point of this strategy. It eliminates the need to
traverse to a property value when just the property itself will suffice for
satisfying the filter. Changing this would effectively remove the optimization.
Is there something I'm not understanding in your suggestion?
> 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
> Priority: Major
>
> 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)