HBASE-24887 Remove Row.compareTo

Closes #2262

Signed-off-by: Viraj Jasani <vjasani@apache.org>
Signed-off-by: Jan Hentschel <jan.hentschel@ultratendency.com>
This commit is contained in:
Joseph295 2020-08-17 17:19:17 +05:30 committed by Viraj Jasani
parent c81ef7368e
commit c8c20160da
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
6 changed files with 4 additions and 65 deletions

View File

@ -80,7 +80,7 @@ public class Action implements Comparable<Action> {
@Override
public int compareTo(Action other) {
return action.compareTo(other.getAction());
return Row.COMPARATOR.compare(action, other.getAction());
}
@Override

View File

@ -459,13 +459,6 @@ public class Get extends Query implements Row {
return map;
}
//Row
@Override
public int compareTo(Row other) {
// TODO: This is wrong. Can't have two gets the same just because on same row.
return Bytes.compareTo(this.getRow(), other.getRow());
}
@Override
public int hashCode() {
// TODO: This is wrong. Can't have two gets the same just because on same row. But it
@ -483,7 +476,7 @@ public class Get extends Query implements Row {
}
Row other = (Row) obj;
// TODO: This is wrong. Can't have two gets the same just because on same row.
return compareTo(other) == 0;
return Row.COMPARATOR.compare(this, other) == 0;
}
@Override

View File

@ -322,16 +322,6 @@ public abstract class Mutation extends OperationWithAttributes implements Row, C
return this.row;
}
/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Use {@link Row#COMPARATOR} instead
*/
@Deprecated
@Override
public int compareTo(final Row d) {
return Bytes.compareTo(this.getRow(), d.getRow());
}
/**
* Method for retrieving the timestamp.
*

View File

@ -72,9 +72,8 @@ public class RegionCoprocessorServiceExec implements Row {
return request;
}
@Override
public int compareTo(Row o) {
int res = Bytes.compareTo(this.getRow(), o.getRow());
int res = Row.COMPARATOR.compare(this, o);
if ((o instanceof RegionCoprocessorServiceExec) && res == 0) {
RegionCoprocessorServiceExec exec = (RegionCoprocessorServiceExec) o;
res = method.getFullName().compareTo(exec.getMethod().getFullName());

View File

@ -26,17 +26,10 @@ import org.apache.yetus.audience.InterfaceAudience;
* Has a row.
*/
@InterfaceAudience.Public
public interface Row extends Comparable<Row> {
public interface Row {
Comparator<Row> COMPARATOR = (v1, v2) -> Bytes.compareTo(v1.getRow(), v2.getRow());
/**
* @return The row.
*/
byte [] getRow();
/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Use {@link Row#COMPARATOR} instead
*/
@Deprecated
int compareTo(Row var1);
}

View File

@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.client;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -127,41 +126,6 @@ public class RowMutations implements Row {
return this;
}
/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Use {@link Row#COMPARATOR} instead
*/
@Deprecated
@Override
public int compareTo(Row i) {
return Bytes.compareTo(this.getRow(), i.getRow());
}
/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* No replacement
*/
@Deprecated
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj instanceof RowMutations) {
RowMutations other = (RowMutations)obj;
return compareTo(other) == 0;
}
return false;
}
/**
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* No replacement
*/
@Deprecated
@Override
public int hashCode(){
return Arrays.hashCode(row);
}
@Override
public byte[] getRow() {
return row;