gremlin - How can I load csv file to janusgraph(addVertex and addEdge)? -
i have below gremlin command below. can work fine.
new file("data/1a78de40-8f0a-1028-9c9e-db07163b51b2.csv").eachline{l->p=l.split(",");v1=g.v().has('uuid',p[0])?:graph.addvertex('uuid',p[0]);v2=g.v().has('uuid',p[1])?:graph.addvertex('uuid',p[1]);}
but below can't work well.
new file("data/1a78de40-8f0a-1028-9c9e-db07163b51b2.csv").eachline{l->p=l.split(",");v1=g.v().has('uuid',p[0])?:graph.addvertex('uuid',p[0]);v2=g.v().has('uuid',p[1])?:graph.addvertex('uuid',p[1]);v1.addedge(p[4],v2)}
the error here:
gremlin> new file("data/1a78de40-8f0a-1028-9c9e-db07163b51b2.csv").eachline{l->p=l.split(",");v1=g.v().has('uuid',p[0])?:graph.addvertex('uuid',p[0]);v2=g.v().has('uuid',p[1])?:graph.addvertex('uuid',p[1]);v1.addedge(p[4],v2)}
21:30:12 warn org.janusgraph.graphdb.transaction.standardjanusgraphtx - query requires iterating on vertices [(uuid = 1a78de40-8f0a-1028-9c9e-db07163b51b2)]. better performance, use indexes 21:30:12 warn org.janusgraph.graphdb.transaction.standardjanusgraphtx - query requires iterating on vertices [(uuid = d803d140-8f0a-1028-98de-db07163b51b2)]. better performance, use indexes 21:30:12 warn org.janusgraph.graphdb.transaction.standardjanusgraphtx - query requires iterating on vertices [(uuid = 1a78de40-8f0a-1028-9c9e-db07163b51b2)]. better performance, use indexes 21:30:12 warn org.janusgraph.graphdb.transaction.standardjanusgraphtx - query requires iterating on vertices [(uuid = 92df9f40-8f0a-1028-8723-db07163b51b2)]. better performance, use indexes no signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.defaultgraphtraversal.addedge() applicable argument types: (java.lang.string, org.janusgraph.graphdb.vertices.standardvertex) values: [communitiesmember, v[122908672]] type ':help' or ':h' help. display stack trace? [yn]
the csv file below: 1a78de40-8f0a-1028-9c9e-db07163b51b2,d803d140-8f0a-1028-98de-db07163b51b2,2012-09-18t08:56:01z,1,communitiesmember 1a78de40-8f0a-1028-9c9e-db07163b51b2,92df9f40-8f0a-1028-8723-db07163b51b2,2012-09-18t08:56:01z,1,communitiesmember 1a78de40-8f0a-1028-9c9e-db07163b51b2,281edc40-3c20-102c-9a69-980191c9f99a,2012-09-18t08:56:01z,1,communitiesmember 1a78de40-8f0a-1028-9c9e-db07163b51b2,878c73c0-8f0a-1028-91a1-db07163b51b2,2012-09-18t08:56:01z,1,communitiesmember 1a78de40-8f0a-1028-9c9e-db07163b51b2,5427d240-9f1e-102c-9233-9c1aa9e13df3,2012-09-18t08:56:01z,1,communitiesmember
the issue here assigning traversal instead of assigning vertex variables.
new file("data/1a78de40-8f0a-1028-9c9e-db07163b51b2.csv").eachline{ l->p=l.split(","); t_v1= g.v().has('uuid',p[0]); v1 = t_v1.hasnext() ? t_v1.next() : graph.addvertex('uuid',p[0]); t_v2 = g.v().has('uuid',p[1]); v2 = t_v2.hasnext() ? t_v2.next() : graph.addvertex('uuid',p[1]); v1.addedge(p[4],v2); } should work.
Comments
Post a Comment