Java Code Examples for org.apache.hadoop.hbase.client.Result#isStale()

The following examples show how to use org.apache.hadoop.hbase.client.Result#isStale() . 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: ProtobufUtil.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example 2
Source File: ProtobufUtil.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}