TitanDB - 按时间戳降序构建属性索引 [英] TitanDB - Build a property index in descending order by timestamp
问题描述
Gremlin 3
我有一组带有标签 a 的顶点。我在这些顶点上有一个 long 类型的属性,它与1970年UTC(创建顶点时的时间戳)的毫秒数相对应。当我拉回那些我希望能够拉动的顶点时他们返回 decsending 顺序。
如何在 decr 顺序中的<强大的>泰坦管理系统?
文档似乎含糊其词。
是 public RelationTypeIndex buildPropertyIndex(PropertyKey key,
String name,
Order sortOrder,
PropertyKey .. 。sortKeys)
但是我作为键和sortKeys放入了什么?我希望能够拉动由timestamp属性命令的整个顶点。
编辑:我知道这样做的唯一方法是通过在边上复制该属性并在边上使用顶点中心索引来提高性能。 我做了一些事情类似于我在特定产品发布日期前订购的产品。如果你想有效地执行 order()。by(Value,decr)
,那么我强烈建议读入混合索引此处。混合指数允许这些操作快速完成。
您可能正在寻找的示例:
TitanGraph graph = TitanFactory.open(config);
TitanManagement mgmt = graph.openManagement();
PropertyKey key = mgmt.makePropertyKey(TimeStamp)。dataType(Long.class).make();
mgmt.buildIndex(timeStampIndex,Vertex.class).addKey(key).buildMixedIndex(search);
mgmt.commit();
上面的索引让我快速执行以下查询:
gV()。order()。by(TimeStamp,decr);
这就是时间戳的降序。上面的遍历可以在没有索引的情况下工作,但在大图中可能很慢。
TitanDB 1.0.0 (on top of DynamoDB)
Gremlin 3
I've got a set of vertices with a label a. I have a property of type long on those vertices which corresponds to the time in milliseconds from 1970 UTC (timestamp of when the vertex was created.) When I pull back those vertices I want to be able to pull them back in decsending order.
How can I create an index on that property in the decr order in Titan Management System?
Documentation seems vague on that.
Closest thing I found is
public RelationTypeIndex buildPropertyIndex(PropertyKey key,
String name,
Order sortOrder,
PropertyKey... sortKeys)
But what do I put in as the key and sortKeys? I want to be able to pull the whole vertex ordered by the timestamp property
Edit: The only way I know of doing this at the minute is by duplicating that property on the edge and using a vertex centric index on the edge to increase the performance.
I do something similar as I order by the release date of a particular product. If you want to execute order().by("Value", decr)
efficiently then I highly recommend reading into mixed indices specified here. Mixed indices allow these operations to be done quickly.
An example of what you may be looking for:
TitanGraph graph = TitanFactory.open(config);
TitanManagement mgmt = graph.openManagement();
PropertyKey key = mgmt.makePropertyKey("TimeStamp").dataType(Long.class).make();
mgmt.buildIndex("timeStampIndex", Vertex.class).addKey(key).buildMixedIndex("search");
mgmt.commit();
The above index lets me execute the following query very quickly:
g.V().order().by("TimeStamp", decr);
Which gets me the time stamps in descending order. The above traversal will work without indexing but can be slow in large graphs.
这篇关于TitanDB - 按时间戳降序构建属性索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!