简体   繁体   English

Gremlin(Titan)中的嵌套变换

[英]Nested transform in Gremlin (Titan)

I have a graph with two vertexes with a key called 'type'. 我有一个带有两个顶点的图形,其中有一个名为“ type”的键。

Why the following: 为什么是以下原因:

g.V("type", "language").transform { language_1 ->
  1+1;
}

returns: 收益:

==>2
==>2

and the following: 以及以下内容:

g.V("type", "language").transform { language_1 ->
  g.V("type", "language").transform { language_2 ->
    1+1;
  }
}

returns: 收益:

==>[GremlinStartPipe, GraphQueryPipe(has,vertex), IdentityPipe, TransformFunctionPipe]
==>[GremlinStartPipe, GraphQueryPipe(has,vertex), IdentityPipe, TransformFunctionPipe]

?

What you are seeing in the second example is the String representation of a pipeline. 在第二个示例中看到的是管道的String表示形式。 Both of your example queries return pipelines, but when the Gremlin console sees a pipeline returned it automatically reads all the data out of it and displays it. 您的两个示例查询都返回管道,但是当Gremlin控制台看到返回的管道时,它将自动从中读取所有数据并显示它们。 If you wish to use the data returned from a nested pipeline within a larger query as you do in the second query, you must explicitly read the data. 如果要像在第二个查询中一样使用较大查询中的嵌套管道返回的数据,则必须显式读取数据。 Try this: 尝试这个:

g.V("type", "language").transform { language_1 ->
  g.V("type", "language").transform { language_2 ->
    1+1;
  }.next()
}

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

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