fixed bug in lsmbtree insert

git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_lsm_tree@1688 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java b/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
index 8c8e7c0..7976cc7 100644
--- a/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
+++ b/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
@@ -228,6 +228,7 @@
         IIndexCursor memCursor = new BTreeRangeSearchCursor(ctx.memBTreeOpCtx.leafFrame, false);
         RangePredicate predicate = new RangePredicate(tuple, tuple, true, true, comparator, comparator);
 
+        // first check the inmemory component
         ctx.memBTreeAccessor.search(memCursor, predicate);
         try {
             if (memCursor.hasNext()) {
@@ -235,12 +236,17 @@
                 LSMBTreeTupleReference lsmbtreeTuple = (LSMBTreeTupleReference) memCursor.getTuple();
                 if (!lsmbtreeTuple.isAntimatter()) {
                     throw new BTreeDuplicateKeyException("Failed to insert key since key already exists.");
+                } else {
+                    memCursor.close();
+                    ctx.memBTreeAccessor.upsertIfConditionElseInsert(tuple, acceptor);
+                    return true;
                 }
             }
         } finally {
             memCursor.close();
         }
 
+        // the key was not in the inmemory component, so check the disk components
         lsmHarness.search(searchCursor, predicate, ctx, false);
         try {
             if (searchCursor.hasNext()) {