use of org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.
the class ValueFilter method parseFrom.
/**
* @param pbBytes A pb serialized {@link ValueFilter} instance
* @return An instance of {@link ValueFilter} made from <code>bytes</code>
* @throws DeserializationException
* @see #toByteArray
*/
public static ValueFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
FilterProtos.ValueFilter proto;
try {
proto = FilterProtos.ValueFilter.parseFrom(pbBytes);
} catch (InvalidProtocolBufferException e) {
throw new DeserializationException(e);
}
final CompareOp valueCompareOp = CompareOp.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 ValueFilter(valueCompareOp, valueComparator);
}
use of org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.
the class MultiRowRangeFilter method parseFrom.
/**
* @param pbBytes A pb serialized instance
* @return An instance of MultiRowRangeFilter
* @throws org.apache.hadoop.hbase.exceptions.DeserializationException
*/
public static MultiRowRangeFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
FilterProtos.MultiRowRangeFilter proto;
try {
proto = FilterProtos.MultiRowRangeFilter.parseFrom(pbBytes);
} catch (InvalidProtocolBufferException e) {
throw new DeserializationException(e);
}
int length = proto.getRowRangeListCount();
List<FilterProtos.RowRange> rangeProtos = proto.getRowRangeListList();
List<RowRange> rangeList = new ArrayList<>(length);
for (FilterProtos.RowRange rangeProto : rangeProtos) {
RowRange range = new RowRange(rangeProto.hasStartRow() ? rangeProto.getStartRow().toByteArray() : null, rangeProto.getStartRowInclusive(), rangeProto.hasStopRow() ? rangeProto.getStopRow().toByteArray() : null, rangeProto.getStopRowInclusive());
rangeList.add(range);
}
return new MultiRowRangeFilter(rangeList);
}
use of org.apache.hadoop.hbase.shaded.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);
}
use of org.apache.hadoop.hbase.shaded.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;
}
use of org.apache.hadoop.hbase.shaded.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 CompareOp valueCompareOp = CompareOp.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);
}
Aggregations