use of org.apache.hadoop.hbase.exceptions.DeserializationException 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.exceptions.DeserializationException 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);
}
use of org.apache.hadoop.hbase.exceptions.DeserializationException 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.exceptions.DeserializationException in project hbase by apache.
the class SingleColumnValueFilter method parseFrom.
/**
* @param pbBytes A pb serialized {@link SingleColumnValueFilter} instance
* @return An instance of {@link SingleColumnValueFilter} made from <code>bytes</code>
* @throws org.apache.hadoop.hbase.exceptions.DeserializationException
* @see #toByteArray
*/
public static SingleColumnValueFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
FilterProtos.SingleColumnValueFilter proto;
try {
proto = FilterProtos.SingleColumnValueFilter.parseFrom(pbBytes);
} catch (InvalidProtocolBufferException e) {
throw new DeserializationException(e);
}
final CompareOperator compareOp = CompareOperator.valueOf(proto.getCompareOp().name());
final org.apache.hadoop.hbase.filter.ByteArrayComparable comparator;
try {
comparator = ProtobufUtil.toComparator(proto.getComparator());
} catch (IOException ioe) {
throw new DeserializationException(ioe);
}
return new SingleColumnValueFilter(proto.hasColumnFamily() ? proto.getColumnFamily().toByteArray() : null, proto.hasColumnQualifier() ? proto.getColumnQualifier().toByteArray() : null, compareOp, comparator, proto.getFilterIfMissing(), proto.getLatestVersionOnly());
}
use of org.apache.hadoop.hbase.exceptions.DeserializationException 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 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 ValueFilter(valueCompareOp, valueComparator);
}
Aggregations