You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2019/07/15 15:02:31 UTC

[accumulo] branch 2.0 updated: Make bulk load mapping matching more strict #1260 (#1269)

This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch 2.0
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.0 by this push:
     new 9a5ec83  Make bulk load mapping matching more strict #1260 (#1269)
9a5ec83 is described below

commit 9a5ec83baf2cae62268982ebb5230fb91ff2ef33
Author: Keith Turner <kt...@apache.org>
AuthorDate: Mon Jul 15 11:02:27 2019 -0400

    Make bulk load mapping matching more strict #1260 (#1269)
---
 .../master/tableOps/bulkVer2/LoadFiles.java        | 59 ++++++++++++++++------
 1 file changed, 43 insertions(+), 16 deletions(-)

diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/bulkVer2/LoadFiles.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/bulkVer2/LoadFiles.java
index e824782..98d59ed 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/bulkVer2/LoadFiles.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/bulkVer2/LoadFiles.java
@@ -19,11 +19,12 @@ package org.apache.accumulo.master.tableOps.bulkVer2;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
+import java.util.NoSuchElementException;
 import java.util.Set;
 
 import org.apache.accumulo.core.client.BatchWriter;
@@ -340,27 +341,53 @@ class LoadFiles extends MasterRepo {
     return sleepTime;
   }
 
+  private static final Comparator<Text> PREV_COMP = Comparator.nullsFirst(Text::compareTo);
+  private static final Comparator<Text> END_COMP = Comparator.nullsLast(Text::compareTo);
+
   /**
    * Find all the tablets within the provided bulk load mapping range.
    */
   private List<TabletMetadata> findOverlappingTablets(KeyExtent loadRange,
       Iterator<TabletMetadata> tabletIter) {
-    List<TabletMetadata> tablets = new ArrayList<>();
-    TabletMetadata currentTablet = tabletIter.next();
 
-    // skip tablets until we find the prevEndRow of loadRange
-    while (!Objects.equals(currentTablet.getPrevEndRow(), loadRange.getPrevEndRow())) {
-      currentTablet = tabletIter.next();
-    }
-    // we have found the first tablet in the range, add it to the list
-    tablets.add(currentTablet);
-
-    // find the remaining tablets within the loadRange by
-    // adding tablets to the list until the endRow matches the loadRange
-    while (!Objects.equals(currentTablet.getEndRow(), loadRange.getEndRow())) {
-      currentTablet = tabletIter.next();
-      tablets.add(currentTablet);
+    TabletMetadata currTablet = null;
+
+    try {
+
+      List<TabletMetadata> tablets = new ArrayList<>();
+      currTablet = tabletIter.next();
+
+      int cmp;
+
+      // skip tablets until we find the prevEndRow of loadRange
+      while ((cmp = PREV_COMP.compare(currTablet.getPrevEndRow(), loadRange.getPrevEndRow())) < 0) {
+        currTablet = tabletIter.next();
+      }
+
+      if (cmp != 0) {
+        throw new IllegalStateException("Unexpected prev end row " + currTablet + " " + loadRange);
+      }
+
+      // we have found the first tablet in the range, add it to the list
+      tablets.add(currTablet);
+
+      // find the remaining tablets within the loadRange by
+      // adding tablets to the list until the endRow matches the loadRange
+      while ((cmp = END_COMP.compare(currTablet.getEndRow(), loadRange.getEndRow())) < 0) {
+        currTablet = tabletIter.next();
+        tablets.add(currTablet);
+      }
+
+      if (cmp != 0) {
+        throw new IllegalStateException("Unexpected end row " + currTablet + " " + loadRange);
+      }
+
+      return tablets;
+    } catch (NoSuchElementException e) {
+      NoSuchElementException ne2 = new NoSuchElementException(
+          "Failed to find overlapping tablets " + currTablet + " " + loadRange);
+      ne2.initCause(e);
+      throw ne2;
     }
-    return tablets;
   }
 }