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


Java CellUtil.cloneRow方法代碼示例

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


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

示例1: deleteColumns

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
private void deleteColumns(HRegion r, String value, String keyPrefix) throws IOException {
  InternalScanner scanner = buildScanner(keyPrefix, value, r);
  int count = 0;
  boolean more = false;
  List<Cell> results = new ArrayList<Cell>();
  do {
    more = scanner.next(results);
    if (results != null && !results.isEmpty())
      count++;
    else
      break;
    Delete delete = new Delete(CellUtil.cloneRow(results.get(0)));
    delete.deleteColumn(Bytes.toBytes("trans-tags"), Bytes.toBytes("qual2"));
    r.delete(delete);
    results.clear();
  } while (more);
  assertEquals("Did not perform correct number of deletes", 3, count);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:TestHRegion.java

示例2: SerializableCell

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
/**
 * Copy data from {@code Cell} instance.
 *
 * @param cell
 */
public SerializableCell( Cell cell ) {
    rowKey = CellUtil.cloneRow(cell);
    family = CellUtil.cloneFamily(cell);
    qualifier = CellUtil.cloneQualifier(cell);
    value = CellUtil.cloneValue(cell);
    timestamp = cell.getTimestamp();
    type = cell.getTypeByte();
}
 
開發者ID:i-knowledge,項目名稱:hbase-client,代碼行數:14,代碼來源:SerializableCell.java

示例3: loadAll

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
/**
 * Loads all of the permission grants stored in a region of the {@code _acl_}
 * table.
 *
 * @param aclRegion
 * @return a map of the permissions for this table.
 * @throws IOException
 */
static Map<byte[], ListMultimap<String,TablePermission>> loadAll(Region aclRegion)
  throws IOException {

  if (!isAclRegion(aclRegion)) {
    throw new IOException("Can only load permissions from "+ACL_TABLE_NAME);
  }

  Map<byte[], ListMultimap<String, TablePermission>> allPerms =
      new TreeMap<byte[], ListMultimap<String, TablePermission>>(Bytes.BYTES_RAWCOMPARATOR);

  // do a full scan of _acl_ table

  Scan scan = new Scan();
  scan.addFamily(ACL_LIST_FAMILY);

  InternalScanner iScanner = null;
  try {
    iScanner = aclRegion.getScanner(scan);

    while (true) {
      List<Cell> row = new ArrayList<Cell>();

      boolean hasNext = iScanner.next(row);
      ListMultimap<String,TablePermission> perms = ArrayListMultimap.create();
      byte[] entry = null;
      for (Cell kv : row) {
        if (entry == null) {
          entry = CellUtil.cloneRow(kv);
        }
        Pair<String,TablePermission> permissionsOfUserOnTable =
            parsePermissionRecord(entry, kv);
        if (permissionsOfUserOnTable != null) {
          String username = permissionsOfUserOnTable.getFirst();
          TablePermission permissions = permissionsOfUserOnTable.getSecond();
          perms.put(username, permissions);
        }
      }
      if (entry != null) {
        allPerms.put(entry, perms);
      }
      if (!hasNext) {
        break;
      }
    }
  } finally {
    if (iScanner != null) {
      iScanner.close();
    }
  }

  return allPerms;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:61,代碼來源:AccessControlLists.java

示例4: getRow

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
/**
 * Method for retrieving the row key that corresponds to
 * the row from which this Result was created.
 * @return row
 */
public byte [] getRow() {
  if (this.row == null) {
    this.row = this.cells == null || this.cells.length == 0? null: CellUtil.cloneRow(this.cells[0]);
  }
  return this.row;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:Result.java

示例5: getRowCount

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
/**
 * Returns a count of the rows in the region where this coprocessor is loaded.
 */
@Override
public void getRowCount(RpcController controller, ExampleProtos.CountRequest request,
                        RpcCallback<ExampleProtos.CountResponse> done) {
  Scan scan = new Scan();
  scan.setFilter(new FirstKeyOnlyFilter());
  ExampleProtos.CountResponse response = null;
  InternalScanner scanner = null;
  try {
    scanner = env.getRegion().getScanner(scan);
    List<Cell> results = new ArrayList<Cell>();
    boolean hasMore = false;
    byte[] lastRow = null;
    long count = 0;
    do {
      hasMore = scanner.next(results);
      for (Cell kv : results) {
        byte[] currentRow = CellUtil.cloneRow(kv);
        if (lastRow == null || !Bytes.equals(lastRow, currentRow)) {
          lastRow = currentRow;
          count++;
        }
      }
      results.clear();
    } while (hasMore);

    response = ExampleProtos.CountResponse.newBuilder()
        .setCount(count).build();
  } catch (IOException ioe) {
    ResponseConverter.setControllerException(controller, ioe);
  } finally {
    if (scanner != null) {
      try {
        scanner.close();
      } catch (IOException ignored) {}
    }
  }
  done.run(response);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:42,代碼來源:RowCountEndpoint.java

示例6: verifyAllEditsMadeItIn

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
/**
 * @param fs
 * @param conf
 * @param edits
 * @param region
 * @return Return how many edits seen.
 * @throws IOException
 */
private int verifyAllEditsMadeItIn(final FileSystem fs, final Configuration conf,
    final Path edits, final HRegion region)
throws IOException {
  int count = 0;
  // Based on HRegion#replayRecoveredEdits
  WAL.Reader reader = null;
  try {
    reader = WALFactory.createReader(fs, edits, conf);
    WAL.Entry entry;
    while ((entry = reader.next()) != null) {
      WALKey key = entry.getKey();
      WALEdit val = entry.getEdit();
      count++;
      // Check this edit is for this region.
      if (!Bytes.equals(key.getEncodedRegionName(),
          region.getRegionInfo().getEncodedNameAsBytes())) {
        continue;
      }
      Cell previous = null;
      for (Cell cell: val.getCells()) {
        if (CellUtil.matchingFamily(cell, WALEdit.METAFAMILY)) continue;
        if (previous != null && CellComparator.compareRows(previous, cell) == 0) continue;
        previous = cell;
        Get g = new Get(CellUtil.cloneRow(cell));
        Result r = region.get(g);
        boolean found = false;
        for (CellScanner scanner = r.cellScanner(); scanner.advance();) {
          Cell current = scanner.current();
          if (CellComparator.compare(cell, current, true) == 0) {
            found = true;
            break;
          }
        }
        assertTrue("Failed to find " + cell, found);
      }
    }
  } finally {
    if (reader != null) reader.close();
  }
  return count;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:50,代碼來源:TestRecoveredEdits.java

示例7: testWideScanBatching

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
public void testWideScanBatching() throws IOException {
  final int batch = 256;
  try {
    this.r = createNewHRegion(TESTTABLEDESC, null, null);
    int inserted = addWideContent(this.r);
    List<Cell> results = new ArrayList<Cell>();
    Scan scan = new Scan();
    scan.addFamily(A);
    scan.addFamily(B);
    scan.addFamily(C);
    scan.setMaxVersions(100);
    scan.setBatch(batch);
    InternalScanner s = r.getScanner(scan);
    int total = 0;
    int i = 0;
    boolean more;
    do {
      more = s.next(results);
      i++;
      LOG.info("iteration #" + i + ", results.size=" + results.size());

      // assert that the result set is no larger
      assertTrue(results.size() <= batch);

      total += results.size();

      if (results.size() > 0) {
        // assert that all results are from the same row
        byte[] row = CellUtil.cloneRow(results.get(0));
        for (Cell kv: results) {
          assertTrue(Bytes.equals(row, CellUtil.cloneRow(kv)));
        }
      }

      results.clear();

      // trigger ChangedReadersObservers
      Iterator<KeyValueScanner> scanners =
        ((HRegion.RegionScannerImpl)s).storeHeap.getHeap().iterator();
      while (scanners.hasNext()) {
        StoreScanner ss = (StoreScanner)scanners.next();
        ss.updateReaders();
      }
    } while (more);

    // assert that the scanner returned all values
    LOG.info("inserted " + inserted + ", scanned " + total);
    assertEquals(total, inserted);

    s.close();
  } finally {
    HRegion.closeHRegion(this.r);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:55,代碼來源:TestWideScanner.java

示例8: testFilterListWithPrefixFilter

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
@Test
public void testFilterListWithPrefixFilter() throws IOException {
  byte[] family = Bytes.toBytes("f1");
  byte[] qualifier = Bytes.toBytes("q1");
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("TestFilter"));
  htd.addFamily(new HColumnDescriptor(family));
  HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
  HRegion testRegion = HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(),
      TEST_UTIL.getConfiguration(), htd);

  for(int i=0; i<5; i++) {
    Put p = new Put(Bytes.toBytes((char)('a'+i) + "row"));
    p.setDurability(Durability.SKIP_WAL);
    p.add(family, qualifier, Bytes.toBytes(String.valueOf(111+i)));
    testRegion.put(p);
  }
  testRegion.flush(true);

  // rows starting with "b"
  PrefixFilter pf = new PrefixFilter(new byte[] {'b'}) ;
  // rows with value of column 'q1' set to '113'
  SingleColumnValueFilter scvf = new SingleColumnValueFilter(
      family, qualifier, CompareOp.EQUAL, Bytes.toBytes("113"));
  // combine these two with OR in a FilterList
  FilterList filterList = new FilterList(Operator.MUST_PASS_ONE, pf, scvf);

  Scan s1 = new Scan();
  s1.setFilter(filterList);
  InternalScanner scanner = testRegion.getScanner(s1);
  List<Cell> results = new ArrayList<Cell>();
  int resultCount = 0;
  while (scanner.next(results)) {
    resultCount++;
    byte[] row =  CellUtil.cloneRow(results.get(0));
    LOG.debug("Found row: " + Bytes.toStringBinary(row));
    assertTrue(Bytes.equals(row, Bytes.toBytes("brow"))
        || Bytes.equals(row, Bytes.toBytes("crow")));
    results.clear();
  }
  assertEquals(2, resultCount);
  scanner.close();

  WAL wal = ((HRegion)testRegion).getWAL();
  ((HRegion)testRegion).close();
  wal.close();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:47,代碼來源:TestFilter.java

示例9: main

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, SecurityException,
    NoSuchMethodException, InterruptedException {
  if (args.length != 2) {
    System.out.println("Usage: TestAsyncIPC <CYCLES> <CELLS_PER_CYCLE>");
    return;
  }
  // ((Log4JLogger)HBaseServer.LOG).getLogger().setLevel(Level.INFO);
  // ((Log4JLogger)HBaseClient.LOG).getLogger().setLevel(Level.INFO);
  int cycles = Integer.parseInt(args[0]);
  int cellcount = Integer.parseInt(args[1]);
  Configuration conf = HBaseConfiguration.create();
  TestRpcServer rpcServer = new TestRpcServer();
  MethodDescriptor md = SERVICE.getDescriptorForType().findMethodByName("echo");
  EchoRequestProto param = EchoRequestProto.newBuilder().setMessage("hello").build();
  AsyncRpcClient client = new AsyncRpcClient(conf);
  KeyValue kv = BIG_CELL;
  Put p = new Put(CellUtil.cloneRow(kv));
  for (int i = 0; i < cellcount; i++) {
    p.add(kv);
  }
  RowMutations rm = new RowMutations(CellUtil.cloneRow(kv));
  rm.add(p);
  try {
    rpcServer.start();
    InetSocketAddress address = rpcServer.getListenerAddress();
    if (address == null) {
      throw new IOException("Listener channel is closed");
    }
    long startTime = System.currentTimeMillis();
    User user = User.getCurrent();
    for (int i = 0; i < cycles; i++) {
      List<CellScannable> cells = new ArrayList<CellScannable>();
      // Message param = RequestConverter.buildMultiRequest(HConstants.EMPTY_BYTE_ARRAY, rm);
      ClientProtos.RegionAction.Builder builder =
          RequestConverter.buildNoDataRegionAction(HConstants.EMPTY_BYTE_ARRAY, rm, cells,
            RegionAction.newBuilder(), ClientProtos.Action.newBuilder(),
            MutationProto.newBuilder());
      builder.setRegion(RegionSpecifier
          .newBuilder()
          .setType(RegionSpecifierType.REGION_NAME)
          .setValue(
            ByteString.copyFrom(HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes())));
      if (i % 100000 == 0) {
        LOG.info("" + i);
        // Uncomment this for a thread dump every so often.
        // ReflectionUtils.printThreadInfo(new PrintWriter(System.out),
        // "Thread dump " + Thread.currentThread().getName());
      }
      PayloadCarryingRpcController pcrc =
          new PayloadCarryingRpcController(CellUtil.createCellScanner(cells));
      // Pair<Message, CellScanner> response =
      client.call(pcrc, md, builder.build(), param, user, address,
          new MetricsConnection.CallStats());
      /*
       * int count = 0; while (p.getSecond().advance()) { count++; } assertEquals(cells.size(),
       * count);
       */
    }
    LOG.info("Cycled " + cycles + " time(s) with " + cellcount + " cell(s) in "
        + (System.currentTimeMillis() - startTime) + "ms");
  } finally {
    client.close();
    rpcServer.stop();
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:66,代碼來源:TestAsyncIPC.java

示例10: main

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, SecurityException,
    NoSuchMethodException, InterruptedException {
  if (args.length != 2) {
    System.out.println("Usage: TestIPC <CYCLES> <CELLS_PER_CYCLE>");
    return;
  }
  // ((Log4JLogger)HBaseServer.LOG).getLogger().setLevel(Level.INFO);
  // ((Log4JLogger)HBaseClient.LOG).getLogger().setLevel(Level.INFO);
  int cycles = Integer.parseInt(args[0]);
  int cellcount = Integer.parseInt(args[1]);
  Configuration conf = HBaseConfiguration.create();
  TestRpcServer rpcServer = new TestRpcServer();
  MethodDescriptor md = SERVICE.getDescriptorForType().findMethodByName("echo");
  EchoRequestProto param = EchoRequestProto.newBuilder().setMessage("hello").build();
  RpcClientImpl client = new RpcClientImpl(conf, HConstants.CLUSTER_ID_DEFAULT);
  KeyValue kv = BIG_CELL;
  Put p = new Put(CellUtil.cloneRow(kv));
  for (int i = 0; i < cellcount; i++) {
    p.add(kv);
  }
  RowMutations rm = new RowMutations(CellUtil.cloneRow(kv));
  rm.add(p);
  try {
    rpcServer.start();
    long startTime = System.currentTimeMillis();
    User user = User.getCurrent();
    InetSocketAddress address = rpcServer.getListenerAddress();
    if (address == null) {
      throw new IOException("Listener channel is closed");
    }
    for (int i = 0; i < cycles; i++) {
      List<CellScannable> cells = new ArrayList<CellScannable>();
      // Message param = RequestConverter.buildMultiRequest(HConstants.EMPTY_BYTE_ARRAY, rm);
      ClientProtos.RegionAction.Builder builder =
          RequestConverter.buildNoDataRegionAction(HConstants.EMPTY_BYTE_ARRAY, rm, cells,
            RegionAction.newBuilder(), ClientProtos.Action.newBuilder(),
            MutationProto.newBuilder());
      builder.setRegion(RegionSpecifier
          .newBuilder()
          .setType(RegionSpecifierType.REGION_NAME)
          .setValue(
            ByteString.copyFrom(HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes())));
      if (i % 100000 == 0) {
        LOG.info("" + i);
        // Uncomment this for a thread dump every so often.
        // ReflectionUtils.printThreadInfo(new PrintWriter(System.out),
        // "Thread dump " + Thread.currentThread().getName());
      }
      PayloadCarryingRpcController pcrc =
          new PayloadCarryingRpcController(CellUtil.createCellScanner(cells));
      // Pair<Message, CellScanner> response =
      client.call(pcrc, md, builder.build(), param, user, address,
          new MetricsConnection.CallStats());
      /*
       * int count = 0; while (p.getSecond().advance()) { count++; } assertEquals(cells.size(),
       * count);
       */
    }
    LOG.info("Cycled " + cycles + " time(s) with " + cellcount + " cell(s) in "
        + (System.currentTimeMillis() - startTime) + "ms");
  } finally {
    client.close();
    rpcServer.stop();
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:66,代碼來源:TestIPC.java

示例11: getRow

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
@Override
public byte[] getRow() {
  return CellUtil.cloneRow(this);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:5,代碼來源:PrefixTreeCell.java

示例12: getRow

import org.apache.hadoop.hbase.CellUtil; //導入方法依賴的package包/類
@Override
@Deprecated
public byte[] getRow() {
  return CellUtil.cloneRow(this);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:6,代碼來源:BufferedDataBlockEncoder.java


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