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 2022/10/05 15:14:19 UTC

[accumulo-testing] branch main updated: fixes two bulk import RW bugs

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 8e83d61  fixes two bulk import RW bugs
     new 2851a84  Merge pull request #235 from keith-turner/fix-rw-bulk
8e83d61 is described below

commit 8e83d616de85c784cf66f3680451a58b5420a523
Author: Keith Turner <kt...@apache.org>
AuthorDate: Wed Oct 5 13:08:07 2022 +0000

    fixes two bulk import RW bugs
    
    One bug is an off by one bug introduced when changing code from a loop to a stream. After that change the set was one larger than it used to be.
    
    The other bug is using a scanner outside of a try with resources block that closes the scanner.
---
 .../testing/randomwalk/bulk/BulkPlusOne.java       |  4 +--
 .../accumulo/testing/randomwalk/bulk/Verify.java   | 40 +++++++++++-----------
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/BulkPlusOne.java b/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/BulkPlusOne.java
index e13e259..448a7e2 100644
--- a/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/BulkPlusOne.java
+++ b/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/BulkPlusOne.java
@@ -59,8 +59,8 @@ public class BulkPlusOne extends BulkImportTest {
     log.debug("Bulk loading from {}", dir);
     final int parts = env.getRandom().nextInt(10) + 1;
 
-    TreeSet<Integer> startRows = Stream.generate(() -> env.getRandom().nextInt(LOTS)).limit(parts)
-        .collect(Collectors.toCollection(TreeSet::new));
+    TreeSet<Integer> startRows = Stream.generate(() -> env.getRandom().nextInt(LOTS))
+        .limit(parts - 1).collect(Collectors.toCollection(TreeSet::new));
     startRows.add(0);
 
     List<String> printRows = startRows.stream().map(row -> String.format(FMT, row))
diff --git a/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Verify.java b/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Verify.java
index 5034abb..016791c 100644
--- a/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Verify.java
+++ b/src/main/java/org/apache/accumulo/testing/randomwalk/bulk/Verify.java
@@ -77,33 +77,33 @@ public class Verify extends Test {
       scanner.clearColumns();
       scanner.fetchColumnFamily(BulkPlusOne.MARKER_CF);
       rowIter = new RowIterator(scanner);
-    }
 
-    while (rowIter.hasNext()) {
-      Iterator<Entry<Key,Value>> row = rowIter.next();
-      long prev = 0;
-      Text rowText = null;
-      while (row.hasNext()) {
-        Entry<Key,Value> entry = row.next();
+      while (rowIter.hasNext()) {
+        Iterator<Entry<Key,Value>> row = rowIter.next();
+        long prev = 0;
+        Text rowText = null;
+        while (row.hasNext()) {
+          Entry<Key,Value> entry = row.next();
 
-        if (rowText == null)
-          rowText = entry.getKey().getRow();
+          if (rowText == null)
+            rowText = entry.getKey().getRow();
 
-        long curr = Long.parseLong(entry.getKey().getColumnQualifier().toString());
+          long curr = Long.parseLong(entry.getKey().getColumnQualifier().toString());
 
-        if (curr - 1 != prev)
-          throw new Exception(
-              "Bad marker count " + entry.getKey() + " " + entry.getValue() + " " + prev);
+          if (curr - 1 != prev)
+            throw new Exception(
+                "Bad marker count " + entry.getKey() + " " + entry.getValue() + " " + prev);
 
-        if (!entry.getValue().toString().equals("1"))
-          throw new Exception("Bad marker value " + entry.getKey() + " " + entry.getValue());
+          if (!entry.getValue().toString().equals("1"))
+            throw new Exception("Bad marker value " + entry.getKey() + " " + entry.getValue());
 
-        prev = curr;
-      }
+          prev = curr;
+        }
 
-      if (BulkPlusOne.counter.get() != prev) {
-        throw new Exception("Row " + rowText + " does not have all markers "
-            + BulkPlusOne.counter.get() + " " + prev);
+        if (BulkPlusOne.counter.get() != prev) {
+          throw new Exception("Row " + rowText + " does not have all markers "
+              + BulkPlusOne.counter.get() + " " + prev);
+        }
       }
     }