@SuppressWarnings("unchecked")
  public static ByteArrayComparable toComparator(ComparatorProtos.Comparator proto)
    throws IOException {
    String type = proto.getName();
    byte[] value = proto.getSerializedComparator().toByteArray();

    try {
      ByteArrayComparable result = COMPARATORS.getAndCallByName(type, value);
      if (result != null) {
        return result;
      }

      if (!ALLOW_FAST_REFLECTION_FALLTHROUGH) {
        throw new IllegalStateException("Failed to deserialize comparator " + type
          + " because fast reflection returned null and fallthrough is disabled");
      }

      Class<?> c = Class.forName(type, true, ClassLoaderHolder.CLASS_LOADER);
      Method parseFrom = c.getMethod(PARSE_FROM, byte[].class);
      if (parseFrom == null) {
        throw new IOException("Unable to locate function: " + PARSE_FROM + " in type: " + type);
      }
      return (ByteArrayComparable) parseFrom.invoke(null, value);
    } catch (Exception e) {
      throw new IOException(e);
    }
  }
Convert a protocol buffer Comparator to a ByteArrayComparable
@param proto the protocol buffer Comparator to convert
@return the converted ByteArrayComparable
hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java