hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1500217 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
Date Sat, 06 Jul 2013 07:31:09 GMT
Author: larsh
Date: Sat Jul  6 07:31:09 2013
New Revision: 1500217

URL: http://svn.apache.org/r1500217
Log:
HBASE-8809 Addendum to correctly hand versions in raw scans aswell (Jesse and LarsH)

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java?rev=1500217&r1=1500216&r2=1500217&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
Sat Jul  6 07:31:09 2013
@@ -164,7 +164,10 @@ public class ScanQueryMatcher {
     // seePastDeleteMarker: user initiated scans
     this.seePastDeleteMarkers = scanInfo.getKeepDeletedCells() && isUserScan;
 
-    int maxVersions = Math.min(scan.getMaxVersions(), scanInfo.getMaxVersions());
+    int maxVersions =
+        scan.isRaw() ? scan.getMaxVersions() : Math.min(scan.getMaxVersions(),
+          scanInfo.getMaxVersions());
+
     // Single branch to deal with two types of reads (columns vs all in family)
     if (columns == null || columns.size() == 0) {
       // there is always a null column in the wildcard column query.

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java?rev=1500217&r1=1500216&r2=1500217&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
Sat Jul  6 07:31:09 2013
@@ -45,6 +45,7 @@ import java.util.concurrent.ThreadPoolEx
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.impl.Log4JLogger;
@@ -4949,5 +4950,79 @@ public class TestFromClientSide {
     assertEquals(1, bar.length);
     assertEquals(2, bar[0].size());
   }
-}
 
+  @Test
+  public void testRawScanRespectsVersions() throws Exception {
+    byte[] TABLE = Bytes.toBytes("testRawScan");
+    HTable table = TEST_UTIL.createTable(TABLE, new byte[][] { FAMILY });
+    byte[] row = Bytes.toBytes("row");
+
+    // put the same row 4 times, with different values
+    Put p = new Put(row);
+    p.add(FAMILY, QUALIFIER, 10, VALUE);
+    table.put(p);
+    table.flushCommits();
+
+    p = new Put(row);
+    p.add(FAMILY, QUALIFIER, 11, ArrayUtils.add(VALUE, (byte) 2));
+    table.put(p);
+    table.flushCommits();
+
+    p = new Put(row);
+    p.add(FAMILY, QUALIFIER, 12, ArrayUtils.add(VALUE, (byte) 3));
+    table.put(p);
+    table.flushCommits();
+
+    p = new Put(row);
+    p.add(FAMILY, QUALIFIER, 13, ArrayUtils.add(VALUE, (byte) 4));
+    table.put(p);
+    table.flushCommits();
+
+    int versions = 4;
+    Scan s = new Scan(row);
+    // get all the possible versions
+    s.setMaxVersions();
+    s.setRaw(true);
+
+    ResultScanner scanner = table.getScanner(s);
+    int count = 0;
+    for (Result r : scanner) {
+      assertEquals("Found an unexpected number of results for the row!", versions, r.list().size());
+      count++;
+    }
+    assertEquals("Found more than a single row when raw scanning the table with a single
row!", 1,
+      count);
+    scanner.close();
+
+    // then if we decrease the number of versions, but keep the scan raw, we should see exactly
that
+    // number of versions
+    versions = 2;
+    s.setMaxVersions(versions);
+    scanner = table.getScanner(s);
+    count = 0;
+    for (Result r : scanner) {
+      assertEquals("Found an unexpected number of results for the row!", versions, r.list().size());
+      count++;
+    }
+    assertEquals("Found more than a single row when raw scanning the table with a single
row!", 1,
+      count);
+    scanner.close();
+
+    // finally, if we turn off raw scanning, but max out the number of versions, we should
go back
+    // to seeing just three
+    versions = 3;
+    s.setMaxVersions(versions);
+    scanner = table.getScanner(s);
+    count = 0;
+    for (Result r : scanner) {
+      assertEquals("Found an unexpected number of results for the row!", versions, r.list().size());
+      count++;
+    }
+    assertEquals("Found more than a single row when raw scanning the table with a single
row!", 1,
+      count);
+    scanner.close();
+
+    table.close();
+    TEST_UTIL.deleteTable(TABLE);
+  }
+}



Mime
View raw message