Various bug and performance fixes for the lsm indexes.
diff --git a/hyracks/hyracks-storage-am-bloomfilter/src/main/java/edu/uci/ics/hyracks/storage/am/bloomfilter/impls/BloomFilter.java b/hyracks/hyracks-storage-am-bloomfilter/src/main/java/edu/uci/ics/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
index fdfa39a..957659b 100644
--- a/hyracks/hyracks-storage-am-bloomfilter/src/main/java/edu/uci/ics/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
+++ b/hyracks/hyracks-storage-am-bloomfilter/src/main/java/edu/uci/ics/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
@@ -82,6 +82,9 @@
}
public boolean contains(ITupleReference tuple, long[] hashes) throws HyracksDataException {
+ if (numPages == 0) {
+ return false;
+ }
MurmurHash128Bit.hash3_x64_128(tuple, keyFields, SEED, hashes);
for (int i = 0; i < numHashes; ++i) {
long hash = Math.abs((hashes[0] + (long) i * hashes[1]) % numBits);
@@ -210,7 +213,7 @@
throw new HyracksDataException("Failed to create the bloom filter builder since it is not activated.");
}
- this.numElements = numElements == 0 ? 1 : numElements;
+ this.numElements = numElements;
this.numHashes = numHashes;
numBits = this.numElements * numBitsPerElement;
long tmp = (long) Math.ceil(numBits / (double) numBitsPerPage);
@@ -263,6 +266,10 @@
@Override
public void add(ITupleReference tuple) throws IndexException, HyracksDataException {
+ if (numPages == 0) {
+ throw new HyracksDataException(
+ "Cannot add elements to this filter since it is supposed to be empty (number of elements hint passed to the filter during construction was 0).");
+ }
MurmurHash128Bit.hash3_x64_128(tuple, keyFields, SEED, hashes);
for (int i = 0; i < numHashes; ++i) {
long hash = Math.abs((hashes[0] + (long) i * hashes[1]) % numBits);
diff --git a/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java b/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java
index 6451173..ff0d9e3 100644
--- a/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java
+++ b/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java
@@ -295,6 +295,7 @@
break;
case FULL_MERGE:
operationalComponents.addAll(immutableComponents);
+ break;
default:
throw new UnsupportedOperationException("Operation " + ctx.getOperation() + " not supported.");
}
diff --git a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
index 7142929..2b9714d 100644
--- a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
+++ b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
@@ -61,8 +61,6 @@
protected final int[] comparatorFields;
protected final IBinaryComparatorFactory[] linearizerArray;
- protected TreeTupleSorter rTreeTupleSorter;
-
// On-disk components.
// For creating RTree's used in flush and merge.
protected final ILSMComponentFactory componentFactory;
@@ -115,7 +113,6 @@
this.linearizer = linearizer;
this.comparatorFields = comparatorFields;
this.linearizerArray = linearizerArray;
- rTreeTupleSorter = null;
}
@Override
@@ -225,6 +222,7 @@
break;
case FULL_MERGE:
operationalComponents.addAll(immutableComponents);
+ break;
default:
throw new UnsupportedOperationException("Operation " + ctx.getOperation() + " not supported.");
}
diff --git a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java
index e14282d..0d35ab3 100644
--- a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java
+++ b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java
@@ -206,9 +206,9 @@
IBinaryComparatorFactory[] linearizerArray = { linearizer };
- rTreeTupleSorter = new TreeTupleSorter(flushingComponent.getRTree().getFileId(), linearizerArray,
- rtreeLeafFrameFactory.createFrame(), rtreeLeafFrameFactory.createFrame(), flushingComponent.getRTree()
- .getBufferCache(), comparatorFields);
+ TreeTupleSorter rTreeTupleSorter = new TreeTupleSorter(flushingComponent.getRTree().getFileId(),
+ linearizerArray, rtreeLeafFrameFactory.createFrame(), rtreeLeafFrameFactory.createFrame(),
+ flushingComponent.getRTree().getBufferCache(), comparatorFields);
// BulkLoad the tuples from the in-memory tree into the new disk
// RTree.
@@ -391,7 +391,7 @@
ctx.setOperation(IndexOperation.DELETE);
lsmHarness.modify(ctx, false, dualTuple);
}
-
+
@Override
public void forceDelete(ITupleReference tuple) throws HyracksDataException, IndexException {
dualTuple.reset(tuple);
diff --git a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeAbstractCursor.java b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeAbstractCursor.java
index 32f3174..0bd45bf 100644
--- a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeAbstractCursor.java
+++ b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeAbstractCursor.java
@@ -140,6 +140,7 @@
lsmHarness.endSearch(opCtx);
}
+ foundNext = false;
open = false;
}
diff --git a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSortedCursor.java b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSortedCursor.java
index 136c8d8..57902b2 100644
--- a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSortedCursor.java
+++ b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeSortedCursor.java
@@ -97,7 +97,7 @@
if (linearizeCmp.compare(frameTuple.getFieldData(0), frameTuple.getFieldStart(0),
frameTuple.getFieldLength(0) * linearizeCmp.getDimensions(), rtreeCursors[i].getTuple()
.getFieldData(0), rtreeCursors[i].getTuple().getFieldStart(0), rtreeCursors[i]
- .getTuple().getFieldLength(0) * linearizeCmp.getDimensions()) <= 0) {
+ .getTuple().getFieldLength(0) * linearizeCmp.getDimensions()) > 0) {
frameTuple = rtreeCursors[i].getTuple();
foundIn = i;
}
diff --git a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuples.java b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuples.java
index 71d83f2..f85a7c6 100644
--- a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuples.java
+++ b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuples.java
@@ -57,9 +57,6 @@
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
public class LSMRTreeWithAntiMatterTuples extends AbstractLSMRTree {
-
- private TreeTupleSorter bTreeTupleSorter;
-
// On-disk components.
// For creating RTree's used in bulk load. Different from diskRTreeFactory
// because it should have a different tuple writer in it's leaf frames.
@@ -79,7 +76,6 @@
diskRTreeFactory), diskFileMapProvider, fieldCount, rtreeCmpFactories, btreeCmpFactories,
linearizer, comparatorFields, linearizerArray, 0, mergePolicy, opTracker, ioScheduler, ioOpCallback);
bulkLoaComponentFactory = new LSMRTreeWithAntiMatterTuplesDiskComponentFactory(bulkLoadRTreeFactory);
- this.bTreeTupleSorter = null;
}
@Override
@@ -183,11 +179,11 @@
// Since the LSM-RTree is used as a secondary assumption, the
// primary key will be the last comparator in the BTree comparators
- rTreeTupleSorter = new TreeTupleSorter(flushingComponent.getRTree().getFileId(), linearizerArray,
+ TreeTupleSorter rTreeTupleSorter = new TreeTupleSorter(flushingComponent.getRTree().getFileId(), linearizerArray,
rtreeLeafFrameFactory.createFrame(), rtreeLeafFrameFactory.createFrame(), flushingComponent.getRTree()
.getBufferCache(), comparatorFields);
- bTreeTupleSorter = new TreeTupleSorter(flushingComponent.getBTree().getFileId(), linearizerArray,
+ TreeTupleSorter bTreeTupleSorter = new TreeTupleSorter(flushingComponent.getBTree().getFileId(), linearizerArray,
btreeLeafFrameFactory.createFrame(), btreeLeafFrameFactory.createFrame(), flushingComponent.getBTree()
.getBufferCache(), comparatorFields);
// BulkLoad the tuples from the in-memory tree into the new disk
diff --git a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesFlushCursor.java b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesFlushCursor.java
index aa3fad8..edc0cae 100644
--- a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesFlushCursor.java
+++ b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesFlushCursor.java
@@ -102,8 +102,10 @@
int c = cmp.selectiveFieldCompare(rtreeTuple, btreeTuple, comparatorFields);
if (c == 0) {
+ frameTuple = rtreeTuple;
leftOverTuple = null;
- continue;
+ foundNext = true;
+ return true;
} else if (c < 0) {
frameTuple = rtreeTuple;
leftOverTuple = btreeTuple;
diff --git a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java
index 7099d7d..c0c52b30 100644
--- a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java
+++ b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java
@@ -52,6 +52,7 @@
private int currentCursor;
private SearchPredicate rtreeSearchPredicate;
private int numMutableComponents;
+ private boolean open;
public LSMRTreeWithAntiMatterTuplesSearchCursor(ILSMIndexOperationContext opCtx) {
this(opCtx, false);
@@ -123,6 +124,7 @@
searchNextCursor();
setPriorityQueueComparator();
initPriorityQueue();
+ open = true;
}
private void searchNextCursor() throws HyracksDataException, IndexException {
@@ -191,18 +193,25 @@
@Override
public void reset() throws HyracksDataException, IndexException {
+ if (!open) {
+ return;
+ }
+ currentCursor = 0;
+ foundNext = false;
if (includeMutableComponent) {
for (int i = 0; i < numMutableComponents; i++) {
mutableRTreeCursors[i].reset();
btreeCursors[i].reset();
}
}
- currentCursor = 0;
super.reset();
}
@Override
public void close() throws HyracksDataException {
+ if (!open) {
+ return;
+ }
if (includeMutableComponent) {
for (int i = 0; i < numMutableComponents; i++) {
mutableRTreeCursors[i].close();
@@ -210,6 +219,7 @@
}
}
currentCursor = 0;
+ open = false;
super.close();
}