How to add vertices to gremlin server in a batch from Gremlin.NET?

跟風遠走 提交于 2020-05-12 08:28:38

问题


I am trying to populate a graph running in gremlin server with data from my SQL database. I would like to read the data from the database, iterate over the results and add them to the graph. This is done in a c# program so I am using Gremlin.NET bytecode.

I CAN do this by doing the c# equivalent of the example found here:

https://github.com/krlawrence/graph/blob/master/sample-code/RemoteAddBatch.java

And the c# equivalent of the answer found here:

Adding multiple vertices, changing one property-value (tinkerpop3 + python GLV)

However, I'd like to take a more functional approach. In both of these answers you have to start a traversal by adding the first vertex in your set and then you can chain off of that in something like a for loop. Is it possible to not have to add first vertex and then begin to chain other additions?

I am trying to avoid adding the first vertex and then looping because the database set might not have any results. If that is the case then I have to add an 'if' statements in order to properly handle the scenario. I'd also like to avoid having to inject a script and stick with bytecode. ie running something like

Gremlin.Net.Driver.GremlinClient.SubmitAsync<string>("g.addV('mylabel').addV('myotherlabel')")

I have also thought about adding a dummy vertex to start the traversal and then I can go into looping through adding the actual vertices I want to add. Afterwards I could then remove this dummy vertex. For reasons that I hope are obvious the dummy vertex idea feels like the wrong approach.

来源:https://stackoverflow.com/questions/57060203/how-to-add-vertices-to-gremlin-server-in-a-batch-from-gremlin-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!