Search in sources :

Example 6 with InvalidProtocolBufferException

use of org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class FilterList method parseFrom.

/**
 * @param pbBytes A pb serialized {@link FilterList} instance
 * @return An instance of {@link FilterList} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FilterList parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.FilterList proto;
    try {
        proto = FilterProtos.FilterList.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    List<Filter> rowFilters = new ArrayList<>(proto.getFiltersCount());
    try {
        List<FilterProtos.Filter> filtersList = proto.getFiltersList();
        for (int i = 0, n = filtersList.size(); i < n; i++) {
            rowFilters.add(ProtobufUtil.toFilter(filtersList.get(i)));
        }
    } catch (IOException ioe) {
        throw new DeserializationException(ioe);
    }
    return new FilterList(Operator.valueOf(proto.getOperator().name()), rowFilters);
}
Also used : InvalidProtocolBufferException(org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException) ArrayList(java.util.ArrayList) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) IOException(java.io.IOException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 7 with InvalidProtocolBufferException

use of org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class FamilyFilter method parseFrom.

/**
 * @param pbBytes A pb serialized {@link FamilyFilter} instance
 * @return An instance of {@link FamilyFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FamilyFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.FamilyFilter proto;
    try {
        proto = FilterProtos.FamilyFilter.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    final CompareOperator valueCompareOp = CompareOperator.valueOf(proto.getCompareFilter().getCompareOp().name());
    ByteArrayComparable valueComparator = null;
    try {
        if (proto.getCompareFilter().hasComparator()) {
            valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
        }
    } catch (IOException ioe) {
        throw new DeserializationException(ioe);
    }
    return new FamilyFilter(valueCompareOp, valueComparator);
}
Also used : CompareOperator(org.apache.hadoop.hbase.CompareOperator) InvalidProtocolBufferException(org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) IOException(java.io.IOException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 8 with InvalidProtocolBufferException

use of org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class BitComparator method parseFrom.

/**
 * @param pbBytes A pb serialized {@link BitComparator} instance
 * @return An instance of {@link BitComparator} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static BitComparator parseFrom(final byte[] pbBytes) throws DeserializationException {
    ComparatorProtos.BitComparator proto;
    try {
        proto = ComparatorProtos.BitComparator.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    BitwiseOp bitwiseOp = BitwiseOp.valueOf(proto.getBitwiseOp().name());
    return new BitComparator(proto.getComparable().getValue().toByteArray(), bitwiseOp);
}
Also used : ComparatorProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ComparatorProtos) InvalidProtocolBufferException(org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 9 with InvalidProtocolBufferException

use of org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class ProtobufUtil method toLockJson.

public static String toLockJson(List<LockServiceProtos.LockedResource> lockedResourceProtos) {
    JsonArray lockedResourceJsons = new JsonArray(lockedResourceProtos.size());
    for (LockServiceProtos.LockedResource lockedResourceProto : lockedResourceProtos) {
        try {
            JsonElement lockedResourceJson = ProtobufMessageConverter.toJsonElement(lockedResourceProto);
            lockedResourceJsons.add(lockedResourceJson);
        } catch (InvalidProtocolBufferException e) {
            lockedResourceJsons.add(e.toString());
        }
    }
    return lockedResourceJsons.toString();
}
Also used : JsonArray(org.apache.hbase.thirdparty.com.google.gson.JsonArray) LockServiceProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos) JsonElement(org.apache.hbase.thirdparty.com.google.gson.JsonElement) InvalidProtocolBufferException(org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException)

Example 10 with InvalidProtocolBufferException

use of org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class ProtobufUtil method toScanMetrics.

public static ScanMetrics toScanMetrics(final byte[] bytes) {
    MapReduceProtos.ScanMetrics pScanMetrics = null;
    try {
        pScanMetrics = MapReduceProtos.ScanMetrics.parseFrom(bytes);
    } catch (InvalidProtocolBufferException e) {
    // Ignored there are just no key values to add.
    }
    ScanMetrics scanMetrics = new ScanMetrics();
    if (pScanMetrics != null) {
        for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
            if (pair.hasName() && pair.hasValue()) {
                scanMetrics.setCounter(pair.getName(), pair.getValue());
            }
        }
    }
    return scanMetrics;
}
Also used : MapReduceProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.MapReduceProtos) InvalidProtocolBufferException(org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException) ScanMetrics(org.apache.hadoop.hbase.client.metrics.ScanMetrics) HBaseProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)

Aggregations

InvalidProtocolBufferException (org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException)25 DeserializationException (org.apache.hadoop.hbase.exceptions.DeserializationException)15 IOException (java.io.IOException)12 FilterProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos)12 CompareOperator (org.apache.hadoop.hbase.CompareOperator)8 ArrayList (java.util.ArrayList)4 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)3 Path (org.apache.hadoop.fs.Path)2 Cell (org.apache.hadoop.hbase.Cell)2 Result (org.apache.hadoop.hbase.client.Result)2 Table (org.apache.hadoop.hbase.client.Table)2 ComparatorProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ComparatorProtos)2 HBaseProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)2 JsonArray (org.apache.hbase.thirdparty.com.google.gson.JsonArray)2 JsonElement (org.apache.hbase.thirdparty.com.google.gson.JsonElement)2 CodedInputStream (org.apache.hbase.thirdparty.com.google.protobuf.CodedInputStream)2 EOFException (java.io.EOFException)1 FileNotFoundException (java.io.FileNotFoundException)1 InterruptedIOException (java.io.InterruptedIOException)1 IllegalCharsetNameException (java.nio.charset.IllegalCharsetNameException)1