<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    ivaneeo's blog

    自由的力量,自由的生活。

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      669 Posts :: 0 Stories :: 64 Comments :: 0 Trackbacks

    We recently set up HBase and HBase-trx (from https://github.com/hbase-trx) to use multiple-column indexes with this code.  After you compile it, just copy the jar and the hbase-trx jar into your hbase’s lib folder and you should be good to to!

    When you create a composite index, you can see the metadata for the index by looking at the table description.  One of the properties will read “INDEXES =>” followed by index names and ‘family:qualifier’ style column names in the index.

    KeyGeneratorFactory:

    package com.ir.store.hbase.indexes;

    import java.util.List;

    import org.apache.hadoop.hbase.client.tableindexed.IndexKeyGenerator;

    public class KeyGeneratorFactory {

    public static IndexKeyGenerator getInstance(List columns) {
    return new HBaseIndexKeyGenerator(columns);
    }
    }

    HBaseIndexKeyGenerator:

    package com.ir.store.hbase.indexes;

    import java.io.DataInput;
    import java.io.DataOutput;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;
    import org.apache.hadoop.hbase.client.tableindexed.IndexKeyGenerator;
    import org.apache.hadoop.hbase.util.Bytes;

    public class HBaseIndexKeyGenerator extends Object implements IndexKeyGenerator {
    public static byte[] KEYSEPERATOR = "~;?".getBytes();

    private int columnCount;
    private List columnNames = new ArrayList();

    public HBaseIndexKeyGenerator(List memberColumns) {
    // For new key generators
    columnNames = memberColumns;
    columnCount = memberColumns.size();
    }

    public HBaseIndexKeyGenerator() {
    // Hollow constructor for deserializing -- should call readFields shortly
    columnCount = 0;
    }

    public void readFields(DataInput binaryInput) throws IOException {
    columnCount = binaryInput.readInt();
    for (int currentColumn = 0; currentColumn < columnCount; currentColumn++)
    columnNames.add(Bytes.readByteArray(binaryInput));
    }

    public void write(DataOutput binaryOutput) throws IOException {
    binaryOutput.writeInt(columnCount);
    for (byte[] columnName : columnNames)
    Bytes.writeByteArray(binaryOutput, columnName);
    }

    public byte[] createIndexKey(byte[] baseRowIdentifier, Map baseRowData) {
    byte[] indexRowIdentifier = null;
    for (byte[] columnName: columnNames) {
    if (indexRowIdentifier == null)
    indexRowIdentifier = baseRowData.get(columnName);
    else indexRowIdentifier = Bytes.add(indexRowIdentifier, HBaseIndexKeyGenerator.KEYSEPERATOR, baseRowData.get(columnName));
    }
    if (baseRowIdentifier != null)
    return Bytes.add(indexRowIdentifier, HBaseIndexKeyGenerator.KEYSEPERATOR, baseRowIdentifier);
    return indexRowIdentifier;
    }
    }
    posted on 2011-06-11 16:21 ivaneeo 閱讀(411) 評論(0)  編輯  收藏 所屬分類:
    主站蜘蛛池模板: 二个人看的www免费视频| 国产亚洲日韩在线a不卡| 可以免费观看的毛片| 91麻豆国产自产在线观看亚洲| 亚洲av日韩综合一区二区三区| 爽爽日本在线视频免费| 久久亚洲中文字幕无码| 免费人成视频x8x8入口| 青草青草视频2免费观看| 亚洲国产a级视频| 皇色在线免费视频| 亚洲爆乳无码专区| 久久A级毛片免费观看| 亚洲精品电影在线| 噼里啪啦电影在线观看免费高清| 亚洲三级中文字幕| AV免费网址在线观看| 国产精品成人亚洲| 日韩一卡2卡3卡4卡新区亚洲 | 亚洲国产香蕉人人爽成AV片久久| 另类图片亚洲校园小说区| 亚洲视频一区二区| 免费毛片在线看不用播放器| 亚洲人成网址在线观看| 免费观看黄色的网站| 亚洲hairy多毛pics大全| 亚洲伊人久久综合影院| 日韩插啊免费视频在线观看| 亚洲va在线va天堂成人| 免费在线观看的黄色网址| 99在线视频免费观看| 亚洲国产精品综合久久久| 日本免费一区二区三区最新| caoporn国产精品免费| 亚洲春黄在线观看| 免费A级毛片无码A∨男男| 久久免费观看国产精品88av| 亚洲a级片在线观看| 亚洲国产一级在线观看| 99在线热视频只有精品免费| 亚洲av成人一区二区三区观看在线 |