@Override public void readFields(final DataInput in) throws IOException { ClientProtos.Result protosResult = ClientProtos.Result.parseDelimitedFrom(DataInputInputStream.from(in)); int size = in.readInt(); if(size < 0) { throw new IOException("Invalid size " + size); } Cell[] kvs = new Cell[size]; for (int i = 0; i < kvs.length; i++) { kvs[i] = KeyValue.create(in); } result = ProtobufUtil.toResult(protosResult, CellUtil.createCellScanner(kvs)); } @Override
private void addResult(final MutateResponse.Builder builder, final Result result, final PayloadCarryingRpcController rpcc) { if (result == null) return; if (isClientCellBlockSupport()) { builder.setResult(ProtobufUtil.toResultNoData(result)); rpcc.setCellScanner(result.cellScanner()); } else { ClientProtos.Result pbr = ProtobufUtil.toResult(result); builder.setResult(pbr); } }
/** * Convert a client Result to a protocol buffer Result. * The pb Result does not include the Cell data. That is for transport otherwise. * * @param result the client Result to convert * @return the converted protocol buffer Result */ public static ClientProtos.Result toResultNoData(final Result result) { if (result.getExists() != null) return toResult(result.getExists(), result.isStale()); int size = result.size(); if (size == 0) return result.isStale() ? EMPTY_RESULT_PB_STALE : EMPTY_RESULT_PB; ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder(); builder.setAssociatedCellCount(size); builder.setStale(result.isStale()); return builder.build(); }
/** * Convert a client Result to a protocol buffer Result * * @param result the client Result to convert * @return the converted protocol buffer Result */ public static ClientProtos.Result toResult(final Result result) { if (result.getExists() != null) { return toResult(result.getExists(), result.isStale()); } Cell[] cells = result.rawCells(); if (cells == null || cells.length == 0) { return result.isStale() ? EMPTY_RESULT_PB_STALE : EMPTY_RESULT_PB; } ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder(); for (Cell c : cells) { builder.addCell(toCell(c)); } builder.setStale(result.isStale()); builder.setPartial(result.mayHaveMoreCellsInRow()); return builder.build(); }
/** * Convert a client Result to a protocol buffer Result. * The pb Result does not include the Cell data. That is for transport otherwise. * * @param result the client Result to convert * @return the converted protocol buffer Result */ public static ClientProtos.Result toResultNoData(final Result result) { if (result.getExists() != null) return toResult(result.getExists(), result.isStale()); int size = result.size(); if (size == 0) return result.isStale() ? EMPTY_RESULT_PB_STALE : EMPTY_RESULT_PB; ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder(); builder.setAssociatedCellCount(size); builder.setStale(result.isStale()); return builder.build(); }
/** * Convert a client Result to a protocol buffer Result * * @param result the client Result to convert * @return the converted protocol buffer Result */ public static ClientProtos.Result toResult(final Result result) { if (result.getExists() != null) { return toResult(result.getExists(), result.isStale()); } Cell[] cells = result.rawCells(); if (cells == null || cells.length == 0) { return result.isStale() ? EMPTY_RESULT_PB_STALE : EMPTY_RESULT_PB; } ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder(); for (Cell c : cells) { builder.addCell(toCell(c)); } builder.setStale(result.isStale()); builder.setPartial(result.mayHaveMoreCellsInRow()); return builder.build(); }
@Override public void encode(Result value, OutputStream outputStream, Coder.Context context) throws IOException { ClientProtos.Result protoResult = ProtobufUtil.toResult(value); protoResult.writeDelimitedTo(outputStream); } }
@Override public Result decode(InputStream inputStream) throws IOException { return ProtobufUtil.toResult(ClientProtos.Result.parseDelimitedFrom(inputStream)); } }
@Override public void serialize(Result result) throws IOException { ProtobufUtil.toResult(result).writeDelimitedTo(out); } }
@Override public void serialize(Result result) throws IOException { ProtobufUtil.toResult(result).writeDelimitedTo(out); } }
@Override public Result decode(InputStream inputStream, Coder.Context context) throws IOException { ClientProtos.Result protoResult = ClientProtos.Result.parseDelimitedFrom(inputStream); return ProtobufUtil.toResult(protoResult); }
@Override public void encode(Result value, OutputStream outputStream) throws IOException { ProtobufUtil.toResult(value).writeDelimitedTo(outputStream); }
@Override public void readFields(final DataInput in) throws IOException { ClientProtos.Result protosResult = ClientProtos.Result.parseDelimitedFrom(DataInputInputStream.from(in)); int size = in.readInt(); if(size < 0) { throw new IOException("Invalid size " + size); } Cell[] kvs = new Cell[size]; for (int i = 0; i < kvs.length; i++) { kvs[i] = KeyValue.create(in); } result = ProtobufUtil.toResult(protosResult, CellUtil.createCellScanner(kvs)); } @Override
@Override public Result deserialize(Result mutation) throws IOException { ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder(); ProtobufUtil.mergeDelimitedFrom(builder, in); ClientProtos.Result proto = builder.build(); return ProtobufUtil.toResult(proto); }
@Override public Result deserialize(Result mutation) throws IOException { ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder(); ProtobufUtil.mergeDelimitedFrom(builder, in); ClientProtos.Result proto = builder.build(); return ProtobufUtil.toResult(proto); }
/** * Convert a client Result to a protocol buffer Result. * The pb Result does not include the Cell data. That is for transport otherwise. * * @param result the client Result to convert * @return the converted protocol buffer Result */ public static ClientProtos.Result toResultNoData(final Result result) { if (result.getExists() != null) return toResult(result.getExists(), result.isStale()); int size = result.size(); if (size == 0) return result.isStale() ? EMPTY_RESULT_PB_STALE : EMPTY_RESULT_PB; ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder(); builder.setAssociatedCellCount(size); builder.setStale(result.isStale()); return builder.build(); }
/** * Convert a client Result to a protocol buffer Result. * The pb Result does not include the Cell data. That is for transport otherwise. * * @param result the client Result to convert * @return the converted protocol buffer Result */ public static ClientProtos.Result toResultNoData(final Result result) { if (result.getExists() != null) return toResult(result.getExists(), result.isStale()); int size = result.size(); if (size == 0) return result.isStale() ? EMPTY_RESULT_PB_STALE : EMPTY_RESULT_PB; ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder(); builder.setAssociatedCellCount(size); builder.setStale(result.isStale()); return builder.build(); }
@Override public Result call(int callTimeout) throws IOException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(tableName); controller.setCallTimeout(callTimeout); ClientProtos.GetRequest request = RequestConverter.buildGetRowOrBeforeRequest( getLocation().getRegionInfo().getRegionName(), row, family); try { ClientProtos.GetResponse response = getStub().get(controller, request); if (!response.hasResult()) return null; return ProtobufUtil.toResult(response.getResult()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };
@Override public Result call(int callTimeout) throws IOException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(getTableName()); controller.setCallTimeout(callTimeout); try { MutateRequest request = RequestConverter.buildMutateRequest( getLocation().getRegionInfo().getRegionName(), increment, nonceGroup, nonce); MutateResponse response = getStub().mutate(controller, request); return ProtobufUtil.toResult(response.getResult(), controller.cellScanner()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };
@Override public Result call(int callTimeout) throws IOException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(getTableName()); controller.setCallTimeout(callTimeout); try { MutateRequest request = RequestConverter.buildMutateRequest( getLocation().getRegionInfo().getRegionName(), append, nonceGroup, nonce); MutateResponse response = getStub().mutate(controller, request); if (!response.hasResult()) return null; return ProtobufUtil.toResult(response.getResult(), controller.cellScanner()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };