use of org.apache.hadoop.hbase.CompareOperator in project hbase by apache.
the class SingleColumnValueFilter method createFilterFromArguments.
public static Filter createFilterFromArguments(ArrayList<byte[]> filterArguments) {
Preconditions.checkArgument(filterArguments.size() == 4 || filterArguments.size() == 6, "Expected 4 or 6 but got: %s", filterArguments.size());
byte[] family = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
byte[] qualifier = ParseFilter.removeQuotesFromByteArray(filterArguments.get(1));
CompareOperator op = ParseFilter.createCompareOperator(filterArguments.get(2));
org.apache.hadoop.hbase.filter.ByteArrayComparable comparator = ParseFilter.createComparator(ParseFilter.removeQuotesFromByteArray(filterArguments.get(3)));
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");
}
}
SingleColumnValueFilter filter = new SingleColumnValueFilter(family, qualifier, op, comparator);
if (filterArguments.size() == 6) {
boolean filterIfMissing = ParseFilter.convertByteArrayToBoolean(filterArguments.get(4));
boolean latestVersionOnly = ParseFilter.convertByteArrayToBoolean(filterArguments.get(5));
filter.setFilterIfMissing(filterIfMissing);
filter.setLatestVersionOnly(latestVersionOnly);
}
return filter;
}
use of org.apache.hadoop.hbase.CompareOperator in project hbase by apache.
the class QualifierFilter method parseFrom.
/**
* @param pbBytes A pb serialized {@link QualifierFilter} instance
* @return An instance of {@link QualifierFilter} made from <code>bytes</code>
* @throws org.apache.hadoop.hbase.exceptions.DeserializationException
* @see #toByteArray
*/
public static QualifierFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
FilterProtos.QualifierFilter proto;
try {
proto = FilterProtos.QualifierFilter.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 QualifierFilter(valueCompareOp, valueComparator);
}
use of org.apache.hadoop.hbase.CompareOperator in project hbase by apache.
the class ColumnValueFilter method parseFrom.
/**
* Parse protobuf bytes to a ColumnValueFilter
* @param pbBytes pbBytes
* @return a ColumnValueFilter
* @throws DeserializationException deserialization exception
*/
public static ColumnValueFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
FilterProtos.ColumnValueFilter proto;
try {
proto = FilterProtos.ColumnValueFilter.parseFrom(pbBytes);
} catch (InvalidProtocolBufferException e) {
throw new DeserializationException(e);
}
final CompareOperator compareOp = CompareOperator.valueOf(proto.getCompareOp().name());
final ByteArrayComparable comparator;
try {
comparator = ProtobufUtil.toComparator(proto.getComparator());
} catch (IOException ioe) {
throw new DeserializationException(ioe);
}
return new ColumnValueFilter(proto.getFamily().toByteArray(), proto.getQualifier().toByteArray(), compareOp, comparator);
}
use of org.apache.hadoop.hbase.CompareOperator in project hbase by apache.
the class ColumnValueFilter method createFilterFromArguments.
/**
* Creating this filter by reflection, it is used by {@link ParseFilter},
* @param filterArguments arguments for creating a ColumnValueFilter
* @return a ColumnValueFilter
*/
public static Filter createFilterFromArguments(ArrayList<byte[]> filterArguments) {
Preconditions.checkArgument(filterArguments.size() == 4, "Expect 4 arguments: %s", filterArguments.size());
byte[] family = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
byte[] qualifier = ParseFilter.removeQuotesFromByteArray(filterArguments.get(1));
CompareOperator operator = ParseFilter.createCompareOperator(filterArguments.get(2));
ByteArrayComparable comparator = ParseFilter.createComparator(ParseFilter.removeQuotesFromByteArray(filterArguments.get(3)));
if (comparator instanceof RegexStringComparator || comparator instanceof SubstringComparator) {
if (operator != CompareOperator.EQUAL && operator != CompareOperator.NOT_EQUAL) {
throw new IllegalArgumentException("A regexstring comparator and substring comparator " + "can only be used with EQUAL and NOT_EQUAL");
}
}
return new ColumnValueFilter(family, qualifier, operator, comparator);
}
use of org.apache.hadoop.hbase.CompareOperator in project hbase by apache.
the class DependentColumnFilter method createFilterFromArguments.
public static Filter createFilterFromArguments(ArrayList<byte[]> filterArguments) {
Preconditions.checkArgument(filterArguments.size() == 2 || filterArguments.size() == 3 || filterArguments.size() == 5, "Expected 2, 3 or 5 but got: %s", filterArguments.size());
if (filterArguments.size() == 2) {
byte[] family = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
byte[] qualifier = ParseFilter.removeQuotesFromByteArray(filterArguments.get(1));
return new DependentColumnFilter(family, qualifier);
} else if (filterArguments.size() == 3) {
byte[] family = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
byte[] qualifier = ParseFilter.removeQuotesFromByteArray(filterArguments.get(1));
boolean dropDependentColumn = ParseFilter.convertByteArrayToBoolean(filterArguments.get(2));
return new DependentColumnFilter(family, qualifier, dropDependentColumn);
} else if (filterArguments.size() == 5) {
byte[] family = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
byte[] qualifier = ParseFilter.removeQuotesFromByteArray(filterArguments.get(1));
boolean dropDependentColumn = ParseFilter.convertByteArrayToBoolean(filterArguments.get(2));
CompareOperator op = ParseFilter.createCompareOperator(filterArguments.get(3));
ByteArrayComparable comparator = ParseFilter.createComparator(ParseFilter.removeQuotesFromByteArray(filterArguments.get(4)));
return new DependentColumnFilter(family, qualifier, dropDependentColumn, op, comparator);
} else {
throw new IllegalArgumentException("Expected 2, 3 or 5 but got: " + filterArguments.size());
}
}
Aggregations