Repository: phoenix Updated Branches: refs/heads/master 507c7270c -> 787cae5b6
PHOENIX-2436 Remove usage of Guava ComparisonChain due to version incompatibilities (Kumar Palaniappan) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/787cae5b Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/787cae5b Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/787cae5b Branch: refs/heads/master Commit: 787cae5b60cc66a78d4a5989ab83b92c9b0b6e1b Parents: 507c727 Author: James Taylor <[email protected]> Authored: Thu Nov 19 13:34:39 2015 -0800 Committer: James Taylor <[email protected]> Committed: Thu Nov 19 13:36:26 2015 -0800 ---------------------------------------------------------------------- .../java/org/apache/phoenix/query/KeyRange.java | 34 ++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/787cae5b/phoenix-core/src/main/java/org/apache/phoenix/query/KeyRange.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/KeyRange.java b/phoenix-core/src/main/java/org/apache/phoenix/query/KeyRange.java index 366a123..6618aa5 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/KeyRange.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/KeyRange.java @@ -35,7 +35,6 @@ import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.ScanUtil.BytesComparator; import com.google.common.base.Function; -import com.google.common.collect.ComparisonChain; import com.google.common.collect.Lists; import edu.umd.cs.findbugs.annotations.NonNull; @@ -82,18 +81,27 @@ public class KeyRange implements Writable { }; public static final Comparator<KeyRange> COMPARATOR = new Comparator<KeyRange>() { @Override public int compare(KeyRange o1, KeyRange o2) { - return ComparisonChain.start() - .compareFalseFirst(o2.lowerUnbound(), o1.lowerUnbound()) - .compare(o1.getLowerRange(), o2.getLowerRange(), Bytes.BYTES_COMPARATOR) - // we want o1 lower inclusive to come before o2 lower inclusive, but - // false comes before true, so we have to negate - .compareFalseFirst(o2.isLowerInclusive(), o1.isLowerInclusive()) - // for the same lower bounding, we want a finite upper bound to - // be ordered before an infinite upper bound - .compareFalseFirst(o1.upperUnbound(), o2.upperUnbound()) - .compare(o1.getUpperRange(), o2.getUpperRange(), Bytes.BYTES_COMPARATOR) - .compareFalseFirst(o2.isUpperInclusive(), o1.isUpperInclusive()) - .result(); + int result = Boolean.compare(o2.lowerUnbound(), o1.lowerUnbound()); + if (result != 0) { + return result; + } + result = Bytes.BYTES_COMPARATOR.compare(o1.getLowerRange(), o2.getLowerRange()); + if (result != 0) { + return result; + } + result = Boolean.compare(o2.isLowerInclusive(), o1.isLowerInclusive()); + if (result != 0) { + return result; + } + result = Boolean.compare(o1.upperUnbound(), o2.upperUnbound()); + if (result != 0) { + return result; + } + result = Bytes.BYTES_COMPARATOR.compare(o1.getUpperRange(), o2.getUpperRange()); + if (result != 0) { + return result; + } + return Boolean.compare(o2.isUpperInclusive(), o1.isUpperInclusive()); } };
