String concatenation without using lambda

389 views
Skip to first unread message

Udit Sharma

unread,
Mar 12, 2019, 7:12:32 AM3/12/19
to Gremlin-users
Hi,

I am executing the following query for concatenating two property values.

g=TinkerFactory.createModern().traversal()

g.V().as('start').values('name').as('person').select('start').out('created').values('name').as('software').select('person','software').map{it.get().get('person')+it.get().get('software')}


Output:

==>markolop

==>joshripple

==>joshlop

==>peterlop


Is it possible to write the same query without using lambda?

Daniel Kuppitz

unread,
Mar 12, 2019, 11:30:37 AM3/12/19
to gremli...@googlegroups.com
String concatenations are not supported, but you could use arrays/lists.

gremlin> g.V().as('person').out('created').values('name').map(union(select('person').by('name'), identity()).fold())
==>[marko,lop]
==>[josh,ripple]
==>[josh,lop]
==>[peter,lop]

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/ee0d07cf-6780-4f87-8b4e-2bae9327dbaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Mallette

unread,
Mar 12, 2019, 2:01:43 PM3/12/19
to gremli...@googlegroups.com
I hope we can think through how to get that types of operations into the language (i.e. simple transformative functions, like string concat). That's one of missing pieces of Gremlin still.

Kelvin Lawrence

unread,
Mar 15, 2019, 11:34:26 AM3/15/19
to Gremlin-users
I think in general, as appropriate,  being able to do things in pure Gremlin that today require a lambda/closure or additional client side processing would be great. I think we have already gone a long way down that road. Thinking back to TP2 days I had lambdas all over the place. I can't say I ever really find myself in a place today where I can not do in Gremlin what at one time required a lambda. As Daniel notes returning a list and concatenating the strings client side is not the worst thing in the world to have to do. Given we are more and more heading down the bytecode road and given many graph providers disallow lambdas I think it would be great to think about anything that today truly does require some sort of inline code and get it into the language. As you note Stephen messing with text is probably one of the few remaining places and the new text predicates take a big step towards removing many of those cases.

Cheers
Kelvin


On Tuesday, March 12, 2019 at 1:01:43 PM UTC-5, Stephen Mallette wrote:
I hope we can think through how to get that types of operations into the language (i.e. simple transformative functions, like string concat). That's one of missing pieces of Gremlin still.

Udit Sharma

unread,
Apr 16, 2019, 2:59:11 AM4/16/19
to Gremlin-users
Are there any plans of including String manipulation functions in the future releases?

Regards
Udit Sharma


On Tuesday, March 12, 2019 at 9:00:37 PM UTC+5:30, Daniel Kuppitz wrote:
String concatenations are not supported, but you could use arrays/lists.

gremlin> g.V().as('person').out('created').values('name').map(union(select('person').by('name'), identity()).fold())
==>[marko,lop]
==>[josh,ripple]
==>[josh,lop]
==>[peter,lop]

Cheers,
Daniel


On Tue, Mar 12, 2019 at 4:12 AM Udit Sharma <ushar...@gmail.com> wrote:
Hi,

I am executing the following query for concatenating two property values.

g=TinkerFactory.createModern().traversal()

g.V().as('start').values('name').as('person').select('start').out('created').values('name').as('software').select('person','software').map{it.get().get('person')+it.get().get('software')}


Output:

==>markolop

==>joshripple

==>joshlop

==>peterlop


Is it possible to write the same query without using lambda?

--
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 gremli...@googlegroups.com.

Stephen Mallette

unread,
Apr 16, 2019, 7:44:29 AM4/16/19
to gremli...@googlegroups.com
well, it's not off the table, but i'm also not sure how we'd want to do it. maybe now that we're discussing types in TP4 we can see something happening there that allows primitive operations that might backport to TP3. I wouldn't count on a way of doing this until 3.5.0 I guess.

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/1621644e-0faf-4fe7-94a0-a3661d610d67%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages