accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/9] accumulo git commit: ACCUMULO-3466 Shortcircuit Range.mergeOverlapping for one range.
Date Sat, 10 Jan 2015 00:59:31 GMT
ACCUMULO-3466 Shortcircuit Range.mergeOverlapping for one range.

Make sure callers don't try to do things to the immutable list of size 1.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/19cd2099
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/19cd2099
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/19cd2099

Branch: refs/heads/1.6
Commit: 19cd209981e09c78299c87addace719037994b85
Parents: 9827b05
Author: Josh Elser <elserj@apache.org>
Authored: Fri Jan 9 18:42:49 2015 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Jan 9 18:42:49 2015 -0500

----------------------------------------------------------------------
 core/src/main/java/org/apache/accumulo/core/data/Range.java      | 2 ++
 .../java/org/apache/accumulo/server/tabletserver/Tablet.java     | 4 +++-
 .../apache/accumulo/test/randomwalk/sequential/BatchVerify.java  | 4 +++-
 3 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/19cd2099/core/src/main/java/org/apache/accumulo/core/data/Range.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/data/Range.java b/core/src/main/java/org/apache/accumulo/core/data/Range.java
index 0d40289..59f7aa8 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Range.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Range.java
@@ -381,6 +381,8 @@ public class Range implements WritableComparable<Range> {
   public static List<Range> mergeOverlapping(Collection<Range> ranges) {
     if (ranges.size() == 0)
       return Collections.emptyList();
+    if (ranges.size() == 1)
+      return Collections.singletonList(ranges.iterator().next());
 
     List<Range> ral = new ArrayList<Range>(ranges);
     Collections.sort(ral);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/19cd2099/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java b/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
index 21ab7e4..96856ae 100644
--- a/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
+++ b/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
@@ -1717,7 +1717,9 @@ public class Tablet {
     }
 
     ranges = Range.mergeOverlapping(ranges);
-    Collections.sort(ranges);
+    if (ranges.size() > 1) {
+      Collections.sort(ranges);
+    }
 
     Range tabletRange = extent.toDataRange();
     for (Range range : ranges) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/19cd2099/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/BatchVerify.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/BatchVerify.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/BatchVerify.java
index 12cb18b..55f4e32 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/BatchVerify.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/sequential/BatchVerify.java
@@ -66,7 +66,9 @@ public class BatchVerify extends Test {
       }
 
       ranges = Range.mergeOverlapping(ranges);
-      Collections.sort(ranges);
+      if (ranges.size() > 1) {
+        Collections.sort(ranges);
+      }
 
       if (count == 0 || ranges.size() == 0)
         return;


Mime
View raw message