在旧版本中泰坦数据库(0.5.2 版) the 泰坦顶点 and 泰坦之刃实施泰坦元素有方法的接口getProperties(String key)
我用来检索元素属性值。这个方法在新版本的Titan中被删除了(我使用的是1.0.0版本)。我找到的不是这个方法valueOrNull(PropertyKey key)
做同样的事情但收到属性键作为参数而不是String作为键名。
仅使用属性键名称作为 String 对象来检索属性值的最佳方法是什么?
或者是否有简单的方法从属性键名称获取 PropertyKey 对象作为 String?
Titan 1.0 是基于TinkerPop 3 的。在Titan 1.0 中,您会发现之前在Titan 0.5 中调用的一些方法是在TinkerPop 接口中定义的,而不是在Titan 接口中定义的。
查看 Javadoccom.thinkaurelius.titan.core.TitanVertex
,你可以看到它延伸了org.apache.tinkerpop.gremlin.structure.Vertex
http://thinkaurelius.github.io/titan/javadoc/1.0.0/com/thinkaurelius/titan/core/TitanVertex.html http://thinkaurelius.github.io/titan/javadoc/1.0.0/com/thinkaurelius/titan/core/TitanVertex.html
你可以找到方法VertexProperty property(String key)
on org.apache.tinkerpop.gremlin.structure.Vertex
http://tinkerpop.incubator.apache.org/javadocs/3.0.1-incubating/full/org/apache/tinkerpop/gremlin/struct/Vertex.html#property-java.lang.String- http://tinkerpop.incubator.apache.org/javadocs/3.0.1-incubating/full/org/apache/tinkerpop/gremlin/structure/Vertex.html#property-java.lang.String-
使用属性键检索顶点属性值的最佳方法如下:
gremlin> graph = TitanFactory.build().set('storage.backend','inmemory').open()
==>standardtitangraph[inmemory:[127.0.0.1]]
gremlin> g = graph.traversal()
==>graphtraversalsource[standardtitangraph[inmemory:[127.0.0.1]], standard]
gremlin> v = graph.addVertex('name', 'octopus')
==>v[4296]
gremlin> v.values('name')
==>octopus
您可以在此处的 TinkerPop3 文档中了解有关顶点属性的更多信息http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#vertex-properties http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#vertex-properties
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)