Edge traveresal .hasId() not returning expected results


AC
 

Thanks Boxuan! I look forward to that release. In the meantime, I was able to work around this issue now that I know it is not producing the expected results, in a way that should be compatible with this change once it is rolled out. I really appreciate your thorough answer and explanation.


On Sat, Nov 6, 2021 at 5:12 PM Boxuan Li <liboxuan@...> wrote:
Fixed by https://github.com/JanusGraph/janusgraph/pull/2849 and will be included in the next release (0.6.1).


Boxuan Li
 

Fixed by https://github.com/JanusGraph/janusgraph/pull/2849 and will be included in the next release (0.6.1).


Boxuan Li
 

Hi Adam,

Thanks for reporting! This is a bug and I just created an issue for it: https://github.com/JanusGraph/janusgraph/issues/2848 If you wanted to know more about this bug, feel free to post a follow-up on that issue.

JanusGraphStep is an implementation of TinkerPop GraphStep which contains some optimization. JanusGraph converts GraphStep to JanusGraphStep as long as it finds there is space to optimize. In the “g.E().hasId(xx)” example, if we strictly follow the execution order, JanusGraph would load all edges and then do an in-memory filtering. That’s where `JanusGraphStep` comes into play - it “folds” all `has` conditions (including `hasId` step) so that  index can be potentially utilized. Unfortunately, due to a bug that you found, g.E().hasId(xx) does not work as expected.

If you insert a dummy `map` step in-between like this:

g.E().map{t -> t.get()}.hasId(“4r6-39s-69zp-3c8”)

Then you will get the result you want. However, this is highly discouraged, as it will aggressively prevent JanusGraph from doing any optimization, and requires a full scan on all data entries.

Best regards,
Boxuan

On Nov 5, 2021, at 2:01 PM, Adam Crane via lists.lfaidata.foundation <acrane=twitter.com@...> wrote:

Hey folks, I'm seeing strange results trying to use the hasId step on an edge traversal:

@ g.E("4r6-39s-69zp-3c8").toList 
res49: List[Edge] = List(e[4r6-39s-69zp-3c8][4240-RetrocomputerPurchaser->4328])

@ g.E().hasId("4r6-39s-69zp-3c8").toList 
res50: List[Edge] = List()

@ g.E("4r6-39s-69zp-3c8").traversal.profile().toList 
res51: java.util.List[org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics] = [Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
GraphStep(edge,[4r6-39s-69zp-3c8])                                     1           1           0.237   100.00
                                            >TOTAL                     -           -           0.237        -]

@ g.E().hasId("4r6-39s-69zp-3c8").traversal.profile().toList 
res52: java.util.List[org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics] = [Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep(edge,[4r6-39s-69zp-3c8])                                                        0.039   100.00
                                            >TOTAL                     -           -           0.039        -]

1) Why would these two traversals produce different results?
2) What's the difference between the GraphStep and JanusGraphStep representations of these traversals? They look the same otherwise via explain/profile.
3) Is there any working encoding of this query starting with an edge traversal g.E() that can produce the same result?

Thanks,
- Adam


AC
 

Hey folks, I'm seeing strange results trying to use the hasId step on an edge traversal:

@ g.E("4r6-39s-69zp-3c8").toList 

res49: List[Edge] = List(e[4r6-39s-69zp-3c8][4240-RetrocomputerPurchaser->4328])


@ g.E().hasId("4r6-39s-69zp-3c8").toList 

res50: List[Edge] = List()


@ g.E("4r6-39s-69zp-3c8").traversal.profile().toList 

res51: java.util.List[org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics] = [Traversal Metrics

Step                                                               Count  Traversers       Time (ms)    % Dur

=============================================================================================================

GraphStep(edge,[4r6-39s-69zp-3c8])                                     1           1           0.237   100.00

                                            >TOTAL                     -           -           0.237        -]


@ g.E().hasId("4r6-39s-69zp-3c8").traversal.profile().toList 

res52: java.util.List[org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics] = [Traversal Metrics

Step                                                               Count  Traversers       Time (ms)    % Dur

=============================================================================================================

JanusGraphStep(edge,[4r6-39s-69zp-3c8])                                                        0.039   100.00

                                            >TOTAL                     -           -           0.039        -]


1) Why would these two traversals produce different results?
2) What's the difference between the GraphStep and JanusGraphStep representations of these traversals? They look the same otherwise via explain/profile.
3) Is there any working encoding of this query starting with an edge traversal g.E() that can produce the same result?

Thanks,
- Adam