public static ClientProtos.Result toResult(final Result result, boolean encodeTags) {
    if (result.getExists() != null) {
      return toResult(result.getExists(), result.isStale());
    }

    ExtendedCell[] cells = ClientInternalHelper.getExtendedRawCells(result);
    if (cells == null || cells.length == 0) {
      return result.isStale() ? EMPTY_RESULT_PB_STALE : EMPTY_RESULT_PB;
    }

    ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder();
    for (ExtendedCell c : cells) {
      builder.addCell(toCell(c, encodeTags));
    }

    builder.setStale(result.isStale());
    builder.setPartial(result.mayHaveMoreCellsInRow());

    if (result.getMetrics() != null) {
      builder.setMetrics(toQueryMetrics(result.getMetrics()));
    }

    return builder.build();
  }
Convert a client Result to a protocol buffer Result
@param result     the client Result to convert
@param encodeTags whether to includeTags in converted protobuf result or not When @encodeTags
                  is set to true, it will return all the tags in the response. These tags may
                  contain some sensitive data like acl permissions, etc. Only the tools like
                  Export, Import which needs to take backup needs to set it to true so that
                  cell tags are persisted in backup. Refer to HBASE-25246 for more context.
@return the converted protocol buffer Result
hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java