.valueMap() is generating {"key" => ArrayList("value")}

閲覧: 895 回
最初の未読メッセージにスキップ

Steven Tang

未読、
2016/02/02 13:19:142016/02/02
To: Gremlin-users
I'm in the process of upgrading from 0.5.4 to 1.0 and am looking for the replacement for the .map() function (in Java)

We used to be able to .map() at the end of a query and then pipe that to a .toList() and we'd end up with key value pairs like you would expect

{"id" : 1, "name" : "marko"}

but now I'm getting this:

{"id" : [1], "name" : ["marko"]}

Screenshot attached
Screen Shot 2016-02-02 at 10.08.30 AM.png

Daniel Kuppitz

未読、
2016/02/02 15:57:452016/02/02
To: gremli...@googlegroups.com
That's the expected behavior. See http://tinkerpop.incubator.apache.org/docs/3.0.2-incubating/#valuemap-step to learn why it's implemented this way.

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/810d029e-d1eb-48d3-9bc1-122f69e4f21f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steven Tang

未読、
2016/02/02 16:12:302016/02/02
To: Gremlin-users
Is there a way to unwrap the values from the array within the query, or does that have to be done outside the context of a traversal?

Daniel Kuppitz

未読、
2016/02/02 16:44:342016/02/02
To: gremli...@googlegroups.com
gremlin> Gremlin.version()
==>3.1.1-SNAPSHOT
gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V().valueMap()
==>[name:[marko], age:[29]]
==>[name:[vadas], age:[27]]
==>[name:[lop], lang:[java]]
==>[name:[josh], age:[32]]
==>[name:[ripple], lang:[java]]
==>[name:[peter], age:[35]]

gremlin> g.V().local(properties().group().by(key()).by(value()))
==>[name:marko, age:29]
==>[name:vadas, age:27]
==>[name:lop, lang:java]
==>[name:josh, age:32]
==>[name:ripple, lang:java]
==>[name:peter, age:35]

Should also work with a slightly older version. Let me know if not.

Cheers,
Daniel


Gaurav Nolkha

未読、
2016/12/05 20:10:342016/12/05
To: Gremlin-users

This is what I'm getting on 3.0.1-incubating:


gremlin> Gremlin.version()

==>3.0.1-incubating


gremlin> :> def trav = g.V().hasLabel('Group'); trav.local(properties().group().by(key()).by(value()))

==>{joinTime={2016-12-05T22:27:01.088Z=1}, groupId={60e76537-9de5-45cf-b40d-e357b40e87b1=1}, mCanInvite={true=1}}


Why does it give me =1 ??

Daniel Kuppitz

未読、
2016/12/05 20:38:022016/12/05
To: gremli...@googlegroups.com
What you see is a BulkSet. I don't have a test environment for 3.0.1, but you can try this:

...local(properties().group().by(key()).by(value().unfold()))

Pretty sure this will give you the same format that we have in newer versions.

Cheers,
Daniel


To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/b9ef34c7-83c4-42fd-9556-c920fa303615%40googlegroups.com.

Gaurav Nolkha

未読、
2016/12/05 21:48:022016/12/05
To: Gremlin-users

:(


gremlin> :> def trav = g.V().hasLabel('Group'); trav.local(properties().group().by(key()).by(value().unfold()))

==>{groupId={4612-4e6a-8f0a-c0645c0631ec=1}, mCanInvite={true=1}, ....}}

全員に返信
投稿者に返信
転送
新着メール 0 件