public static List<TRowResult> rowResultFromHBase(Result[] in, boolean sortColumns) {
    List<TRowResult> results = new ArrayList<>(in.length);
    for (Result result_ : in) {
      if (result_ == null || result_.isEmpty()) {
        continue;
      }

      TRowResult result = new TRowResult();
      result.row = ByteBuffer.wrap(result_.getRow());

      if (sortColumns) {
        result.sortedColumns = new ArrayList<>();
        for (Cell kv : result_.rawCells()) {
          result.sortedColumns.add(new TColumn(
            ByteBuffer
              .wrap(CellUtil.makeColumn(CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv))),
            new TCell(ByteBuffer.wrap(CellUtil.cloneValue(kv)), kv.getTimestamp())));
        }
      } else {
        result.columns = new TreeMap<>();
        for (Cell kv : result_.rawCells()) {
          result.columns.put(
            ByteBuffer
              .wrap(CellUtil.makeColumn(CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv))),
            new TCell(ByteBuffer.wrap(CellUtil.cloneValue(kv)), kv.getTimestamp()));
        }
      }

      results.add(result);
    }

    return results;
  }
This utility method creates a list of Thrift TRowResult "struct" based on an Hbase RowResult
object. The empty list is returned if the input is null. Hbase RowResult object This boolean
dictates if row data is returned in a sorted order sortColumns = True will set TRowResult's
sortedColumns member which is an ArrayList of TColumn struct sortColumns = False will set
TRowResult's columns member which is a map of columnName and TCell struct
@return Thrift TRowResult array
hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java