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


Java CellScanner类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.CellScanner的典型用法代码示例。如果您正苦于以下问题:Java CellScanner类的具体用法?Java CellScanner怎么用?Java CellScanner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: replayToServer

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
private void replayToServer(HRegionInfo regionInfo, List<Entry> entries)
    throws IOException, ServiceException {
  if (entries.isEmpty()) return;

  Entry[] entriesArray = new Entry[entries.size()];
  entriesArray = entries.toArray(entriesArray);
  AdminService.BlockingInterface remoteSvr = conn.getAdmin(getLocation().getServerName());

  Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner> p =
      ReplicationProtbufUtil.buildReplicateWALEntryRequest(entriesArray);
  PayloadCarryingRpcController controller = rpcControllerFactory.newController(p.getSecond());
  try {
    remoteSvr.replay(controller, p.getFirst());
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:WALEditsReplaySink.java

示例2: replicateWALEntry

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
/**
 * Replicate WAL entries on the region server.
 *
 * @param controller the RPC controller
 * @param request the request
 * @throws ServiceException
 */
@Override
@QosPriority(priority=HConstants.REPLICATION_QOS)
public ReplicateWALEntryResponse replicateWALEntry(final RpcController controller,
    final ReplicateWALEntryRequest request) throws ServiceException {
  try {
    checkOpen();
    if (regionServer.replicationSinkHandler != null) {
      requestCount.increment();
      List<WALEntry> entries = request.getEntryList();
      CellScanner cellScanner = ((PayloadCarryingRpcController)controller).cellScanner();
      regionServer.getRegionServerCoprocessorHost().preReplicateLogEntries(entries, cellScanner);
      regionServer.replicationSinkHandler.replicateLogEntries(entries, cellScanner);
      regionServer.getRegionServerCoprocessorHost().postReplicateLogEntries(entries, cellScanner);
      return ReplicateWALEntryResponse.newBuilder().build();
    } else {
      throw new ServiceException("Replication services are not initialized yet");
    }
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:RSRpcServices.java

示例3: skipCellsForMutation

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
private void skipCellsForMutation(Action action, CellScanner cellScanner) {
  try {
    if (action.hasMutation()) {
      MutationProto m = action.getMutation();
      if (m.hasAssociatedCellCount()) {
        for (int i = 0; i < m.getAssociatedCellCount(); i++) {
          cellScanner.advance();
        }
      }
    }
  } catch (IOException e) {
    // No need to handle these Individual Muatation level issue. Any way this entire RegionAction
    // marked as failed as we could not see the Region here. At client side the top level
    // RegionAction exception will be considered first.
    LOG.error("Error while skipping Cells in CellScanner for invalid Region Mutations", e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:RSRpcServices.java

示例4: Call

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NP_NULL_ON_SOME_PATH",
    justification="Can't figure why this complaint is happening... see below")
Call(int id, final BlockingService service, final MethodDescriptor md, RequestHeader header,
     Message param, CellScanner cellScanner, Connection connection, Responder responder,
     long size, TraceInfo tinfo, final InetAddress remoteAddress) {
  this.id = id;
  this.service = service;
  this.md = md;
  this.header = header;
  this.param = param;
  this.cellScanner = cellScanner;
  this.connection = connection;
  this.timestamp = System.currentTimeMillis();
  this.response = null;
  this.responder = responder;
  this.isError = false;
  this.size = size;
  this.tinfo = tinfo;
  this.user = connection == null? null: connection.user; // FindBugs: NP_NULL_ON_SOME_PATH
  this.remoteAddress = remoteAddress;
  this.retryImmediatelySupported =
      connection == null? null: connection.retryImmediatelySupported;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:RpcServer.java

示例5: testSimpleVisibilityLabels

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
@Test
public void testSimpleVisibilityLabels() throws Exception {
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  try (Table table = createTableAndWriteDataWithLabels(tableName, SECRET + "|" + CONFIDENTIAL,
      PRIVATE + "|" + CONFIDENTIAL)) {
    Scan s = new Scan();
    s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL, PRIVATE));
    ResultScanner scanner = table.getScanner(s);
    Result[] next = scanner.next(3);

    assertTrue(next.length == 2);
    CellScanner cellScanner = next[0].cellScanner();
    cellScanner.advance();
    Cell current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    cellScanner = next[1].cellScanner();
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row2, 0, row2.length));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestVisibilityLabels.java

示例6: verifyRow

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
private static void verifyRow(Result result) throws IOException {
  byte[] row = result.getRow();
  CellScanner scanner = result.cellScanner();
  while (scanner.advance()) {
    Cell cell = scanner.current();

    //assert that all Cells in the Result have the same key
   Assert.assertEquals(0, Bytes.compareTo(row, 0, row.length,
       cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
  }

  for (int j = 0; j < FAMILIES.length; j++) {
    byte[] actual = result.getValue(FAMILIES[j], null);
    Assert.assertArrayEquals("Row in snapshot does not match, expected:" + Bytes.toString(row)
        + " ,actual:" + Bytes.toString(actual), row, actual);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestTableSnapshotScanner.java

示例7: verifyRowFromMap

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
protected static void verifyRowFromMap(ImmutableBytesWritable key, Result result)
  throws IOException {
  byte[] row = key.get();
  CellScanner scanner = result.cellScanner();
  while (scanner.advance()) {
    Cell cell = scanner.current();

    //assert that all Cells in the Result have the same key
    Assert.assertEquals(0, Bytes.compareTo(row, 0, row.length,
      cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
  }

  for (int j = 0; j < FAMILIES.length; j++) {
    byte[] actual = result.getValue(FAMILIES[j], null);
    Assert.assertArrayEquals("Row in snapshot does not match, expected:" + Bytes.toString(row)
      + " ,actual:" + Bytes.toString(actual), row, actual);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TableSnapshotInputFormatTestBase.java

示例8: postScannerNext

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
@Override
public boolean postScannerNext(ObserverContext<RegionCoprocessorEnvironment> e,
    InternalScanner s, List<Result> results, int limit, boolean hasMore) throws IOException {
  if (checkTagPresence) {
    if (results.size() > 0) {
      // Check tag presence in the 1st cell in 1st Result
      Result result = results.get(0);
      CellScanner cellScanner = result.cellScanner();
      if (cellScanner.advance()) {
        Cell cell = cellScanner.current();
        tags = Tag.asList(cell.getTagsArray(), cell.getTagsOffset(),
            cell.getTagsLength());
      }
    }
  }
  return hasMore;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestTags.java

示例9: testNoCodec

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
/**
 * Ensure we do not HAVE TO HAVE a codec.
 * @throws InterruptedException
 * @throws IOException
 */
@Test
public void testNoCodec() throws InterruptedException, IOException {
  Configuration conf = HBaseConfiguration.create();
  AbstractRpcClient client = createRpcClientNoCodec(conf);
  TestRpcServer rpcServer = new TestRpcServer();
  try {
    rpcServer.start();
    MethodDescriptor md = SERVICE.getDescriptorForType().findMethodByName("echo");
    final String message = "hello";
    EchoRequestProto param = EchoRequestProto.newBuilder().setMessage(message).build();
    InetSocketAddress address = rpcServer.getListenerAddress();
    if (address == null) {
      throw new IOException("Listener channel is closed");
    }
    Pair<Message, CellScanner> r =
        client.call(null, md, param, md.getOutputType().toProto(), User.getCurrent(), address,
            new MetricsConnection.CallStats());
    assertTrue(r.getSecond() == null);
    // Silly assertion that the message is in the returned pb.
    assertTrue(r.getFirst().toString().contains(message));
  } finally {
    client.close();
    rpcServer.stop();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:AbstractTestIPC.java

示例10: testListOfCellScannerables

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
@Test
public void testListOfCellScannerables() throws IOException {
  List<CellScannable> cells = new ArrayList<CellScannable>();
  final int count = 10;
  for (int i = 0; i < count; i++) {
    cells.add(createCell(i));
  }
  PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cells);
  CellScanner cellScanner = controller.cellScanner();
  int index = 0;
  for (; cellScanner.advance(); index++) {
    Cell cell = cellScanner.current();
    byte [] indexBytes = Bytes.toBytes(index);
    assertTrue("" + index, Bytes.equals(indexBytes, 0, indexBytes.length, cell.getValueArray(),
      cell.getValueOffset(), cell.getValueLength()));
  }
  assertEquals(count, index);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestPayloadCarryingRpcController.java

示例11: getSizedCellScanner

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
static CellScanner getSizedCellScanner(final Cell [] cells) {
  int size = -1;
  for (Cell cell: cells) {
    size += CellUtil.estimatedSerializedSizeOf(cell);
  }
  final int totalSize = ClassSize.align(size);
  final CellScanner cellScanner = CellUtil.createCellScanner(cells);
  return new SizedCellScanner() {
    @Override
    public long heapSize() {
      return totalSize;
    }

    @Override
    public Cell current() {
      return cellScanner.current();
    }

    @Override
    public boolean advance() throws IOException {
      return cellScanner.advance();
    }
  };
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:TestIPCUtil.java

示例12: scanRow

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
private void scanRow(final Result result, final RowKeyBuilder simpleRowKeyBuilder, final RowKey rowKey,
                     final StatisticType statsType, EventStoreTimeIntervalEnum interval) throws IOException {
    final CellScanner cellScanner = result.cellScanner();
    while (cellScanner.advance()) {
        final Cell cell = cellScanner.current();

        // get the column qualifier
        final byte[] bTimeQualifier = new byte[cell.getQualifierLength()];
        System.arraycopy(cell.getQualifierArray(), cell.getQualifierOffset(), bTimeQualifier, 0,
                cell.getQualifierLength());

        // convert this into a true time, albeit rounded to the column
        // interval granularity
        final long columnIntervalNo = Bytes.toInt(bTimeQualifier);
        final long columnIntervalSize = interval.columnInterval();
        final long columnTimeComponentMillis = columnIntervalNo * columnIntervalSize;
        final long rowKeyPartialTimeMillis = simpleRowKeyBuilder.getPartialTimestamp(rowKey);
        final long fullTimestamp = rowKeyPartialTimeMillis + columnTimeComponentMillis;

        LOGGER.debug("Col: [" + ByteArrayUtils.byteArrayToHex(bTimeQualifier) + "] - ["
                + Bytes.toInt(bTimeQualifier) + "] - [" + fullTimestamp + "] - ["
                + DateUtil.createNormalDateTimeString(fullTimestamp) + "]");

        final byte[] bValue = new byte[cell.getValueLength()];
        System.arraycopy(cell.getValueArray(), cell.getValueOffset(), bValue, 0, cell.getValueLength());

        switch (statsType) {
            case VALUE:
                final ValueCellValue cellValue = new ValueCellValue(bValue);

                LOGGER.debug("Val: " + cellValue);
                break;
            case COUNT:
                LOGGER.debug("Val: " + Bytes.toLong(bValue));
                break;
        }

    }
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:40,代码来源:StatisticsTestService.java

示例13: preAppend

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
@Override
public Result preAppend(ObserverContext<RegionCoprocessorEnvironment> e, Append append)
    throws IOException {
  // If authorization is not enabled, we don't care about reserved tags
  if (!authorizationEnabled) {
    return null;
  }
  for (CellScanner cellScanner = append.cellScanner(); cellScanner.advance();) {
    if (!checkForReservedVisibilityTagPresence(cellScanner.current())) {
      throw new FailedSanityCheckException("Append contains cell with reserved type tag");
    }
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:VisibilityController.java

示例14: preIncrement

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
@Override
public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> e, Increment increment)
    throws IOException {
  // If authorization is not enabled, we don't care about reserved tags
  if (!authorizationEnabled) {
    return null;
  }
  for (CellScanner cellScanner = increment.cellScanner(); cellScanner.advance();) {
    if (!checkForReservedVisibilityTagPresence(cellScanner.current())) {
      throw new FailedSanityCheckException("Increment contains cell with reserved type tag");
    }
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:VisibilityController.java

示例15: checkForReservedTagPresence

import org.apache.hadoop.hbase.CellScanner; //导入依赖的package包/类
private void checkForReservedTagPresence(User user, Mutation m) throws IOException {
  // No need to check if we're not going to throw
  if (!authorizationEnabled) {
    m.setAttribute(TAG_CHECK_PASSED, TRUE);
    return;
  }
  // Superusers are allowed to store cells unconditionally.
  if (Superusers.isSuperUser(user)) {
    m.setAttribute(TAG_CHECK_PASSED, TRUE);
    return;
  }
  // We already checked (prePut vs preBatchMutation)
  if (m.getAttribute(TAG_CHECK_PASSED) != null) {
    return;
  }
  for (CellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
    Cell cell = cellScanner.current();
    if (cell.getTagsLength() > 0) {
      Iterator<Tag> tagsItr = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
        cell.getTagsLength());
      while (tagsItr.hasNext()) {
        if (tagsItr.next().getType() == AccessControlLists.ACL_TAG_TYPE) {
          throw new AccessDeniedException("Mutation contains cell with reserved type tag");
        }
      }
    }
  }
  m.setAttribute(TAG_CHECK_PASSED, TRUE);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:AccessController.java


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