<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 閱讀(402) 評論(0)  編輯  收藏 所屬分類:
    主站蜘蛛池模板: 一级特黄录像视频免费| 美女被免费喷白浆视频| 亚洲高清免费在线观看| 性感美女视频免费网站午夜 | 无码人妻一区二区三区免费视频| 亚洲色精品88色婷婷七月丁香| 一本岛高清v不卡免费一三区| 羞羞视频在线免费观看| 久久精品蜜芽亚洲国产AV| 全部免费毛片免费播放| 一级做a爰全过程免费视频| 亚洲av无码成人精品国产| 久久噜噜噜久久亚洲va久| 国产黄色片在线免费观看| 无码日韩精品一区二区三区免费 | 暖暖日本免费在线视频| 日本免费中文字幕| 国产AV无码专区亚洲AV麻豆丫| 亚洲va无码va在线va天堂| 四虎永久在线精品免费影视 | 免费在线观看你懂的| 免费能直接在线观看黄的视频| 51午夜精品免费视频| 91在线亚洲综合在线| 亚洲天堂中文资源| 亚洲午夜精品第一区二区8050| 国内自产少妇自拍区免费| 蜜臀98精品国产免费观看| 中文字幕在线免费播放| 国产精品手机在线亚洲| 国产午夜亚洲精品国产| 久久亚洲精品无码VA大香大香| 伊人久久亚洲综合| 免费萌白酱国产一区二区| 在线免费不卡视频| 18国产精品白浆在线观看免费 | 亚洲成年看片在线观看| 蜜桃精品免费久久久久影院 | 亚洲欧洲免费视频| 国产午夜亚洲精品午夜鲁丝片| 在线免费一区二区|