當前位置: 首頁>>代碼示例>>Java>>正文


Java HRegionInfo.createRegionName方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HRegionInfo.createRegionName方法的典型用法代碼示例。如果您正苦於以下問題:Java HRegionInfo.createRegionName方法的具體用法?Java HRegionInfo.createRegionName怎麽用?Java HRegionInfo.createRegionName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.HRegionInfo的用法示例。


在下文中一共展示了HRegionInfo.createRegionName方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCreateHRegionInfoName

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Test
public void testCreateHRegionInfoName() throws Exception {
  String tableName = "tablename";
  final TableName tn = TableName.valueOf(tableName);
  String startKey = "startkey";
  final byte[] sk = Bytes.toBytes(startKey);
  String id = "id";

  // old format region name
  byte [] name = HRegionInfo.createRegionName(tn, sk, id, false);
  String nameStr = Bytes.toString(name);
  assertEquals(tableName + "," + startKey + "," + id, nameStr);


  // new format region name.
  String md5HashInHex = MD5Hash.getMD5AsHex(name);
  assertEquals(HRegionInfo.MD5_HEX_LENGTH, md5HashInHex.length());
  name = HRegionInfo.createRegionName(tn, sk, id, true);
  nameStr = Bytes.toString(name);
  assertEquals(tableName + "," + startKey + ","
               + id + "." + md5HashInHex + ".",
               nameStr);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:TestHRegionInfo.java

示例2: doTestGetRegionInfo

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
public static void doTestGetRegionInfo(Hbase.Iface handler) throws Exception {
  // Create tableA and add two columns to rowA
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    handler.mutateRow(tableAname, rowAname, getMutations(), null);
    byte[] searchRow = HRegionInfo.createRegionName(
        TableName.valueOf(tableAname.array()), rowAname.array(),
        HConstants.NINES, false);
    TRegionInfo regionInfo = handler.getRegionInfo(ByteBuffer.wrap(searchRow));
    assertTrue(Bytes.toStringBinary(regionInfo.getName()).startsWith(
          Bytes.toStringBinary(tableAname)));
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:TestThriftServer.java

示例3: findRow

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
private byte [] findRow(final Region mr, final char table,
  final int rowToFind, final int answer)
throws IOException {
  TableName tableb = TableName.valueOf("" + table);
  // Find the row.
  byte [] tofindBytes = Bytes.toBytes((short)rowToFind);
  byte [] metaKey = HRegionInfo.createRegionName(
      tableb, tofindBytes,
    HConstants.NINES, false);
  LOG.info("find=" + new String(metaKey));
  Result r = mr.getClosestRowBefore(metaKey, HConstants.CATALOG_FAMILY);
  if (answer == -1) {
    assertNull(r);
    return null;
  }
  assertTrue(Bytes.compareTo(Bytes.toBytes((short)answer),
    extractRowFromMetaRow(r.getRow())) == 0);
  return r.getRow();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:20,代碼來源:TestGetClosestAtOrBefore.java

示例4: getRegionNameFromManifest

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Extract the region encoded name from the region manifest
 */
static String getRegionNameFromManifest(final SnapshotRegionManifest manifest) {
  byte[] regionName = HRegionInfo.createRegionName(
          ProtobufUtil.toTableName(manifest.getRegionInfo().getTableName()),
          manifest.getRegionInfo().getStartKey().toByteArray(),
          manifest.getRegionInfo().getRegionId(), true);
  return HRegionInfo.encodeRegionName(regionName);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:11,代碼來源:SnapshotManifest.java

示例5: testRegionNameForRegionReplicas

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Test
public void testRegionNameForRegionReplicas() throws Exception {
  String tableName = "tablename";
  final TableName tn = TableName.valueOf(tableName);
  String startKey = "startkey";
  final byte[] sk = Bytes.toBytes(startKey);
  String id = "id";

  // assert with only the region name without encoding

  // primary, replicaId = 0
  byte [] name = HRegionInfo.createRegionName(tn, sk, Bytes.toBytes(id), 0, false);
  String nameStr = Bytes.toString(name);
  assertEquals(tableName + "," + startKey + "," + id, nameStr);

  // replicaId = 1
  name = HRegionInfo.createRegionName(tn, sk, Bytes.toBytes(id), 1, false);
  nameStr = Bytes.toString(name);
  assertEquals(tableName + "," + startKey + "," + id + "_" +
    String.format(HRegionInfo.REPLICA_ID_FORMAT, 1), nameStr);

  // replicaId = max
  name = HRegionInfo.createRegionName(tn, sk, Bytes.toBytes(id), 0xFFFF, false);
  nameStr = Bytes.toString(name);
  assertEquals(tableName + "," + startKey + "," + id + "_" +
      String.format(HRegionInfo.REPLICA_ID_FORMAT, 0xFFFF), nameStr);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:TestHRegionInfo.java

示例6: testParseName

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
@Test
public void testParseName() throws IOException {
  TableName tableName = TableName.valueOf("testParseName");
  byte[] startKey = Bytes.toBytes("startKey");
  long regionId = System.currentTimeMillis();
  int replicaId = 42;

  // test without replicaId
  byte[] regionName = HRegionInfo.createRegionName(tableName, startKey, regionId, false);

  byte[][] fields = HRegionInfo.parseRegionName(regionName);
  assertArrayEquals(Bytes.toString(fields[0]),tableName.getName(), fields[0]);
  assertArrayEquals(Bytes.toString(fields[1]),startKey, fields[1]);
  assertArrayEquals(Bytes.toString(fields[2]), Bytes.toBytes(Long.toString(regionId)),fields[2]);
  assertEquals(3, fields.length);

  // test with replicaId
  regionName = HRegionInfo.createRegionName(tableName, startKey, regionId,
    replicaId, false);

  fields = HRegionInfo.parseRegionName(regionName);
  assertArrayEquals(Bytes.toString(fields[0]),tableName.getName(), fields[0]);
  assertArrayEquals(Bytes.toString(fields[1]),startKey, fields[1]);
  assertArrayEquals(Bytes.toString(fields[2]), Bytes.toBytes(Long.toString(regionId)),fields[2]);
  assertArrayEquals(Bytes.toString(fields[3]), Bytes.toBytes(
    String.format(HRegionInfo.REPLICA_ID_FORMAT, replicaId)), fields[3]);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:TestHRegionInfo.java

示例7: getClosestRowOrBefore

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * @return Get closest metatable region row to passed <code>row</code>
 * @throws IOException
 */
private static Result getClosestRowOrBefore(final Table metaTable, final TableName userTableName,
    final byte [] row, boolean useMetaReplicas)
throws IOException {
  byte[] searchRow = HRegionInfo.createRegionName(userTableName, row, HConstants.NINES, false);
  Scan scan = Scan.createGetClosestRowOrBeforeReverseScan(searchRow);
  if (useMetaReplicas) {
    scan.setConsistency(Consistency.TIMELINE);
  }
  try (ResultScanner resultScanner = metaTable.getScanner(scan)) {
    return resultScanner.next();
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:MetaScanner.java

示例8: getName

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * @return the region name
 */
@XmlAttribute
public String getName() {
  byte [] tableNameAsBytes = Bytes.toBytes(this.table);
  TableName tableName = TableName.valueOf(tableNameAsBytes);
  byte [] nameAsBytes = HRegionInfo.createRegionName(
    tableName, this.startKey, this.id, !tableName.isSystemTable());
  return Bytes.toString(nameAsBytes);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:TableRegionModel.java


注:本文中的org.apache.hadoop.hbase.HRegionInfo.createRegionName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。