0

I create an empty graph partitioned on 'a' and seed with the following:

g.addV('person').property('a','1').property('name','person 1').property('number',1)
g.addV('person').property('a','1').property('name','person 2').property('number',2)
g.addV('person').property('a','1').property('name','person 3').property('number',3)

g.V().order().by('number')
returns: person 1, person 2, person 3

g.V().order().by('number').tail(1)
returns: person 1

I expected .tail() to return from the end of the list

Whats weird is that when i select just a property it works just as I expected:

g.V().order().by('number').properties('name')
returns: person 1, person 2, person 3

g.V().order().by('number').properties('name').tail(1)
returns: person 3

When I try the same in the tinkerpop gremlin console, tail(1) returns the last entry for both variations..

Am I missing something? I find it hard to believe that this is an actual bug.

Edit: I have managed to get it to work by doing a .fold().unfold() before .tail().. Still have no idea what is going on here..

Toodleey
  • 913
  • 1
  • 8
  • 22

1 Answers1

1

I'm not sure what the problem is there, but it seems like there must be a bug there somehow as TinkerGraph displays the behavior that you want (and obviously that's what's expected):

gremlin> g.V().order().by('number').tail(1)
==>v[8]
gremlin> g.V().order().by('number').tail(1).values('name')
==>person 3
gremlin> g.V().order().by('number').tail(1).valueMap(true)
==>[id:8,label:person,a:[1],number:[3],name:[person 3]]

The fact that fold().unfold() makes a difference (which was smart to try) seems to indicate that there is some CosmosDB optimization that is misbehaving.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135