如何有效地创建带有标签和多个属性的顶点? [英] How to efficiently create a vertex with a label and several properties?

查看:73
本文介绍了如何有效地创建带有标签和多个属性的顶点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个具有给定标签和一些属性的顶点.由于g.addVertexWithLabel()方法仅将标签用作参数,而我找不到任何v.addLabel()方法,因此似乎必须在创建顶点后逐个添加属性.

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?

推荐答案

否.从Titan 0.5.4开始,没有API允许您一次添加所有内容.实际上,即使是Gremlin Groovy糖,也可以:

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"]) 

只需为Map中的每个键/值对调用Element.setProperty(k,v).在TinkerPop3和Titan 0.9/1.0中,您可以执行以下操作:

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.

这篇关于如何有效地创建带有标签和多个属性的顶点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