org.apache.hadoop.hbase.CellScannable Java Examples

The following examples show how to use org.apache.hadoop.hbase.CellScannable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RequestConverter.java    From hbase with Apache License 2.0 6 votes vote down vote up
private static void buildNoDataRegionAction(final Delete delete,
  final List<CellScannable> cells, final RegionAction.Builder regionActionBuilder,
  final ClientProtos.Action.Builder actionBuilder, final MutationProto.Builder mutationBuilder)
  throws IOException {
  int size = delete.size();
  // Note that a legitimate Delete may have a size of zero; i.e. a Delete that has nothing
  // in it but the row to delete.  In this case, the current implementation does not make
  // a KeyValue to represent a delete-of-all-the-row until we serialize... For such cases
  // where the size returned is zero, we will send the Delete fully pb'd rather than have
  // metadata only in the pb and then send the kv along the side in cells.
  if (size > 0) {
    cells.add(delete);
    regionActionBuilder.addAction(actionBuilder.
      setMutation(ProtobufUtil.toMutationNoData(MutationType.DELETE, delete, mutationBuilder)));
  } else {
    regionActionBuilder.addAction(actionBuilder.
      setMutation(ProtobufUtil.toMutation(MutationType.DELETE, delete, mutationBuilder)));
  }
}
 
Example #2
Source File: RequestConverter.java    From hbase with Apache License 2.0 6 votes vote down vote up
private static void buildNoDataRegionAction(final RowMutations rowMutations,
  final List<CellScannable> cells, final RegionAction.Builder regionActionBuilder,
  final ClientProtos.Action.Builder actionBuilder, final MutationProto.Builder mutationBuilder)
  throws IOException {
  for (Mutation mutation: rowMutations.getMutations()) {
    MutationType type;
    if (mutation instanceof Put) {
      type = MutationType.PUT;
    } else if (mutation instanceof Delete) {
      type = MutationType.DELETE;
    } else {
      throw new DoNotRetryIOException("RowMutations supports only put and delete, not " +
        mutation.getClass().getName());
    }
    mutationBuilder.clear();
    MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
    cells.add(mutation);
    actionBuilder.clear();
    regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
  }
}
 
Example #3
Source File: AsyncBatchRpcRetryingCaller.java    From hbase with Apache License 2.0 6 votes vote down vote up
private ClientProtos.MultiRequest buildReq(Map<byte[], RegionRequest> actionsByRegion,
    List<CellScannable> cells, Map<Integer, Integer> indexMap) throws IOException {
  ClientProtos.MultiRequest.Builder multiRequestBuilder = ClientProtos.MultiRequest.newBuilder();
  ClientProtos.RegionAction.Builder regionActionBuilder = ClientProtos.RegionAction.newBuilder();
  ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
  ClientProtos.MutationProto.Builder mutationBuilder = ClientProtos.MutationProto.newBuilder();
  for (Map.Entry<byte[], RegionRequest> entry : actionsByRegion.entrySet()) {
    long nonceGroup = conn.getNonceGenerator().getNonceGroup();
    // multiRequestBuilder will be populated with region actions.
    // indexMap will be non-empty after the call if there is RowMutations/CheckAndMutate in the
    // action list.
    RequestConverter.buildNoDataRegionActions(entry.getKey(),
      entry.getValue().actions.stream()
        .sorted((a1, a2) -> Integer.compare(a1.getOriginalIndex(), a2.getOriginalIndex()))
        .collect(Collectors.toList()),
      cells, multiRequestBuilder, regionActionBuilder, actionBuilder, mutationBuilder,
      nonceGroup, indexMap);
  }
  return multiRequestBuilder.build();
}
 
Example #4
Source File: TestHBaseRpcControllerImpl.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testListOfCellScannerables() throws IOException {
  final int count = 10;
  List<CellScannable> cells = new ArrayList<>(count);

  for (int i = 0; i < count; i++) {
    cells.add(createCell(i));
  }
  HBaseRpcController controller = new HBaseRpcControllerImpl(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);
}
 
