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

The following examples show how to use org.apache.hadoop.hbase.client.Result#getExists() . These examples are extracted from open source projects. 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
private Result internalGetFromHTable(Table table, String path, boolean fetchContent, boolean fetchTimestamp)
        throws IOException {
    byte[] rowkey = Bytes.toBytes(path);

    Get get = new Get(rowkey);

    if (!fetchContent && !fetchTimestamp) {
        get.setCheckExistenceOnly(true);
    } else {
        if (fetchContent)
            get.addColumn(B_FAMILY, B_COLUMN);
        if (fetchTimestamp)
            get.addColumn(B_FAMILY, B_COLUMN_TS);
    }

    Result result = table.get(get);
    boolean exists = result != null && (!result.isEmpty() || (result.getExists() != null && result.getExists()));
    return exists ? result : null;
}
 
Example 2
Source Project: kylin   File: HBaseResourceStore.java    License: Apache License 2.0 6 votes vote down vote up
private Result internalGetFromHTable(Table table, String path, boolean fetchContent, boolean fetchTimestamp)
        throws IOException {
    byte[] rowkey = Bytes.toBytes(path);

    Get get = new Get(rowkey);

    if (!fetchContent && !fetchTimestamp) {
        get.setCheckExistenceOnly(true);
    } else {
        if (fetchContent)
            get.addColumn(B_FAMILY, B_COLUMN);
        if (fetchTimestamp)
            get.addColumn(B_FAMILY, B_COLUMN_TS);
    }

    Result result = table.get(get);
    boolean exists = result != null && (!result.isEmpty() || (result.getExists() != null && result.getExists()));
    return exists ? result : null;
}
 
Example 3
Source Project: hbase   File: ProtobufUtil.java    License: 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 4
Source Project: hbase   File: ProtobufUtil.java    License: 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();
}