use of org.apache.hadoop.hbase.CompareOperator 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.CompareOperator 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);
}
use of org.apache.hadoop.hbase.CompareOperator in project hbase by apache.
the class ValueFilter method createFilterFromArguments.
public static Filter createFilterFromArguments(ArrayList<byte[]> filterArguments) {
// for arguments
@SuppressWarnings("rawtypes") ArrayList arguments = CompareFilter.extractArguments(filterArguments);
CompareOperator compareOp = (CompareOperator) arguments.get(0);
ByteArrayComparable comparator = (ByteArrayComparable) arguments.get(1);
return new ValueFilter(compareOp, comparator);
}
use of org.apache.hadoop.hbase.CompareOperator in project hbase by apache.
the class CompareFilter method extractArguments.
// returns an array of heterogeneous objects
public static ArrayList<Object> extractArguments(ArrayList<byte[]> filterArguments) {
Preconditions.checkArgument(filterArguments.size() == 2, "Expected 2 but got: %s", filterArguments.size());
CompareOperator op = ParseFilter.createCompareOperator(filterArguments.get(0));
ByteArrayComparable comparator = ParseFilter.createComparator(ParseFilter.removeQuotesFromByteArray(filterArguments.get(1)));
if (comparator instanceof RegexStringComparator || comparator instanceof SubstringComparator) {
if (op != CompareOperator.EQUAL && op != CompareOperator.NOT_EQUAL) {
throw new IllegalArgumentException("A regexstring comparator and substring comparator" + " can only be used with EQUAL and NOT_EQUAL");
}
}
ArrayList<Object> arguments = new ArrayList<>(2);
arguments.add(op);
arguments.add(comparator);
return arguments;
}
Aggregations