简体   繁体   English

在Titan Graph数据库中创建顶点和边的问题

[英]Issues with Creating Vertex and Edges in Titan Graph Database

I am trying to create vertex and edges in Titan graph database (Titan1.0.0).. 我正在尝试在Titan图形数据库(Titan1.0.0)中创建顶点和边缘。

gremlin> graph = TitanFactory.open('titan-1.0.0-hadoop1/conf/titan-cassandra-es.properties')

gremlin> t1 = graph.addVertex(label, "Testbed", "Name", "testbed1","Status","A","TId",101)
==>v[1228816568]

gremlin> r2= graph.addVertex(label, "Router", "RStatus","F","RId",1002, "TId", 101)
==>v[3686424680]

gremlin> t1.addEdge("tbConRtr", r2)
==>e[kblqtz-kblsxk-d6vp-1oysvhk][1228816568-tbConRtr->3686424680]

Questions: 问题:

1) Why is the vertex number returned here are not sequence and it is some random number? 1)为什么这里返回的顶点数不是序列,而是一些随机数? For addEdge step also it is creating edge with some random value ( kblqtz-kblsxk-d6vp-1oysvhk ) 对于addEdge步骤,它还会创建具有一些随机值的边缘( kblqtz-kblsxk-d6vp-1oysvhk

e[kblqtz-kblsxk-d6vp-1oysvhk][1228816568-tbConRtr->3686424680]

2) I want my TId value should be unique I have tried the following and got Error Msg: 2)我希望我的TId值应该唯一,我尝试了以下操作并获得了错误消息:

gremlin> mgmt.buildIndex("TId",Vertex.class).addKey(TId).unique().buildCompositeIndex();
No such property: TId for class: groovysh_evaluate

How can I create a unique property value in Titan database? 如何在Titan数据库中创建唯一的属性值?

Kindly help me to resolve this. 请帮助我解决这个问题。

  1. Vertex ids and edge ids are generated and assigned by Titan. 顶点ID和边ID由Titan生成和分配。 If you want to have your own identifier, you should define a property and index it. 如果要拥有自己的标识符,则应定义一个属性并为其编制索引。
  2. The error No such property: TId indicates that you are trying to use a variable TId that has not been initialized. 错误No such property: TId表示您正在尝试使用尚未初始化的变量TId You should define the vertex property before trying to index it 您应先定义顶点属性,然后再尝试为其建立索引

     gremlin> graph = TitanFactory.open('conf/titan-cassandra-es.properties') ==>standardtitangraph[cassandrathrift:[127.0.0.1]] gremlin> mgmt = graph.openManagement() ==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem@4b97b3d2 gremlin> TId = mgmt.makePropertyKey("TId").dataType(Integer.class).cardinality(Cardinality.SINGLE).make() ==>TId gremlin> mgmt.buildIndex("TId",Vertex.class).addKey(TId).unique().buildCompositeIndex() ==>TId gremlin> mgmt.commit() ==>null gremlin> t1 = graph.addVertex(label, "Testbed", "Name", "testbed1","Status","A","TId",101) ==>v[4200] gremlin> r2= graph.addVertex(label, "Router", "RStatus","F","RId",1002, "TId", 101) Adding this property for key [TId] and value [101] violates a uniqueness constraint [TId] 

Please refer to the Titan documentation on schema and data modeling and also indexing for better performance . 请参阅有关架构和数据建模的Titan文档, 请参阅索引以获得更好的性能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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