Why does properties().dedup() return duplicates?

When I run the query V().both().properties().dedup() on the TinkerFactory modern graph, I see duplicates for some properties (for instance, vp[NAME->Marko] and vp[LANG->java] appear twice). Looking at the documentation, I do not understand how this is possible. Any help is appreciated. Thank you!
2 Replies
wiebe
wiebe2y ago
EDIT: Never mind, that doesn't even make much sense to me anymore. g.V().both().properties().dedup().by(value) does seem to work better. I think dedup() should filter on ID. There should be duplicate IDs, but they're all unique. g.V().both().properties().dedup().id()
spmallette
spmallette2y ago
i think @wiebe has the answer right. you get duplicates of the property value because a VertexProperty is dedup'd on T.id because it is a first class graph Element. In the modern graph there are two vertices with a "java" property and each has its own id so you see it twice:
gremlin> g.V().hasLabel('software').properties().dedup()
==>vp[name->lop]
==>vp[lang->java]
==>vp[name->ripple]
==>vp[lang->java]
gremlin> g.V().hasLabel('software').properties().dedup()
==>vp[name->lop]
==>vp[lang->java]
==>vp[name->ripple]
==>vp[lang->java]
if you do an elementMap() you can see the ids/values more clearly:
gremlin> g.V().hasLabel('software').properties().dedup().elementMap()
==>[id:4,key:name,value:lop]
==>[id:5,key:lang,value:java]
==>[id:8,key:name,value:ripple]
==>[id:9,key:lang,value:java]
gremlin> g.V().hasLabel('software').properties().dedup().elementMap()
==>[id:4,key:name,value:lop]
==>[id:5,key:lang,value:java]
==>[id:8,key:name,value:ripple]
==>[id:9,key:lang,value:java]
using dedup().by(value) is one way to deal with that, just note that you are filtering unique VertexProperty objects there which may have some impact on your traversal depending on what you are trying to do.
Want results from more Discord servers?
Add your server