Java Code Examples for org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toResult()

The following examples show how to use org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toResult() . 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: RSRpcServices.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void addResult(final MutateResponse.Builder builder, final Result result,
    final HBaseRpcController rpcc, boolean clientCellBlockSupported) {
  if (result == null) return;
  if (clientCellBlockSupported) {
    builder.setResult(ProtobufUtil.toResultNoData(result));
    rpcc.setCellScanner(result.cellScanner());
  } else {
    ClientProtos.Result pbr = ProtobufUtil.toResult(result);
    builder.setResult(pbr);
  }
}
 
Example 2
Source File: TestRegionReplicas.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void assertGetRpc(RegionInfo info, int value, boolean expect)
    throws IOException, org.apache.hbase.thirdparty.com.google.protobuf.ServiceException {
  byte[] row = Bytes.toBytes(String.valueOf(value));
  Get get = new Get(row);
  ClientProtos.GetRequest getReq = RequestConverter.buildGetRequest(info.getRegionName(), get);
  ClientProtos.GetResponse getResp =  getRS().getRSRpcServices().get(null, getReq);
  Result result = ProtobufUtil.toResult(getResp.getResult());
  if (expect) {
    Assert.assertArrayEquals(row, result.getValue(f, null));
  } else {
    result.isEmpty();
  }
}
 
Example 3
Source File: RawAsyncTableImpl.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static Result toResult(HBaseRpcController controller, MutateResponse resp)
    throws IOException {
  if (!resp.hasResult()) {
    return null;
  }
  return ProtobufUtil.toResult(resp.getResult(), controller.cellScanner());
}
 
Example 4
Source File: AdapterPartition.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected Result doGet(Get get) throws IOException{
    if (!useProxy) {
        try {
            return delegate.doGet(get);
        } catch (AccessDeniedException ade) {
            activateProxy(ade);
        }
    }

    try {
        try (java.sql.Connection jdbcConnection = connectionPool.getConnection();
             PreparedStatement statement = jdbcConnection.prepareStatement("call SYSCS_UTIL.SYSCS_HBASE_OPERATION(?, ?, ?)")) {
            statement.setString(1, tableName.toString());
            statement.setString(2, "get");
            ClientProtos.Get getRequest = ProtobufUtil.toGet(get);
            statement.setBlob(3, new ArrayInputStream(getRequest.toByteArray()));
            try (ResultSet rs = statement.executeQuery()) {
                if (!rs.next()) {
                    throw new IOException("No results for get");
                }

                Blob blob = rs.getBlob(1);
                byte[] bytes = blob.getBytes(1, (int) blob.length());

                ClientProtos.Result result = ClientProtos.Result.parseFrom(bytes);
                return ProtobufUtil.toResult(result);
            }
        }
    } catch (SQLException e) {
        throw new IOException(e);
    }
}
 
Example 5
Source File: ResultSerialization.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Override
public Result deserialize(Result mutation) throws IOException {
  ClientProtos.Result proto = ClientProtos.Result.parseDelimitedFrom(in);
  return ProtobufUtil.toResult(proto);
}