5
g.V()
    .has('atom', '_value', 'red').fold()
    .coalesce(unfold(), addV('atom').property('_value', 'red')).as('atom')
    .out('view').has('view', '_name', 'color').fold()
    .coalesce(unfold(), addE('view').from('atom').to(addV('view').property('_name', 'color')))

Gives me an error:

The provided traverser does not map to a value: []->[SelectOneStep(last,atom)] (597)

What does it mean?

Yamiteru XYZ
  • 151
  • 9

3 Answers3

5

Adding to this in case someone else comes across this.

This specific error occurs when you use the id as a string in from() instead of the vertex object.

To see what I mean, as a simple test run the following gremlin query:

g.addE('view').from('atom').to(addV('view').property('_name', 'color'))

then run this query:

g.addE('view').from(V('atom')).to(addV('view').property('_name', 'color'))

The first query will give you the error stated above, the second one will not.

oonyalo
  • 466
  • 1
  • 6
  • 12
4

So it looks like when as() is followed by fold() it deletes the variable set in the as() step. I used aggregate() instead as follows:

g.V()
    .has('atom', '_value', 'red')
    .fold().coalesce(
        unfold(), 
        addV('atom').property('_value', 'red')
    )
    .aggregate('atom')
    .out('view').has('view', '_name', 'color')
    .fold().coalesce(
        unfold(), 
        addE('view')
            .from(select('atom').unfold())
            .to(addV('view').property('_name', 'color'))
            .inV()
    )
Yamiteru XYZ
  • 151
  • 9
2

The as() step is what is known as a reducing barrier step. With reducing barrier steps any path history of a query (such as applying a label via as()) is lost. In reducing barrier steps many paths are reduced down to a single path. After that step there would be no way to know which of the many original labeled vertices would be the correct one to retrieve.

bechbd
  • 6,206
  • 3
  • 28
  • 47