Example #5
Source File: MockRegionServer.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public ScanResponse scan(RpcController controller, ScanRequest request)
    throws ServiceException {
  ScanResponse.Builder builder = ScanResponse.newBuilder();
  try {
    if (request.hasScan()) {
      byte[] regionName = request.getRegion().getValue().toByteArray();
      builder.setScannerId(openScanner(regionName, null));
      builder.setMoreResults(true);
    }
    else {
      long scannerId = request.getScannerId();
      Result result = next(scannerId);
      if (result != null) {
        builder.addCellsPerResult(result.size());
        List<CellScannable> results = new ArrayList<>(1);
        results.add(result);
        ((HBaseRpcController) controller).setCellScanner(CellUtil
            .createCellScanner(results));
        builder.setMoreResults(true);
      }
      else {
        builder.setMoreResults(false);
        close(scannerId);
      }
    }
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
  return builder.build();
}
 
Example #6
Source File: RequestConverter.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static void buildNoDataRegionAction(final Put put, final List<CellScannable> cells,
  final RegionAction.Builder regionActionBuilder,
  final ClientProtos.Action.Builder actionBuilder,
  final MutationProto.Builder mutationBuilder) throws IOException {
  cells.add(put);
  regionActionBuilder.addAction(actionBuilder.
    setMutation(ProtobufUtil.toMutationNoData(MutationType.PUT, put, mutationBuilder)));
}
 
Example #7
Source File: InterRegionServerRpcControllerFactory.java    From phoenix-omid with Apache License 2.0 4 votes vote down vote up
@Override
public HBaseRpcController newController(List<CellScannable> cellIterables) {
    HBaseRpcController delegate = super.newController(cellIterables);
    return getController(delegate);
}
 
Example #8
Source File: InterRegionServerRpcControllerFactory.java    From phoenix-omid with Apache License 2.0 4 votes vote down vote up
@Override
public PayloadCarryingRpcController newController(List<CellScannable> cellIterables) {
    PayloadCarryingRpcController delegate = super.newController(cellIterables);
    return getController(delegate);
}
 
Example #9
Source File: IndexQosRpcControllerFactory.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public PayloadCarryingRpcController newController(List<CellScannable> cellIterables) {
    PayloadCarryingRpcController delegate = super.newController(cellIterables);
    return new IndexQosRpcController(delegate, conf);
}
 
Example #10
Source File: IndexHandlerIT.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public PayloadCarryingRpcController newController(List<CellScannable> cellIterables) {
    PayloadCarryingRpcController controller = delegate.newController(cellIterables);
    return new CountingIndexClientRpcController(controller);
}
 
Example #11
Source File: TestRpcControllerFactory.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Override
public HBaseRpcController newController(final List<CellScannable> cellIterables) {
  return new CountingRpcController(super.newController(cellIterables));
}
 
Example #12
Source File: HBaseRpcControllerImpl.java    From hbase with Apache License 2.0 4 votes vote down vote up
public HBaseRpcControllerImpl(final List<CellScannable> cellIterables) {
  this.cellScanner = cellIterables == null ? null : CellUtil.createCellScanner(cellIterables);
}
 
Example #13
Source File: RpcControllerFactory.java    From hbase with Apache License 2.0 4 votes vote down vote up
public HBaseRpcController newController(final List<CellScannable> cellIterables) {
  return new HBaseRpcControllerImpl(cellIterables);
}
 
Example #14
Source File: InterRegionServerMetadataRpcControllerFactory.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public HBaseRpcController newController(List<CellScannable> cellIterables) {
    HBaseRpcController delegate = super.newController(cellIterables);
    return getController(delegate);
}
 
Example #15
Source File: InterRegionServerIndexRpcControllerFactory.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public HBaseRpcController newController(List<CellScannable> cellIterables) {
    HBaseRpcController delegate = super.newController(cellIterables);
    return getController(delegate);
}
 
Example #16
Source File: ClientRpcControllerFactory.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public HBaseRpcController newController(List<CellScannable> cellIterables) {
    HBaseRpcController delegate = super.newController(cellIterables);
    return getController(delegate);
}