【问题标题】:Titan Warn: Query requires iterating over all vertices [(name <> null)]Titan 警告:查询需要遍历所有顶点 [(name <> null)]
【发布时间】:2016-04-21 15:16:05
【问题描述】:

我用过下面的代码

mgmt = g.getManagementSystem()
PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make();
mgmt.buildIndex("name",Vertex.class).addKey(name).unique().buildCompositeIndex();

从图表中检索数据时,我收到此警告,

TransactionalGraph tx = g.newTransaction();
Iterator vertex=tx.query().has("name").vertices.iterator();

遍历整个图以获取顶点而不是索引顶点。 请提出更改建议。

【问题讨论】:

  • 什么版本的泰坦?
  • 我正在使用titan-0.5.2-hadoop2

标签: java hbase titan


【解决方案1】:

这是 Titan 1.0 indexing documentation 的链接,但它对复合索引的描述也适用于 0.5.2。

复合索引非常快速高效,但仅限于相等 查找特定的、先前定义的属性组合 键。

复合索引用于完全匹配的键值检索。您的查询应包含您要查找的属性值,以便利用索引。

tx.query().has("name", "userRaj").vertices.iterator()

按照您在问题中进行编码的方式,它必须扫描具有属性name 的所有顶点,因为它不会尝试匹配任何特定值(即null)。

WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [(name <> null)]. For better performance, use indexes

如果您正在进行新的 Titan 开发,我建议您升级到 1.0,因为 0.5.x 流中不会再有任何版本了。

【讨论】:

  • 我想获取所有 key=name 的顶点。我试过 graph.indexQuery("name","v.name:*").vertices().iterator();但它给出了非法ArgumentException
  • 因为现在您正在尝试执行直接索引查询,该查询应该用于混合索引(外部索引后端),而不是复合索引。 s3.thinkaurelius.com/docs/titan/1.0.0/direct-index-query.html
猜你喜欢
  • 1970-01-01
  • 2016-09-30
  • 1970-01-01
  • 1970-01-01
  • 2016-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多