【问题标题】:How does titan store vertex id (translate vertex id to HBase key column)?titan 如何存储顶点 id(将顶点 id 转换为 HBase 键列)?
【发布时间】:2015-01-22 11:25:21
【问题描述】:

我正在使用titan 0.5.0 版和HBase。 我有一个没有分裂的区域,因为顶点有很多边,我想知道这个顶点的 id 是什么。 如何将 HBase 键列转换为 Titan 顶点 ID?

我的 HBase 键列是 \x00\x8C\x1D\xB3\xBDZ<\x10

【问题讨论】:

    标签: hbase titan


    【解决方案1】:

    用于将HBase键列转换为Titan顶点id的函数是getKeyIDManager类下(在titan-core中)。

    这是取出后的代码。 仅适用于 NormalVertex

    String hexKey = "008C1DB3BD5A3C10";
    byte[] byteArr = BaseEncoding.base16().decode(hexKey);
    StaticArrayBuffer buff = new StaticArrayBuffer(byteArr,0,hexKey.length());
    
    // The code from titan with some simplifications
    long partitionBits = 6;
    long normalVertexOffset = 3l;
    long TOTAL_BITS = Long.SIZE - 1;
    
    long value = b.getLong(0);
    long partitionOffset = Long.Size - partitionBits;
    IDManager.VertexIDType type = IDManager.VertexIDType.NormalVertex;
    long partition = partitionOffset < Long.SIZE ? value >>> partitionOffset : 0;
    long USERVERTEX_PADDING_BITWIDTH = normalVertexOffset;
    long count = ( value >>> USERVERTEX_PADDING_BITWIDTH & ((1l <<(partitionOffset - USERVERTEX_PADDING_BITWIDTH )) -1 );
    
    long partitionIDBound = (1l << (partitionBits));
    long id = (count << partitionBits) + partition;
    if(type != null) id = type.addPadding(id);
    System.out.println("Key is " + id);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-28
      • 1970-01-01
      • 1970-01-01
      • 2016-10-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多