本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}