<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)  編輯  收藏 所屬分類:
    主站蜘蛛池模板: 黄色网址免费观看| 免费日韩在线视频| 亚洲老熟女五十路老熟女bbw| 国产网站免费观看| 成人电影在线免费观看| 亚洲乱码一二三四五六区| 国产三级电影免费观看| 久久免费线看线看| 亚洲狠狠色丁香婷婷综合| 国产成人无码综合亚洲日韩| 91情侣在线精品国产免费| 五月天婷婷免费视频| 亚洲二区在线视频| 国产亚洲精品成人a v小说| 免费人成在线视频| 在线观看肉片AV网站免费| 亚洲av永久无码精品秋霞电影秋 | 国产精品jizz在线观看免费| 97无码人妻福利免费公开在线视频| 亚洲色欲色欲www| 久久亚洲高清观看| 亚洲AV无码一区二区三区在线观看| 久久国产色AV免费观看| 一级午夜免费视频| 亚洲免费综合色在线视频| 亚洲国产精久久久久久久| gogo全球高清大胆亚洲| 国产麻豆视频免费观看| 三年片在线观看免费西瓜视频| 久久久久久亚洲av无码蜜芽| 亚洲视频免费一区| 亚洲国产成人精品无码区在线观看| 国产嫩草影院精品免费网址| 999国内精品永久免费观看| 手机看片国产免费永久| 美女裸体无遮挡免费视频网站| 亚洲Av无码一区二区二三区| 久久青青草原亚洲av无码app| 国产成人亚洲综合| 亚洲?V乱码久久精品蜜桃 | 亚洲?V乱码久久精品蜜桃|