Search in sources :

Example 11 with InvalidProtocolBufferException

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

the class RegexStringComparator method parseFrom.

/**
 * @param pbBytes A pb serialized {@link RegexStringComparator} instance
 * @return An instance of {@link RegexStringComparator} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static RegexStringComparator parseFrom(final byte[] pbBytes) throws DeserializationException {
    ComparatorProtos.RegexStringComparator proto;
    try {
        proto = ComparatorProtos.RegexStringComparator.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    RegexStringComparator comparator;
    if (proto.hasEngine()) {
        EngineType engine = EngineType.valueOf(proto.getEngine());
        comparator = new RegexStringComparator(proto.getPattern(), proto.getPatternFlags(), engine);
    } else {
        comparator = new RegexStringComparator(proto.getPattern(), proto.getPatternFlags());
    }
    String charset = proto.getCharset();
    if (charset.length() > 0) {
        try {
            comparator.getEngine().setCharset(charset);
        } catch (IllegalCharsetNameException e) {
            LOG.error("invalid charset", e);
        }
    }
    return comparator;
}
Also used : IllegalCharsetNameException(java.nio.charset.IllegalCharsetNameException) 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 12 with InvalidProtocolBufferException

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

the class RowFilter method parseFrom.

/**
 * @param pbBytes A pb serialized {@link RowFilter} instance
 * @return An instance of {@link RowFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static RowFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.RowFilter proto;
    try {
        proto = FilterProtos.RowFilter.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 RowFilter(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 13 with InvalidProtocolBufferException

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

the class SingleColumnValueExcludeFilter method parseFrom.

/**
 * @param pbBytes A pb serialized {@link SingleColumnValueExcludeFilter} instance
 * @return An instance of {@link SingleColumnValueExcludeFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static SingleColumnValueExcludeFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.SingleColumnValueExcludeFilter proto;
    try {
        proto = FilterProtos.SingleColumnValueExcludeFilter.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    FilterProtos.SingleColumnValueFilter parentProto = proto.getSingleColumnValueFilter();
    final CompareOperator compareOp = CompareOperator.valueOf(parentProto.getCompareOp().name());
    final ByteArrayComparable comparator;
    try {
        comparator = ProtobufUtil.toComparator(parentProto.getComparator());
    } catch (IOException ioe) {
        throw new DeserializationException(ioe);
    }
    return new SingleColumnValueExcludeFilter(parentProto.hasColumnFamily() ? parentProto.getColumnFamily().toByteArray() : null, parentProto.hasColumnQualifier() ? parentProto.getColumnQualifier().toByteArray() : null, compareOp, comparator, parentProto.getFilterIfMissing(), parentProto.getLatestVersionOnly());
}
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 14 with InvalidProtocolBufferException

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

the class MultipleColumnPrefixFilter method parseFrom.

/**
 * @param pbBytes A pb serialized {@link MultipleColumnPrefixFilter} instance
 * @return An instance of {@link MultipleColumnPrefixFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static MultipleColumnPrefixFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.MultipleColumnPrefixFilter proto;
    try {
        proto = FilterProtos.MultipleColumnPrefixFilter.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    int numPrefixes = proto.getSortedPrefixesCount();
    byte[][] prefixes = new byte[numPrefixes][];
    for (int i = 0; i < numPrefixes; ++i) {
        prefixes[i] = proto.getSortedPrefixes(i).toByteArray();
    }
    return new MultipleColumnPrefixFilter(prefixes);
}
Also used : InvalidProtocolBufferException(org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 15 with InvalidProtocolBufferException

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

the class FuzzyRowFilter method parseFrom.

/**
 * @param pbBytes A pb serialized {@link FuzzyRowFilter} instance
 * @return An instance of {@link FuzzyRowFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FuzzyRowFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.FuzzyRowFilter proto;
    try {
        proto = FilterProtos.FuzzyRowFilter.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    int count = proto.getFuzzyKeysDataCount();
    ArrayList<Pair<byte[], byte[]>> fuzzyKeysData = new ArrayList<>(count);
    for (int i = 0; i < count; ++i) {
        BytesBytesPair current = proto.getFuzzyKeysData(i);
        byte[] keyBytes = current.getFirst().toByteArray();
        byte[] keyMeta = current.getSecond().toByteArray();
        fuzzyKeysData.add(new Pair<>(keyBytes, keyMeta));
    }
    return new FuzzyRowFilter(fuzzyKeysData);
}
Also used : BytesBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BytesBytesPair) InvalidProtocolBufferException(org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException) ArrayList(java.util.ArrayList) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException) BytesBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BytesBytesPair) Pair(org.apache.hadoop.hbase.util.Pair)

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