在 gremlin groovy (3.0.1-incubating) 中,inV() 和 hasID() 需要什么导入
What import do i need for inV() and hasID() in gremlin groovy (3.0.1-incubating)
我正在尝试获取给定源和目标顶点 ID 以及边标签的边的 属性 值。
在 gremlin 终端中,以下工作正常:
g.V("fromNodeId").outE("edgeLabel").where(inV().hasID("toNodeID")).values("edgeProp")
遗憾的是,在 groovy 中,inV() 和 hasID() 无法识别,我找不到正确的导入来让它工作。
以下是我尝试过的导入:
import org.apache.commons.configuration.Configuration;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
import org.apache.tinkerpop.gremlin.process.*
import org.apache.tinkerpop.gremlin.groovy.*
import org.apache.tinkerpop.gremlin.groovy.function.*
import org.apache.tinkerpop.gremlin.groovy.util.*
import org.apache.tinkerpop.gremlin.pipes.filter.*
import org.apache.tinkerpop.gremlin.structure.Edge
import org.apache.tinkerpop.gremlin.structure.Vertex
import org.apache.tinkerpop.gremlin.structure.EdgeTest;
import org.apache.tinkerpop.gremlin.structure.Graph
我会注意到其他查询 s.a。以下工作正常:
String getPropValueByID(Long id, String prop){
def result = []
**g.V(id).values(prop).fill(result)**
if(result.empty) return null
return result.first()
}
中有描述
To reduce the verbosity of the expression, it is good to import
static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*
.
This way, instead of doing __.inE()
for an anonymous traversal, it
is possible to simply write inE()
. Be aware of language-specific
reserved keywords when using anonymous traversals. For example, in and
as are reserved keywords in Groovy, therefore you must use the verbose
syntax __.in()
and __.as()
to avoid collisions.
我正在尝试获取给定源和目标顶点 ID 以及边标签的边的 属性 值。
在 gremlin 终端中,以下工作正常:
g.V("fromNodeId").outE("edgeLabel").where(inV().hasID("toNodeID")).values("edgeProp")
遗憾的是,在 groovy 中,inV() 和 hasID() 无法识别,我找不到正确的导入来让它工作。
以下是我尝试过的导入:
import org.apache.commons.configuration.Configuration;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
import org.apache.tinkerpop.gremlin.process.*
import org.apache.tinkerpop.gremlin.groovy.*
import org.apache.tinkerpop.gremlin.groovy.function.*
import org.apache.tinkerpop.gremlin.groovy.util.*
import org.apache.tinkerpop.gremlin.pipes.filter.*
import org.apache.tinkerpop.gremlin.structure.Edge
import org.apache.tinkerpop.gremlin.structure.Vertex
import org.apache.tinkerpop.gremlin.structure.EdgeTest;
import org.apache.tinkerpop.gremlin.structure.Graph
我会注意到其他查询 s.a。以下工作正常:
String getPropValueByID(Long id, String prop){
def result = []
**g.V(id).values(prop).fill(result)**
if(result.empty) return null
return result.first()
}
To reduce the verbosity of the expression, it is good to
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*
. This way, instead of doing__.inE()
for an anonymous traversal, it is possible to simply writeinE()
. Be aware of language-specific reserved keywords when using anonymous traversals. For example, in and as are reserved keywords in Groovy, therefore you must use the verbose syntax__.in()
and__.as()
to avoid collisions.