<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)  編輯  收藏 所屬分類:
    主站蜘蛛池模板: 亚洲国产成人乱码精品女人久久久不卡 | a级毛片毛片免费观看久潮喷| 好大好硬好爽免费视频| 亚洲免费电影网站| 免费看片在线观看| 亚洲国产精品xo在线观看| 2019中文字幕在线电影免费| 久久亚洲精品中文字幕无码| 久久青草91免费观看| 久久亚洲精品国产精品黑人| 日韩精品无码专区免费播放| 亚洲精品白色在线发布| 国产免费的野战视频| 亚洲人成人网毛片在线播放| 成年性午夜免费视频网站不卡 | 国产亚洲人成在线影院| 国产一级高清视频免费看| 精品女同一区二区三区免费播放| 亚洲精品99久久久久中文字幕 | 国产精品亚洲综合一区| 99久久99这里只有免费的精品| 亚洲AV中文无码乱人伦下载 | 免费看h片的网站| 中文字幕亚洲码在线| 免费日本黄色网址| 成在人线av无码免费高潮水| 久久精品国产精品亚洲艾| 巨波霸乳在线永久免费视频 | 亚洲日本韩国在线| 一级毛片免费不卡在线| 亚洲乱码在线播放| 免费人妻av无码专区| 男的把j放进女人下面视频免费| 337p日本欧洲亚洲大胆色噜噜| 毛片在线看免费版| 一级毛片人与动免费观看| 亚洲AV人无码激艳猛片| 成人免费视频一区二区三区| 一级中文字幕乱码免费| 亚洲福利视频一区二区三区| 四虎影视精品永久免费|