select vs. back

86 views
Skip to first unread message

Matt Frantz

unread,
Mar 25, 2015, 12:28:27 PM3/25/15
to gremli...@googlegroups.com
Is there a difference between select('foo') and back('foo')?  I see that they have different implementations, but conceptually, I think of them as equivalent.

Nick De Young

unread,
Mar 25, 2015, 12:34:36 PM3/25/15
to gremli...@googlegroups.com
Select emits all out of the named step, back emits only items from named step that pathed all the way down to the back step . 




Sent from my iPhone

On Mar 25, 2015, at 9:28 AM, Matt Frantz <matthew....@gmail.com> wrote:

Is there a difference between select('foo') and back('foo')?  I see that they have different implementations, but conceptually, I think of them as equivalent.

--
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/91efebeb-5d1a-4a3c-92fc-eaed328a4f9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matt Frantz

unread,
Mar 25, 2015, 1:23:27 PM3/25/15
to gremli...@googlegroups.com
So if I have this...

g.V().has('foo').as('foo').out('bar').select('foo')

...then I will get all foo vertices, and not just the ones that have an outbound bar edge?

But this...

g.V().has('foo').as('foo').out('bar').back('foo')

...will only produce foo vertices that have an outbound bar edge?

Nick De Young

unread,
Mar 25, 2015, 1:33:31 PM3/25/15
to gremli...@googlegroups.com
That's how it's works for me in my code

Sent from my iPhone

Marko Rodriguez

unread,
Mar 25, 2015, 1:37:49 PM3/25/15
to gremli...@googlegroups.com
Hi,

Huh. Thats a really good point. I would have to look at the code, but from memory, I don't think there is a difference between select and back (when you select on a single label).

If this is the case, I would opt to remove BackStep and direct people to use select().

@dkuppitz: Can you think of why back() would be needed instead of just single-label select()?

Thanks,
Marko.

Daniel Kuppitz

unread,
Mar 25, 2015, 9:48:39 PM3/25/15
to gremli...@googlegroups.com
Well, there are some differences:

gremlin> g.V(1).out().as("x").out().as("x").select("x")
==>v[5]
==>v[3]
gremlin> g.V(1).out().as("x").out().as("x").back("x")
==>[v[4], v[5]]
==>[v[4], v[3]]

But then:

gremlin> g.V(1).repeat(out().as("x")).times(2).select("x")
==>[v[4], v[5]]
==>[v[4], v[3]]
gremlin> g.V(1).repeat(out().as("x")).times(2).back("x")
==>[v[4], v[5]]
==>[v[4], v[3]]

So, the question is: what is the expected behavior in query block #1? I would say that only .back() returns the correct result. Maybe, maybe not. Anyway, as long as these steps behave differently, we can't get rid of one one or another.

Cheers,
Daniel


Marko Rodriguez

unread,
Mar 26, 2015, 8:46:59 AM3/26/15
to gremli...@googlegroups.com
Huh, we should make single label select("x") behave as back("x") when there are two as its not "single-label" (we just don't have the logic in there right now).

@dkuppitz: Do you want to make a ticket and/or make it so that select() and back() are "the same" so we can get rid of back()?

Thanks,

Matt Frantz

unread,
Mar 26, 2015, 11:58:45 AM3/26/15
to gremli...@googlegroups.com
I rely on the current behavior of select in the presence of loops.  I only want the most recent value at a particular step label.  If you decide to combine select and back, is there a way to maintain the single-value behavior?  This also affects the issue I raised earlier here with the strong type declaration of the back step:


This might be accomplished either via a parameter to select, e.g. select(Cardinality.single, "x") or as a different step, e.g. selectlast("x").  I tend to think of step labels within a loop as being loop variables, rather than showing the history of all iterations, but I could appreciate the use case where you use a step within a loop to accumulate a path.

Marko Rodriguez

unread,
Apr 10, 2015, 1:24:08 PM4/10/15
to gremli...@googlegroups.com, d...@tinkerpop.incubator.apache.org
Hello,

back()-step is gutted and will not exist come TinkerPop M9.

You can read the rationale here:

Thanks for your input everyone,
Marko.
On Mar 26, 2015, at 6:46 AM, Marko Rodriguez <okram...@gmail.com> wrote:

Huh, we should make single label select("x") behave as back("x") when there are two as its not "single-label" (we just don't have the logic in there right now).

@dkuppitz: Do you want to make a ticket and/or make it so that select() and back() are "the same" so we can get rid of back()?

On Mar 25, 2015, at 7:48 PM, Daniel Kuppitz <m...@gremlin.guru> wrote:

Reply all
Reply to author
Forward
0 new messages