简体   繁体   中英

Gremlin : Add multiple vertices in single gremlin query?

I am using Titan 0.4 + Cassandra. My use-case requires insert multiple vertices at a time. (aprrox batch size is 100 vertices at a time.) eg :

v01 = g.addVertex(["UC":"B","i":2]); v02 = g.addVertex(["UC":"H","i":1])
v03 = g.addVertex(["LC":"a"]); v04 = g.addVertex(["LC":"a"]);
v05 = g.addVertex(["LC":"d"]); v06 = g.addVertex(["LC":"h"]); 
v07 = g.addVertex(["LC":"i"]); v08 = g.addVertex(["LC":"p"]);

Is there any gremlin command to add all Eight vertices in a single request . ( something like g.addVertices() ?? )

Gremlin没有addVertices()包装器-您需要多次调用addVertex()。

I'm using the c# SDK. What worked for me is just chaining the addV commands:

g.addV('item').property('id', '5aa3a51e-6434-4d53-aed4-
5db3c90e3551').addV('item').property('id', '7f859920-2251-4553-8325-
5dbb2f626d1c')

for your example:

g.addVertex(["UC":"B","i":2]).addVertex(["UC":"H","i":1]).addVertex(["LC":"a"]).addVertex(["LC":"a"]).addVertex(["LC":"d"]).addVertex(["LC":"h"]).addVertex(["LC":"i"]).addVertex(["LC":"p"])

hope this helps

I had the requirement to add several vertices at the same time too. Individual addV queries weren't practical for inserting thousands of record at a time, while also retrieving their database generated ids.

Here's what I came up with as a batch insertion command/query

g.addV('One').values('id').as('one').addV('Two').values('id').as('two').select('one', 'two')

CosmosDB returns

[{
   "one": "372be552-7f63-4d7b-be81-a73d5d677afa",
   "two": "a60d3773-5c29-454e-b079-dec734c4f431"
}]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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