How to efficiently create a vertex with a label and several properties?

不打扰是莪最后的温柔 提交于 2019-12-13 02:05:26

问题


I want to create a vertex with a given label and some properties. Since the g.addVertexWithLabel() method only takes the label as an argument and I cannot find any v.addLabel() method, it seems that I have to add the properties one by one after creating the vertex.

Or am I missing something here?


回答1:


No. As of Titan 0.5.4, there is no API that allows you to add it all at once. In fact, even the Gremlin Groovy sugar of:

g.addVertex([name:"stephen"]) 

just calls Element.setProperty(k,v) for each key/value pair in the Map. In TinkerPop3 and Titan 0.9/1.0, you can do:

g.addVertex(T.label,"person","name","stephen")

so it is a bit nicer assuming you are using the newer version.



来源:https://stackoverflow.com/questions/30727307/how-to-efficiently-create-a-vertex-with-a-label-and-several-properties

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