異常

2016-12-15 61 views
1

這是我在Netbeans的Groovy腳本:異常

import org.apache.tinkerpop.gremlin.tinkergraph.structure.* 
import org.apache.tinkerpop.gremlin.groovy.loaders.* 


GremlinLoader.load() 
SugarLoader.load() 

def graph = TinkerFactory.createModern() 
def g = graph.traversal() 

def results = [] 

g.V(1).outE('knows').inV().values('name').fill(results) //==>[vadas, josh] which is OK 
println results 

g.V(1).repeat(**out**()).times(2).fill(results) //==>Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: Test.**out**() is applicable for argument types:() values: [] 
println results 

//also getting "Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: ..." for all the following ones: 
g.V().hasLabel('person').out().has('name',within('vadas','josh')).fill(results) 
g.V().values('age').is(lte(30)).fill(results) 
g.V().group().by(bothE().count()).fill(results) 

我得到主‘groovy.lang.MissingMethodException的「在線程異常’:沒有簽名方法:...「僅用於」嵌套「步驟(例如,repeat(**out**()),has('xxx',**within**(...),is(**lte**(30))by(**bothE**())等)。所有簡單步驟(outE('xxx'),is(32)等)運行良好。 Gremlin控制檯中的所有遍歷都正常運行。

我使用NetBeans中的如下因素的Java庫:

commons-cli-1.2.jar 
commons-codec-1.9.jar 
commons-configuration-1.10.jar 
commons-lang-2.6.jar 
commons-lang3-3.3.1.jar 
commons-logging-1.2.jar 
gbench-0.4.3-groovy-2.4.jar 
gprof-0.3.1-groovy-2.4.jar 
gremlin-console-3.2.3.jar 
gremlin-core-3.2.3.jar 
gremlin-driver-3.2.3.jar 
gremlin-groovy-3.2.3.jar 
gremlin-shaded-3.2.3.jar 
groovy-2.4.7-indy.jar 
groovy-2.4.7.jar 
groovy-ant-2.4.7.jar 
groovy-console-2.4.7.jar 
groovy-groovysh-2.4.7-indy.jar 
groovy-json-2.4.7-indy.jar 
groovy-jsr223-2.4.7-indy.jar 
groovy-sql-2.4.7-indy.jar 
groovy-swing-2.4.7.jar 
groovy-templates-2.4.7.jar 
groovy-xml-2.4.7.jar 
hppc-0.7.1.jar 
httpclient-4.5.1.jar 
httpcore-4.4.3.jar 
ivy-2.3.0.jar 
jBCrypt-jbcrypt-0.4.jar 
javatuples-1.2.jar 
jcabi-log-0.14.jar 
jcabi-manifests-1.1.jar 
jcl-over-slf4j-1.7.21.jar 
jline-2.12.jar 
log4j-1.2.17.jar 
netty-all-4.0.40.Final.jar 
slf4j-api-1.7.21.jar 
slf4j-log4j12-1.7.21.jar 
snakeyaml-1.15.jar 
tinkergraph-gremlin-3.2.3.jar 

我在做什麼錯?

回答

1

Apache TinkerPop docs上圖遍歷:

爲了減少表達的詳細程度,這是好事,import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*。通過這種方式,不用爲匿名遍歷做__.inE(),可以簡單地編寫inE()。使用匿名遍歷時,請注意語言特定的保留關鍵字。例如,在Groovy中保留關鍵字,因此您必須使用詳細語法__.in()__.as()以避免衝突。

同樣爲predicates,像lte()within()

爲了減少謂詞表達式的詳細程度,這是好事,import static org.apache.tinkerpop.gremlin.process.traversal.P.*

0

非常感謝,但這些進口運行良好:

import org.apache.tinkerpop.gremlin.tinkergraph.structure.* 
import org.apache.tinkerpop.gremlin.groovy.loaders.* 
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.* 
import static org.apache.tinkerpop.gremlin.process.traversal.P.* 
import static org.apache.tinkerpop.gremlin.process.traversal.Order.* 


GremlinLoader.load() 
SugarLoader.load() 

def graph = TinkerFactory.createModern() 
def g = graph.traversal() 

def results = [] 


def v4=g.V(4).next() 
def v6=g.V(6).next() 
v4.addEdge("knows", v6, "id" , 13, "weight", 0.4) 

def subGraph = g.E().hasLabel('knows').subgraph('subGraph').cap('subGraph').next() 
def sg = subGraph.traversal() 
sg.E().fill(results) 
println "sg.E() =>[e[7][1-knows->2], e[8][1-knows->4], e[12][4-knows->6]] ==>" + results 
results = [] 

g.V(1).outE('knows').inV().values('name').fill(results) 
println "g.V(1).outE('knows').inV().values('name') =>[vadas, josh] ==>" + results 
results = [] 
g.V(4).outE('knows').inV().values('name').fill(results) 
println "g.V(4).outE('knows').inV().values('name') =>[peter] ==>" + results 
results = [] 
g.V(1).outE('knows').fill(results) 
println "g.V(1).outE('knows') =>[e[7][1-knows->2], e[8][1-knows->4]] ==>" + results 
results = [] 
g.V().has('name','marko').out('created').fill(results) 
println "g.V(1).outE('knows') =>[v[3]] ==>" + results 
results = [] 
g.V().has('name','marko').out('created').in('created').values('name').fill(results) 
println "g.V().has('name','marko').out('created').in('created').values('name') =>[marko, josh, peter] ==>" + results 
results = [] 
g.V().range(0, 2).fill(results) 
println "g.V().range(0, 2) =>[v[1], v[2]] ==>" + results 
results = [] 
g.V().values('name').order().fill(results) 
println "g.V().values('name').order() =>[josh, lop, marko, peter, ripple, vadas] ==>" + results 
results = [] 
g.V().values('name').order().tail().fill(results) 
println "g.V().values('name').order().tail() =>[vadas] ==>" + results 
results = [] 
g.V().hasLabel('person').fill(results) 
println "g.V().hasLabel('person') =>[v[1], v[2], v[4], v[6]] ==>" + results 
results = [] 
g.V().hasLabel('person').out().has('name','josh').fill(results) // 
println "g.V().hasLabel('person').out().has('name','josh') =>[v[4]] ==>" + results 
results = [] 
g.V().out('knows').map{it.get().value('name') + ' is the friend name'}.fill(results) 
println "g.V().out('knows').map{it.get().value('name') + ' is the friend name'} =>[vadas is the friend name, josh is the friend name, peter is the friend name] ==>" + results 
results = [] 
g.V().values('name').order().fill(results) 
println "g.V().values('name').order() =>[josh, lop, marko, peter, ripple, vadas] ==>" + results 
results = [] 
g.V().values('age').is(32).fill(results) 
println "g.V().values('age').is(32) =>[32] ==>" + results 
results = [] 
g.V().values('age').mean().fill(results) 
println "g.V().values('age').mean() =>[30.75] ==>" + results 
results = [] 
g.V(1).property('country','usa').fill(results) 
println "g.V(1).property('country','usa') =>[v[1]] ==>" + results 
results = [] 
g.V(1).out('created').aggregate('x').fill(results) 
println "g.V(1).out('created').aggregate('x') =>[v[3]] ==>" + results 
results = [] 
g.V().as('a').out('created').as('b').select('a','b').fill(results) 
println "g.V().as('a').out('created').as('b').select('a','b') =>[[a:v[1], b:v[3]], [a:v[4], b:v[5]], [a:v[4], b:v[3]], [a:v[6], b:v[3]]] ==>" + results 
results = [] 
g.V().hasLabel('person').count().fill(results) 
println "g.V().hasLabel('person').count() =>[4] ==>" + results 
results = [] 
g.V().coin(0.5).fill(results) 
println "g.V().coin(0.5) =>some random vertices ==>" + results 
results = [] 
g.withSack(1.0f).V().sack().fill(results) 
println "g.withSack(1.0f).V().sack() =>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ==>" + results 
results = [] 
g.V().outE().sample(1).values('weight').fill(results) 
println "g.V().outE().sample(1).values('weight') =>[0.5] ==>" + results 
results = [] 
g.V().values('age').sum().fill(results) 
println "g.V().values('age').sum() =>[123] ==>" + results 
results = [] 
g.V().as('a').both().both().as('b').count().fill(results) 
println "g.V().as('a').both().both().as('b').count() =>[40] ==>" + results 
results = [] 
g.V().as('a').both().both().as('b').where('a',neq('b')).count().fill(results) 
println "g.V().as('a').both().both().as('b').where('a',neq('b')) =>[26] ==>" + results 
results = [] 
g.V().hasLabel('person').out().has('name',within('vadas','josh')).fill(results) 
println "g.V().hasLabel('person').out().has('name',within('vadas','josh')) =>[v[2], v[4]] ==>" + results 
results = [] 
g.V().values('age').is(lte(30)).fill(results) 
println "g.V().values('age').is(lte(30)) =>[29, 27] ==>" + results 
results = [] 
g.V().group().by(bothE().count()).fill(results) 
println "g.V().group().by(bothE().count()) =>[[1:[v[2], v[5]], 2:[v[6]], 3:[v[1], v[3]], 4:[v[4]]]] ==>" + results 
results = [] 
g.V(1).repeat(out()).times(2).fill(results) 
println "g.V(1).repeat(out()).times(2) =>[v[5], v[3], v[6]] ==>" + results 
results = [] 
g.V(1).repeat(out()).times(2).path().by('name').fill(results) 
println "g.V(1).repeat(out()).times(2).path().by('name') =>[[marko, josh, ripple], [marko, josh, lop], [marko, josh, peter]] ==>" + results 
results = [] 
g.V(1).repeat(out().simplePath()).until(hasId(6)).path().limit(1).fill(results) 
println "g.V(1).repeat(out().simplePath()).until(hasId(6)).path().limit(1) =>[[v[1], v[4], v[6]]] ==>" + results 
results = [] 
g.V().until(has('name','ripple')).repeat(out()).fill(results) 
println "g.V().until(has('name','ripple')).repeat(out()) =>[v[5], v[5], v[5]] ==>" + results 
results = [] 
g.V().until(has('name','ripple')).repeat(out()).path().by('name').fill(results) 
println "g.V().until(has('name','ripple')).repeat(out()).path().by('name') =>[[marko, josh, ripple], [josh, ripple], [ripple]] ==>" + results 
results = [] 
g.V(1).until(has('name','josh')).repeat(out('knows')).path().by('name').fill(results) 
println "g.V(1).until(has('name','josh')).repeat(out('knows')).path().by('name') =>[[marko, josh]] ==>" + results 
results = [] 
g.V(1).until(outE('knows').count().is(0)).repeat(out('knows')).path().by('name').fill(results) 
println "g.V(1).until(outE('knows').count().is(0)).repeat(out('knows')).path().by('name') =>[[marko, vadas], [marko, josh, peter]] ==>" + results 
results = [] 
g.V(2).optional(out('knows')).fill(results) 
println "g.V(1).optional(out('knows')) =>[v[2]] ==>" + results 
results = [] 
g.V().where(outE('created').and().outE('knows')).values('name').fill(results) 
println "g.V().where(outE('created').and().outE('knows')).values('name') =>[marko, josh] ==>" + results 
results = [] 
g.V().values('name').order().by(decr).fill(results) 
println "g.V().values('name').order().by(decr) =>[vadas, ripple, peter, marko, lop, josh] ==>" + results 
results = [] 
g.V().hasLabel('person').order().by(shuffle).fill(results) 
println "g.V().hasLabel('person').order().by(shuffle) =>some random order of v[1], v[2], v[4], v[6] ==>" + results 
results = []