简体   繁体   English

Gremlin:提供的遍历器没有 map 到一个值

[英]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.所以看起来当as()后跟fold()时,它会删除在as()步骤中设置的变量。 I used aggregate() instead as follows:我使用了aggregate() ,如下所示:

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 . as()步骤是所谓的减少障碍步骤 With reducing barrier steps any path history of a query (such as applying a label via as() ) is lost.通过减少障碍步骤,任何查询的路径历史记录(例如通过as()应用 label)都会丢失。 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.当您在from()中使用 id 作为字符串而不是顶点 object 时,会发生此特定错误。

To see what I mean, as a simple test run the following gremlin query:要明白我的意思,作为一个简单的测试运行以下 gremlin 查询:

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.第一个查询会给你上面提到的错误,第二个不会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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