Author: stack
Date: Fri Sep 16 20:40:26 2011
New Revision: 1171766

URL: http://svn.apache.org/viewvc?rev=1171766&view=rev
Log:
HBASE-4423 HBASE-4238 broke TestCatalogJanitor#testCleanParent test

Modified:
    hbase/branches/0.90/CHANGES.txt
    
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1171766&r1=1171765&r2=1171766&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Fri Sep 16 20:40:26 2011
@@ -49,6 +49,8 @@ Release 0.90.5 - Unreleased
                accurate region split problem summary (Jon Hsieh)
    HBASE-4417  HBaseAdmin.checkHBaseAvailable() doesn't close ZooKeeper 
connections
                (Stefan Seelmann)
+   HBASE-4423  HBASE-4238 broke TestCatalogJanitor#testCleanParent test
+               (ramkrishna.s.vasudevan)
 
   IMPROVEMENT
    HBASE-4205  Enhance HTable javadoc (Eric Charles)

Modified: 
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java
URL: 
http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java?rev=1171766&r1=1171765&r2=1171766&view=diff
==============================================================================
--- 
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java
 (original)
+++ 
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java
 Fri Sep 16 20:40:26 2011
@@ -646,12 +646,15 @@ public class MemStore implements HeapSiz
     private KeyValue snapshotNextRow = null;
 
     // iterator based scanning.
-    Iterator<KeyValue> kvsetIt;
-    Iterator<KeyValue> snapshotIt;
+    private Iterator<KeyValue> kvsetIt;
+    private Iterator<KeyValue> snapshotIt;
 
     // number of iterations in this reseek operation
-    int numIterReseek;
-    
+    private int numIterReseek;
+
+    // the pre-calculated KeyValue to be returned by peek() or next()
+    private KeyValue theNext;
+
     /*
     Some notes...
 
@@ -721,14 +724,14 @@ public class MemStore implements HeapSiz
       //    snapshot.size() + " threadread = " + readPoint);
 
 
-      KeyValue lowest = getLowest();
+      theNext = getLowest();
 
-      // has data := (lowest != null)
-      return lowest != null;
+      // has data := (theNext != null)
+      return theNext != null;
     }
 
     @Override
-    public boolean reseek(KeyValue key) {
+    public synchronized boolean reseek(KeyValue key) {
       numIterReseek = reseekNumKeys;
       while (kvsetNextRow != null &&
           comparator.compare(kvsetNextRow, key) < 0) {
@@ -751,17 +754,21 @@ public class MemStore implements HeapSiz
           return seek(key);
         }
       }
-      return (kvsetNextRow != null || snapshotNextRow != null);
+
+      theNext = getLowest();
+
+      // has data := (theNext != null)
+      return theNext != null;
     }
 
+    @Override
     public synchronized KeyValue peek() {
       //DebugPrint.println(" MS@" + hashCode() + " peek = " + getLowest());
-      return getLowest();
+      return theNext;
     }
 
-
+    @Override
     public synchronized KeyValue next() {
-      KeyValue theNext = getLowest();
 
       if (theNext == null) {
           return null;
@@ -777,7 +784,13 @@ public class MemStore implements HeapSiz
       //long readpoint = ReadWriteConsistencyControl.getThreadReadPoint();
       //DebugPrint.println(" MS@" + hashCode() + " next: " + theNext + " 
next_next: " +
       //    getLowest() + " threadpoint=" + readpoint);
-      return theNext;
+
+
+      final KeyValue ret = theNext;
+
+      theNext = getLowest();
+
+      return ret;
     }
 
     protected KeyValue getLowest() {
@@ -801,6 +814,7 @@ public class MemStore implements HeapSiz
       return (first != null ? first : second);
     }
 
+    @Override
     public synchronized void close() {
       this.kvsetNextRow = null;
       this.snapshotNextRow = null;


Reply via email to