Skip to content

Commit

Permalink
HBASE-24887 Remove Row.compareTo
Browse files Browse the repository at this point in the history
Closes #2262

Signed-off-by: Viraj Jasani <vjasani@apache.org>
Signed-off-by: Jan Hentschel <jan.hentschel@ultratendency.com>
  • Loading branch information
ArthurSXL8 authored and virajjasani committed Aug 17, 2020
1 parent c81ef73 commit c8c2016
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public int getReplicaId() {

@Override
public int compareTo(Action other) {
return action.compareTo(other.getAction());
return Row.COMPARATOR.compare(action, other.getAction());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,6 @@ public Map<String, Object> toMap(int maxCols) {
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
Expand All @@ -483,7 +476,7 @@ public boolean equals(Object obj) {
}
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,6 @@ public boolean isEmpty() {
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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ public Message getRequest() {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,10 @@
* 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -127,41 +126,6 @@ public RowMutations add(List<? extends Mutation> mutations) throws IOException {
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;
Expand Down

0 comments on commit c8c2016

Please sign in to comment.