Skip to content

Commit

Permalink
HBASE-22232 Removed deprecated methods in CompareFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
HorizonNet committed Apr 23, 2019
1 parent 1584d24 commit 1f0e43a
Show file tree
Hide file tree
Showing 24 changed files with 34 additions and 576 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.client.coprocessor.Batch.Callback;
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
Expand Down Expand Up @@ -667,13 +666,6 @@ public boolean checkAndPut(final byte [] row, final byte [] family, final byte [
return doCheckAndPut(row, family, qualifier, CompareOperator.EQUAL.name(), value, null, put);
}

@Override
@Deprecated
public boolean checkAndPut(final byte [] row, final byte [] family, final byte [] qualifier,
final CompareOp compareOp, final byte [] value, final Put put) throws IOException {
return doCheckAndPut(row, family, qualifier, compareOp.name(), value, null, put);
}

@Override
@Deprecated
public boolean checkAndPut(final byte [] row, final byte [] family, final byte [] qualifier,
Expand Down Expand Up @@ -711,13 +703,6 @@ public boolean checkAndDelete(final byte[] row, final byte[] family, final byte[
delete);
}

@Override
@Deprecated
public boolean checkAndDelete(final byte[] row, final byte[] family, final byte[] qualifier,
final CompareOp compareOp, final byte[] value, final Delete delete) throws IOException {
return doCheckAndDelete(row, family, qualifier, compareOp.name(), value, null, delete);
}

@Override
@Deprecated
public boolean checkAndDelete(final byte[] row, final byte[] family, final byte[] qualifier,
Expand Down Expand Up @@ -816,14 +801,6 @@ protected MultiResponse rpcCall() throws Exception {
return ((Result)results[0]).getExists();
}

@Override
@Deprecated
public boolean checkAndMutate(final byte [] row, final byte [] family, final byte [] qualifier,
final CompareOp compareOp, final byte [] value, final RowMutations rm)
throws IOException {
return doCheckAndMutate(row, family, qualifier, compareOp.name(), value, null, rm);
}

@Override
@Deprecated
public boolean checkAndMutate(final byte [] row, final byte [] family, final byte [] qualifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
import org.apache.hadoop.hbase.util.Bytes;
Expand Down Expand Up @@ -305,35 +304,6 @@ default boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[]
return checkAndPut(row, family, qualifier, CompareOperator.EQUAL, value, put);
}

/**
* Atomically checks if a row/family/qualifier value matches the expected
* value. If it does, it adds the put. If the passed value is null, the check
* is for the lack of column (ie: non-existence)
*
* The expected value argument of this call is on the left and the current
* value of the cell is on the right side of the comparison operator.
*
* Ie. eg. GREATER operator means expected value > existing <=> add the put.
*
* @param row to check
* @param family column family to check
* @param qualifier column qualifier to check
* @param compareOp comparison operator to use
* @param value the expected value
* @param put data to put if check succeeds
* @throws IOException e
* @return true if the new put was executed, false otherwise
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])}
*/
@Deprecated
default boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
CompareFilter.CompareOp compareOp, byte[] value, Put put) throws IOException {
RowMutations mutations = new RowMutations(put.getRow(), 1);
mutations.add(put);

return checkAndMutate(row, family, qualifier, compareOp, value, mutations);
}

/**
* Atomically checks if a row/family/qualifier value matches the expected
* value. If it does, it adds the put. If the passed value is null, the check
Expand Down Expand Up @@ -421,35 +391,6 @@ default boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
return checkAndDelete(row, family, qualifier, CompareOperator.EQUAL, value, delete);
}

/**
* Atomically checks if a row/family/qualifier value matches the expected
* value. If it does, it adds the delete. If the passed value is null, the
* check is for the lack of column (ie: non-existence)
*
* The expected value argument of this call is on the left and the current
* value of the cell is on the right side of the comparison operator.
*
* Ie. eg. GREATER operator means expected value > existing <=> add the delete.
*
* @param row to check
* @param family column family to check
* @param qualifier column qualifier to check
* @param compareOp comparison operator to use
* @param value the expected value
* @param delete data to delete if check succeeds
* @throws IOException e
* @return true if the new delete was executed, false otherwise
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])}
*/
@Deprecated
default boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException {
RowMutations mutations = new RowMutations(delete.getRow(), 1);
mutations.add(delete);

return checkAndMutate(row, family, qualifier, compareOp, value, mutations);
}

/**
* Atomically checks if a row/family/qualifier value matches the expected
* value. If it does, it adds the delete. If the passed value is null, the
Expand Down Expand Up @@ -790,32 +731,6 @@ default <R extends Message> void batchCoprocessorService(
throw new NotImplementedException("Add an implementation!");
}

/**
* Atomically checks if a row/family/qualifier value matches the expected value.
* If it does, it performs the row mutations. If the passed value is null, the check
* is for the lack of column (ie: non-existence)
*
* The expected value argument of this call is on the left and the current
* value of the cell is on the right side of the comparison operator.
*
* Ie. eg. GREATER operator means expected value > existing <=> perform row mutations.
*
* @param row to check
* @param family column family to check
* @param qualifier column qualifier to check
* @param compareOp the comparison operator
* @param value the expected value
* @param mutation mutations to perform if check succeeds
* @throws IOException e
* @return true if the new put was executed, false otherwise
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])}
*/
@Deprecated
default boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier,
CompareFilter.CompareOp compareOp, byte[] value, RowMutations mutation) throws IOException {
throw new NotImplementedException("Add an implementation!");
}

/**
* Atomically checks if a row/family/qualifier value matches the expected value.
* If it does, it performs the row mutations. If the passed value is null, the check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.hbase.filter;

import java.io.IOException;
Expand Down Expand Up @@ -55,46 +54,9 @@
*/
@InterfaceAudience.Public
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.
* @deprecated since 2.0.0. Will be removed in 3.0.0. Use {@link CompareOperator} instead.
*/
@Deprecated
@InterfaceAudience.Public
public enum CompareOp {
/** less than */
LESS,
/** less than or equal to */
LESS_OR_EQUAL,
/** equals */
EQUAL,
/** not equal */
NOT_EQUAL,
/** greater than or equal to */
GREATER_OR_EQUAL,
/** greater than */
GREATER,
/** no operation */
NO_OP,
}

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(CompareOperator.valueOf(compareOp.name()), comparator);
}

