Fixed a bug where the lsm rtree search cursor was not resetting correctly when it is closed and re-opened again. Minor variable renaming.

git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_lsm_tree@2881 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeAbstractCursor.java b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeAbstractCursor.java
index 2a463c8..289c904 100644
--- a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeAbstractCursor.java
+++ b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeAbstractCursor.java
@@ -29,8 +29,8 @@
     protected RTreeSearchCursor[] rtreeCursors;

     protected boolean open = false;

     protected ITreeIndexCursor[] btreeCursors;

-    protected ITreeIndexAccessor[] diskRTreeAccessors;

-    protected ITreeIndexAccessor[] diskBTreeAccessors;

+    protected ITreeIndexAccessor[] rTreeAccessors;

+    protected ITreeIndexAccessor[] bTreeAccessors;

     private MultiComparator btreeCmp;

     protected int numberOfTrees;

     protected SearchPredicate rtreeSearchPredicate;

@@ -61,8 +61,8 @@
         operationalComponents = lsmInitialState.getOperationalComponents();

         lsmHarness = lsmInitialState.getLSMHarness();

         numberOfTrees = lsmInitialState.getNumberOfTrees();

-        diskRTreeAccessors = lsmInitialState.getRTreeAccessors();

-        diskBTreeAccessors = lsmInitialState.getBTreeAccessors();

+        rTreeAccessors = lsmInitialState.getRTreeAccessors();

+        bTreeAccessors = lsmInitialState.getBTreeAccessors();

 

         rtreeCursors = new RTreeSearchCursor[numberOfTrees];

         btreeCursors = new ITreeIndexCursor[numberOfTrees];

diff --git a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSearchCursor.java b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSearchCursor.java
index d898f6c..966ed8d 100644
--- a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSearchCursor.java
+++ b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSearchCursor.java
@@ -24,11 +24,17 @@
 
 public class LSMRTreeSearchCursor extends LSMRTreeAbstractCursor {
 
-    private int currentCursror;
+    private int currentCursor;
 
     public LSMRTreeSearchCursor(ILSMIndexOperationContext opCtx) {
         super(opCtx);
-        currentCursror = 0;
+        currentCursor = 0;
+    }
+
+    @Override
+    public void close() throws HyracksDataException {
+        super.close();
+        currentCursor = 0;
     }
 
     @Override
@@ -37,7 +43,7 @@
             return;
         }
 
-        currentCursror = 0;
+        currentCursor = 0;
         foundNext = false;
         try {
             for (int i = 0; i < numberOfTrees; i++) {
@@ -52,10 +58,10 @@
     }
 
     private void searchNextCursor() throws HyracksDataException {
-        if (currentCursror < numberOfTrees) {
-            rtreeCursors[currentCursror].reset();
+        if (currentCursor < numberOfTrees) {
+            rtreeCursors[currentCursor].reset();
             try {
-                diskRTreeAccessors[currentCursror].search(rtreeCursors[currentCursror], rtreeSearchPredicate);
+                rTreeAccessors[currentCursor].search(rtreeCursors[currentCursor], rtreeSearchPredicate);
             } catch (IndexException e) {
                 throw new HyracksDataException(e);
             }
@@ -67,18 +73,18 @@
         if (foundNext) {
             return true;
         }
-        while (currentCursror < numberOfTrees) {
-            while (rtreeCursors[currentCursror].hasNext()) {
-                rtreeCursors[currentCursror].next();
-                ITupleReference currentTuple = rtreeCursors[currentCursror].getTuple();
+        while (currentCursor < numberOfTrees) {
+            while (rtreeCursors[currentCursor].hasNext()) {
+                rtreeCursors[currentCursor].next();
+                ITupleReference currentTuple = rtreeCursors[currentCursor].getTuple();
 
                 boolean killerTupleFound = false;
-                for (int i = 0; i <= currentCursror; i++) {
+                for (int i = 0; i <= currentCursor; i++) {
                     try {
                         btreeCursors[i].reset();
                         btreeRangePredicate.setHighKey(currentTuple, true);
                         btreeRangePredicate.setLowKey(currentTuple, true);
-                        diskBTreeAccessors[i].search(btreeCursors[i], btreeRangePredicate);
+                        bTreeAccessors[i].search(btreeCursors[i], btreeRangePredicate);
                     } catch (IndexException e) {
                         throw new HyracksDataException(e);
                     }
@@ -97,8 +103,8 @@
                     return true;
                 }
             }
-            rtreeCursors[currentCursror].close();
-            currentCursror++;
+            rtreeCursors[currentCursor].close();
+            currentCursor++;
             searchNextCursor();
         }
         return false;
diff --git a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSortedCursor.java b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSortedCursor.java
index f691839..02a1876 100644
--- a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSortedCursor.java
+++ b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSortedCursor.java
@@ -44,7 +44,7 @@
             for (int i = 0; i < numberOfTrees; i++) {
                 rtreeCursors[i].reset();
                 try {
-                    diskRTreeAccessors[i].search(rtreeCursors[i], rtreeSearchPredicate);
+                    rTreeAccessors[i].search(rtreeCursors[i], rtreeSearchPredicate);
                 } catch (IndexException e) {
                     throw new HyracksDataException(e);
                 }
@@ -103,7 +103,7 @@
                     btreeCursors[i].reset();
                     btreeRangePredicate.setHighKey(frameTuple, true);
                     btreeRangePredicate.setLowKey(frameTuple, true);
-                    diskBTreeAccessors[i].search(btreeCursors[i], btreeRangePredicate);
+                    bTreeAccessors[i].search(btreeCursors[i], btreeRangePredicate);
                 } catch (IndexException e) {
                     throw new HyracksDataException(e);
                 }
@@ -138,7 +138,7 @@
         for (int i = 0; i < numberOfTrees; i++) {
             rtreeCursors[i].reset();
             try {
-                diskRTreeAccessors[i].search(rtreeCursors[i], rtreeSearchPredicate);
+                rTreeAccessors[i].search(rtreeCursors[i], rtreeSearchPredicate);
             } catch (IndexException e) {
                 throw new HyracksDataException(e);
             }