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

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

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

    ivaneeo's blog

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

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      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 閱讀(410) 評論(0)  編輯  收藏 所屬分類:
    主站蜘蛛池模板: 亚洲AV第一页国产精品| 暖暖日本免费在线视频| 亚洲中文久久精品无码| 免费看黄网站在线看| 亚洲国产精品视频| 深夜久久AAAAA级毛片免费看| 日韩电影免费在线| 阿v免费在线观看| 亚洲国产午夜福利在线播放| 免费中文字幕视频| 亚洲无线码一区二区三区| 亚洲精品无码久久久久A片苍井空| 免费人成在线观看网站品爱网| 亚洲成亚洲乱码一二三四区软件| 伊人免费在线观看| 亚洲一区二区在线视频| 男女免费观看在线爽爽爽视频| 国产老女人精品免费视频| 麻豆亚洲AV成人无码久久精品| 免费一级毛片不卡在线播放| 亚洲av日韩av无码| 最近中文字幕无免费| 亚洲欧洲在线播放| 日本免费人成黄页网观看视频| 黄页网站在线视频免费| 亚洲欧洲日产国码无码网站| 永久在线免费观看| 亚洲国产精品无码久久98 | 免费A级毛片无码专区| 亚洲国产成人久久精品app| 午夜老司机免费视频| 免费在线观看自拍性爱视频| 久久精品国产亚洲av麻豆| 可以免费看黄视频的网站| 三年片在线观看免费观看大全中国 | 久久久久亚洲AV无码专区首JN| 毛片a级毛片免费播放下载| 免费人成网站永久| 亚洲激情黄色小说| 久久不见久久见免费视频7| 亚洲精品无码人妻无码|