HBASE-18769 Make CompareFilter use generic CompareOperator instead of

internal enum
This commit is contained in:
Michael Stack 2017-09-07 13:59:46 -07:00
parent 331910192a
commit b8e0a8396f
39 changed files with 678 additions and 338 deletions

View File

@ -134,8 +134,7 @@ public interface Table extends Closeable {
*/
<R> void batchCallback(
final List<? extends Row> actions, final Object[] results, final Batch.Callback<R> callback
)
throws IOException, InterruptedException;
) throws IOException, InterruptedException;
/**
* Extracts certain cells from a given row.

View File

@ -54,8 +54,9 @@ public abstract class CompareFilter extends FilterBase {
* Comparison operators. For filters only!
* Use {@link CompareOperator} otherwise.
* It (intentionally) has at least the below enums with same names.
* TODO: Replace with generic {@link CompareOperator}
* @deprecated since 2.0.0. Will be removed in 3.0.0. Use {@link CompareOperator} instead.
*/
@Deprecated
@InterfaceAudience.Public
public enum CompareOp {
/** less than */
@ -74,25 +75,43 @@ public abstract class CompareFilter extends FilterBase {
NO_OP,
}
protected CompareOp compareOp;
protected CompareOperator op;
protected ByteArrayComparable comparator;
/**
* Constructor.
* @param compareOp the compare op for row matching
* @param comparator the comparator for row matching
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use other constructor.
*/
@Deprecated
public CompareFilter(final CompareOp compareOp,
final ByteArrayComparable comparator) {
this.compareOp = compareOp;
this(CompareOperator.valueOf(compareOp.name()), comparator);
}
/**
* Constructor.
* @param op the compare op for row matching
* @param comparator the comparator for row matching
*/
public CompareFilter(final CompareOperator op,
final ByteArrayComparable comparator) {
this.op = op;
this.comparator = comparator;
}
/**
* @return operator
* @deprecated since 2.0.0. Will be removed in 3.0.0. Use {@link #getCompareOperator()} instead.
*/
@Deprecated
public CompareOp getOperator() {
return compareOp;
return CompareOp.valueOf(op.name());
}
public CompareOperator getCompareOperator() {
return op;
}
/**
@ -108,6 +127,11 @@ public abstract class CompareFilter extends FilterBase {
return false;
}
/**
* @deprecated Since 2.0.0. Will be removed in 3.0.0.
* Use {@link #compareRow(CompareOperator, ByteArrayComparable, Cell)}
*/
@Deprecated
protected boolean compareRow(final CompareOp compareOp, final ByteArrayComparable comparator,
final Cell cell) {
if (compareOp == CompareOp.NO_OP) {
@ -117,6 +141,20 @@ public abstract class CompareFilter extends FilterBase {
return compare(compareOp, compareResult);
}
protected boolean compareRow(final CompareOperator op, final ByteArrayComparable comparator,
final Cell cell) {
if (op == CompareOperator.NO_OP) {
return true;
}
int compareResult = CellComparator.compareRow(cell, comparator);
return compare(op, compareResult);
}
/**
* @deprecated Since 2.0.0. Will be removed in 3.0.0.
* Use {@link #compareFamily(CompareOperator, ByteArrayComparable, Cell)}
*/
@Deprecated
protected boolean compareFamily(final CompareOp compareOp, final ByteArrayComparable comparator,
final Cell cell) {
if (compareOp == CompareOp.NO_OP) {
@ -126,8 +164,23 @@ public abstract class CompareFilter extends FilterBase {
return compare(compareOp, compareResult);
}
protected boolean compareFamily(final CompareOperator op, final ByteArrayComparable comparator,
final Cell cell) {
if (op == CompareOperator.NO_OP) {
return true;
}
int compareResult = CellComparator.compareFamily(cell, comparator);
return compare(op, compareResult);
}
/**
* @deprecated Since 2.0.0. Will be removed in 3.0.0.
* Use {@link #compareQualifier(CompareOperator, ByteArrayComparable, Cell)}
*/
@Deprecated
protected boolean compareQualifier(final CompareOp compareOp,
final ByteArrayComparable comparator, final Cell cell) {
// We do not call through to the non-deprecated method for perf reasons.
if (compareOp == CompareOp.NO_OP) {
return true;
}
@ -135,8 +188,24 @@ public abstract class CompareFilter extends FilterBase {
return compare(compareOp, compareResult);
}
protected boolean compareQualifier(final CompareOperator op,
final ByteArrayComparable comparator, final Cell cell) {
// We do not call through to the non-deprecated method for perf reasons.
if (op == CompareOperator.NO_OP) {
return true;
}
int compareResult = CellComparator.compareQualifier(cell, comparator);
return compare(op, compareResult);
}
/**
* @deprecated Since 2.0.0. Will be removed in 3.0.0.
* Use {@link #compareValue(CompareOperator, ByteArrayComparable, Cell)}
*/
@Deprecated
protected boolean compareValue(final CompareOp compareOp, final ByteArrayComparable comparator,
final Cell cell) {
// We do not call through to the non-deprecated method for perf reasons.
if (compareOp == CompareOp.NO_OP) {
return true;
}
@ -144,8 +213,17 @@ public abstract class CompareFilter extends FilterBase {
return compare(compareOp, compareResult);
}
private boolean compare(final CompareOp compareOp, int compareResult) {
switch (compareOp) {
protected boolean compareValue(final CompareOperator op, final ByteArrayComparable comparator,
final Cell cell) {
if (op == CompareOperator.NO_OP) {
return true;
}
int compareResult = CellComparator.compareValue(cell, comparator);
return compare(op, compareResult);
}
static boolean compare(final CompareOp op, int compareResult) {
switch (op) {
case LESS:
return compareResult <= 0;
case LESS_OR_EQUAL:
@ -159,7 +237,26 @@ public abstract class CompareFilter extends FilterBase {
case GREATER:
return compareResult >= 0;
default:
throw new RuntimeException("Unknown Compare op " + compareOp.name());
throw new RuntimeException("Unknown Compare op " + op.name());
}
}
static boolean compare(final CompareOperator op, int compareResult) {
switch (op) {
case LESS:
return compareResult <= 0;
case LESS_OR_EQUAL:
return compareResult < 0;
case EQUAL:
return compareResult != 0;
case NOT_EQUAL:
return compareResult == 0;
case GREATER_OR_EQUAL:
return compareResult > 0;
case GREATER:
return compareResult >= 0;
default:
throw new RuntimeException("Unknown Compare op " + op.name());
}
}
@ -167,20 +264,20 @@ public abstract class CompareFilter extends FilterBase {
public static ArrayList<Object> extractArguments(ArrayList<byte []> filterArguments) {
Preconditions.checkArgument(filterArguments.size() == 2,
"Expected 2 but got: %s", filterArguments.size());
CompareOp compareOp = ParseFilter.createCompareOp(filterArguments.get(0));
CompareOperator op = ParseFilter.createCompareOperator(filterArguments.get(0));
ByteArrayComparable comparator = ParseFilter.createComparator(
ParseFilter.removeQuotesFromByteArray(filterArguments.get(1)));
if (comparator instanceof RegexStringComparator ||
comparator instanceof SubstringComparator) {
if (compareOp != CompareOp.EQUAL &&
compareOp != CompareOp.NOT_EQUAL) {
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(compareOp);
arguments.add(op);
arguments.add(comparator);
return arguments;
}
@ -191,7 +288,7 @@ public abstract class CompareFilter extends FilterBase {
FilterProtos.CompareFilter convert() {
FilterProtos.CompareFilter.Builder builder =
FilterProtos.CompareFilter.newBuilder();
HBaseProtos.CompareType compareOp = CompareType.valueOf(this.compareOp.name());
HBaseProtos.CompareType compareOp = CompareType.valueOf(this.op.name());
builder.setCompareOp(compareOp);
if (this.comparator != null) builder.setComparator(ProtobufUtil.toComparator(this.comparator));
return builder.build();
@ -206,9 +303,8 @@ public abstract class CompareFilter extends FilterBase {
boolean areSerializedFieldsEqual(Filter o) {
if (o == this) return true;
if (!(o instanceof CompareFilter)) return false;
CompareFilter other = (CompareFilter)o;
return this.getOperator().equals(other.getOperator()) &&
return this.getCompareOperator().equals(other.getCompareOperator()) &&
(this.getComparator() == other.getComparator()
|| this.getComparator().areSerializedFieldsEqual(other.getComparator()));
}
@ -217,7 +313,7 @@ public abstract class CompareFilter extends FilterBase {
public String toString() {
return String.format("%s (%s, %s)",
this.getClass().getSimpleName(),
this.compareOp.name(),
this.op.name(),
Bytes.toStringBinary(this.comparator.getValue()));
}
}

View File

@ -26,6 +26,7 @@ import java.util.Set;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
@ -64,12 +65,35 @@ public class DependentColumnFilter extends CompareFilter {
* @param dropDependentColumn whether the column should be discarded after
* @param valueCompareOp comparison op
* @param valueComparator comparator
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
* {@link #DependentColumnFilter(byte[], byte[], boolean, CompareOperator, ByteArrayComparable)}
* instead.
*/
@Deprecated
public DependentColumnFilter(final byte [] family, final byte[] qualifier,
final boolean dropDependentColumn, final CompareOp valueCompareOp,
final ByteArrayComparable valueComparator) {
this(family, qualifier, dropDependentColumn, CompareOperator.valueOf(valueCompareOp.name()),
valueComparator);
}
/**
* Build a dependent column filter with value checking
* dependent column varies will be compared using the supplied
* compareOp and comparator, for usage of which
* refer to {@link CompareFilter}
*
* @param family dependent column family
* @param qualifier dependent column qualifier
* @param dropDependentColumn whether the column should be discarded after
* @param op Value comparison op
* @param valueComparator comparator
*/
public DependentColumnFilter(final byte [] family, final byte[] qualifier,
final boolean dropDependentColumn, final CompareOperator op,
final ByteArrayComparable valueComparator) {
// set up the comparator
super(valueCompareOp, valueComparator);
super(op, valueComparator);
this.columnFamily = family;
this.columnQualifier = qualifier;
this.dropDependentColumn = dropDependentColumn;
@ -140,7 +164,7 @@ public class DependentColumnFilter extends CompareFilter {
}
// If it doesn't pass the op, skip it
if (comparator != null
&& compareValue(compareOp, comparator, c))
&& compareValue(getCompareOperator(), comparator, c))
return ReturnCode.SKIP;
stampSet.add(c.getTimestamp());
@ -194,11 +218,11 @@ public class DependentColumnFilter extends CompareFilter {
byte [] family = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
byte [] qualifier = ParseFilter.removeQuotesFromByteArray(filterArguments.get(1));
boolean dropDependentColumn = ParseFilter.convertByteArrayToBoolean(filterArguments.get(2));
CompareOp compareOp = ParseFilter.createCompareOp(filterArguments.get(3));
CompareOperator op = ParseFilter.createCompareOperator(filterArguments.get(3));
ByteArrayComparable comparator = ParseFilter.createComparator(
ParseFilter.removeQuotesFromByteArray(filterArguments.get(4)));
return new DependentColumnFilter(family, qualifier, dropDependentColumn,
compareOp, comparator);
op, comparator);
} else {
throw new IllegalArgumentException("Expected 2, 3 or 5 but got: " + filterArguments.size());
}
@ -235,8 +259,8 @@ public class DependentColumnFilter extends CompareFilter {
} catch (InvalidProtocolBufferException e) {
throw new DeserializationException(e);
}
final CompareOp valueCompareOp =
CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
final CompareOperator valueCompareOp =
CompareOperator.valueOf(proto.getCompareFilter().getCompareOp().name());
ByteArrayComparable valueComparator = null;
try {
if (proto.getCompareFilter().hasComparator()) {
@ -276,7 +300,7 @@ public class DependentColumnFilter extends CompareFilter {
Bytes.toStringBinary(this.columnFamily),
Bytes.toStringBinary(this.columnQualifier),
this.dropDependentColumn,
this.compareOp.name(),
this.op.name(),
this.comparator != null ? Bytes.toStringBinary(this.comparator.getValue()) : "null");
}
}

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
@ -51,17 +52,31 @@ public class FamilyFilter extends CompareFilter {
*
* @param familyCompareOp the compare op for column family matching
* @param familyComparator the comparator for column family matching
* @deprecated Since 2.0.0. Will be removed in 3.0.0.
* Use {@link #FamilyFilter(CompareOperator, ByteArrayComparable)}
*/
@Deprecated
public FamilyFilter(final CompareOp familyCompareOp,
final ByteArrayComparable familyComparator) {
super(familyCompareOp, familyComparator);
}
/**
* Constructor.
*
* @param op the compare op for column family matching
* @param familyComparator the comparator for column family matching
*/
public FamilyFilter(final CompareOperator op,
final ByteArrayComparable familyComparator) {
super(op, familyComparator);
}
@Override
public ReturnCode filterKeyValue(Cell v) {
int familyLength = v.getFamilyLength();
if (familyLength > 0) {
if (compareFamily(this.compareOp, this.comparator, v)) {
if (compareFamily(getCompareOperator(), this.comparator, v)) {
return ReturnCode.NEXT_ROW;
}
}
@ -70,7 +85,7 @@ public class FamilyFilter extends CompareFilter {
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
ArrayList<?> arguments = CompareFilter.extractArguments(filterArguments);
CompareOp compareOp = (CompareOp)arguments.get(0);
CompareOperator compareOp = (CompareOperator)arguments.get(0);
ByteArrayComparable comparator = (ByteArrayComparable)arguments.get(1);
return new FamilyFilter(compareOp, comparator);
}
@ -99,8 +114,8 @@ public class FamilyFilter extends CompareFilter {
} catch (InvalidProtocolBufferException e) {
throw new DeserializationException(e);
}
final CompareOp valueCompareOp =
CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
final CompareOperator valueCompareOp =
CompareOperator.valueOf(proto.getCompareFilter().getCompareOp().name());
ByteArrayComparable valueComparator = null;
try {
if (proto.getCompareFilter().hasComparator()) {
@ -113,7 +128,6 @@ public class FamilyFilter extends CompareFilter {
}
/**
* @param other
* @return true if and only if the fields of the filter that are serialized
* are equal to the corresponding fields in other. Used for testing.
*/

View File

@ -32,6 +32,7 @@ import java.util.Stack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.util.Bytes;
@ -767,10 +768,38 @@ public class ParseFilter {
/**
* Takes a compareOperator symbol as a byte array and returns the corresponding CompareOperator
* @deprecated Since 2.0
* <p>
* @param compareOpAsByteArray the comparatorOperator symbol as a byte array
* @return the Compare Operator
*/
public static CompareOperator createCompareOperator (byte [] compareOpAsByteArray) {
ByteBuffer compareOp = ByteBuffer.wrap(compareOpAsByteArray);
if (compareOp.equals(ParseConstants.LESS_THAN_BUFFER))
return CompareOperator.LESS;
else if (compareOp.equals(ParseConstants.LESS_THAN_OR_EQUAL_TO_BUFFER))
return CompareOperator.LESS_OR_EQUAL;
else if (compareOp.equals(ParseConstants.GREATER_THAN_BUFFER))
return CompareOperator.GREATER;
else if (compareOp.equals(ParseConstants.GREATER_THAN_OR_EQUAL_TO_BUFFER))
return CompareOperator.GREATER_OR_EQUAL;
else if (compareOp.equals(ParseConstants.NOT_EQUAL_TO_BUFFER))
return CompareOperator.NOT_EQUAL;
else if (compareOp.equals(ParseConstants.EQUAL_TO_BUFFER))
return CompareOperator.EQUAL;
else
throw new IllegalArgumentException("Invalid compare operator");
}
/**
* Takes a compareOperator symbol as a byte array and returns the corresponding CompareOperator
* @deprecated Since 2.0
* <p>
* @param compareOpAsByteArray the comparatorOperator symbol as a byte array
* @return the Compare Operator
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #createCompareOperator(byte [])}
*/
@Deprecated
public static CompareFilter.CompareOp createCompareOp (byte [] compareOpAsByteArray) {
ByteBuffer compareOp = ByteBuffer.wrap(compareOpAsByteArray);
if (compareOp.equals(ParseConstants.LESS_THAN_BUFFER))

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
@ -50,17 +51,30 @@ public class QualifierFilter extends CompareFilter {
* Constructor.
* @param op the compare op for column qualifier matching
* @param qualifierComparator the comparator for column qualifier matching
* @deprecated Since 2.0.0. Will be removed in 3.0.0.
* Use {@link #QualifierFilter(CompareOperator, ByteArrayComparable)} instead.
*/
@Deprecated
public QualifierFilter(final CompareOp op,
final ByteArrayComparable qualifierComparator) {
super(op, qualifierComparator);
}
/**
* Constructor.
* @param op the compare op for column qualifier matching
* @param qualifierComparator the comparator for column qualifier matching
*/
public QualifierFilter(final CompareOperator op,
final ByteArrayComparable qualifierComparator) {
super(op, qualifierComparator);
}
@Override
public ReturnCode filterKeyValue(Cell v) {
int qualifierLength = v.getQualifierLength();
if (qualifierLength > 0) {
if (compareQualifier(this.compareOp, this.comparator, v)) {
if (compareQualifier(getCompareOperator(), this.comparator, v)) {
return ReturnCode.SKIP;
}
}
@ -69,7 +83,7 @@ public class QualifierFilter extends CompareFilter {
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
ArrayList<?> arguments = CompareFilter.extractArguments(filterArguments);
CompareOp compareOp = (CompareOp)arguments.get(0);
CompareOperator compareOp = (CompareOperator)arguments.get(0);
ByteArrayComparable comparator = (ByteArrayComparable)arguments.get(1);
return new QualifierFilter(compareOp, comparator);
}
@ -98,8 +112,8 @@ public class QualifierFilter extends CompareFilter {
} catch (InvalidProtocolBufferException e) {
throw new DeserializationException(e);
}
final CompareOp valueCompareOp =
CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
final CompareOperator valueCompareOp =
CompareOperator.valueOf(proto.getCompareFilter().getCompareOp().name());
ByteArrayComparable valueComparator = null;
try {
if (proto.getCompareFilter().hasComparator()) {
@ -112,7 +126,6 @@ public class QualifierFilter extends CompareFilter {
}
/**
* @param other
* @return true if and only if the fields of the filter that are serialized
* are equal to the corresponding fields in other. Used for testing.
*/

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
@ -51,12 +52,25 @@ public class RowFilter extends CompareFilter {
* Constructor.
* @param rowCompareOp the compare op for row matching
* @param rowComparator the comparator for row matching
* @deprecated Since 2.0.0. Will remove in 3.0.0. Use
* {@link #RowFilter(CompareOperator, ByteArrayComparable)}} instead.
*/
@Deprecated
public RowFilter(final CompareOp rowCompareOp,
final ByteArrayComparable rowComparator) {
super(rowCompareOp, rowComparator);
}
/**
* Constructor.
* @param op the compare op for row matching
* @param rowComparator the comparator for row matching
*/
public RowFilter(final CompareOperator op,
final ByteArrayComparable rowComparator) {
super(op, rowComparator);
}
@Override
public void reset() {
this.filterOutRow = false;
@ -72,7 +86,7 @@ public class RowFilter extends CompareFilter {
@Override
public boolean filterRowKey(Cell firstRowCell) {
if (compareRow(this.compareOp, this.comparator, firstRowCell)) {
if (compareRow(getCompareOperator(), this.comparator, firstRowCell)) {
this.filterOutRow = true;
}
return this.filterOutRow;
@ -86,7 +100,7 @@ public class RowFilter extends CompareFilter {
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
@SuppressWarnings("rawtypes") // for arguments
ArrayList arguments = CompareFilter.extractArguments(filterArguments);
CompareOp compareOp = (CompareOp)arguments.get(0);
CompareOperator compareOp = (CompareOperator)arguments.get(0);
ByteArrayComparable comparator = (ByteArrayComparable)arguments.get(1);
return new RowFilter(compareOp, comparator);
}
@ -115,8 +129,8 @@ public class RowFilter extends CompareFilter {
} catch (InvalidProtocolBufferException e) {
throw new DeserializationException(e);
}
final CompareOp valueCompareOp =
CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
final CompareOperator valueCompareOp =
CompareOperator.valueOf(proto.getCompareFilter().getCompareOp().name());
ByteArrayComparable valueComparator = null;
try {
if (proto.getCompareFilter().hasComparator()) {
@ -129,7 +143,6 @@ public class RowFilter extends CompareFilter {
}
/**
* @param other
* @return true if and only if the fields of the filter that are serialized
* are equal to the corresponding fields in other. Used for testing.
*/

View File

@ -26,6 +26,7 @@ import java.util.List;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
@ -52,12 +53,30 @@ public class SingleColumnValueExcludeFilter extends SingleColumnValueFilter {
* @param qualifier name of column qualifier
* @param compareOp operator
* @param value value to compare column values against
* {@link #SingleColumnValueExcludeFilter(byte[], byte[], CompareOperator, byte[])}
*/
@Deprecated
public SingleColumnValueExcludeFilter(byte[] family, byte[] qualifier,
CompareOp compareOp, byte[] value) {
super(family, qualifier, compareOp, value);
}
/**
* Constructor for binary compare of the value of a single column. If the
* column is found and the condition passes, all columns of the row will be
* emitted; except for the tested column value. If the column is not found or
* the condition fails, the row will not be emitted.
*
* @param family name of column family
* @param qualifier name of column qualifier
* @param op operator
* @param value value to compare column values against
*/
public SingleColumnValueExcludeFilter(byte[] family, byte[] qualifier,
CompareOperator op, byte[] value) {
super(family, qualifier, op, value);
}
/**
* Constructor for binary compare of the value of a single column. If the
* column is found and the condition passes, all columns of the row will be
@ -72,12 +91,36 @@ public class SingleColumnValueExcludeFilter extends SingleColumnValueFilter {
* @param qualifier name of column qualifier
* @param compareOp operator
* @param comparator Comparator to use.
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
* {@link #SingleColumnValueExcludeFilter(byte[], byte[], CompareOperator, ByteArrayComparable)}
*/
@Deprecated
public SingleColumnValueExcludeFilter(byte[] family, byte[] qualifier,
CompareOp compareOp, ByteArrayComparable comparator) {
super(family, qualifier, compareOp, comparator);
}
/**
* Constructor for binary compare of the value of a single column. If the
* column is found and the condition passes, all columns of the row will be
* emitted; except for the tested column value. If the condition fails, the
* row will not be emitted.
* <p>
* Use the filterIfColumnMissing flag to set whether the rest of the columns
* in a row will be emitted if the specified column to check is not found in
* the row.
*
* @param family name of column family
* @param qualifier name of column qualifier
* @param op operator
* @param comparator Comparator to use.
*/
public SingleColumnValueExcludeFilter(byte[] family, byte[] qualifier,
CompareOperator op, ByteArrayComparable comparator) {
super(family, qualifier, op, comparator);
}
/**
* Constructor for protobuf deserialization only.
* @param family
@ -86,11 +129,30 @@ public class SingleColumnValueExcludeFilter extends SingleColumnValueFilter {
* @param comparator
* @param filterIfMissing
* @param latestVersionOnly
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
* {@link #SingleColumnValueExcludeFilter(byte[], byte[], CompareOperator, ByteArrayComparable, boolean, boolean)}
*/
@Deprecated
protected SingleColumnValueExcludeFilter(final byte[] family, final byte[] qualifier,
final CompareOp compareOp, ByteArrayComparable comparator, final boolean filterIfMissing,
final boolean latestVersionOnly) {
super(family, qualifier, compareOp, comparator, filterIfMissing, latestVersionOnly);
this(family, qualifier, CompareOperator.valueOf(compareOp.name()), comparator,
filterIfMissing, latestVersionOnly);
}
/**
* Constructor for protobuf deserialization only.
* @param family
* @param qualifier
* @param op
* @param comparator
* @param filterIfMissing
* @param latestVersionOnly
*/
protected SingleColumnValueExcludeFilter(final byte[] family, final byte[] qualifier,
final CompareOperator op, ByteArrayComparable comparator, final boolean filterIfMissing,
final boolean latestVersionOnly) {
super(family, qualifier, op, comparator, filterIfMissing, latestVersionOnly);
}
// We cleaned result row in FilterRow to be consistent with scanning process.
@ -151,8 +213,8 @@ public class SingleColumnValueExcludeFilter extends SingleColumnValueFilter {
}
FilterProtos.SingleColumnValueFilter parentProto = proto.getSingleColumnValueFilter();
final CompareOp compareOp =
CompareOp.valueOf(parentProto.getCompareOp().name());
final CompareOperator compareOp =
CompareOperator.valueOf(parentProto.getCompareOp().name());
final ByteArrayComparable comparator;
try {
comparator = ProtobufUtil.toComparator(parentProto.getComparator());
@ -167,7 +229,6 @@ public class SingleColumnValueExcludeFilter extends SingleColumnValueFilter {
}
/**
* @param other
* @return true if and only if the fields of the filter that are serialized
* are equal to the corresponding fields in other. Used for testing.
*/

View File

@ -25,6 +25,7 @@ import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
@ -71,7 +72,7 @@ public class SingleColumnValueFilter extends FilterBase {
protected byte [] columnFamily;
protected byte [] columnQualifier;
protected CompareOp compareOp;
protected CompareOperator op;
protected org.apache.hadoop.hbase.filter.ByteArrayComparable comparator;
protected boolean foundColumn = false;
protected boolean matchedColumn = false;
@ -91,10 +92,34 @@ public class SingleColumnValueFilter extends FilterBase {
* @param qualifier name of column qualifier
* @param compareOp operator
* @param value value to compare column values against
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
* {@link #SingleColumnValueFilter(byte[], byte[], CompareOperator, byte[])} instead.
*/
@Deprecated
public SingleColumnValueFilter(final byte [] family, final byte [] qualifier,
final CompareOp compareOp, final byte[] value) {
this(family, qualifier, compareOp, new org.apache.hadoop.hbase.filter.BinaryComparator(value));
this(family, qualifier, CompareOperator.valueOf(compareOp.name()),
new org.apache.hadoop.hbase.filter.BinaryComparator(value));
}
/**
* Constructor for binary compare of the value of a single column. If the
* column is found and the condition passes, all columns of the row will be
* emitted. If the condition fails, the row will not be emitted.
* <p>
* Use the filterIfColumnMissing flag to set whether the rest of the columns
* in a row will be emitted if the specified column to check is not found in
* the row.
*
* @param family name of column family
* @param qualifier name of column qualifier
* @param op operator
* @param value value to compare column values against
*/
public SingleColumnValueFilter(final byte [] family, final byte [] qualifier,
final CompareOperator op, final byte[] value) {
this(family, qualifier, op,
new org.apache.hadoop.hbase.filter.BinaryComparator(value));
}
/**
@ -110,13 +135,36 @@ public class SingleColumnValueFilter extends FilterBase {
* @param qualifier name of column qualifier
* @param compareOp operator
* @param comparator Comparator to use.
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
* {@link #SingleColumnValueFilter(byte[], byte[], CompareOperator, ByteArrayComparable)} instead.
*/
@Deprecated
public SingleColumnValueFilter(final byte [] family, final byte [] qualifier,
final CompareOp compareOp,
final org.apache.hadoop.hbase.filter.ByteArrayComparable comparator) {
this(family, qualifier, CompareOperator.valueOf(compareOp.name()), comparator);
}
/**
* Constructor for binary compare of the value of a single column. If the
* column is found and the condition passes, all columns of the row will be
* emitted. If the condition fails, the row will not be emitted.
* <p>
* Use the filterIfColumnMissing flag to set whether the rest of the columns
* in a row will be emitted if the specified column to check is not found in
* the row.
*
* @param family name of column family
* @param qualifier name of column qualifier
* @param op operator
* @param comparator Comparator to use.
*/
public SingleColumnValueFilter(final byte [] family, final byte [] qualifier,
final CompareOperator op,
final org.apache.hadoop.hbase.filter.ByteArrayComparable comparator) {
this.columnFamily = family;
this.columnQualifier = qualifier;
this.compareOp = compareOp;
this.op = op;
this.comparator = comparator;
}
@ -128,21 +176,47 @@ public class SingleColumnValueFilter extends FilterBase {
* @param comparator
* @param filterIfMissing
* @param latestVersionOnly
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
* {@link #SingleColumnValueFilter(byte[], byte[], CompareOperator, ByteArrayComparable,
* boolean, boolean)} instead.
*/
@Deprecated
protected SingleColumnValueFilter(final byte[] family, final byte[] qualifier,
final CompareOp compareOp, org.apache.hadoop.hbase.filter.ByteArrayComparable comparator,
final boolean filterIfMissing,
final boolean latestVersionOnly) {
this(family, qualifier, compareOp, comparator);
this(family, qualifier, CompareOperator.valueOf(compareOp.name()), comparator, filterIfMissing,
latestVersionOnly);
}
/**
* Constructor for protobuf deserialization only.
* @param family
* @param qualifier
* @param op
* @param comparator
* @param filterIfMissing
* @param latestVersionOnly
*/
protected SingleColumnValueFilter(final byte[] family, final byte[] qualifier,
final CompareOperator op, org.apache.hadoop.hbase.filter.ByteArrayComparable comparator,
final boolean filterIfMissing, final boolean latestVersionOnly) {
this(family, qualifier, op, comparator);
this.filterIfMissing = filterIfMissing;
this.latestVersionOnly = latestVersionOnly;
}
/**
* @return operator
* @deprecated since 2.0.0. Will be removed in 3.0.0. Use {@link #getCompareOperator()} instead.
*/
@Deprecated
public CompareOp getOperator() {
return compareOp;
return CompareOp.valueOf(op.name());
}
public CompareOperator getCompareOperator() {
return op;
}
/**
@ -195,22 +269,7 @@ public class SingleColumnValueFilter extends FilterBase {
private boolean filterColumnValue(final Cell cell) {
int compareResult = CellComparator.compareValue(cell, this.comparator);
switch (this.compareOp) {
case LESS:
return compareResult <= 0;
case LESS_OR_EQUAL:
return compareResult < 0;
case EQUAL:
return compareResult != 0;
case NOT_EQUAL:
return compareResult == 0;
case GREATER_OR_EQUAL:
return compareResult > 0;
case GREATER:
return compareResult >= 0;
default:
throw new RuntimeException("Unknown Compare op " + compareOp.name());
}
return CompareFilter.compare(this.op, compareResult);
}
public boolean filterRow() {
@ -276,21 +335,21 @@ public class SingleColumnValueFilter extends FilterBase {
"Expected 4 or 6 but got: %s", filterArguments.size());
byte [] family = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));
byte [] qualifier = ParseFilter.removeQuotesFromByteArray(filterArguments.get(1));
CompareOp compareOp = ParseFilter.createCompareOp(filterArguments.get(2));
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 (compareOp != CompareOp.EQUAL &&
compareOp != CompareOp.NOT_EQUAL) {
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,
compareOp, comparator);
op, comparator);
if (filterArguments.size() == 6) {
boolean filterIfMissing = ParseFilter.convertByteArrayToBoolean(filterArguments.get(4));
@ -310,7 +369,7 @@ public class SingleColumnValueFilter extends FilterBase {
if (this.columnQualifier != null) {
builder.setColumnQualifier(UnsafeByteOperations.unsafeWrap(this.columnQualifier));
}
HBaseProtos.CompareType compareOp = CompareType.valueOf(this.compareOp.name());
HBaseProtos.CompareType compareOp = CompareType.valueOf(this.op.name());
builder.setCompareOp(compareOp);
builder.setComparator(ProtobufUtil.toComparator(this.comparator));
builder.setFilterIfMissing(this.filterIfMissing);
@ -341,8 +400,8 @@ public class SingleColumnValueFilter extends FilterBase {
throw new DeserializationException(e);
}
final CompareOp compareOp =
CompareOp.valueOf(proto.getCompareOp().name());
final CompareOperator compareOp =
CompareOperator.valueOf(proto.getCompareOp().name());
final org.apache.hadoop.hbase.filter.ByteArrayComparable comparator;
try {
comparator = ProtobufUtil.toComparator(proto.getComparator());
@ -357,7 +416,6 @@ public class SingleColumnValueFilter extends FilterBase {
}
/**
* @param other
* @return true if and only if the fields of the filter that are serialized
* are equal to the corresponding fields in other. Used for testing.
*/
@ -368,7 +426,7 @@ public class SingleColumnValueFilter extends FilterBase {
SingleColumnValueFilter other = (SingleColumnValueFilter)o;
return Bytes.equals(this.getFamily(), other.getFamily())
&& Bytes.equals(this.getQualifier(), other.getQualifier())
&& this.compareOp.equals(other.compareOp)
&& this.op.equals(other.op)
&& this.getComparator().areSerializedFieldsEqual(other.getComparator())
&& this.getFilterIfMissing() == other.getFilterIfMissing()
&& this.getLatestVersionOnly() == other.getLatestVersionOnly();
@ -387,7 +445,7 @@ public class SingleColumnValueFilter extends FilterBase {
public String toString() {
return String.format("%s (%s, %s, %s, %s)",
this.getClass().getSimpleName(), Bytes.toStringBinary(this.columnFamily),
Bytes.toStringBinary(this.columnQualifier), this.compareOp.name(),
Bytes.toStringBinary(this.columnQualifier), this.op.name(),
Bytes.toStringBinary(this.comparator.getValue()));
}
}

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
@ -49,15 +50,27 @@ public class ValueFilter extends CompareFilter {
* Constructor.
* @param valueCompareOp the compare op for value matching
* @param valueComparator the comparator for value matching
* @deprecated Since 2.0.0. Will be removed in 3.0.0.
* Use {@link #ValueFilter(CompareOperator, ByteArrayComparable)}
*/
public ValueFilter(final CompareOp valueCompareOp,
final ByteArrayComparable valueComparator) {
super(valueCompareOp, valueComparator);
}
/**
* Constructor.
* @param valueCompareOp the compare op for value matching
* @param valueComparator the comparator for value matching
*/
public ValueFilter(final CompareOperator valueCompareOp,
final ByteArrayComparable valueComparator) {
super(valueCompareOp, valueComparator);
}
@Override
public ReturnCode filterKeyValue(Cell v) {
if (compareValue(this.compareOp, this.comparator, v)) {
if (compareValue(getCompareOperator(), this.comparator, v)) {
return ReturnCode.SKIP;
}
return ReturnCode.INCLUDE;
@ -66,7 +79,7 @@ public class ValueFilter extends CompareFilter {
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
@SuppressWarnings("rawtypes") // for arguments
ArrayList arguments = CompareFilter.extractArguments(filterArguments);
CompareOp compareOp = (CompareOp)arguments.get(0);
CompareOperator compareOp = (CompareOperator)arguments.get(0);
ByteArrayComparable comparator = (ByteArrayComparable)arguments.get(1);
return new ValueFilter(compareOp, comparator);
}
@ -95,8 +108,8 @@ public class ValueFilter extends CompareFilter {
} catch (InvalidProtocolBufferException e) {
throw new DeserializationException(e);
}
final CompareOp valueCompareOp =
CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
final CompareOperator valueCompareOp =
CompareOperator.valueOf(proto.getCompareFilter().getCompareOp().name());
ByteArrayComparable valueComparator = null;
try {
if (proto.getCompareFilter().hasComparator()) {
@ -109,7 +122,7 @@ public class ValueFilter extends CompareFilter {
}
/**
* @param other
* @return true if and only if the fields of the filter that are serialized
* are equal to the corresponding fields in other. Used for testing.
*/

View File

@ -32,6 +32,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@ -196,9 +197,9 @@ public class QuotaTableUtil {
if (!Strings.isEmpty(filter.getNamespaceFilter())) {
FilterList nsFilters = new FilterList(FilterList.Operator.MUST_PASS_ALL);
nsFilters.addFilter(new RowFilter(CompareFilter.CompareOp.EQUAL,
nsFilters.addFilter(new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator(getUserRowKeyRegex(filter.getUserFilter()), 0)));
nsFilters.addFilter(new QualifierFilter(CompareFilter.CompareOp.EQUAL,
nsFilters.addFilter(new QualifierFilter(CompareOperator.EQUAL,
new RegexStringComparator(
getSettingsQualifierRegexForUserNamespace(filter.getNamespaceFilter()), 0)));
userFilters.addFilter(nsFilters);
@ -206,25 +207,25 @@ public class QuotaTableUtil {
}
if (!Strings.isEmpty(filter.getTableFilter())) {
FilterList tableFilters = new FilterList(FilterList.Operator.MUST_PASS_ALL);
tableFilters.addFilter(new RowFilter(CompareFilter.CompareOp.EQUAL,
tableFilters.addFilter(new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator(getUserRowKeyRegex(filter.getUserFilter()), 0)));
tableFilters.addFilter(new QualifierFilter(CompareFilter.CompareOp.EQUAL,
tableFilters.addFilter(new QualifierFilter(CompareOperator.EQUAL,
new RegexStringComparator(
getSettingsQualifierRegexForUserTable(filter.getTableFilter()), 0)));
userFilters.addFilter(tableFilters);
hasFilter = true;
}
if (!hasFilter) {
userFilters.addFilter(new RowFilter(CompareFilter.CompareOp.EQUAL,
userFilters.addFilter(new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator(getUserRowKeyRegex(filter.getUserFilter()), 0)));
}
filterList.addFilter(userFilters);
} else if (!Strings.isEmpty(filter.getTableFilter())) {
filterList.addFilter(new RowFilter(CompareFilter.CompareOp.EQUAL,
filterList.addFilter(new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator(getTableRowKeyRegex(filter.getTableFilter()), 0)));
} else if (!Strings.isEmpty(filter.getNamespaceFilter())) {
filterList.addFilter(new RowFilter(CompareFilter.CompareOp.EQUAL,
filterList.addFilter(new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator(getNamespaceRowKeyRegex(filter.getNamespaceFilter()), 0)));
}
return filterList;

View File

@ -28,7 +28,7 @@ import org.apache.hadoop.hbase.util.Bytes;
/** Base class for byte array comparators */
@InterfaceAudience.Public
// TODO Now we are deviating a lot from the actual Comparable<byte[]> what this implements, by
// TODO Now we are deviating a lot from the actual Comparable<byte[]> that this implements, by
// adding special compareTo methods. We have to clean it. Deprecate this class and replace it
// with a more generic one which says it compares bytes (not necessary a byte array only)
// BytesComparable implements Comparable<Byte> will work?

View File

@ -165,7 +165,7 @@ public class IntegrationTestLazyCfLoading {
public Filter getScanFilter() {
SingleColumnValueFilter scf = new SingleColumnValueFilter(ESSENTIAL_CF, FILTER_COLUMN,
CompareFilter.CompareOp.EQUAL, Bytes.toBytes(ACCEPTED_VALUE));
CompareOperator.EQUAL, Bytes.toBytes(ACCEPTED_VALUE));
scf.setFilterIfMissing(true);
return scf;
}

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
@ -124,8 +125,6 @@ public class CellCounter extends Configured implements Tool {
* @param values The columns.
* @param context The current context.
* @throws IOException When something is broken with the data.
* @see org.apache.hadoop.mapreduce.Mapper#map(KEYIN, VALUEIN,
* org.apache.hadoop.mapreduce.Mapper.Context)
*/
@Override
@ -260,7 +259,7 @@ public class CellCounter extends Configured implements Tool {
if (filterCriteria == null) return null;
if (filterCriteria.startsWith("^")) {
String regexPattern = filterCriteria.substring(1, filterCriteria.length());
rowFilter = new RowFilter(CompareFilter.CompareOp.EQUAL, new RegexStringComparator(regexPattern));
rowFilter = new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(regexPattern));
} else {
rowFilter = new PrefixFilter(Bytes.toBytesBinary(filterCriteria));
}

View File

@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
@ -86,7 +87,7 @@ public final class ExportUtils {
if (filterCriteria == null) return null;
if (filterCriteria.startsWith("^")) {
String regexPattern = filterCriteria.substring(1, filterCriteria.length());
exportFilter = new RowFilter(CompareFilter.CompareOp.EQUAL, new RegexStringComparator(regexPattern));
exportFilter = new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(regexPattern));
} else {
exportFilter = new PrefixFilter(Bytes.toBytesBinary(filterCriteria));
}

View File

@ -1889,7 +1889,7 @@ public class PerformanceEvaluation extends Configured implements Tool {
this.table.put(put);
RowMutations mutations = new RowMutations(bytes);
mutations.add(put);
this.table.checkAndMutate(bytes, FAMILY_NAME, getQualifier(), CompareOp.EQUAL, bytes,
this.table.checkAndMutate(bytes, FAMILY_NAME, getQualifier(), CompareOperator.EQUAL, bytes,
mutations);
}
}
@ -1906,7 +1906,7 @@ public class PerformanceEvaluation extends Configured implements Tool {
Put put = new Put(bytes);
put.addColumn(FAMILY_NAME, getQualifier(), bytes);
this.table.put(put);
this.table.checkAndPut(bytes, FAMILY_NAME, getQualifier(), CompareOp.EQUAL, bytes, put);
this.table.checkAndPut(bytes, FAMILY_NAME, getQualifier(), CompareOperator.EQUAL, bytes, put);
}
}
@ -1924,7 +1924,8 @@ public class PerformanceEvaluation extends Configured implements Tool {
this.table.put(put);
Delete delete = new Delete(put.getRow());
delete.addColumn(FAMILY_NAME, getQualifier());
this.table.checkAndDelete(bytes, FAMILY_NAME, getQualifier(), CompareOp.EQUAL, bytes, delete);
this.table.checkAndDelete(bytes, FAMILY_NAME, getQualifier(),
CompareOperator.EQUAL, bytes, delete);
}
}
@ -2008,7 +2009,7 @@ public class PerformanceEvaluation extends Configured implements Tool {
protected Scan constructScan(byte[] valuePrefix) throws IOException {
FilterList list = new FilterList();
Filter filter = new SingleColumnValueFilter(
FAMILY_NAME, COLUMN_ZERO, CompareFilter.CompareOp.EQUAL,
FAMILY_NAME, COLUMN_ZERO, CompareOperator.EQUAL,
new BinaryComparator(valuePrefix)
);
list.addFilter(filter);

View File

@ -405,7 +405,8 @@ public class TestTableInputFormat {
Bytes.toBytes("columnB") };
// mandatory
setInputColumns(inputColumns);
Filter exampleFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator("aa.*"));
Filter exampleFilter =
new RowFilter(CompareOperator.EQUAL, new RegexStringComparator("aa.*"));
// optional
setRowFilter(exampleFilter);
} catch (IOException exception) {
@ -449,7 +450,8 @@ public class TestTableInputFormat {
Bytes.toBytes("columnB") };
// mandatory
setInputColumns(inputColumns);
Filter exampleFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator("aa.*"));
Filter exampleFilter =
new RowFilter(CompareOperator.EQUAL, new RegexStringComparator("aa.*"));
// optional
setRowFilter(exampleFilter);
}

View File

@ -417,7 +417,8 @@ public class TestTableInputFormat {
for (byte[] family : inputColumns) {
scan.addFamily(family);
}
Filter exampleFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator("aa.*"));
Filter exampleFilter =
new RowFilter(CompareOperator.EQUAL, new RegexStringComparator("aa.*"));
scan.setFilter(exampleFilter);
setScan(scan);
} catch (IOException exception) {
@ -445,7 +446,8 @@ public class TestTableInputFormat {
for (byte[] family : inputColumns) {
scan.addFamily(family);
}
Filter exampleFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator("aa.*"));
Filter exampleFilter =
new RowFilter(CompareOperator.EQUAL, new RegexStringComparator("aa.*"));
scan.setFilter(exampleFilter);
setScan(scan);
} catch (IOException exception) {
@ -471,7 +473,8 @@ public class TestTableInputFormat {
for (byte[] family : inputColumns) {
scan.addFamily(family);
}
Filter exampleFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator("aa.*"));
Filter exampleFilter =
new RowFilter(CompareOperator.EQUAL, new RegexStringComparator("aa.*"));
scan.setFilter(exampleFilter);
setScan(scan);
}

View File

@ -18,6 +18,7 @@
*/
package org.apache.hadoop.hbase.replication;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.shaded.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
@ -325,7 +326,7 @@ abstract class ReplicationTableBase {
protected ResultScanner getQueuesBelongingToServer(String server) throws IOException {
Scan scan = new Scan();
SingleColumnValueFilter filterMyQueues = new SingleColumnValueFilter(CF_QUEUE, COL_QUEUE_OWNER,
CompareFilter.CompareOp.EQUAL, Bytes.toBytes(server));
CompareOperator.EQUAL, Bytes.toBytes(server));
scan.setFilter(filterMyQueues);
scan.addColumn(CF_QUEUE, COL_QUEUE_OWNER);
scan.addColumn(CF_QUEUE, COL_QUEUE_OWNER_HISTORY);

View File

@ -433,7 +433,7 @@ public class TableBasedReplicationQueuesImpl extends ReplicationTableBase
}
scan.setMaxResultSize(1);
SingleColumnValueFilter checkOwner = new SingleColumnValueFilter(CF_QUEUE, COL_QUEUE_OWNER,
CompareFilter.CompareOp.EQUAL, serverNameBytes);
CompareOperator.EQUAL, serverNameBytes);
scan.setFilter(checkOwner);
ResultScanner scanner = null;
try (Table replicationTable = getOrBlockOnReplicationTable()) {

View File

@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.client.Scan;
@ -383,10 +384,10 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
case DependentColumnFilter:
filter = new DependentColumnFilter(Base64.decode(family),
qualifier != null ? Base64.decode(qualifier) : null,
dropDependentColumn, CompareOp.valueOf(op), comparator.build());
dropDependentColumn, CompareOperator.valueOf(op), comparator.build());
break;
case FamilyFilter:
filter = new FamilyFilter(CompareOp.valueOf(op), comparator.build());
filter = new FamilyFilter(CompareOperator.valueOf(op), comparator.build());
break;
case FilterList: {
List<Filter> list = new ArrayList<>(filters.size());
@ -421,18 +422,18 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
filter = new PrefixFilter(Base64.decode(value));
break;
case QualifierFilter:
filter = new QualifierFilter(CompareOp.valueOf(op), comparator.build());
filter = new QualifierFilter(CompareOperator.valueOf(op), comparator.build());
break;
case RandomRowFilter:
filter = new RandomRowFilter(chance);
break;
case RowFilter:
filter = new RowFilter(CompareOp.valueOf(op), comparator.build());
filter = new RowFilter(CompareOperator.valueOf(op), comparator.build());
break;
case SingleColumnValueFilter:
filter = new SingleColumnValueFilter(Base64.decode(family),
qualifier != null ? Base64.decode(qualifier) : null,
CompareOp.valueOf(op), comparator.build());
CompareOperator.valueOf(op), comparator.build());
if (ifMissing != null) {
((SingleColumnValueFilter)filter).setFilterIfMissing(ifMissing);
}
@ -443,7 +444,7 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
case SingleColumnValueExcludeFilter:
filter = new SingleColumnValueExcludeFilter(Base64.decode(family),
qualifier != null ? Base64.decode(qualifier) : null,
CompareOp.valueOf(op), comparator.build());
CompareOperator.valueOf(op), comparator.build());
if (ifMissing != null) {
((SingleColumnValueExcludeFilter)filter).setFilterIfMissing(ifMissing);
}
@ -458,7 +459,7 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
filter = new TimestampsFilter(timestamps);
break;
case ValueFilter:
filter = new ValueFilter(CompareOp.valueOf(op), comparator.build());
filter = new ValueFilter(CompareOperator.valueOf(op), comparator.build());
break;
case WhileMatchFilter:
filter = new WhileMatchFilter(filters.get(0).build());

View File

@ -42,6 +42,7 @@ import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
@ -1235,7 +1236,7 @@ public class PerformanceEvaluation extends Configured implements Tool {
protected Scan constructScan(byte[] valuePrefix) throws IOException {
Filter filter = new SingleColumnValueFilter(
FAMILY_NAME, QUALIFIER_NAME, CompareFilter.CompareOp.EQUAL,
FAMILY_NAME, QUALIFIER_NAME, CompareOperator.EQUAL,
new BinaryComparator(valuePrefix)
);
Scan scan = new Scan();

View File

@ -37,6 +37,7 @@ import javax.xml.bind.Unmarshaller;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
@ -499,7 +500,7 @@ public class TestScannersWithFilters {
// Match two keys (one from each family) in half the rows
long expectedRows = numRows / 2;
long expectedKeys = 2;
Filter f = new QualifierFilter(CompareOp.EQUAL,
Filter f = new QualifierFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
Scan s = new Scan();
s.setFilter(f);
@ -509,7 +510,7 @@ public class TestScannersWithFilters {
// Expect only two keys (one from each family) in half the rows
expectedRows = numRows / 2;
expectedKeys = 2;
f = new QualifierFilter(CompareOp.LESS,
f = new QualifierFilter(CompareOperator.LESS,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan();
s.setFilter(f);
@ -519,7 +520,7 @@ public class TestScannersWithFilters {
// Expect four keys (two from each family) in half the rows
expectedRows = numRows / 2;
expectedKeys = 4;
f = new QualifierFilter(CompareOp.LESS_OR_EQUAL,
f = new QualifierFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan();
s.setFilter(f);
@ -530,7 +531,7 @@ public class TestScannersWithFilters {
// Only look in first group of rows
expectedRows = numRows / 2;
expectedKeys = 4;
f = new QualifierFilter(CompareOp.NOT_EQUAL,
f = new QualifierFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan(HConstants.EMPTY_START_ROW, Bytes.toBytes("testRowTwo"));
s.setFilter(f);
@ -541,7 +542,7 @@ public class TestScannersWithFilters {
// Only look in first group of rows
expectedRows = numRows / 2;
expectedKeys = 4;
f = new QualifierFilter(CompareOp.GREATER_OR_EQUAL,
f = new QualifierFilter(CompareOperator.GREATER_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan(HConstants.EMPTY_START_ROW, Bytes.toBytes("testRowTwo"));
s.setFilter(f);
@ -552,7 +553,7 @@ public class TestScannersWithFilters {
// Only look in first group of rows
expectedRows = numRows / 2;
expectedKeys = 2;
f = new QualifierFilter(CompareOp.GREATER,
f = new QualifierFilter(CompareOperator.GREATER,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan(HConstants.EMPTY_START_ROW, Bytes.toBytes("testRowTwo"));
s.setFilter(f);
@ -562,7 +563,7 @@ public class TestScannersWithFilters {
// Look across rows and fully validate the keys and ordering
// Expect varied numbers of keys, 4 per row in group one, 6 per row in
// group two
f = new QualifierFilter(CompareOp.NOT_EQUAL,
f = new QualifierFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(QUALIFIERS_ONE[2]));
s = new Scan();
s.setFilter(f);
@ -610,7 +611,7 @@ public class TestScannersWithFilters {
// Test across rows and groups with a regex
// Filter out "test*-2"
// Expect 4 keys per row across both groups
f = new QualifierFilter(CompareOp.NOT_EQUAL,
f = new QualifierFilter(CompareOperator.NOT_EQUAL,
new RegexStringComparator("test.+-2"));
s = new Scan();
s.setFilter(f);
@ -655,7 +656,7 @@ public class TestScannersWithFilters {
// Match a single row, all keys
long expectedRows = 1;
long expectedKeys = colsPerRow;
Filter f = new RowFilter(CompareOp.EQUAL,
Filter f = new RowFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
Scan s = new Scan();
s.setFilter(f);
@ -664,7 +665,7 @@ public class TestScannersWithFilters {
// Match a two rows, one from each group, using regex
expectedRows = 2;
expectedKeys = colsPerRow;
f = new RowFilter(CompareOp.EQUAL,
f = new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator("testRow.+-2"));
s = new Scan();
s.setFilter(f);
@ -674,7 +675,7 @@ public class TestScannersWithFilters {
// Expect all keys in one row
expectedRows = 1;
expectedKeys = colsPerRow;
f = new RowFilter(CompareOp.LESS,
f = new RowFilter(CompareOperator.LESS,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -684,7 +685,7 @@ public class TestScannersWithFilters {
// Expect all keys in two rows
expectedRows = 2;
expectedKeys = colsPerRow;
f = new RowFilter(CompareOp.LESS_OR_EQUAL,
f = new RowFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -694,7 +695,7 @@ public class TestScannersWithFilters {
// Expect all keys in all but one row
expectedRows = numRows - 1;
expectedKeys = colsPerRow;
f = new RowFilter(CompareOp.NOT_EQUAL,
f = new RowFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -704,7 +705,7 @@ public class TestScannersWithFilters {
// Expect all keys in all but one row
expectedRows = numRows - 1;
expectedKeys = colsPerRow;
f = new RowFilter(CompareOp.GREATER_OR_EQUAL,
f = new RowFilter(CompareOperator.GREATER_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -714,7 +715,7 @@ public class TestScannersWithFilters {
// Expect all keys in all but two rows
expectedRows = numRows - 2;
expectedKeys = colsPerRow;
f = new RowFilter(CompareOp.GREATER,
f = new RowFilter(CompareOperator.GREATER,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -723,7 +724,7 @@ public class TestScannersWithFilters {
// Match rows not equal to testRowTwo-2
// Look across rows and fully validate the keys and ordering
// Should see all keys in all rows but testRowTwo-2
f = new RowFilter(CompareOp.NOT_EQUAL,
f = new RowFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -770,7 +771,7 @@ public class TestScannersWithFilters {
// Test across rows and groups with a regex
// Filter out everything that doesn't match "*-2"
// Expect all keys in two rows
f = new RowFilter(CompareOp.EQUAL,
f = new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator(".+-2"));
s = new Scan();
s.setFilter(f);
@ -799,7 +800,7 @@ public class TestScannersWithFilters {
// Match group one rows
long expectedRows = numRows / 2;
long expectedKeys = colsPerRow;
Filter f = new ValueFilter(CompareOp.EQUAL,
Filter f = new ValueFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
Scan s = new Scan();
s.setFilter(f);
@ -808,7 +809,7 @@ public class TestScannersWithFilters {
// Match group two rows
expectedRows = numRows / 2;
expectedKeys = colsPerRow;
f = new ValueFilter(CompareOp.EQUAL,
f = new ValueFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testValueTwo")));
s = new Scan();
s.setFilter(f);
@ -817,7 +818,7 @@ public class TestScannersWithFilters {
// Match all values using regex
expectedRows = numRows;
expectedKeys = colsPerRow;
f = new ValueFilter(CompareOp.EQUAL,
f = new ValueFilter(CompareOperator.EQUAL,
new RegexStringComparator("testValue((One)|(Two))"));
s = new Scan();
s.setFilter(f);
@ -827,7 +828,7 @@ public class TestScannersWithFilters {
// Expect group one rows
expectedRows = numRows / 2;
expectedKeys = colsPerRow;
f = new ValueFilter(CompareOp.LESS,
f = new ValueFilter(CompareOperator.LESS,
new BinaryComparator(Bytes.toBytes("testValueTwo")));
s = new Scan();
s.setFilter(f);
@ -837,7 +838,7 @@ public class TestScannersWithFilters {
// Expect all rows
expectedRows = numRows;
expectedKeys = colsPerRow;
f = new ValueFilter(CompareOp.LESS_OR_EQUAL,
f = new ValueFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueTwo")));
s = new Scan();
s.setFilter(f);
@ -847,7 +848,7 @@ public class TestScannersWithFilters {
// Expect group one rows
expectedRows = numRows / 2;
expectedKeys = colsPerRow;
f = new ValueFilter(CompareOp.LESS_OR_EQUAL,
f = new ValueFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -857,7 +858,7 @@ public class TestScannersWithFilters {
// Expect half the rows
expectedRows = numRows / 2;
expectedKeys = colsPerRow;
f = new ValueFilter(CompareOp.NOT_EQUAL,
f = new ValueFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -867,7 +868,7 @@ public class TestScannersWithFilters {
// Expect all rows
expectedRows = numRows;
expectedKeys = colsPerRow;
f = new ValueFilter(CompareOp.GREATER_OR_EQUAL,
f = new ValueFilter(CompareOperator.GREATER_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -877,7 +878,7 @@ public class TestScannersWithFilters {
// Expect half rows
expectedRows = numRows / 2;
expectedKeys = colsPerRow;
f = new ValueFilter(CompareOp.GREATER,
f = new ValueFilter(CompareOperator.GREATER,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -886,7 +887,7 @@ public class TestScannersWithFilters {
// Match values not equal to testValueOne
// Look across rows and fully validate the keys and ordering
// Should see all keys in all group two rows
f = new ValueFilter(CompareOp.NOT_EQUAL,
f = new ValueFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -921,7 +922,7 @@ public class TestScannersWithFilters {
public void testSkipFilter() throws Exception {
// Test for qualifier regex: "testQualifierOne-2"
// Should only get rows from second group, and all keys
Filter f = new SkipFilter(new QualifierFilter(CompareOp.NOT_EQUAL,
Filter f = new SkipFilter(new QualifierFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2"))));
Scan s = new Scan();
s.setFilter(f);
@ -958,11 +959,11 @@ public class TestScannersWithFilters {
// regular expression and substring filters
// Use must pass all
List<Filter> filters = new ArrayList<>(3);
filters.add(new RowFilter(CompareOp.EQUAL,
filters.add(new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator(".+-2")));
filters.add(new QualifierFilter(CompareOp.EQUAL,
filters.add(new QualifierFilter(CompareOperator.EQUAL,
new RegexStringComparator(".+-2")));
filters.add(new ValueFilter(CompareOp.EQUAL,
filters.add(new ValueFilter(CompareOperator.EQUAL,
new SubstringComparator("One")));
Filter f = new FilterList(Operator.MUST_PASS_ALL, filters);
Scan s = new Scan();
@ -976,11 +977,11 @@ public class TestScannersWithFilters {
// Test getting everything with a MUST_PASS_ONE filter including row, qf,
// val, regular expression and substring filters
filters.clear();
filters.add(new RowFilter(CompareOp.EQUAL,
filters.add(new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator(".+Two.+")));
filters.add(new QualifierFilter(CompareOp.EQUAL,
filters.add(new QualifierFilter(CompareOperator.EQUAL,
new RegexStringComparator(".+-2")));
filters.add(new ValueFilter(CompareOp.EQUAL,
filters.add(new ValueFilter(CompareOperator.EQUAL,
new SubstringComparator("One")));
f = new FilterList(Operator.MUST_PASS_ONE, filters);
s = new Scan();
@ -1003,6 +1004,4 @@ public class TestScannersWithFilters {
};
verifyScanFull(s, kvs);
}
}

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.security.access;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.ArrayListMultimap;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.ListMultimap;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
@ -323,7 +324,7 @@ public class AccessControlLists {
scan.addFamily(ACL_LIST_FAMILY);
String columnName = Bytes.toString(column);
scan.setFilter(new QualifierFilter(CompareOp.EQUAL, new RegexStringComparator(
scan.setFilter(new QualifierFilter(CompareOperator.EQUAL, new RegexStringComparator(
String.format("(%s%s%s)|(%s%s)$",
ACL_KEY_DELIMITER, columnName, ACL_KEY_DELIMITER,
ACL_KEY_DELIMITER, columnName))));

View File

@ -131,7 +131,7 @@ public class TestSerialization {
}
@Test public void testCompareFilter() throws Exception {
Filter f = new RowFilter(CompareOp.EQUAL,
Filter f = new RowFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
byte [] bytes = f.toByteArray();
Filter ff = RowFilter.parseFrom(bytes);

View File

@ -205,21 +205,21 @@ public class TestServerSideScanMetricsFromClientSide {
}
// The filter should filter out all rows, but we still expect to see every row.
Filter filter = new RowFilter(CompareOp.EQUAL, new BinaryComparator("xyz".getBytes()));
Filter filter = new RowFilter(CompareOperator.EQUAL, new BinaryComparator("xyz".getBytes()));
scan = new Scan(baseScan);
scan.setFilter(filter);
testMetric(scan, ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME, ROWS.length);
// Filter should pass on all rows
SingleColumnValueFilter singleColumnValueFilter =
new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0], CompareOp.EQUAL, VALUE);
new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0], CompareOperator.EQUAL, VALUE);
scan = new Scan(baseScan);
scan.setFilter(singleColumnValueFilter);
testMetric(scan, ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME, ROWS.length);
// Filter should filter out all rows
singleColumnValueFilter =
new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0], CompareOp.NOT_EQUAL, VALUE);
new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0], CompareOperator.NOT_EQUAL, VALUE);
scan = new Scan(baseScan);
scan.setFilter(singleColumnValueFilter);
testMetric(scan, ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME, ROWS.length);
@ -255,7 +255,7 @@ public class TestServerSideScanMetricsFromClientSide {
testRowsFilteredMetric(baseScan, null, 0);
// Row filter doesn't match any row key. All rows should be filtered
Filter filter = new RowFilter(CompareOp.EQUAL, new BinaryComparator("xyz".getBytes()));
Filter filter = new RowFilter(CompareOperator.EQUAL, new BinaryComparator("xyz".getBytes()));
testRowsFilteredMetric(baseScan, filter, ROWS.length);
// Filter will return results containing only the first key. Number of entire rows filtered
@ -273,16 +273,17 @@ public class TestServerSideScanMetricsFromClientSide {
testRowsFilteredMetric(baseScan, filter, ROWS.length);
// Matching column value should exist in each row. No rows should be filtered.
filter = new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0], CompareOp.EQUAL, VALUE);
filter = new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0], CompareOperator.EQUAL, VALUE);
testRowsFilteredMetric(baseScan, filter, 0);
// No matching column value should exist in any row. Filter all rows
filter = new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0], CompareOp.NOT_EQUAL, VALUE);
filter = new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0],
CompareOperator.NOT_EQUAL, VALUE);
testRowsFilteredMetric(baseScan, filter, ROWS.length);
List<Filter> filters = new ArrayList<>();
filters.add(new RowFilter(CompareOp.EQUAL, new BinaryComparator(ROWS[0])));
filters.add(new RowFilter(CompareOp.EQUAL, new BinaryComparator(ROWS[3])));
filters.add(new RowFilter(CompareOperator.EQUAL, new BinaryComparator(ROWS[0])));
filters.add(new RowFilter(CompareOperator.EQUAL, new BinaryComparator(ROWS[3])));
int numberOfMatchingRowFilters = filters.size();
filter = new FilterList(Operator.MUST_PASS_ONE, filters);
testRowsFilteredMetric(baseScan, filter, ROWS.length - numberOfMatchingRowFilters);
@ -294,7 +295,7 @@ public class TestServerSideScanMetricsFromClientSide {
for (int family = 0; family < FAMILIES.length; family++) {
for (int qualifier = 0; qualifier < QUALIFIERS.length; qualifier++) {
filters.add(new SingleColumnValueExcludeFilter(FAMILIES[family], QUALIFIERS[qualifier],
CompareOp.EQUAL, VALUE));
CompareOperator.EQUAL, VALUE));
}
}
filter = new FilterList(Operator.MUST_PASS_ONE, filters);

View File

@ -132,7 +132,7 @@ public class TestCheckAndMutate {
// put the same row again with C column deleted
RowMutations rm = makeRowMutationsWithColumnCDeleted();
boolean res = table.checkAndMutate(ROWKEY, FAMILY, Bytes.toBytes("A"),
CompareFilter.CompareOp.EQUAL, Bytes.toBytes("a"), rm);
CompareOperator.EQUAL, Bytes.toBytes("a"), rm);
assertTrue(res);
// get row back and assert the values
@ -141,7 +141,7 @@ public class TestCheckAndMutate {
//Test that we get a region level exception
try {
rm = getBogusRowMutations();
table.checkAndMutate(ROWKEY, FAMILY, Bytes.toBytes("A"), CompareFilter.CompareOp.EQUAL,
table.checkAndMutate(ROWKEY, FAMILY, Bytes.toBytes("A"), CompareOperator.EQUAL,
Bytes.toBytes("a"), rm);
fail("Expected NoSuchColumnFamilyException");
} catch (RetriesExhaustedWithDetailsException e) {

View File

@ -53,6 +53,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
@ -453,7 +454,7 @@ public class TestFromClientSide {
FilterList allFilters = new FilterList(/* FilterList.Operator.MUST_PASS_ALL */);
allFilters.addFilter(new PrefixFilter(Bytes.toBytes(keyPrefix)));
SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes
.toBytes("trans-tags"), Bytes.toBytes("qual2"), CompareOp.EQUAL, Bytes
.toBytes("trans-tags"), Bytes.toBytes("qual2"), CompareOperator.EQUAL, Bytes
.toBytes(value));
filter.setFilterIfMissing(true);
allFilters.addFilter(filter);
@ -542,15 +543,15 @@ public class TestFromClientSide {
key = new byte [] {'a', 'a', 'a'};
int countBBB = TEST_UTIL.countRows(t,
createScanWithRowFilter(key, null, CompareFilter.CompareOp.EQUAL));
createScanWithRowFilter(key, null, CompareOperator.EQUAL));
assertEquals(1, countBBB);
int countGreater = TEST_UTIL.countRows(t, createScanWithRowFilter(endKey, null,
CompareFilter.CompareOp.GREATER_OR_EQUAL));
CompareOperator.GREATER_OR_EQUAL));
// Because started at start of table.
assertEquals(0, countGreater);
countGreater = TEST_UTIL.countRows(t, createScanWithRowFilter(endKey, endKey,
CompareFilter.CompareOp.GREATER_OR_EQUAL));
CompareOperator.GREATER_OR_EQUAL));
assertEquals(rowCount - endKeyCount, countGreater);
}
@ -694,7 +695,7 @@ public class TestFromClientSide {
* @return Scan with RowFilter that does LESS than passed key.
*/
private Scan createScanWithRowFilter(final byte [] key) {
return createScanWithRowFilter(key, null, CompareFilter.CompareOp.LESS);
return createScanWithRowFilter(key, null, CompareOperator.LESS);
}
/*
@ -704,7 +705,7 @@ public class TestFromClientSide {
* @return Scan with RowFilter that does CompareOp op on passed key.
*/
private Scan createScanWithRowFilter(final byte [] key,
final byte [] startRow, CompareFilter.CompareOp op) {
final byte [] startRow, CompareOperator op) {
// Make sure key is of some substance... non-null and > than first key.
assertTrue(key != null && key.length > 0 &&
Bytes.BYTES_COMPARATOR.compare(key, new byte [] {'a', 'a', 'a'}) >= 0);
@ -826,7 +827,7 @@ public class TestFromClientSide {
}
Scan scan = new Scan();
scan.addFamily(FAMILY);
Filter filter = new QualifierFilter(CompareOp.EQUAL,
Filter filter = new QualifierFilter(CompareOperator.EQUAL,
new RegexStringComparator("col[1-5]"));
scan.setFilter(filter);
ResultScanner scanner = ht.getScanner(scan);
@ -859,7 +860,7 @@ public class TestFromClientSide {
}
Scan scan = new Scan();
scan.addFamily(FAMILY);
Filter filter = new SingleColumnValueFilter(FAMILY, QUALIFIER, CompareOp.GREATER,
Filter filter = new SingleColumnValueFilter(FAMILY, QUALIFIER, CompareOperator.GREATER,
new LongComparator(500));
scan.setFilter(filter);
ResultScanner scanner = ht.getScanner(scan);
@ -1478,7 +1479,7 @@ public class TestFromClientSide {
RowMutations mutate = new RowMutations(ROW);
mutate.add(new Put(ROW).addColumn(FAMILY, null, Bytes.toBytes("checkAndMutate")));
table.checkAndMutate(ROW, FAMILY, null, CompareOp.EQUAL, Bytes.toBytes("checkAndPut"), mutate);
table.checkAndMutate(ROW, FAMILY, null, CompareOperator.EQUAL, Bytes.toBytes("checkAndPut"), mutate);
delete = new Delete(ROW);
delete.addColumns(FAMILY, null);
@ -4913,47 +4914,47 @@ public class TestFromClientSide {
// cell = "bbbb", using "aaaa" to compare only LESS/LESS_OR_EQUAL/NOT_EQUAL
// turns out "match"
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.GREATER, value1, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER, value1, put2);
assertEquals(ok, false);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.EQUAL, value1, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.EQUAL, value1, put2);
assertEquals(ok, false);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.GREATER_OR_EQUAL, value1, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER_OR_EQUAL, value1, put2);
assertEquals(ok, false);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.LESS, value1, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.LESS, value1, put2);
assertEquals(ok, true);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.LESS_OR_EQUAL, value1, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.LESS_OR_EQUAL, value1, put2);
assertEquals(ok, true);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.NOT_EQUAL, value1, put3);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.NOT_EQUAL, value1, put3);
assertEquals(ok, true);
// cell = "cccc", using "dddd" to compare only LARGER/LARGER_OR_EQUAL/NOT_EQUAL
// turns out "match"
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.LESS, value4, put3);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.LESS, value4, put3);
assertEquals(ok, false);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.LESS_OR_EQUAL, value4, put3);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.LESS_OR_EQUAL, value4, put3);
assertEquals(ok, false);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.EQUAL, value4, put3);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.EQUAL, value4, put3);
assertEquals(ok, false);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.GREATER, value4, put3);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER, value4, put3);
assertEquals(ok, true);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.GREATER_OR_EQUAL, value4, put3);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER_OR_EQUAL, value4, put3);
assertEquals(ok, true);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.NOT_EQUAL, value4, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.NOT_EQUAL, value4, put2);
assertEquals(ok, true);
// cell = "bbbb", using "bbbb" to compare only GREATER_OR_EQUAL/LESS_OR_EQUAL/EQUAL
// turns out "match"
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.GREATER, value2, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER, value2, put2);
assertEquals(ok, false);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.NOT_EQUAL, value2, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.NOT_EQUAL, value2, put2);
assertEquals(ok, false);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.LESS, value2, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.LESS, value2, put2);
assertEquals(ok, false);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.GREATER_OR_EQUAL, value2, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER_OR_EQUAL, value2, put2);
assertEquals(ok, true);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.LESS_OR_EQUAL, value2, put2);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.LESS_OR_EQUAL, value2, put2);
assertEquals(ok, true);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOp.EQUAL, value2, put3);
ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, CompareOperator.EQUAL, value2, put3);
assertEquals(ok, true);
}
@ -4997,55 +4998,55 @@ public class TestFromClientSide {
// cell = "bbbb", using "aaaa" to compare only LESS/LESS_OR_EQUAL/NOT_EQUAL
// turns out "match"
boolean ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.GREATER, value1, delete);
boolean ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER, value1, delete);
assertEquals(ok, false);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.EQUAL, value1, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.EQUAL, value1, delete);
assertEquals(ok, false);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.GREATER_OR_EQUAL, value1, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER_OR_EQUAL, value1, delete);
assertEquals(ok, false);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.LESS, value1, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.LESS, value1, delete);
assertEquals(ok, true);
table.put(put2);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.LESS_OR_EQUAL, value1, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.LESS_OR_EQUAL, value1, delete);
assertEquals(ok, true);
table.put(put2);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.NOT_EQUAL, value1, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.NOT_EQUAL, value1, delete);
assertEquals(ok, true);
// cell = "cccc", using "dddd" to compare only LARGER/LARGER_OR_EQUAL/NOT_EQUAL
// turns out "match"
table.put(put3);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.LESS, value4, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.LESS, value4, delete);
assertEquals(ok, false);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.LESS_OR_EQUAL, value4, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.LESS_OR_EQUAL, value4, delete);
assertEquals(ok, false);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.EQUAL, value4, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.EQUAL, value4, delete);
assertEquals(ok, false);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.GREATER, value4, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER, value4, delete);
assertEquals(ok, true);
table.put(put3);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.GREATER_OR_EQUAL, value4, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER_OR_EQUAL, value4, delete);
assertEquals(ok, true);
table.put(put3);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.NOT_EQUAL, value4, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.NOT_EQUAL, value4, delete);
assertEquals(ok, true);
// cell = "bbbb", using "bbbb" to compare only GREATER_OR_EQUAL/LESS_OR_EQUAL/EQUAL
// turns out "match"
table.put(put2);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.GREATER, value2, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER, value2, delete);
assertEquals(ok, false);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.NOT_EQUAL, value2, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.NOT_EQUAL, value2, delete);
assertEquals(ok, false);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.LESS, value2, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.LESS, value2, delete);
assertEquals(ok, false);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.GREATER_OR_EQUAL, value2, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.GREATER_OR_EQUAL, value2, delete);
assertEquals(ok, true);
table.put(put2);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.LESS_OR_EQUAL, value2, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.LESS_OR_EQUAL, value2, delete);
assertEquals(ok, true);
table.put(put2);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOp.EQUAL, value2, delete);
ok = table.checkAndDelete(ROW, FAMILY, QUALIFIER, CompareOperator.EQUAL, value2, delete);
assertEquals(ok, true);
}
@ -5450,7 +5451,7 @@ public class TestFromClientSide {
scan.setStartRow(Bytes.toBytes(1));
scan.setStopRow(Bytes.toBytes(3));
scan.addColumn(FAMILY, FAMILY);
scan.setFilter(new RowFilter(CompareFilter.CompareOp.NOT_EQUAL,
scan.setFilter(new RowFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes(1))));
ResultScanner scanner = foo.getScanner(scan);
@ -5757,7 +5758,7 @@ public class TestFromClientSide {
Scan scan = new Scan();
scan.setReversed(true);
scan.addFamily(FAMILY);
Filter filter = new QualifierFilter(CompareOp.EQUAL,
Filter filter = new QualifierFilter(CompareOperator.EQUAL,
new RegexStringComparator("col[1-5]"));
scan.setFilter(filter);
ResultScanner scanner = ht.getScanner(scan);
@ -6561,7 +6562,7 @@ public class TestFromClientSide {
table.put(put);
Scan scan =
new Scan().setFilter(new ValueFilter(CompareOp.EQUAL, new SubstringComparator("value-a")))
new Scan().setFilter(new ValueFilter(CompareOperator.EQUAL, new SubstringComparator("value-a")))
.setMaxVersions(3);
ResultScanner scanner = table.getScanner(scan);
Result result = scanner.next();
@ -6571,7 +6572,7 @@ public class TestFromClientSide {
Get get =
new Get(ROW)
.setFilter(new ValueFilter(CompareOp.EQUAL, new SubstringComparator("value-a")))
.setFilter(new ValueFilter(CompareOperator.EQUAL, new SubstringComparator("value-a")))
.setMaxVersions(3);
result = table.get(get);
// ts[0] has gone from user view. Only read ts[2] which value is less or equal to 3
@ -6580,7 +6581,7 @@ public class TestFromClientSide {
// Test with max versions 1, it should still read ts[1]
scan =
new Scan().setFilter(new ValueFilter(CompareOp.EQUAL, new SubstringComparator("value-a")))
new Scan().setFilter(new ValueFilter(CompareOperator.EQUAL, new SubstringComparator("value-a")))
.setMaxVersions(1);
scanner = table.getScanner(scan);
result = scanner.next();
@ -6591,7 +6592,7 @@ public class TestFromClientSide {
// Test with max versions 1, it should still read ts[1]
get =
new Get(ROW)
.setFilter(new ValueFilter(CompareOp.EQUAL, new SubstringComparator("value-a")))
.setFilter(new ValueFilter(CompareOperator.EQUAL, new SubstringComparator("value-a")))
.setMaxVersions(1);
result = table.get(get);
// ts[0] has gone from user view. Only read ts[2] which value is less or equal to 3
@ -6600,7 +6601,7 @@ public class TestFromClientSide {
// Test with max versions 5, it should still read ts[1]
scan =
new Scan().setFilter(new ValueFilter(CompareOp.EQUAL, new SubstringComparator("value-a")))
new Scan().setFilter(new ValueFilter(CompareOperator.EQUAL, new SubstringComparator("value-a")))
.setMaxVersions(5);
scanner = table.getScanner(scan);
result = scanner.next();
@ -6611,7 +6612,7 @@ public class TestFromClientSide {
// Test with max versions 5, it should still read ts[1]
get =
new Get(ROW)
.setFilter(new ValueFilter(CompareOp.EQUAL, new SubstringComparator("value-a")))
.setFilter(new ValueFilter(CompareOperator.EQUAL, new SubstringComparator("value-a")))
.setMaxVersions(5);
result = table.get(get);
// ts[0] has gone from user view. Only read ts[2] which value is less or equal to 3

View File

@ -32,6 +32,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
@ -192,7 +193,7 @@ public class TestDependentColumnFilter {
// include a comparator operation
filter = new DependentColumnFilter(FAMILIES[0], QUALIFIER, false,
CompareOp.EQUAL, new BinaryComparator(MATCH_VAL));
CompareOperator.EQUAL, new BinaryComparator(MATCH_VAL));
scan = new Scan();
scan.setFilter(filter);
scan.setMaxVersions(Integer.MAX_VALUE);
@ -209,7 +210,7 @@ public class TestDependentColumnFilter {
// include a comparator operation and drop comparator
filter = new DependentColumnFilter(FAMILIES[0], QUALIFIER, true,
CompareOp.EQUAL, new BinaryComparator(MATCH_VAL));
CompareOperator.EQUAL, new BinaryComparator(MATCH_VAL));
scan = new Scan();
scan.setFilter(filter);
scan.setMaxVersions(Integer.MAX_VALUE);
@ -268,7 +269,7 @@ public class TestDependentColumnFilter {
filter.toString().contains("null"));
// Test constructor with explicit null comparator
filter = new DependentColumnFilter(FAMILIES[0], QUALIFIER, true, CompareOp.EQUAL, null);
filter = new DependentColumnFilter(FAMILIES[0], QUALIFIER, true, CompareOperator.EQUAL, null);
assertNotNull(filter.toString());
assertTrue("check string contains 'null' as compatator is null",
filter.toString().contains("null"));
@ -277,7 +278,7 @@ public class TestDependentColumnFilter {
@Test
public void testToStringWithNonNullComparator() {
Filter filter =
new DependentColumnFilter(FAMILIES[0], QUALIFIER, true, CompareOp.EQUAL,
new DependentColumnFilter(FAMILIES[0], QUALIFIER, true, CompareOperator.EQUAL,
new BinaryComparator(MATCH_VAL));
assertNotNull(filter.toString());
assertTrue("check string contains comparator value", filter.toString().contains("match"));

View File

@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
@ -675,7 +676,7 @@ public class TestFilter {
public void testWhileMatchFilterWithFilterKeyValue() throws Exception {
Scan s = new Scan();
WhileMatchFilter filter = new WhileMatchFilter(
new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[0], CompareOp.EQUAL, Bytes.toBytes("foo"))
new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[0], CompareOperator.EQUAL, Bytes.toBytes("foo"))
);
s.setFilter(filter);
@ -768,7 +769,7 @@ public class TestFilter {
// Match two keys (one from each family) in half the rows
long expectedRows = this.numRows / 2;
long expectedKeys = 2;
Filter f = new QualifierFilter(CompareOp.EQUAL,
Filter f = new QualifierFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
Scan s = new Scan();
s.setFilter(f);
@ -778,7 +779,7 @@ public class TestFilter {
// Expect only two keys (one from each family) in half the rows
expectedRows = this.numRows / 2;
expectedKeys = 2;
f = new QualifierFilter(CompareOp.LESS,
f = new QualifierFilter(CompareOperator.LESS,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan();
s.setFilter(f);
@ -788,7 +789,7 @@ public class TestFilter {
// Expect four keys (two from each family) in half the rows
expectedRows = this.numRows / 2;
expectedKeys = 4;
f = new QualifierFilter(CompareOp.LESS_OR_EQUAL,
f = new QualifierFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan();
s.setFilter(f);
@ -799,7 +800,7 @@ public class TestFilter {
// Only look in first group of rows
expectedRows = this.numRows / 2;
expectedKeys = 4;
f = new QualifierFilter(CompareOp.NOT_EQUAL,
f = new QualifierFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan(HConstants.EMPTY_START_ROW, Bytes.toBytes("testRowTwo"));
s.setFilter(f);
@ -810,7 +811,7 @@ public class TestFilter {
// Only look in first group of rows
expectedRows = this.numRows / 2;
expectedKeys = 4;
f = new QualifierFilter(CompareOp.GREATER_OR_EQUAL,
f = new QualifierFilter(CompareOperator.GREATER_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan(HConstants.EMPTY_START_ROW, Bytes.toBytes("testRowTwo"));
s.setFilter(f);
@ -821,7 +822,7 @@ public class TestFilter {
// Only look in first group of rows
expectedRows = this.numRows / 2;
expectedKeys = 2;
f = new QualifierFilter(CompareOp.GREATER,
f = new QualifierFilter(CompareOperator.GREATER,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2")));
s = new Scan(HConstants.EMPTY_START_ROW, Bytes.toBytes("testRowTwo"));
s.setFilter(f);
@ -830,7 +831,7 @@ public class TestFilter {
// Match keys not equal to
// Look across rows and fully validate the keys and ordering
// Expect varied numbers of keys, 4 per row in group one, 6 per row in group two
f = new QualifierFilter(CompareOp.NOT_EQUAL,
f = new QualifierFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(QUALIFIERS_ONE[2]));
s = new Scan();
s.setFilter(f);
@ -879,7 +880,7 @@ public class TestFilter {
// Test across rows and groups with a regex
// Filter out "test*-2"
// Expect 4 keys per row across both groups
f = new QualifierFilter(CompareOp.NOT_EQUAL,
f = new QualifierFilter(CompareOperator.NOT_EQUAL,
new RegexStringComparator("test.+-2"));
s = new Scan();
s.setFilter(f);
@ -926,7 +927,7 @@ public class TestFilter {
// Match family, only half of columns returned.
long expectedRows = this.numRows;
long expectedKeys = this.colsPerRow / 2;
Filter f = new FamilyFilter(CompareOp.EQUAL,
Filter f = new FamilyFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testFamilyOne")));
Scan s = new Scan();
s.setFilter(f);
@ -935,7 +936,7 @@ public class TestFilter {
// Match keys less than given family, should return nothing
expectedRows = 0;
expectedKeys = 0;
f = new FamilyFilter(CompareOp.LESS,
f = new FamilyFilter(CompareOperator.LESS,
new BinaryComparator(Bytes.toBytes("testFamily")));
s = new Scan();
s.setFilter(f);
@ -944,7 +945,7 @@ public class TestFilter {
// Match keys less than or equal, should return half of columns
expectedRows = this.numRows;
expectedKeys = this.colsPerRow / 2;
f = new FamilyFilter(CompareOp.LESS_OR_EQUAL,
f = new FamilyFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testFamilyOne")));
s = new Scan();
s.setFilter(f);
@ -954,7 +955,7 @@ public class TestFilter {
// look only in second group of rows
expectedRows = this.numRows / 2;
expectedKeys = this.colsPerRow / 2;
f = new FamilyFilter(CompareOp.NOT_EQUAL,
f = new FamilyFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testFamilyOne")));
s = new Scan(HConstants.EMPTY_START_ROW, Bytes.toBytes("testRowTwo"));
s.setFilter(f);
@ -964,7 +965,7 @@ public class TestFilter {
// look only in second group of rows
expectedRows = this.numRows / 2;
expectedKeys = this.colsPerRow;
f = new FamilyFilter(CompareOp.GREATER_OR_EQUAL,
f = new FamilyFilter(CompareOperator.GREATER_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testFamilyOne")));
s = new Scan(HConstants.EMPTY_START_ROW, Bytes.toBytes("testRowTwo"));
s.setFilter(f);
@ -974,7 +975,7 @@ public class TestFilter {
// look only in second group of rows
expectedRows = this.numRows / 2;
expectedKeys = this.colsPerRow / 2;
f = new FamilyFilter(CompareOp.GREATER,
f = new FamilyFilter(CompareOperator.GREATER,
new BinaryComparator(Bytes.toBytes("testFamilyOne")));
s = new Scan(HConstants.EMPTY_START_ROW, Bytes.toBytes("testRowTwo"));
s.setFilter(f);
@ -982,7 +983,7 @@ public class TestFilter {
// Match keys not equal to given family
// Look across rows and fully validate the keys and ordering
f = new FamilyFilter(CompareOp.NOT_EQUAL,
f = new FamilyFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(FAMILIES[1]));
s = new Scan();
s.setFilter(f);
@ -1019,7 +1020,7 @@ public class TestFilter {
// Test across rows and groups with a regex
// Filter out "test*-2"
// Expect 4 keys per row across both groups
f = new FamilyFilter(CompareOp.NOT_EQUAL,
f = new FamilyFilter(CompareOperator.NOT_EQUAL,
new RegexStringComparator("test.*One"));
s = new Scan();
s.setFilter(f);
@ -1061,7 +1062,7 @@ public class TestFilter {
// Match a single row, all keys
long expectedRows = 1;
long expectedKeys = this.colsPerRow;
Filter f = new RowFilter(CompareOp.EQUAL,
Filter f = new RowFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
Scan s = new Scan();
s.setFilter(f);
@ -1070,7 +1071,7 @@ public class TestFilter {
// Match a two rows, one from each group, using regex
expectedRows = 2;
expectedKeys = this.colsPerRow;
f = new RowFilter(CompareOp.EQUAL,
f = new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator("testRow.+-2"));
s = new Scan();
s.setFilter(f);
@ -1080,7 +1081,7 @@ public class TestFilter {
// Expect all keys in one row
expectedRows = 1;
expectedKeys = this.colsPerRow;
f = new RowFilter(CompareOp.LESS,
f = new RowFilter(CompareOperator.LESS,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -1090,7 +1091,7 @@ public class TestFilter {
// Expect all keys in two rows
expectedRows = 2;
expectedKeys = this.colsPerRow;
f = new RowFilter(CompareOp.LESS_OR_EQUAL,
f = new RowFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -1100,7 +1101,7 @@ public class TestFilter {
// Expect all keys in all but one row
expectedRows = this.numRows - 1;
expectedKeys = this.colsPerRow;
f = new RowFilter(CompareOp.NOT_EQUAL,
f = new RowFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -1110,7 +1111,7 @@ public class TestFilter {
// Expect all keys in all but one row
expectedRows = this.numRows - 1;
expectedKeys = this.colsPerRow;
f = new RowFilter(CompareOp.GREATER_OR_EQUAL,
f = new RowFilter(CompareOperator.GREATER_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -1120,7 +1121,7 @@ public class TestFilter {
// Expect all keys in all but two rows
expectedRows = this.numRows - 2;
expectedKeys = this.colsPerRow;
f = new RowFilter(CompareOp.GREATER,
f = new RowFilter(CompareOperator.GREATER,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -1129,7 +1130,7 @@ public class TestFilter {
// Match rows not equal to testRowTwo-2
// Look across rows and fully validate the keys and ordering
// Should see all keys in all rows but testRowTwo-2
f = new RowFilter(CompareOp.NOT_EQUAL,
f = new RowFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testRowOne-2")));
s = new Scan();
s.setFilter(f);
@ -1177,7 +1178,7 @@ public class TestFilter {
// Test across rows and groups with a regex
// Filter out everything that doesn't match "*-2"
// Expect all keys in two rows
f = new RowFilter(CompareOp.EQUAL,
f = new RowFilter(CompareOperator.EQUAL,
new RegexStringComparator(".+-2"));
s = new Scan();
s.setFilter(f);
@ -1208,7 +1209,7 @@ public class TestFilter {
// Match group one rows
long expectedRows = this.numRows / 2;
long expectedKeys = this.colsPerRow;
Filter f = new ValueFilter(CompareOp.EQUAL,
Filter f = new ValueFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
Scan s = new Scan();
s.setFilter(f);
@ -1217,7 +1218,7 @@ public class TestFilter {
// Match group two rows
expectedRows = this.numRows / 2;
expectedKeys = this.colsPerRow;
f = new ValueFilter(CompareOp.EQUAL,
f = new ValueFilter(CompareOperator.EQUAL,
new BinaryComparator(Bytes.toBytes("testValueTwo")));
s = new Scan();
s.setFilter(f);
@ -1226,7 +1227,7 @@ public class TestFilter {
// Match all values using regex
expectedRows = this.numRows;
expectedKeys = this.colsPerRow;
f = new ValueFilter(CompareOp.EQUAL,
f = new ValueFilter(CompareOperator.EQUAL,
new RegexStringComparator("testValue((One)|(Two))"));
s = new Scan();
s.setFilter(f);
@ -1236,7 +1237,7 @@ public class TestFilter {
// Expect group one rows
expectedRows = this.numRows / 2;
expectedKeys = this.colsPerRow;
f = new ValueFilter(CompareOp.LESS,
f = new ValueFilter(CompareOperator.LESS,
new BinaryComparator(Bytes.toBytes("testValueTwo")));
s = new Scan();
s.setFilter(f);
@ -1246,7 +1247,7 @@ public class TestFilter {
// Expect all rows
expectedRows = this.numRows;
expectedKeys = this.colsPerRow;
f = new ValueFilter(CompareOp.LESS_OR_EQUAL,
f = new ValueFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueTwo")));
s = new Scan();
s.setFilter(f);
@ -1256,7 +1257,7 @@ public class TestFilter {
// Expect group one rows
expectedRows = this.numRows / 2;
expectedKeys = this.colsPerRow;
f = new ValueFilter(CompareOp.LESS_OR_EQUAL,
f = new ValueFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -1266,7 +1267,7 @@ public class TestFilter {
// Expect half the rows
expectedRows = this.numRows / 2;
expectedKeys = this.colsPerRow;
f = new ValueFilter(CompareOp.NOT_EQUAL,
f = new ValueFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -1276,7 +1277,7 @@ public class TestFilter {
// Expect all rows
expectedRows = this.numRows;
expectedKeys = this.colsPerRow;
f = new ValueFilter(CompareOp.GREATER_OR_EQUAL,
f = new ValueFilter(CompareOperator.GREATER_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -1286,7 +1287,7 @@ public class TestFilter {
// Expect half rows
expectedRows = this.numRows / 2;
expectedKeys = this.colsPerRow;
f = new ValueFilter(CompareOp.GREATER,
f = new ValueFilter(CompareOperator.GREATER,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -1295,7 +1296,7 @@ public class TestFilter {
// Match values not equal to testValueOne
// Look across rows and fully validate the keys and ordering
// Should see all keys in all group two rows
f = new ValueFilter(CompareOp.NOT_EQUAL,
f = new ValueFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testValueOne")));
s = new Scan();
s.setFilter(f);
@ -1331,7 +1332,7 @@ public class TestFilter {
// Test for qualifier regex: "testQualifierOne-2"
// Should only get rows from second group, and all keys
Filter f = new SkipFilter(new QualifierFilter(CompareOp.NOT_EQUAL,
Filter f = new SkipFilter(new QualifierFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes("testQualifierOne-2"))));
Scan s = new Scan();
s.setFilter(f);
@ -1371,9 +1372,9 @@ public class TestFilter {
// regular expression and substring filters
// Use must pass all
List<Filter> filters = new ArrayList<>();
filters.add(new RowFilter(CompareOp.EQUAL, new RegexStringComparator(".+-2")));
filters.add(new QualifierFilter(CompareOp.EQUAL, new RegexStringComparator(".+-2")));
filters.add(new ValueFilter(CompareOp.EQUAL, new SubstringComparator("One")));
filters.add(new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(".+-2")));
filters.add(new QualifierFilter(CompareOperator.EQUAL, new RegexStringComparator(".+-2")));
filters.add(new ValueFilter(CompareOperator.EQUAL, new SubstringComparator("One")));
Filter f = new FilterList(Operator.MUST_PASS_ALL, filters);
Scan s = new Scan();
s.addFamily(FAMILIES[0]);
@ -1386,9 +1387,9 @@ public class TestFilter {
// Test getting everything with a MUST_PASS_ONE filter including row, qf, val
// regular expression and substring filters
filters.clear();
filters.add(new RowFilter(CompareOp.EQUAL, new RegexStringComparator(".+Two.+")));
filters.add(new QualifierFilter(CompareOp.EQUAL, new RegexStringComparator(".+-2")));
filters.add(new ValueFilter(CompareOp.EQUAL, new SubstringComparator("One")));
filters.add(new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(".+Two.+")));
filters.add(new QualifierFilter(CompareOperator.EQUAL, new RegexStringComparator(".+-2")));
filters.add(new ValueFilter(CompareOperator.EQUAL, new SubstringComparator("One")));
f = new FilterList(Operator.MUST_PASS_ONE, filters);
s = new Scan();
s.setFilter(f);
@ -1419,7 +1420,7 @@ public class TestFilter {
// Scan using SingleColumnValueFilter
SingleColumnValueFilter f1 = new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[0],
CompareOp.EQUAL, VALUES[0]);
CompareOperator.EQUAL, VALUES[0]);
f1.setFilterIfMissing( true );
Scan s1 = new Scan();
s1.addFamily(FAMILIES[0]);
@ -1440,7 +1441,7 @@ public class TestFilter {
// Scan using another SingleColumnValueFilter, expect disjoint result
SingleColumnValueFilter f2 = new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_TWO[0],
CompareOp.EQUAL, VALUES[1]);
CompareOperator.EQUAL, VALUES[1]);
f2.setFilterIfMissing( true );
Scan s2 = new Scan();
s2.addFamily(FAMILIES[0]);
@ -1513,7 +1514,7 @@ public class TestFilter {
PrefixFilter pf = new PrefixFilter(new byte[] {'b'}) ;
// rows with value of column 'q1' set to '113'
SingleColumnValueFilter scvf = new SingleColumnValueFilter(
family, qualifier, CompareOp.EQUAL, Bytes.toBytes("113"));
family, qualifier, CompareOperator.EQUAL, Bytes.toBytes("113"));
// combine these two with OR in a FilterList
FilterList filterList = new FilterList(Operator.MUST_PASS_ONE, pf, scvf);
@ -1555,9 +1556,9 @@ public class TestFilter {
// so limiting scan to group one
List<Filter> filters = new ArrayList<>();
filters.add(new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[0],
CompareOp.EQUAL, VALUES[0]));
CompareOperator.EQUAL, VALUES[0]));
filters.add(new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[2],
CompareOp.EQUAL, VALUES[1]));
CompareOperator.EQUAL, VALUES[1]));
Filter f = new FilterList(Operator.MUST_PASS_ALL, filters);
Scan s = new Scan(ROWS_ONE[0], ROWS_TWO[0]);
s.addFamily(FAMILIES[0]);
@ -1575,9 +1576,9 @@ public class TestFilter {
// need to wrap SCVFs in SkipFilters
filters = new ArrayList<>();
filters.add(new SkipFilter(new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[0],
CompareOp.EQUAL, VALUES[0])));
CompareOperator.EQUAL, VALUES[0])));
filters.add(new SkipFilter(new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[2],
CompareOp.EQUAL, VALUES[1])));
CompareOperator.EQUAL, VALUES[1])));
f = new FilterList(Operator.MUST_PASS_ALL, filters);
s = new Scan(ROWS_ONE[0], ROWS_TWO[0]);
s.addFamily(FAMILIES[0]);
@ -1612,7 +1613,7 @@ public class TestFilter {
// Match VALUES[0] against QUALIFIERS_ONE[0] with filterIfMissing = false
// Expect 3 rows (0, 2, 3)
SingleColumnValueFilter scvf = new SingleColumnValueFilter(FAMILIES[0],
QUALIFIERS_ONE[0], CompareOp.EQUAL, VALUES[0]);
QUALIFIERS_ONE[0], CompareOperator.EQUAL, VALUES[0]);
s = new Scan(ROWS_THREE[0], Bytes.toBytes("rowThree-4"));
s.addFamily(FAMILIES[0]);
s.setFilter(scvf);
@ -1622,7 +1623,7 @@ public class TestFilter {
// Match VALUES[0] against QUALIFIERS_ONE[0] with filterIfMissing = true
// Expect 1 row (0)
scvf = new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS_ONE[0],
CompareOp.EQUAL, VALUES[0]);
CompareOperator.EQUAL, VALUES[0]);
scvf.setFilterIfMissing(true);
s = new Scan(ROWS_THREE[0], Bytes.toBytes("rowThree-4"));
s.addFamily(FAMILIES[0]);
@ -1633,7 +1634,7 @@ public class TestFilter {
// Match VALUES[1] against QUALIFIERS_ONE[1] with filterIfMissing = true
// Expect 1 row (3)
scvf = new SingleColumnValueFilter(FAMILIES[0],
QUALIFIERS_ONE[1], CompareOp.EQUAL, VALUES[1]);
QUALIFIERS_ONE[1], CompareOperator.EQUAL, VALUES[1]);
scvf.setFilterIfMissing(true);
s = new Scan(ROWS_THREE[0], Bytes.toBytes("rowThree-4"));
s.addFamily(FAMILIES[0]);
@ -1648,7 +1649,7 @@ public class TestFilter {
// Match VALUES[1] against QUALIFIERS_ONE[1] with filterIfMissing = true
// Expect 1 row (3)
scvf = new SingleColumnValueFilter(FAMILIES[0],
QUALIFIERS_ONE[1], CompareOp.EQUAL, VALUES[1]);
QUALIFIERS_ONE[1], CompareOperator.EQUAL, VALUES[1]);
scvf.setFilterIfMissing(true);
s = new Scan(ROWS_THREE[0], Bytes.toBytes("rowThree-4"));
s.addFamily(FAMILIES[0]);
@ -2069,7 +2070,7 @@ public class TestFilter {
}
testRegion.flush(true);
// 1. got rows > "row4"
Filter rowFilter = new RowFilter(CompareOp.GREATER,new BinaryComparator(Bytes.toBytes("row4")));
Filter rowFilter = new RowFilter(CompareOperator.GREATER,new BinaryComparator(Bytes.toBytes("row4")));
Scan s1 = new Scan();
s1.setFilter(rowFilter);
InternalScanner scanner = testRegion.getScanner(s1);
@ -2083,10 +2084,10 @@ public class TestFilter {
}
// 2. got rows <= "row4" and S=
FilterList subFilterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
Filter subFilter1 = new RowFilter(CompareOp.LESS_OR_EQUAL,
Filter subFilter1 = new RowFilter(CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("row4")));
subFilterList.addFilter(subFilter1);
Filter subFilter2 = new SingleColumnValueFilter(FAMILIES[0], columnStatus, CompareOp.EQUAL,
Filter subFilter2 = new SingleColumnValueFilter(FAMILIES[0], columnStatus, CompareOperator.EQUAL,
Bytes.toBytes(0));
subFilterList.addFilter(subFilter2);
s1 = new Scan();

View File

@ -18,6 +18,7 @@
*/
package org.apache.hadoop.hbase.filter;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
import java.io.IOException;
import java.util.ArrayList;
@ -565,12 +566,12 @@ public class TestFilterList {
// OR (family=fam AND qualifier=qual2)
final FilterList flist = new FilterList(Operator.MUST_PASS_ONE, Lists.<Filter>newArrayList(
new FilterList(Operator.MUST_PASS_ALL, Lists.<Filter>newArrayList(
new FamilyFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("fam"))),
new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("qual1"))),
new FamilyFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("fam"))),
new QualifierFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("qual1"))),
new KeyOnlyFilter())),
new FilterList(Operator.MUST_PASS_ALL, Lists.<Filter>newArrayList(
new FamilyFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("fam"))),
new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("qual2")))))));
new FamilyFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("fam"))),
new QualifierFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("qual2")))))));
final KeyValue kvQual1 = new KeyValue(
Bytes.toBytes("row"), Bytes.toBytes("fam"), Bytes.toBytes("qual1"), Bytes.toBytes("value"));

View File

@ -26,6 +26,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.TreeSet;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.testclassification.FilterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
@ -88,7 +89,7 @@ public class TestFilterSerialization {
// non-null column qualifier/family
dependentColumnFilter = new DependentColumnFilter(Bytes.toBytes("family"),
Bytes.toBytes("qual"), true, CompareOp.GREATER_OR_EQUAL,
Bytes.toBytes("qual"), true, CompareOperator.GREATER_OR_EQUAL,
new BitComparator(Bytes.toBytes("bitComparator"), BitComparator.BitwiseOp.OR));
assertTrue(dependentColumnFilter.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(dependentColumnFilter))));
@ -96,7 +97,7 @@ public class TestFilterSerialization {
@Test
public void testFamilyFilter() throws Exception {
FamilyFilter familyFilter = new FamilyFilter(CompareFilter.CompareOp.EQUAL,
FamilyFilter familyFilter = new FamilyFilter(CompareOperator.EQUAL,
new BinaryPrefixComparator(Bytes.toBytes("testValueOne")));
assertTrue(familyFilter.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(familyFilter))));
@ -112,7 +113,7 @@ public class TestFilterSerialization {
// non-empty filter list
LinkedList<Filter> list = new LinkedList<>();
list.add(new ColumnCountGetFilter(1));
list.add(new RowFilter(CompareFilter.CompareOp.EQUAL,
list.add(new RowFilter(CompareOperator.EQUAL,
new SubstringComparator("testFilterList")));
assertTrue(filterList.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(filterList))));
@ -229,7 +230,7 @@ public class TestFilterSerialization {
@Test
public void testQualifierFilter() throws Exception {
QualifierFilter qualifierFilter = new QualifierFilter(CompareFilter.CompareOp.EQUAL,
QualifierFilter qualifierFilter = new QualifierFilter(CompareOperator.EQUAL,
new NullComparator());
assertTrue(qualifierFilter.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(qualifierFilter))));
@ -244,7 +245,7 @@ public class TestFilterSerialization {
@Test
public void testRowFilter() throws Exception {
RowFilter rowFilter = new RowFilter(CompareFilter.CompareOp.EQUAL,
RowFilter rowFilter = new RowFilter(CompareOperator.EQUAL,
new SubstringComparator("testRowFilter"));
assertTrue(rowFilter.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(rowFilter))));
@ -255,14 +256,14 @@ public class TestFilterSerialization {
// null family/column SingleColumnValueExcludeFilter
SingleColumnValueExcludeFilter singleColumnValueExcludeFilter =
new SingleColumnValueExcludeFilter(null, null,
CompareFilter.CompareOp.GREATER_OR_EQUAL, Bytes.toBytes("value"));
CompareOperator.GREATER_OR_EQUAL, Bytes.toBytes("value"));
assertTrue(singleColumnValueExcludeFilter.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(singleColumnValueExcludeFilter))));
// non-null family/column SingleColumnValueFilter
singleColumnValueExcludeFilter =
new SingleColumnValueExcludeFilter(Bytes.toBytes("fam"), Bytes.toBytes("qual"),
CompareFilter.CompareOp.LESS_OR_EQUAL, new NullComparator(), false, false);
CompareOperator.LESS_OR_EQUAL, new NullComparator(), false, false);
assertTrue(singleColumnValueExcludeFilter.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(singleColumnValueExcludeFilter))));
}
@ -272,14 +273,14 @@ public class TestFilterSerialization {
// null family/column SingleColumnValueFilter
SingleColumnValueFilter singleColumnValueFilter =
new SingleColumnValueFilter(null, null,
CompareFilter.CompareOp.LESS, Bytes.toBytes("value"));
CompareOperator.LESS, Bytes.toBytes("value"));
assertTrue(singleColumnValueFilter.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(singleColumnValueFilter))));
// non-null family/column SingleColumnValueFilter
singleColumnValueFilter =
new SingleColumnValueFilter(Bytes.toBytes("family"), Bytes.toBytes("qualifier"),
CompareFilter.CompareOp.NOT_EQUAL, new NullComparator(), true, true);
CompareOperator.NOT_EQUAL, new NullComparator(), true, true);
assertTrue(singleColumnValueFilter.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(singleColumnValueFilter))));
}
@ -309,7 +310,7 @@ public class TestFilterSerialization {
@Test
public void testValueFilter() throws Exception {
ValueFilter valueFilter = new ValueFilter(CompareFilter.CompareOp.NO_OP,
ValueFilter valueFilter = new ValueFilter(CompareOperator.NO_OP,
new BinaryComparator(Bytes.toBytes("testValueOne")));
assertTrue(valueFilter.areSerializedFieldsEqual(
ProtobufUtil.toFilter(ProtobufUtil.toFilter(valueFilter))));

View File

@ -30,6 +30,7 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@ -63,7 +64,7 @@ public class TestFilterWithScanLimits extends FilterTestingCluster {
scan.setBatch(2);
SingleColumnValueFilter filter = new SingleColumnValueFilter(
Bytes.toBytes(columnFamily), Bytes.toBytes("c5"),
CompareFilter.CompareOp.EQUAL, new SubstringComparator("2_c5"));
CompareOperator .EQUAL, new SubstringComparator("2_c5"));
// add filter after batch defined
scan.setFilter(filter);

View File

@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
@ -78,7 +79,7 @@ public class TestFilterWrapper {
List<Filter> fs = new ArrayList<>();
DependentColumnFilter f1 = new DependentColumnFilter(Bytes.toBytes("f1"),
Bytes.toBytes("c5"), true, CompareFilter.CompareOp.EQUAL,
Bytes.toBytes("c5"), true, CompareOperator.EQUAL,
new SubstringComparator("c5"));
PageFilter f2 = new PageFilter(2);
fs.add(f1);

View File

@ -24,6 +24,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
@ -242,7 +243,7 @@ public class TestParseFilter {
String filterString = "RowFilter ( =, 'binary:regionse')";
RowFilter rowFilter =
doTestFilter(filterString, RowFilter.class);
assertEquals(CompareFilter.CompareOp.EQUAL, rowFilter.getOperator());
assertEquals(CompareOperator.EQUAL, rowFilter.getCompareOperator());
assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
assertEquals("regionse", new String(binaryComparator.getValue()));
@ -253,7 +254,7 @@ public class TestParseFilter {
String filterString = "FamilyFilter(>=, 'binaryprefix:pre')";
FamilyFilter familyFilter =
doTestFilter(filterString, FamilyFilter.class);
assertEquals(CompareFilter.CompareOp.GREATER_OR_EQUAL, familyFilter.getOperator());
assertEquals(CompareOperator.GREATER_OR_EQUAL, familyFilter.getCompareOperator());
assertTrue(familyFilter.getComparator() instanceof BinaryPrefixComparator);
BinaryPrefixComparator binaryPrefixComparator =
(BinaryPrefixComparator) familyFilter.getComparator();
@ -265,7 +266,7 @@ public class TestParseFilter {
String filterString = "QualifierFilter(=, 'regexstring:pre*')";
QualifierFilter qualifierFilter =
doTestFilter(filterString, QualifierFilter.class);
assertEquals(CompareFilter.CompareOp.EQUAL, qualifierFilter.getOperator());
assertEquals(CompareOperator.EQUAL, qualifierFilter.getCompareOperator());
assertTrue(qualifierFilter.getComparator() instanceof RegexStringComparator);
RegexStringComparator regexStringComparator =
(RegexStringComparator) qualifierFilter.getComparator();
@ -277,7 +278,7 @@ public class TestParseFilter {
String filterString = "ValueFilter(!=, 'substring:pre')";
ValueFilter valueFilter =
doTestFilter(filterString, ValueFilter.class);
assertEquals(CompareFilter.CompareOp.NOT_EQUAL, valueFilter.getOperator());
assertEquals(CompareOperator.NOT_EQUAL, valueFilter.getCompareOperator());
assertTrue(valueFilter.getComparator() instanceof SubstringComparator);
SubstringComparator substringComparator =
(SubstringComparator) valueFilter.getComparator();
@ -303,7 +304,7 @@ public class TestParseFilter {
assertEquals("family", new String(dependentColumnFilter.getFamily()));
assertEquals("qualifier", new String(dependentColumnFilter.getQualifier()));
assertTrue(dependentColumnFilter.getDropDependentColumn());
assertEquals(CompareFilter.CompareOp.EQUAL, dependentColumnFilter.getOperator());
assertEquals(CompareOperator.EQUAL, dependentColumnFilter.getCompareOperator());
assertTrue(dependentColumnFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator)dependentColumnFilter.getComparator();
assertEquals("abc", new String(binaryComparator.getValue()));
@ -317,7 +318,7 @@ public class TestParseFilter {
doTestFilter(filterString, SingleColumnValueFilter.class);
assertEquals("family", new String(singleColumnValueFilter.getFamily()));
assertEquals("qualifier", new String(singleColumnValueFilter.getQualifier()));
assertEquals(singleColumnValueFilter.getOperator(), CompareFilter.CompareOp.GREATER_OR_EQUAL);
assertEquals(singleColumnValueFilter.getCompareOperator(), CompareOperator.GREATER_OR_EQUAL);
assertTrue(singleColumnValueFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator) singleColumnValueFilter.getComparator();
assertEquals(new String(binaryComparator.getValue()), "a");
@ -329,7 +330,7 @@ public class TestParseFilter {
singleColumnValueFilter = doTestFilter(filterString, SingleColumnValueFilter.class);
assertEquals("family", new String(singleColumnValueFilter.getFamily()));
assertEquals("qualifier", new String(singleColumnValueFilter.getQualifier()));
assertEquals(singleColumnValueFilter.getOperator(), CompareFilter.CompareOp.GREATER);
assertEquals(singleColumnValueFilter.getCompareOperator(), CompareOperator.GREATER);
assertTrue(singleColumnValueFilter.getComparator() instanceof BinaryPrefixComparator);
BinaryPrefixComparator binaryPrefixComparator =
(BinaryPrefixComparator) singleColumnValueFilter.getComparator();
@ -344,7 +345,7 @@ public class TestParseFilter {
"SingleColumnValueExcludeFilter ('family', 'qualifier', <, 'binaryprefix:a')";
SingleColumnValueExcludeFilter singleColumnValueExcludeFilter =
doTestFilter(filterString, SingleColumnValueExcludeFilter.class);
assertEquals(singleColumnValueExcludeFilter.getOperator(), CompareFilter.CompareOp.LESS);
assertEquals(singleColumnValueExcludeFilter.getCompareOperator(), CompareOperator.LESS);
assertEquals("family", new String(singleColumnValueExcludeFilter.getFamily()));
assertEquals("qualifier", new String(singleColumnValueExcludeFilter.getQualifier()));
assertEquals(new String(singleColumnValueExcludeFilter.getComparator().getValue()), "a");
@ -357,8 +358,8 @@ public class TestParseFilter {
doTestFilter(filterString, SingleColumnValueExcludeFilter.class);
assertEquals("family", new String(singleColumnValueExcludeFilter.getFamily()));
assertEquals("qualifier", new String(singleColumnValueExcludeFilter.getQualifier()));
assertEquals(singleColumnValueExcludeFilter.getOperator(),
CompareFilter.CompareOp.LESS_OR_EQUAL);
assertEquals(singleColumnValueExcludeFilter.getCompareOperator(),
CompareOperator.LESS_OR_EQUAL);
assertTrue(singleColumnValueExcludeFilter.getComparator() instanceof BinaryPrefixComparator);
BinaryPrefixComparator binaryPrefixComparator =
(BinaryPrefixComparator) singleColumnValueExcludeFilter.getComparator();
@ -375,7 +376,7 @@ public class TestParseFilter {
assertTrue(skipFilter.getFilter() instanceof ValueFilter);
ValueFilter valueFilter = (ValueFilter) skipFilter.getFilter();
assertEquals(CompareFilter.CompareOp.EQUAL, valueFilter.getOperator());
assertEquals(CompareOperator.EQUAL, valueFilter.getCompareOperator());
assertTrue(valueFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator) valueFilter.getComparator();
assertEquals("0", new String(binaryComparator.getValue()));
@ -389,7 +390,7 @@ public class TestParseFilter {
assertTrue(whileMatchFilter.getFilter() instanceof RowFilter);
RowFilter rowFilter = (RowFilter) whileMatchFilter.getFilter();
assertEquals(CompareFilter.CompareOp.NOT_EQUAL, rowFilter.getOperator());
assertEquals(CompareOperator.NOT_EQUAL, rowFilter.getCompareOperator());
assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
assertEquals("row1", new String(binaryComparator.getValue()));
@ -429,7 +430,7 @@ public class TestParseFilter {
assertTrue(filterListFilters.get(1) instanceof QualifierFilter);
assertEquals(filterList.getOperator(), FilterList.Operator.MUST_PASS_ALL);
assertEquals(CompareFilter.CompareOp.EQUAL, familyFilter.getOperator());
assertEquals(CompareOperator.EQUAL, familyFilter.getCompareOperator());
assertTrue(familyFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator) familyFilter.getComparator();
assertEquals("qualifier", new String(binaryComparator.getValue()));
@ -439,7 +440,7 @@ public class TestParseFilter {
assertEquals(new String(prefix), "realtime");
QualifierFilter qualifierFilter = (QualifierFilter) filterListFilters.get(1);
assertEquals(CompareFilter.CompareOp.GREATER_OR_EQUAL, qualifierFilter.getOperator());
assertEquals(CompareOperator.GREATER_OR_EQUAL, qualifierFilter.getCompareOperator());
assertTrue(qualifierFilter.getComparator() instanceof BinaryComparator);
binaryComparator = (BinaryComparator) qualifierFilter.getComparator();
assertEquals("e", new String(binaryComparator.getValue()));
@ -472,7 +473,7 @@ public class TestParseFilter {
assertTrue(skipFilter.getFilter() instanceof FamilyFilter);
FamilyFilter familyFilter = (FamilyFilter) skipFilter.getFilter();
assertEquals(CompareFilter.CompareOp.EQUAL, familyFilter.getOperator());
assertEquals(CompareOperator.EQUAL, familyFilter.getCompareOperator());
assertTrue(familyFilter.getComparator() instanceof SubstringComparator);
SubstringComparator substringComparator =
(SubstringComparator) familyFilter.getComparator();
@ -501,7 +502,7 @@ public class TestParseFilter {
assertTrue(skipFilter.getFilter() instanceof FamilyFilter);
FamilyFilter familyFilter = (FamilyFilter) skipFilter.getFilter();
assertEquals(CompareFilter.CompareOp.EQUAL, familyFilter.getOperator());
assertEquals(CompareOperator.EQUAL, familyFilter.getCompareOperator());
assertTrue(familyFilter.getComparator() instanceof SubstringComparator);
SubstringComparator substringComparator =
(SubstringComparator) familyFilter.getComparator();
@ -670,6 +671,4 @@ public class TestParseFilter {
assertEquals(clazz, filter.getClass());
return clazz.cast(filter);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.filter;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.testclassification.FilterTests;
@ -55,7 +56,7 @@ public class TestSingleColumnValueExcludeFilter {
@Test
public void testFilterKeyValue() throws Exception {
Filter filter = new SingleColumnValueExcludeFilter(COLUMN_FAMILY, COLUMN_QUALIFIER,
CompareOp.EQUAL, VAL_1);
CompareOperator.EQUAL, VAL_1);
// A 'match' situation
List<Cell> kvs = new ArrayList<>();

View File

@ -27,6 +27,7 @@ import java.util.regex.Pattern;
import org.apache.hadoop.hbase.ByteBufferKeyValue;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.testclassification.FilterTests;
@ -73,36 +74,36 @@ public class TestSingleColumnValueFilter {
private Filter basicFilterNew() {
return new SingleColumnValueFilter(COLUMN_FAMILY, COLUMN_QUALIFIER,
CompareOp.GREATER_OR_EQUAL, VAL_2);
CompareOperator.GREATER_OR_EQUAL, VAL_2);
}
private Filter nullFilterNew() {
return new SingleColumnValueFilter(COLUMN_FAMILY, COLUMN_QUALIFIER, CompareOp.NOT_EQUAL,
return new SingleColumnValueFilter(COLUMN_FAMILY, COLUMN_QUALIFIER, CompareOperator.NOT_EQUAL,
new NullComparator());
}
private Filter substrFilterNew() {
return new SingleColumnValueFilter(COLUMN_FAMILY, COLUMN_QUALIFIER,
CompareOp.EQUAL,
CompareOperator.EQUAL,
new SubstringComparator(QUICK_SUBSTR));
}
private Filter regexFilterNew() {
return new SingleColumnValueFilter(COLUMN_FAMILY, COLUMN_QUALIFIER,
CompareOp.EQUAL,
CompareOperator.EQUAL,
new RegexStringComparator(QUICK_REGEX));
}
private Filter regexFilterNew(Pattern pattern) {
return new SingleColumnValueFilter(COLUMN_FAMILY, COLUMN_QUALIFIER,
CompareOp.EQUAL,
CompareOperator.EQUAL,
new RegexStringComparator(pattern.pattern(), pattern.flags()));
}
@Test
public void testLongComparator() throws IOException {
Filter filter = new SingleColumnValueFilter(COLUMN_FAMILY,
COLUMN_QUALIFIER, CompareOp.GREATER, new LongComparator(100L));
COLUMN_QUALIFIER, CompareOperator.GREATER, new LongComparator(100L));
KeyValue kv = new KeyValue(ROW, COLUMN_FAMILY, COLUMN_QUALIFIER,
Bytes.toBytes(1L));
assertTrue("less than", filter.filterKeyValue(kv) == Filter.ReturnCode.NEXT_ROW);

View File

@ -27,6 +27,7 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.collections4.MapUtils;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.ServerName;
@ -570,15 +571,15 @@ public class ThriftUtilities {
}
}
public static CompareOp compareOpFromThrift(TCompareOp tCompareOp) {
public static CompareOperator compareOpFromThrift(TCompareOp tCompareOp) {
switch (tCompareOp.getValue()) {
case 0: return CompareOp.LESS;
case 1: return CompareOp.LESS_OR_EQUAL;
case 2: return CompareOp.EQUAL;
case 3: return CompareOp.NOT_EQUAL;
case 4: return CompareOp.GREATER_OR_EQUAL;
case 5: return CompareOp.GREATER;
case 6: return CompareOp.NO_OP;
case 0: return CompareOperator.LESS;
case 1: return CompareOperator.LESS_OR_EQUAL;
case 2: return CompareOperator.EQUAL;
case 3: return CompareOperator.NOT_EQUAL;
case 4: return CompareOperator.GREATER_OR_EQUAL;
case 5: return CompareOperator.GREATER;
case 6: return CompareOperator.NO_OP;
default: return null;
}
}

View File

@ -286,14 +286,14 @@ FilterList list = new FilterList(FilterList.Operator.MUST_PASS_ONE);
SingleColumnValueFilter filter1 = new SingleColumnValueFilter(
cf,
column,
CompareOp.EQUAL,
CompareOperator.EQUAL,
Bytes.toBytes("my value")
);
list.add(filter1);
SingleColumnValueFilter filter2 = new SingleColumnValueFilter(
cf,
column,
CompareOp.EQUAL,
CompareOperator.EQUAL,
Bytes.toBytes("my other value")
);
list.add(filter2);
@ -308,8 +308,8 @@ scan.setFilter(list);
A SingleColumnValueFilter (see:
http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.html)
can be used to test column values for equivalence (`CompareOp.EQUAL`),
inequality (`CompareOp.NOT_EQUAL`), or ranges (e.g., `CompareOp.GREATER`). The following is an
can be used to test column values for equivalence (`CompareOperaor.EQUAL`),
inequality (`CompareOperaor.NOT_EQUAL`), or ranges (e.g., `CompareOperaor.GREATER`). The following is an
example of testing equivalence of a column to a String value "my value"...
[source,java]
@ -317,7 +317,7 @@ example of testing equivalence of a column to a String value "my value"...
SingleColumnValueFilter filter = new SingleColumnValueFilter(
cf,
column,
CompareOp.EQUAL,
CompareOperaor.EQUAL,
Bytes.toBytes("my value")
);
scan.setFilter(filter);
@ -340,7 +340,7 @@ RegexStringComparator comp = new RegexStringComparator("my."); // any value th
SingleColumnValueFilter filter = new SingleColumnValueFilter(
cf,
column,
CompareOp.EQUAL,
CompareOperaor.EQUAL,
comp
);
scan.setFilter(filter);
@ -361,7 +361,7 @@ SubstringComparator comp = new SubstringComparator("y val"); // looking for 'm
SingleColumnValueFilter filter = new SingleColumnValueFilter(
cf,
column,
CompareOp.EQUAL,
CompareOperaor.EQUAL,
comp
);
scan.setFilter(filter);