【问题标题】:Titan: Range query in graphTitan:图中的范围查询
【发布时间】:2014-02-07 05:23:56
【问题描述】:

我正在使用Titan Graph Database。假设我有一个 id VID 的顶点 V 并且有 10K 个顶点连接到它 v1 的 id 为 v1id,v2 的 id 为 v2id ....................v10000 id 为 v10000id。

现在我想要分页来获取邻居顶点,即每次调用 10 个顶点细节。

它应该支持nextprevious 结果。我看到了limit(),但它只是限制了返回结果的数量。我看到THIS SO 并且似乎接近我需要的东西,但是在Titan 中是否有某种范围之类的东西,我可以在其中传递起始顶点 id 和我想要的结果数??

【问题讨论】:

    标签: graph-databases titan


    【解决方案1】:

    使用 Gremlin,您可以传递范围的索引:

      // for the second ten links
      g.v(1).outE.has('time',T.gte, fiveDaysAgoInMs)[10..19]
    
      // for the previous ten links
      g.v(1).outE.has('time',T.gte, fiveDaysAgoInMs)[0..9]
    
      // for the next ten links
      g.v(1).outE.has('time',T.gte, fiveDaysAgoInMs)[20..29]
    
      // for one link only
      g.v(1).outE.has('time',T.gte, fiveDaysAgoInMs)[0..<1]
    

    来源:GremlinDocs

    在 Java 代码中:

    Graph g = ... // a reference to a Blueprints graph
    GremlinePipeline pipe = new GremlinPipeline();
    
    Long DAY_IN_MS = 1000 * 60 * 60 * 24;
    
    // first 10
    pipe.start(g.getVertex(1)).outE().has("time", Tokens.gte, new Date(date.getTime() - (5 * DAY_IN_MS))).range(0, 10));
    
    // if you want next 10
    pipe.next(10);
    

    来源:GremlinPipelineUsing Gremlin though Java

    【讨论】:

    • DAY_IN_MS 是什么?whts 是它的价值
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-20
    • 2012-01-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多