当前位置: 首页>>代码示例>>Java>>正文


Java ByteArrayBuilder.allocate方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.index.util.ByteArrayBuilder.allocate方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayBuilder.allocate方法的具体用法?Java ByteArrayBuilder.allocate怎么用?Java ByteArrayBuilder.allocate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.index.util.ByteArrayBuilder的用法示例。


在下文中一共展示了ByteArrayBuilder.allocate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addIndexForTable

import org.apache.hadoop.hbase.index.util.ByteArrayBuilder; //导入方法依赖的package包/类
/**
 * @param tableName on which index applying
 * @param indexList list of table
 */
public void addIndexForTable(String tableName, List<IndexSpecification> indexList) {
  this.tableVsIndices.put(tableName, indexList);
  // TODO the inner map needs to be thread safe when we support dynamic index add/remove
  Map<byte[], IndexSpecification> indexMap =
      new TreeMap<byte[], IndexSpecification>(Bytes.BYTES_COMPARATOR);
  for (IndexSpecification index : indexList) {
    ByteArrayBuilder keyBuilder = ByteArrayBuilder.allocate(IndexUtils.getMaxIndexNameLength());
    keyBuilder.put(Bytes.toBytes(index.getName()));
    indexMap.put(keyBuilder.array(), index);
  }
  this.tableIndexMap.put(tableName, indexMap);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:17,代码来源:IndexManager.java

示例2: createCommonKeyForIndex

import org.apache.hadoop.hbase.index.util.ByteArrayBuilder; //导入方法依赖的package包/类
private byte[] createCommonKeyForIndex(byte[] regionStartKey, byte[] indexName) {
  // Format for index table rowkey [Startkey for the index region] + [one 0 byte]+
  // [Index name] + [Padding for the max index name] + ....
  int commonKeyLength = regionStartKey.length + 1 + IndexUtils.getMaxIndexNameLength();
  ByteArrayBuilder builder = ByteArrayBuilder.allocate(commonKeyLength);
  // Adding the startkey for the index region and single 0 Byte.
  builder.put(regionStartKey);
  builder.position(builder.position() + 1);
  // Adding the index name and the padding needed
  builder.put(indexName);
  // No need to add the padding bytes specifically. In the array all the bytes will be 0s.
  return builder.array();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:14,代码来源:ScanFilterEvaluator.java

示例3: formIndexNameFromKV

import org.apache.hadoop.hbase.index.util.ByteArrayBuilder; //导入方法依赖的package包/类
private byte[] formIndexNameFromKV(KeyValue kv) {
  byte[] rowKey = kv.getRow();
  // First two bytes are going to be the
  ByteArrayBuilder keyBuilder = ByteArrayBuilder.allocate(rowKey.length);
  // Start from 2nd offset because the first 2 bytes corresponds to the rowkeylength
  keyBuilder.put(rowKey, 0, rowKey.length);
  String replacedKey = Bytes.toString(keyBuilder.array());
  String emptyByte = Bytes.toString(new byte[1]);
  int indexOf = replacedKey.indexOf(emptyByte);
  return keyBuilder.array(indexOf + 1, IndexUtils.getMaxIndexNameLength());
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:12,代码来源:TTLStoreScanner.java

示例4: addIndexForTable

import org.apache.hadoop.hbase.index.util.ByteArrayBuilder; //导入方法依赖的package包/类
/**
 * @param table name on which index applying
 * @param IndexSpecification list of table
 */
public void addIndexForTable(String tableName, List<IndexSpecification> indexList) {
  this.tableVsIndices.put(tableName, indexList);
  // TODO the inner map needs to be thread safe when we support dynamic index add/remove
  Map<byte[], IndexSpecification> indexMap =
      new TreeMap<byte[], IndexSpecification>(Bytes.BYTES_COMPARATOR);
  for (IndexSpecification index : indexList) {
    ByteArrayBuilder keyBuilder = ByteArrayBuilder.allocate(IndexUtils.getMaxIndexNameLength());
    keyBuilder.put(Bytes.toBytes(index.getName()));
    indexMap.put(keyBuilder.array(), index);
  }
  this.tableIndexMap.put(tableName, indexMap);
}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:17,代码来源:IndexManager.java

示例5: formIndexNameFromKV

import org.apache.hadoop.hbase.index.util.ByteArrayBuilder; //导入方法依赖的package包/类
private byte[] formIndexNameFromKV(KeyValue kv) {
  byte[] rowKey = kv.getRow();
  // First two bytes are going to be the
  ByteArrayBuilder keyBuilder = ByteArrayBuilder.allocate(rowKey.length);
  // Start from 2nd offset because the first 2 bytes corresponds to the rowkeylength
  keyBuilder.put(rowKey, 0, rowKey.length);
  int indexOf = com.google.common.primitives.Bytes.indexOf(keyBuilder.array(), new byte[1]);
  return keyBuilder.array(indexOf + 1, IndexUtils.getMaxIndexNameLength());
}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:10,代码来源:TTLStoreScanner.java

示例6: genSomeKeys

import org.apache.hadoop.hbase.index.util.ByteArrayBuilder; //导入方法依赖的package包/类
private List<KeyValue> genSomeKeys(String userTableName) throws Exception {
  List<KeyValue> ret = new ArrayList<KeyValue>(4);
  HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(userTableName));
  HColumnDescriptor hcd1 = new HColumnDescriptor("column1");
  HColumnDescriptor hcd2 = new HColumnDescriptor("column2");
  IndexSpecification iSpec1 = new IndexSpecification("Index");
  iSpec1.addIndexColumn(hcd1, "q", ValueType.String, 10);
  iSpec1.addIndexColumn(hcd2, "q", ValueType.String, 10);
  ihtd.addFamily(hcd1);
  ihtd.addFamily(hcd2);
  TableIndices indices = new TableIndices();
  indices.addIndex(iSpec1);
  ihtd.setValue(Constants.INDEX_SPEC_KEY, indices.toByteArray());
  admin.createTable(ihtd);
  ByteArrayBuilder indexColVal = ByteArrayBuilder.allocate(4);
  indexColVal.put(Bytes.toBytes((short) 3));
  indexColVal.put(Bytes.toBytes((short) 32));

  Put p1 = generatePuts("006".getBytes(), "05".getBytes());
  Put p2 = generatePuts("003".getBytes(), "06".getBytes());
  Put p3 = generatePuts("004".getBytes(), "06".getBytes());
  Put p4 = generatePuts("007".getBytes(), "06".getBytes());

  byte[] seekToPut =
      new byte[3 + 1 + IndexUtils.getMaxIndexNameLength() + 10 + "006".getBytes().length];
  System.arraycopy(p1.getRow(), 0, seekToPut, 0, p1.getRow().length);
  byte[] seekToRow = "007".getBytes();
  System.arraycopy(seekToRow, 0, seekToPut, p1.getRow().length - 3, seekToRow.length);
  System.arraycopy("005".getBytes(), 0, seekToPut, 0, 3);
  setSeekToRowKey(seekToPut, indexColVal);

  byte[] expectedPut =
      new byte[3 + 1 + IndexUtils.getMaxIndexNameLength() + 10 + "006".getBytes().length];
  System.arraycopy(p4.getRow(), 0, expectedPut, 0, p4.getRow().length);
  // Copy first 3 bytes to splitKey since getKeyValue will replace the start key with splitKey.
  // Just for assertion this is been added
  System.arraycopy("005".getBytes(), 0, expectedPut, 0, 3);
  setExpected(expectedPut);

  KeyValue kv =
      new KeyValue(p1.getRow(), Constants.IDX_COL_FAMILY, Constants.IDX_COL_QUAL, 0,
          indexColVal.array());
  ret.add(kv);
  KeyValue kv1 =
      new KeyValue(p2.getRow(), Constants.IDX_COL_FAMILY, Constants.IDX_COL_QUAL, 0,
          indexColVal.array());
  ret.add(kv1);
  KeyValue kv2 =
      new KeyValue(p3.getRow(), Constants.IDX_COL_FAMILY, Constants.IDX_COL_QUAL, 0,
          indexColVal.array());
  ret.add(kv2);
  KeyValue kv3 =
      new KeyValue(p4.getRow(), Constants.IDX_COL_FAMILY, Constants.IDX_COL_QUAL, 0,
          indexColVal.array());
  ret.add(kv3);
  return ret;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:58,代码来源:TestIndexHalfStoreFileReader.java

示例7: genSomeKeys

import org.apache.hadoop.hbase.index.util.ByteArrayBuilder; //导入方法依赖的package包/类
private List<KeyValue> genSomeKeys(String userTableName) throws Exception {
  List<KeyValue> ret = new ArrayList<KeyValue>(4);
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
  IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
  HColumnDescriptor hcd1 = new HColumnDescriptor("column1");
  HColumnDescriptor hcd2 = new HColumnDescriptor("column2");
  IndexSpecification iSpec1 = new IndexSpecification("Index");
  iSpec1.addIndexColumn(hcd1, "q", ValueType.String, 10);
  iSpec1.addIndexColumn(hcd2, "q", ValueType.String, 10);
  ihtd.addFamily(hcd1);
  ihtd.addFamily(hcd2);
  ihtd.addIndex(iSpec1);
  admin.createTable(ihtd);
  ZKAssign.blockUntilNoRIT(zkw);
  ByteArrayBuilder indexColVal = ByteArrayBuilder.allocate(4);
  indexColVal.put(Bytes.toBytes((short) 3));
  indexColVal.put(Bytes.toBytes((short) 32));

  Put p1 = generatePuts("006".getBytes(), "05".getBytes());
  Put p2 = generatePuts("003".getBytes(), "06".getBytes());
  Put p3 = generatePuts("004".getBytes(), "06".getBytes());
  Put p4 = generatePuts("007".getBytes(), "06".getBytes());

  byte[] seekToPut =
      new byte[3 + 1 + IndexUtils.getMaxIndexNameLength() + 10 + "006".getBytes().length];
  System.arraycopy(p1.getRow(), 0, seekToPut, 0, p1.getRow().length);
  byte[] seekToRow = "007".getBytes();
  System.arraycopy(seekToRow, 0, seekToPut, p1.getRow().length - 3, seekToRow.length);
  System.arraycopy("005".getBytes(), 0, seekToPut, 0, 3);
  setSeekToRowKey(seekToPut, indexColVal);

  byte[] expectedPut =
      new byte[3 + 1 + IndexUtils.getMaxIndexNameLength() + 10 + "006".getBytes().length];
  System.arraycopy(p4.getRow(), 0, expectedPut, 0, p4.getRow().length);
  // Copy first 3 bytes to splitKey since getKeyValue will replace the start key with splitKey.
  // Just for assertion this is been added
  System.arraycopy("005".getBytes(), 0, expectedPut, 0, 3);
  setExpected(expectedPut);

  KeyValue kv =
      new KeyValue(p1.getRow(), Constants.IDX_COL_FAMILY, Constants.IDX_COL_QUAL, 0,
          indexColVal.array());
  ret.add(kv);
  KeyValue kv1 =
      new KeyValue(p2.getRow(), Constants.IDX_COL_FAMILY, Constants.IDX_COL_QUAL, 0,
          indexColVal.array());
  ret.add(kv1);
  KeyValue kv2 =
      new KeyValue(p3.getRow(), Constants.IDX_COL_FAMILY, Constants.IDX_COL_QUAL, 0,
          indexColVal.array());
  ret.add(kv2);
  KeyValue kv3 =
      new KeyValue(p4.getRow(), Constants.IDX_COL_FAMILY, Constants.IDX_COL_QUAL, 0,
          indexColVal.array());
  ret.add(kv3);
  return ret;
}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:59,代码来源:TestIndexHalfStoreFileReader.java


注:本文中的org.apache.hadoop.hbase.index.util.ByteArrayBuilder.allocate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。