accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1434696 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/file/rfile/RFile.java test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
Date Thu, 17 Jan 2013 14:45:57 GMT
Author: kturner
Date: Thu Jan 17 14:45:57 2013
New Revision: 1434696

URL: http://svn.apache.org/viewvc?rev=1434696&view=rev
Log:
ACCUMULO-962 fixed issue where rfile would read more data than it was supposed to.  Added
unit test that reproduced the bug.

Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java?rev=1434696&r1=1434695&r2=1434696&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java Thu Jan
17 14:45:57 2013
@@ -642,6 +642,7 @@ public class RFile {
     private void _seek(Range range) throws IOException {
       
       this.range = range;
+      this.checkRange = true;
       
       if (blockCount == 0) {
         // its an empty file

Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java?rev=1434696&r1=1434695&r2=1434696&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java (original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java Thu
Jan 17 14:45:57 2013
@@ -28,6 +28,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Random;
@@ -1442,6 +1443,63 @@ public class RFileTest {
     trf.closeReader();
   }
   
+  @Test
+  public void testReseekUnconsumed() throws Exception {
+    TestRFile trf = new TestRFile();
+    
+    trf.openWriter();
+    
+    for (int i = 0; i < 2500; i++) {
+      trf.writer.append(nk(nf("r_", i), "cf1", "cq1", "L1", 42), nv("foo" + i));
+    }
+    
+    trf.closeWriter();
+    trf.openReader();
+    
+    Set<ByteSequence> cfs = Collections.emptySet();
+
+    Random rand = new Random();
+
+    for (int count = 0; count < 100; count++) {
+      
+      int start = rand.nextInt(2300);
+      Range range = new Range(nk(nf("r_", start), "cf1", "cq1", "L1", 42), nk(nf("r_", start
+ 100), "cf1", "cq1", "L1", 42));
+
+      trf.reader.seek(range, cfs, false);
+      
+      int numToScan = rand.nextInt(100);
+      
+      for (int j = 0; j < numToScan; j++) {
+        assertTrue(trf.reader.hasTop());
+        assertEquals(nk(nf("r_", start + j), "cf1", "cq1", "L1", 42), trf.reader.getTopKey());
+        trf.reader.next();
+      }
+      
+      assertTrue(trf.reader.hasTop());
+      assertEquals(nk(nf("r_", start + numToScan), "cf1", "cq1", "L1", 42), trf.reader.getTopKey());
+
+      // seek a little forward from the last range and read a few keys within the unconsumed
portion of the last range
+
+      int start2 = start + numToScan + rand.nextInt(3);
+      int end2 = start2 + rand.nextInt(3);
+
+      range = new Range(nk(nf("r_", start2), "cf1", "cq1", "L1", 42), nk(nf("r_", end2),
"cf1", "cq1", "L1", 42));
+      trf.reader.seek(range, cfs, false);
+      
+      for (int j = start2; j <= end2; j++) {
+        assertTrue(trf.reader.hasTop());
+        assertEquals(nk(nf("r_", j), "cf1", "cq1", "L1", 42), trf.reader.getTopKey());
+        trf.reader.next();
+      }
+      
+      assertFalse(trf.reader.hasTop());
+
+    }
+    
+    trf.closeReader();
+  }
+
+
   @Test(expected = NullPointerException.class)
   public void testMissingUnreleasedVersions() throws Exception {
     runVersionTest(5);



Mime
View raw message