/**
* Constructor.
* @param op the compare op for row matching
Expand All @@ -106,15 +68,6 @@ public CompareFilter(final CompareOperator 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.valueOf(op.name());
}

public CompareOperator getCompareOperator() {
return op;
}
Expand All @@ -132,20 +85,6 @@ public boolean filterRowKey(Cell cell) throws IOException {
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) {
return true;
}
int compareResult = PrivateCellUtil.compareRow(cell, comparator);
return compare(compareOp, compareResult);
}

protected boolean compareRow(final CompareOperator op, final ByteArrayComparable comparator,
final Cell cell) {
if (op == CompareOperator.NO_OP) {
Expand All @@ -155,20 +94,6 @@ protected boolean compareRow(final CompareOperator op, final ByteArrayComparable
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) {
return true;
}
int compareResult = PrivateCellUtil.compareFamily(cell, comparator);
return compare(compareOp, compareResult);
}

protected boolean compareFamily(final CompareOperator op, final ByteArrayComparable comparator,
final Cell cell) {
if (op == CompareOperator.NO_OP) {
Expand All @@ -178,21 +103,6 @@ protected boolean compareFamily(final CompareOperator op, final ByteArrayCompara
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;
}
int compareResult = PrivateCellUtil.compareQualifier(cell, comparator);
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.
Expand All @@ -203,21 +113,6 @@ protected boolean compareQualifier(final CompareOperator op,
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;
}
int compareResult = PrivateCellUtil.compareValue(cell, comparator);
return compare(compareOp, compareResult);
}

protected boolean compareValue(final CompareOperator op, final ByteArrayComparable comparator,
final Cell cell) {
if (op == CompareOperator.NO_OP) {
Expand All @@ -227,25 +122,6 @@ protected boolean compareValue(final CompareOperator op, final ByteArrayComparab
return compare(op, compareResult);
}

static boolean compare(final CompareOp 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());
}
}

static boolean compare(final CompareOperator op, int compareResult) {
switch (op) {
case LESS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,6 @@ public class DependentColumnFilter extends CompareFilter {
protected boolean dropDependentColumn;

protected Set<Long> stampSet = new HashSet<>();

/**
* 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 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
Expand Down Expand Up @@ -123,7 +100,7 @@ public DependentColumnFilter(final byte [] family, final byte [] qualifier) {
*/
public DependentColumnFilter(final byte [] family, final byte [] qualifier,
final boolean dropDependentColumn) {
this(family, qualifier, dropDependentColumn, CompareOp.NO_OP, null);
this(family, qualifier, dropDependentColumn, CompareOperator.NO_OP, null);
}

/**
Expand Down
Loading

0 comments on commit 1f0e43a

Please sign in to comment.