You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ji...@apache.org on 2008/04/08 20:56:37 UTC

svn commit: r646031 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Author: jimk
Date: Tue Apr  8 11:56:36 2008
New Revision: 646031

URL: http://svn.apache.org/viewvc?rev=646031&view=rev
Log:
HBASE-544   filters generate StackOverflowException

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=646031&r1=646030&r2=646031&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue Apr  8 11:56:36 2008
@@ -14,6 +14,7 @@
                0.0.0.0:60100 rather than relying on conf
    HBASE-507   Use Callable pattern to sleep between retries
    HBASE-564   Don't do a cache flush if there are zero entries in the cache.
+   HBASE-544   filters generate StackOverflowException
 
   NEW FEATURES
    HBASE-548   Tool to online single region

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=646031&r1=646030&r2=646031&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java Tue Apr  8 11:56:36 2008
@@ -1739,69 +1739,73 @@
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("null")
     public boolean next(HStoreKey key, SortedMap<Text, byte[]> results)
     throws IOException {
       boolean moreToFollow = false;
 
-      // Find the lowest-possible key.
+      do {
+        // Find the lowest-possible key.
 
-      Text chosenRow = null;
-      long chosenTimestamp = -1;
-      for (int i = 0; i < this.keys.length; i++) {
-        if (scanners[i] != null &&
-            (chosenRow == null ||
-                (keys[i].getRow().compareTo(chosenRow) < 0) ||
-                ((keys[i].getRow().compareTo(chosenRow) == 0) &&
-                    (keys[i].getTimestamp() > chosenTimestamp)))) {
-          chosenRow = new Text(keys[i].getRow());
-          chosenTimestamp = keys[i].getTimestamp();
+        Text chosenRow = null;
+        long chosenTimestamp = -1;
+        for (int i = 0; i < this.keys.length; i++) {
+          if (scanners[i] != null &&
+              (chosenRow == null ||
+                  (keys[i].getRow().compareTo(chosenRow) < 0) ||
+                  ((keys[i].getRow().compareTo(chosenRow) == 0) &&
+                      (keys[i].getTimestamp() > chosenTimestamp)))) {
+            chosenRow = new Text(keys[i].getRow());
+            chosenTimestamp = keys[i].getTimestamp();
+          }
         }
-      }
-
-      // Store the key and results for each sub-scanner. Merge them as
-      // appropriate.
-      if (chosenTimestamp >= 0) {
-        // Here we are setting the passed in key with current row+timestamp
-        key.setRow(chosenRow);
-        key.setVersion(chosenTimestamp);
-        key.setColumn(HConstants.EMPTY_TEXT);
 
-        for (int i = 0; i < scanners.length; i++) {
-          if (scanners[i] != null && keys[i].getRow().compareTo(chosenRow) == 0) {
-            // NOTE: We used to do results.putAll(resultSets[i]);
-            // but this had the effect of overwriting newer
-            // values with older ones. So now we only insert
-            // a result if the map does not contain the key.
-            for (Map.Entry<Text, byte[]> e : resultSets[i].entrySet()) {
-              if (!results.containsKey(e.getKey())) {
-                results.put(e.getKey(), e.getValue());
+        // Store the key and results for each sub-scanner. Merge them as
+        // appropriate.
+        if (chosenTimestamp >= 0) {
+          // Here we are setting the passed in key with current row+timestamp
+          key.setRow(chosenRow);
+          key.setVersion(chosenTimestamp);
+          key.setColumn(HConstants.EMPTY_TEXT);
+
+          for (int i = 0; i < scanners.length; i++) {
+            if (scanners[i] != null &&
+                keys[i].getRow().compareTo(chosenRow) == 0) {
+              // NOTE: We used to do results.putAll(resultSets[i]);
+              // but this had the effect of overwriting newer
+              // values with older ones. So now we only insert
+              // a result if the map does not contain the key.
+              for (Map.Entry<Text, byte[]> e : resultSets[i].entrySet()) {
+                if (!results.containsKey(e.getKey())) {
+                  results.put(e.getKey(), e.getValue());
+                }
+              }
+              resultSets[i].clear();
+              if (!scanners[i].next(keys[i], resultSets[i])) {
+                closeScanner(i);
               }
             }
+          }
+        }
+
+        for (int i = 0; i < scanners.length; i++) {
+          // If the current scanner is non-null AND has a lower-or-equal
+          // row label, then its timestamp is bad. We need to advance it.
+          while ((scanners[i] != null) &&
+              (keys[i].getRow().compareTo(chosenRow) <= 0)) {
             resultSets[i].clear();
             if (!scanners[i].next(keys[i], resultSets[i])) {
               closeScanner(i);
             }
           }
         }
-      }
 
-      for (int i = 0; i < scanners.length; i++) {
-        // If the current scanner is non-null AND has a lower-or-equal
-        // row label, then its timestamp is bad. We need to advance it.
-        while ((scanners[i] != null) &&
-            (keys[i].getRow().compareTo(chosenRow) <= 0)) {
-          resultSets[i].clear();
-          if (!scanners[i].next(keys[i], resultSets[i])) {
-            closeScanner(i);
-          }
+        moreToFollow = chosenTimestamp >= 0;
+        if (results == null || results.size() <= 0) {
+          // If we got no results, then there is no more to follow.
+          moreToFollow = false;
         }
-      }
-
-      moreToFollow = chosenTimestamp >= 0;
-      if (results == null || results.size() <= 0) {
-        // If we got no results, then there is no more to follow.
-        moreToFollow = false;
-      }
+      } while(filter != null && filter.filterNotNull(results) && moreToFollow);
 
       // Make sure scanners closed if no more results
       if (!moreToFollow) {
@@ -1810,11 +1814,6 @@
             closeScanner(i);
           }
         }
-      }
-      
-      if (filter != null && filter.filterNotNull(results)) {
-          LOG.warn("Filter return true on assembled Results in hstore");
-          return moreToFollow == true && this.next(key, results);
       }
       
       return moreToFollow;