public static org.apache.hadoop.hbase.client.MultiResponse getResults(final MultiRequest request,
    final Map<Integer, Integer> indexMap, final MultiResponse response, final CellScanner cells)
    throws IOException {
    int requestRegionActionCount = request.getRegionActionCount();
    int responseRegionActionResultCount = response.getRegionActionResultCount();
    if (requestRegionActionCount != responseRegionActionResultCount) {
      throw new IllegalStateException("Request mutation count=" + requestRegionActionCount
        + " does not match response mutation result count=" + responseRegionActionResultCount);
    }

    org.apache.hadoop.hbase.client.MultiResponse results =
      new org.apache.hadoop.hbase.client.MultiResponse();

    for (int i = 0; i < responseRegionActionResultCount; i++) {
      RegionAction actions = request.getRegionAction(i);
      RegionActionResult actionResult = response.getRegionActionResult(i);
      HBaseProtos.RegionSpecifier rs = actions.getRegion();
      if (
        rs.hasType()
          && (rs.getType() != HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME)
      ) {
        throw new IllegalArgumentException(
          "We support only encoded types for protobuf multi response.");
      }
      byte[] regionName = rs.getValue().toByteArray();

      if (actionResult.hasException()) {
        Throwable regionException = ProtobufUtil.toException(actionResult.getException());
        results.addException(regionName, regionException);
        continue;
      }

      if (actions.getActionCount() != actionResult.getResultOrExceptionCount()) {
        throw new IllegalStateException("actions.getActionCount=" + actions.getActionCount()
          + ", actionResult.getResultOrExceptionCount=" + actionResult.getResultOrExceptionCount()
          + " for region " + actions.getRegion());
      }

      // For RowMutations/CheckAndMutate action, if there is an exception, the exception is set
      // at the RegionActionResult level and the ResultOrException is null at the original index
      Integer index = (indexMap == null ? null : indexMap.get(i));
      if (index != null) {
        // This RegionAction is from a RowMutations/CheckAndMutate in a batch.
        // If there is an exception from the server, the exception is set at
        // the RegionActionResult level, which has been handled above.
        if (actions.hasCondition()) {
          results.add(regionName, index, getCheckAndMutateResult(actionResult, cells));
        } else {
          results.add(regionName, index, getMutateRowResult(actionResult, cells));
        }
        continue;
      }

      if (actions.hasCondition()) {
        results.add(regionName, 0, getCheckAndMutateResult(actionResult, cells));
      } else {
        if (actionResult.hasProcessed()) {
          results.add(regionName, 0, getMutateRowResult(actionResult, cells));
          continue;
        }
        for (ResultOrException roe : actionResult.getResultOrExceptionList()) {
          Object responseValue;
          if (roe.hasException()) {
            responseValue = ProtobufUtil.toException(roe.getException());
          } else if (roe.hasResult()) {
            responseValue = ProtobufUtil.toResult(roe.getResult(), cells);
          } else if (roe.hasServiceResult()) {
            responseValue = roe.getServiceResult();
          } else {
            responseValue = ProtobufUtil.EMPTY_RESULT_EXISTS_TRUE;
          }
          results.add(regionName, roe.getIndex(), responseValue);
        }
      }
    }

    if (response.hasRegionStatistics()) {
      ClientProtos.MultiRegionLoadStats stats = response.getRegionStatistics();
      for (int i = 0; i < stats.getRegionCount(); i++) {
        results.addStatistic(stats.getRegion(i).getValue().toByteArray(), stats.getStat(i));
      }
    }

    return results;
  }
Get the results from a protocol buffer MultiResponse
@param request  the original protocol buffer MultiRequest
@param indexMap Used to support RowMutations/CheckAndMutate in batch
@param response the protocol buffer MultiResponse to convert
@param cells    Cells to go with the passed in <code>proto</code>. Can be null.
@return the results that were in the MultiResponse (a Result or an Exception).
hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ResponseConverter.java