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


Java ScanRequest.hasScan方法代码示例

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


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

示例1: scan

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入方法依赖的package包/类
@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<CellScannable>(1);
        results.add(result);
        ((PayloadCarryingRpcController) controller).setCellScanner(CellUtil
            .createCellScanner(results));
        builder.setMoreResults(true);
      }
      else {
        builder.setMoreResults(false);
        close(scannerId);
      }
    }
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:MockRegionServer.java

示例2: doMetaScanResponse

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入方法依赖的package包/类
static ScanResponse doMetaScanResponse(final SortedMap<byte [], Pair<HRegionInfo, ServerName>> meta,
    final AtomicLong sequenceids, final ScanRequest request) {
  ScanResponse.Builder builder = ScanResponse.newBuilder();
  int max = request.getNumberOfRows();
  int count = 0;
  Map<byte [], Pair<HRegionInfo, ServerName>> tail =
    request.hasScan()? meta.tailMap(request.getScan().getStartRow().toByteArray()): meta;
    ClientProtos.Result.Builder resultBuilder = ClientProtos.Result.newBuilder();
  for (Map.Entry<byte [], Pair<HRegionInfo, ServerName>> e: tail.entrySet()) {
    // Can be 0 on open of a scanner -- i.e. rpc to setup scannerid only.
    if (max <= 0) break;
    if (++count > max) break;
    HRegionInfo hri = e.getValue().getFirst();
    ByteString row = ByteStringer.wrap(hri.getRegionName());
    resultBuilder.clear();
    resultBuilder.addCell(getRegionInfo(row, hri));
    resultBuilder.addCell(getServer(row, e.getValue().getSecond()));
    resultBuilder.addCell(getStartCode(row));
    builder.addResults(resultBuilder.build());
    // Set more to false if we are on the last region in table.
    if (hri.getEndKey().length <= 0) builder.setMoreResults(false);
    else builder.setMoreResults(true);
  }
  // If no scannerid, set one.
  builder.setScannerId(request.hasScannerId()?
    request.getScannerId(): sequenceids.incrementAndGet());
  return builder.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:TestClientNoCluster.java

示例3: doMetaScanResponse

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入方法依赖的package包/类
static ScanResponse doMetaScanResponse(final SortedMap<byte [], Pair<HRegionInfo, ServerName>> meta,
    final AtomicLong sequenceids, final ScanRequest request) {
  ScanResponse.Builder builder = ScanResponse.newBuilder();
  int max = request.getNumberOfRows();
  int count = 0;
  Map<byte [], Pair<HRegionInfo, ServerName>> tail =
    request.hasScan()? meta.tailMap(request.getScan().getStartRow().toByteArray()): meta;
    ClientProtos.Result.Builder resultBuilder = ClientProtos.Result.newBuilder();
  for (Map.Entry<byte [], Pair<HRegionInfo, ServerName>> e: tail.entrySet()) {
    // Can be 0 on open of a scanner -- i.e. rpc to setup scannerid only.
    if (max <= 0) break;
    if (++count > max) break;
    HRegionInfo hri = e.getValue().getFirst();
    ByteString row = HBaseZeroCopyByteString.wrap(hri.getRegionName());
    resultBuilder.clear();
    resultBuilder.addCell(getRegionInfo(row, hri));
    resultBuilder.addCell(getServer(row, e.getValue().getSecond()));
    resultBuilder.addCell(getStartCode(row));
    builder.addResults(resultBuilder.build());
    // Set more to false if we are on the last region in table.
    if (hri.getEndKey().length <= 0) builder.setMoreResults(false);
    else builder.setMoreResults(true);
  }
  // If no scannerid, set one.
  builder.setScannerId(request.hasScannerId()?
    request.getScannerId(): sequenceids.incrementAndGet());
  return builder.build();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:29,代码来源:TestClientNoCluster.java

示例4: doMetaScanResponse

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入方法依赖的package包/类
static ScanResponse doMetaScanResponse(final SortedMap<byte [], Pair<HRegionInfo, ServerName>> meta,
    final AtomicLong sequenceids, final ScanRequest request) {
  ScanResponse.Builder builder = ScanResponse.newBuilder();
  int max = request.getNumberOfRows();
  int count = 0;
  Map<byte [], Pair<HRegionInfo, ServerName>> tail =
    request.hasScan()? meta.tailMap(request.getScan().getStartRow().toByteArray()): meta;
    ClientProtos.Result.Builder resultBuilder = ClientProtos.Result.newBuilder();
  for (Map.Entry<byte [], Pair<HRegionInfo, ServerName>> e: tail.entrySet()) {
    // Can be 0 on open of a scanner -- i.e. rpc to setup scannerid only.
    if (max <= 0) break;
    if (++count > max) break;
    HRegionInfo hri = e.getValue().getFirst();
    ByteString row = ZeroCopyLiteralByteString.wrap(hri.getRegionName());
    resultBuilder.clear();
    resultBuilder.addCell(getRegionInfo(row, hri));
    resultBuilder.addCell(getServer(row, e.getValue().getSecond()));
    resultBuilder.addCell(getStartCode(row));
    builder.addResults(resultBuilder.build());
    // Set more to false if we are on the last region in table.
    if (hri.getEndKey().length <= 0) builder.setMoreResults(false);
    else builder.setMoreResults(true);
  }
  // If no scannerid, set one.
  builder.setScannerId(request.hasScannerId()?
    request.getScannerId(): sequenceids.incrementAndGet());
  return builder.build();
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:29,代码来源:TestClientNoCluster.java

示例5: scan

import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest; //导入方法依赖的package包/类
@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.addResult(ProtobufUtil.toResult(result));
        builder.setMoreResults(true);
      }
      else {
        builder.setMoreResults(false);
        close(scannerId);
      }
    }
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
  return builder.build();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:28,代码来源:MockRegionServer.java


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