简体   繁体   中英

Gremlin: The provided traverser does not map to a value

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?

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()
    )

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM