You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Cameron Smith (Jira)" <ji...@apache.org> on 2022/10/10 15:53:00 UTC

[jira] [Commented] (TINKERPOP-2811) ElementIdStrategy doesn't replace all references of an element's id with the specified custom id property

    [ https://issues.apache.org/jira/browse/TINKERPOP-2811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17615182#comment-17615182 ] 

Cameron Smith commented on TINKERPOP-2811:
------------------------------------------

My initial thought about what might be the issue here is that it seems like [the initial mutation of HasSteps in a traversal only update the first member of the steps hasContainers|https://github.com/apache/tinkerpop/blob/10ce768917d5a0557c137f7dad50384e70250c6c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/ElementIdStrategy.java#L84-L86]. Based on the output of the explain steps in the description it looks like chained has steps in a traversal become a single HasStep with each step on the traversal becoming an element in the hasContainers list in the order in which they were added onto the traversal.

> ElementIdStrategy doesn't replace all references of an element's id with the specified custom id property
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: TINKERPOP-2811
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2811
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: process
>    Affects Versions: 3.4.0, 3.6.1
>            Reporter: Cameron Smith
>            Priority: Minor
>
> When using the ElementIdStrategy, if a traversal attempts to filter graph elements with multiple _has_ steps and the id filter is not the first property to be filtered on, then the reference to the element's id is not replaced with the custom id property during the ElementIdStrategy's mutation of the traversal:
> {noformat}
> gremlin> graph = TinkerGraph.open()
> ==>tinkergraph[vertices:0 edges:0]
> gremlin> g = graph.traversal().withStrategies(ElementIdStrategy.build().create())
> ==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
> gremlin> g.V().hasId("foo").has("name", "bar").explain()
> ==>Traversal Explanation
> ===================================================================================================
> Original Traversal                    [GraphStep(vertex,[]), HasStep([~id.eq(foo), name.eq(bar)])]
> ConnectiveStrategy              [D]   [GraphStep(vertex,[]), HasStep([~id.eq(foo), name.eq(bar)])]
> ElementIdStrategy               [D]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> IdentityRemovalStrategy         [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> MatchPredicateStrategy          [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> FilterRankingStrategy           [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> InlineFilterStrategy            [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> IncidentToAdjacentStrategy      [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> AdjacentToIncidentStrategy      [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> EarlyLimitStrategy              [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> ByModulatorOptimizationStrategy [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> RepeatUnrollStrategy            [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> CountStrategy                   [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> PathRetractionStrategy          [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> LazyBarrierStrategy             [O]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> TinkerGraphCountStrategy        [P]   [GraphStep(vertex,[]), HasStep([__id.eq(foo), name.eq(bar)])]
> TinkerGraphStepStrategy         [P]   [TinkerGraphStep(vertex,[__id.eq(foo), name.eq(bar)])]
> TinkerMergeEVStepStrategy       [P]   [TinkerGraphStep(vertex,[__id.eq(foo), name.eq(bar)])]
> ProfileStrategy                 [F]   [TinkerGraphStep(vertex,[__id.eq(foo), name.eq(bar)])]
> StandardVerificationStrategy    [V]   [TinkerGraphStep(vertex,[__id.eq(foo), name.eq(bar)])]
> Final Traversal                       [TinkerGraphStep(vertex,[__id.eq(foo), name.eq(bar)])]
> gremlin> g.V().has("name", "bar").hasId("foo").explain()
> ==>Traversal Explanation
> ==================================================================================================
> Original Traversal                    [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> ConnectiveStrategy              [D]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> ElementIdStrategy               [D]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> IdentityRemovalStrategy         [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> MatchPredicateStrategy          [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> FilterRankingStrategy           [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> InlineFilterStrategy            [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> IncidentToAdjacentStrategy      [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> AdjacentToIncidentStrategy      [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> EarlyLimitStrategy              [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> ByModulatorOptimizationStrategy [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> RepeatUnrollStrategy            [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> CountStrategy                   [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> PathRetractionStrategy          [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> LazyBarrierStrategy             [O]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> TinkerGraphCountStrategy        [P]   [GraphStep(vertex,[]), HasStep([name.eq(bar), ~id.eq(foo)])]
> TinkerGraphStepStrategy         [P]   [TinkerGraphStep(vertex,[foo],[name.eq(bar)])]
> TinkerMergeEVStepStrategy       [P]   [TinkerGraphStep(vertex,[foo],[name.eq(bar)])]
> ProfileStrategy                 [F]   [TinkerGraphStep(vertex,[foo],[name.eq(bar)])]
> StandardVerificationStrategy    [V]   [TinkerGraphStep(vertex,[foo],[name.eq(bar)])]
> Final Traversal                       [TinkerGraphStep(vertex,[foo],[name.eq(bar)])]{noformat}
> In the above example, the first traversal shows the behavior when id filtering is done first, and the second traversal demonstrates the behavior when id filtering is not the first filtering step.
> This was reproduced on both TinkerPop 3.6.1 and 3.4.0.
> The current workaround is to ensure that when chaining _has_ steps together that the first filter on id, if filtering on id is required.



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