hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r668822 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/regionserver/Memcache.java src/test/org/apache/hadoop/hbase/regionserver/TestHMemcache.java
Date Tue, 17 Jun 2008 20:49:10 GMT
Author: jimk
Date: Tue Jun 17 13:49:10 2008
New Revision: 668822

URL: http://svn.apache.org/viewvc?rev=668822&view=rev
Log:
HBASE-686   MemcacheScanner didn't return the first row(if it exists), because HScannerInterface's
output incorrect (LN via Jim Kellerman)

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHMemcache.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=668822&r1=668821&r2=668822&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue Jun 17 13:49:10 2008
@@ -52,6 +52,8 @@
                (LN via Stack)
    HBASE-682   Unnecessary iteration in HMemcache.internalGet? got much better
                reading performance after break it (LN via Stack)
+   HBASE-686   MemcacheScanner didn't return the first row(if it exists),
+               because HScannerInterface's output incorrect (LN via Jim Kellerman)
    
   IMPROVEMENTS
    HBASE-559   MR example job to count table rows

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java?rev=668822&r1=668821&r2=668822&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java Tue Jun
17 13:49:10 2008
@@ -421,8 +421,7 @@
           // take note of the row of this candidate so that we'll know when
           // we cross the row boundary into the previous row.
           if (!HLogEdit.isDeleted(headMap.get(thisKey))) {
-            if (ttl == HConstants.FOREVER ||
-                    now < found_key.getTimestamp() + ttl) {
+            if (ttl == HConstants.FOREVER) {
               lastRowFound = thisKey.getRow();
               candidateKeys.put(stripTimestamp(thisKey), 
                 new Long(thisKey.getTimestamp()));
@@ -698,8 +697,7 @@
       if (results.size() > 0) {
         results.clear();
       }
-      while (results.size() <= 0 &&
-          (this.currentRow = getNextRow(this.currentRow)) != null) {
+      while (results.size() <= 0 && this.currentRow != null) {
         if (deletes.size() > 0) {
           deletes.clear();
         }
@@ -727,6 +725,8 @@
           }
           results.put(column, c.getValue());
         }
+        this.currentRow = getNextRow(this.currentRow);
+
       }
       return results.size() > 0;
     }

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHMemcache.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHMemcache.java?rev=668822&r1=668821&r2=668822&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHMemcache.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestHMemcache.java Tue
Jun 17 13:49:10 2008
@@ -304,4 +304,42 @@
   private HStoreKey getHSKForRow(byte [] row) {
     return new HStoreKey(row, Bytes.toBytes("test_col:"), HConstants.LATEST_TIMESTAMP);
   }
+
+  /**
+   * Test memcache scanner scanning cached rows, HBASE-686
+   * @throws IOException
+   */
+  public void testScanner_686() throws IOException {
+    addRows(this.hmemcache);
+    long timestamp = System.currentTimeMillis();
+    byte[][] cols = new byte[COLUMNS_COUNT * ROW_COUNT][];
+    for (int i = 0; i < ROW_COUNT; i++) {
+      for (int ii = 0; ii < COLUMNS_COUNT; ii++) {
+        cols[(ii + (i * COLUMNS_COUNT))] = getColumnName(i, ii);
+      }
+    }
+    //starting from each row, validate results should contain the starting row
+    for (int startRowId = 0; startRowId < ROW_COUNT; startRowId++) {
+      InternalScanner scanner = this.hmemcache.getScanner(timestamp,
+          cols, getRowName(startRowId));
+      HStoreKey key = new HStoreKey();
+      TreeMap<byte[], byte[]> results =
+        new TreeMap<byte[], byte[]>(Bytes.BYTES_COMPARATOR);
+      for (int i = 0; scanner.next(key, results); i++) {
+        int rowId = startRowId + i;
+        assertTrue("Row name",
+            key.toString().startsWith(Bytes.toString(getRowName(rowId))));
+        assertEquals("Count of columns", COLUMNS_COUNT, results.size());
+        TreeMap<byte[], Cell> row =
+          new TreeMap<byte[], Cell>(Bytes.BYTES_COMPARATOR);
+        for (Map.Entry<byte[], byte[]> e : results.entrySet()) {
+          row.put(e.getKey(),
+              new Cell(e.getValue(), HConstants.LATEST_TIMESTAMP));
+        }
+        isExpectedRow(rowId, row);
+        // Clear out set.  Otherwise row results accumulate.
+        results.clear();
+      }
+    }
+  }
 }
\ No newline at end of file



Mime
View raw message