g.E().properties().element() gives weird (wrong?) results
g.E().properties().element() doesn't return what I expect.
Using TinkerPop modern:
g.E().properties().element()
[e[7][1-knows->2],
e[8][1-knows->4],
e[8][1-knows->4],
e[9][1-created->3],
e[9][1-created->3],
e[12][6-created->3]]
Item 1 (2nd) and 2 are duplicate, so are 3 and 4. e[10][4-created-5] and e[11][4-created-3] are missing.
g.E().properties().element().path() (and g.E().properties().path() too) work as expected:
path[e[7][1-knows->2], p[weight->0.5], e[7][1-knows->2]],
path[e[8][1-knows->4], p[weight->1.0], e[8][1-knows->4]],
path[e[9][1-created->3], p[weight->0.4], e[9][1-created->3]],
path[e[10][4-created->5], p[weight->1.0], e[10][4-created->5]],
path[e[11][4-created->3], p[weight->0.4], e[11][4-created->3]],
path[e[12][6-created->3], p[weight->0.2], e[12][6-created->3]]
I upgraded to gdotv 1.18.49. The results are different, but still unexpected (still 2 duplicate edges, and 2 edges missing).
Solution:Jump to solution
right, there is a bug. i see it. it's what i thought - relates to
Property
equality14 Replies
this looks like a misunderstanding of your traversal in this instance. g.E() will return all edges in your graph. g.E().properties() will return all properties for these edges, which means 2 important things:
- at this point in the traversal, edges without properties will no longer be of relevance
- edges with multiple properties will return multiple properties for that same edge
when calling .element() on this, this effectively means that edges with no properties will no longer be in the traversal, and that edges with multiple properties will be there multiple times in the traversal too
on gdotv if you use query debugging and jump into the traversal simulation you can see this behaviour highlighted quite clearly
I could be completely wrong of course, but
1) every edge has exactly 1 property in TinkerPop Modern. g.E().properties() confirms this.
2) This doesn't explain why g.E().properties().element().path() gives the right result?
that does look wrong
assuming this is the "modern" graph then every edge has a property and so
element()
should return each edge 😕Yes, exactly what I though.
Also adding path() to the query, the last item in the path should match the items in the list. But path() changes the results completely.
i bet it has to do with
Property
equality somehow....I wouldn't know...
Is it coincidence the element() step is about the only step that doesn't show results in the documentation?
no...it's not that
the docs aren't tagged properly to execute the example to generate the output
basically executing against an empty graph.
But if that got fixed, it wouldn't give the correct results, right?
Solution
right, there is a bug. i see it. it's what i thought - relates to
Property
equalitydo you have a JIRA account to create an issue there?
Sorry, no.
(nice job finding two bugs btw)
ok. i'll handle it for you
if you keep being good at finding bugs though, it might be good if you created one though 😄
Thanks.
here is the workaround for now:
terrible bug. our tests only validated a single property. it wouldn't have shown up without bulking
https://issues.apache.org/jira/browse/TINKERPOP-2928