accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [3/9] git commit: ACCUMULO-2870 Fail hard and fast if we don't calculate a midpoint.
Date Wed, 23 Jul 2014 16:07:55 GMT
ACCUMULO-2870 Fail hard and fast if we don't calculate a midpoint.

By failing early, we catch the change in functionality from FileUtil.findMidPoint
which always returns a mid-point. Also prevents an NPE from unexpectedly being thrown.


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

Branch: refs/heads/master
Commit: 3c513c894d711dd6d52e798a239b893ea94aa124
Parents: 9f3cbb3
Author: Josh Elser <elserj@apache.org>
Authored: Thu Jun 26 14:10:26 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Wed Jul 23 11:38:31 2014 -0400

----------------------------------------------------------------------
 .../apache/accumulo/server/tabletserver/Tablet.java    | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3c513c89/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 a6a5e88..a1fc707 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
@@ -3118,9 +3118,15 @@ public class Tablet {
       } else {
         lastRow = extent.getEndRow();
       }
-      
+
+      // We expect to get a midPoint for this set of files. If we don't get one, we have
a problem.
+      final Key mid = keys.get(.5);
+      if (null == mid) {
+        throw new IllegalStateException("Could not determine midpoint for files");
+      }
+
       // check to see that the midPoint is not equal to the end key
-      if (keys.get(.5).compareRow(lastRow) == 0) {
+      if (mid.compareRow(lastRow) == 0) {
         if (keys.firstKey() < .5) {
           Key candidate = keys.get(keys.firstKey());
           if (candidate.compareRow(lastRow) != 0) {
@@ -3140,8 +3146,7 @@ public class Tablet {
         
         return null;
       }
-      Key mid = keys.get(.5);
-      Text text = (mid == null) ? null : mid.getRow();
+      Text text = mid.getRow();
       SortedMap<Double,Key> firstHalf = keys.headMap(.5);
       if (firstHalf.size() > 0) {
         Text beforeMid = firstHalf.get(firstHalf.lastKey()).getRow();


Mime
View raw message