[ASTERIXDB-2204][STO] Fix the IIndexCursor interface - user model changes: no - storage format changes: no - interface changes: yes - replace IIndexCursor.reset with close - replace IIndexCursor.close with destroy
Details: - This change is the first step towards fixing the behavior of implementors/callers of the IIndexCursor interface - In this change, we simply rename the reset -> close and close -> destroy and we write down the javadocs explaining the semantics of the interface. - LSM Index Cursors don't implements ITreeIndexCursor anymore. Change-Id: I64cf8c0a5473268bdfd71fd560ee6b3bff219ce9 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2238 Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: abdullah alamoudi <bamou...@gmail.com> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/08dc8597 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/08dc8597 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/08dc8597 Branch: refs/heads/master Commit: 08dc8597e2c9bcbf133250487c71b82d53fd1224 Parents: b4899c8 Author: Abdullah Alamoudi <bamou...@gmail.com> Authored: Thu Jan 4 17:56:38 2018 +0300 Committer: abdullah alamoudi <bamou...@gmail.com> Committed: Thu Jan 4 16:35:06 2018 -0800 ---------------------------------------------------------------------- .../indexing/ExternalFileIndexAccessor.java | 4 +- .../apache/asterix/metadata/MetadataNode.java | 23 +++++------ .../LSMPrimaryUpsertOperatorNodePushable.java | 7 ++-- .../btree/impls/BTreeCountingSearchCursor.java | 6 +-- .../am/btree/impls/BTreeRangeSearchCursor.java | 6 +-- .../storage/am/btree/test/FramewriterTest.java | 2 +- .../IndexSearchOperatorNodePushable.java | 4 +- ...eIndexDiskOrderScanOperatorNodePushable.java | 2 +- .../impls/TreeIndexDiskOrderScanCursor.java | 4 +- .../am/lsm/btree/impls/ExternalBTree.java | 3 +- .../lsm/btree/impls/ExternalBTreeWithBuddy.java | 7 ++-- .../storage/am/lsm/btree/impls/LSMBTree.java | 15 ++++--- .../impls/LSMBTreeDiskComponentScanCursor.java | 4 +- .../lsm/btree/impls/LSMBTreeMergeOperation.java | 4 +- .../btree/impls/LSMBTreePointSearchCursor.java | 42 ++++++-------------- .../btree/impls/LSMBTreeRangeSearchCursor.java | 14 +++---- .../lsm/btree/impls/LSMBTreeSearchCursor.java | 32 ++++----------- .../impls/LSMBTreeWithBuddyAbstractCursor.java | 32 ++++----------- .../impls/LSMBTreeWithBuddyMergeOperation.java | 4 +- .../impls/LSMBTreeWithBuddySearchCursor.java | 18 ++++----- .../impls/LSMBTreeWithBuddySortedCursor.java | 12 +++--- .../am/lsm/common/impls/AbstractLSMIndex.java | 12 +++--- .../lsm/common/impls/LSMIndexSearchCursor.java | 29 +++----------- .../lsm/common/impls/LSMTreeIndexAccessor.java | 5 +-- .../invertedindex/impls/LSMInvertedIndex.java | 10 ++--- .../LSMInvertedIndexRangeSearchCursor.java | 4 +- .../impls/LSMInvertedIndexSearchCursor.java | 16 ++++---- .../inmemory/InMemoryInvertedListCursor.java | 12 +++--- .../ondisk/OnDiskInvertedIndex.java | 4 +- .../OnDiskInvertedIndexRangeSearchCursor.java | 8 ++-- .../ondisk/OnDiskInvertedIndexSearchCursor.java | 4 +- .../ondisk/PartitionedOnDiskInvertedIndex.java | 2 +- .../am/lsm/rtree/impls/ExternalRTree.java | 9 ++--- .../storage/am/lsm/rtree/impls/LSMRTree.java | 14 +++---- .../lsm/rtree/impls/LSMRTreeAbstractCursor.java | 33 +++++---------- .../lsm/rtree/impls/LSMRTreeMergeOperation.java | 4 +- .../lsm/rtree/impls/LSMRTreeSearchCursor.java | 18 ++++----- .../lsm/rtree/impls/LSMRTreeSortedCursor.java | 12 +++--- .../impls/LSMRTreeWithAntiMatterTuples.java | 12 +++--- ...LSMRTreeWithAntiMatterTuplesFlushCursor.java | 23 ++--------- ...SMRTreeWithAntiMatterTuplesSearchCursor.java | 25 ++++++------ .../am/lsm/rtree/impls/TreeTupleSorter.java | 4 +- .../am/rtree/impls/RTreeSearchCursor.java | 6 +-- .../hyracks/storage/common/IIndexCursor.java | 37 ++++++++++++++--- .../AbstractSearchOperationCallbackTest.java | 2 +- .../am/btree/OrderedIndexExamplesTest.java | 9 ++--- .../storage/am/btree/OrderedIndexTestUtils.java | 9 ++--- .../am/common/AbstractIndexTestWorker.java | 2 +- .../storage/am/common/TreeIndexTestUtils.java | 10 +++-- .../am/rtree/AbstractRTreeExamplesTest.java | 12 +++--- .../storage/am/rtree/RTreeTestUtils.java | 8 ++-- .../storage/am/btree/BTreeSearchCursorTest.java | 2 +- .../storage/am/btree/BTreeUpdateSearchTest.java | 4 +- .../am/btree/multithread/BTreeTestWorker.java | 8 ++-- .../LSMBTreeSearchOperationCallbackTest.java | 2 +- ...TreeUpdateInPlaceScanDiskComponentsTest.java | 2 +- .../btree/multithread/LSMBTreeTestWorker.java | 4 +- .../multithread/LSMInvertedIndexTestWorker.java | 4 +- .../util/LSMInvertedIndexTestUtils.java | 4 +- .../multithread/AbstractLSMRTreeTestWorker.java | 2 +- .../rtree/multithread/LSMRTreeTestWorker.java | 7 ++-- .../LSMRTreeWithAntiMatterTuplesTestWorker.java | 6 +-- .../am/rtree/multithread/RTreeTestWorker.java | 4 +- 63 files changed, 284 insertions(+), 365 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java index c11fb61..88b8a14 100644 --- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java +++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/ExternalFileIndexAccessor.java @@ -102,7 +102,7 @@ public class ExternalFileIndexAccessor { searchKeyTupleBuilder.reset(); searchKeyTupleBuilder.addField(intSerde, currentFileNumber); searchKey.reset(searchKeyTupleBuilder.getFieldEndOffsets(), searchKeyTupleBuilder.getByteArray()); - fileIndexSearchCursor.reset(); + fileIndexSearchCursor.close(); // Perform search fileIndexAccessor.search(fileIndexSearchCursor, searchPredicate); @@ -137,7 +137,7 @@ public class ExternalFileIndexAccessor { public void close() throws HyracksDataException { if (index != null) { try { - fileIndexSearchCursor.close(); + fileIndexSearchCursor.destroy(); } finally { indexDataflowHelper.close(); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataNode.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataNode.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataNode.java index 368fc2a..ed3bbe0 100644 --- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataNode.java +++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataNode.java @@ -19,15 +19,12 @@ package org.apache.asterix.metadata; -import static org.apache.asterix.common.transactions.ITransactionManager.AtomicityLevel; - import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Logger; import org.apache.asterix.common.api.IDatasetLifecycleManager; import org.apache.asterix.common.api.INcApplicationContext; @@ -40,6 +37,7 @@ import org.apache.asterix.common.metadata.MetadataIndexImmutableProperties; import org.apache.asterix.common.transactions.DatasetId; import org.apache.asterix.common.transactions.IRecoveryManager.ResourceType; import org.apache.asterix.common.transactions.ITransactionContext; +import org.apache.asterix.common.transactions.ITransactionManager.AtomicityLevel; import org.apache.asterix.common.transactions.ITransactionSubsystem; import org.apache.asterix.common.transactions.ImmutableDatasetId; import org.apache.asterix.common.transactions.TransactionOptions; @@ -111,7 +109,6 @@ import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleReference; import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference; import org.apache.hyracks.dataflow.common.utils.TupleUtils; import org.apache.hyracks.storage.am.btree.impls.RangePredicate; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.common.impls.IndexAccessParameters; import org.apache.hyracks.storage.am.common.impls.NoOpIndexAccessParameters; import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallback; @@ -1182,7 +1179,7 @@ public class MetadataNode implements IMetadataNode { IIndex indexInstance = datasetLifecycleManager.get(resourceName); datasetLifecycleManager.open(resourceName); IIndexAccessor indexAccessor = indexInstance.createAccessor(NoOpIndexAccessParameters.INSTANCE); - ITreeIndexCursor rangeCursor = (ITreeIndexCursor) indexAccessor.createSearchCursor(false); + IIndexCursor rangeCursor = indexAccessor.createSearchCursor(false); RangePredicate rangePred = null; rangePred = new RangePredicate(null, null, true, true, null, null); @@ -1194,7 +1191,7 @@ public class MetadataNode implements IMetadataNode { SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING) })); } } finally { - rangeCursor.close(); + rangeCursor.destroy(); } datasetLifecycleManager.close(resourceName); @@ -1202,7 +1199,7 @@ public class MetadataNode implements IMetadataNode { indexInstance = datasetLifecycleManager.get(resourceName); datasetLifecycleManager.open(resourceName); indexAccessor = indexInstance.createAccessor(NoOpIndexAccessParameters.INSTANCE); - rangeCursor = (ITreeIndexCursor) indexAccessor.createSearchCursor(false); + rangeCursor = indexAccessor.createSearchCursor(false); rangePred = null; rangePred = new RangePredicate(null, null, true, true, null, null); @@ -1215,7 +1212,7 @@ public class MetadataNode implements IMetadataNode { SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING) })); } } finally { - rangeCursor.close(); + rangeCursor.destroy(); } datasetLifecycleManager.close(resourceName); @@ -1223,7 +1220,7 @@ public class MetadataNode implements IMetadataNode { indexInstance = datasetLifecycleManager.get(resourceName); datasetLifecycleManager.open(resourceName); indexAccessor = indexInstance.createAccessor(NoOpIndexAccessParameters.INSTANCE); - rangeCursor = (ITreeIndexCursor) indexAccessor.createSearchCursor(false); + rangeCursor = indexAccessor.createSearchCursor(false); rangePred = null; rangePred = new RangePredicate(null, null, true, true, null, null); @@ -1237,7 +1234,7 @@ public class MetadataNode implements IMetadataNode { SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING) })); } } finally { - rangeCursor.close(); + rangeCursor.destroy(); } datasetLifecycleManager.close(resourceName); } catch (Exception e) { @@ -1258,7 +1255,7 @@ public class MetadataNode implements IMetadataNode { IIndex indexInstance = datasetLifecycleManager.get(resourceName); datasetLifecycleManager.open(resourceName); IIndexAccessor indexAccessor = indexInstance.createAccessor(NoOpIndexAccessParameters.INSTANCE); - ITreeIndexCursor rangeCursor = (ITreeIndexCursor) indexAccessor.createSearchCursor(false); + IIndexCursor rangeCursor = indexAccessor.createSearchCursor(false); IBinaryComparator[] searchCmps = null; MultiComparator searchCmp = null; @@ -1282,7 +1279,7 @@ public class MetadataNode implements IMetadataNode { } } } finally { - rangeCursor.close(); + rangeCursor.destroy(); } datasetLifecycleManager.close(resourceName); } @@ -1316,7 +1313,7 @@ public class MetadataNode implements IMetadataNode { } } } finally { - rangeCursor.close(); + rangeCursor.destroy(); } } finally { datasetLifecycleManager.close(resourceName); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java index 4855a27..0d74e30 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/LSMPrimaryUpsertOperatorNodePushable.java @@ -25,7 +25,6 @@ import java.nio.ByteBuffer; import org.apache.asterix.common.api.INcApplicationContext; import org.apache.asterix.common.dataflow.LSMIndexUtil; import org.apache.asterix.common.exceptions.ACIDException; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.common.transactions.ILogMarkerCallback; import org.apache.asterix.common.transactions.PrimaryIndexLogMarkerCallback; import org.apache.asterix.om.pointables.nonvisitor.ARecordPointable; @@ -143,7 +142,7 @@ public class LSMPrimaryUpsertOperatorNodePushable extends LSMIndexInsertUpdateDe if (cursor.hasNext()) { cursor.next(); prevTuple = cursor.getTuple(); - cursor.reset(); // end the search + cursor.close(); // end the search appendFilterToPrevTuple(); appendPrevRecord(); appendPreviousMeta(); @@ -318,7 +317,7 @@ public class LSMPrimaryUpsertOperatorNodePushable extends LSMIndexInsertUpdateDe if (isFiltered) { writeMissingField(); } - cursor.reset(); + cursor.close(); } /** @@ -361,7 +360,7 @@ public class LSMPrimaryUpsertOperatorNodePushable extends LSMIndexInsertUpdateDe public void close() throws HyracksDataException { try { try { - cursor.close(); + cursor.destroy(); } finally { writer.close(); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java index d7084bb..82df92c 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeCountingSearchCursor.java @@ -207,7 +207,7 @@ public class BTreeCountingSearchCursor implements ITreeIndexCursor { } @Override - public void close() throws HyracksDataException { + public void destroy() throws HyracksDataException { if (page != null) { releasePage(); } @@ -220,9 +220,9 @@ public class BTreeCountingSearchCursor implements ITreeIndexCursor { } @Override - public void reset() { + public void close() { try { - close(); + destroy(); } catch (Exception e) { e.printStackTrace(); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java index 13cb57a..5ce9e1a 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/BTreeRangeSearchCursor.java @@ -81,7 +81,7 @@ public class BTreeRangeSearchCursor implements ITreeIndexCursor { } @Override - public void close() throws HyracksDataException { + public void destroy() throws HyracksDataException { if (page != null) { if (exclusiveLatchNodes) { page.releaseWriteLatch(isPageDirty); @@ -292,8 +292,8 @@ public class BTreeRangeSearchCursor implements ITreeIndexCursor { } @Override - public void reset() throws HyracksDataException { - close(); + public void close() throws HyracksDataException { + destroy(); } @Override http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java index 64f8263..4ff0656 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java @@ -390,7 +390,7 @@ public class FramewriterTest { cursor = Mockito.mock(IIndexCursor.class); Mockito.when(cursor.hasNext()).thenReturn(true, true, false); Mockito.when(cursor.getTuple()).thenReturn(tuples[i]); - Mockito.doThrow(new HyracksDataException("Failed to close cursor")).when(cursor).close(); + Mockito.doThrow(new HyracksDataException("Failed to close cursor")).when(cursor).destroy(); cursors[j] = cursor; j++; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IndexSearchOperatorNodePushable.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IndexSearchOperatorNodePushable.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IndexSearchOperatorNodePushable.java index 1e5f69b..09812c1 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IndexSearchOperatorNodePushable.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IndexSearchOperatorNodePushable.java @@ -201,7 +201,7 @@ public abstract class IndexSearchOperatorNodePushable extends AbstractUnaryInput try { for (int i = 0; i < tupleCount; i++) { resetSearchPredicate(i); - cursor.reset(); + cursor.close(); indexAccessor.search(cursor, searchPred); writeSearchResults(i); } @@ -232,7 +232,7 @@ public abstract class IndexSearchOperatorNodePushable extends AbstractUnaryInput } try { - cursor.close(); + cursor.destroy(); } catch (Throwable th) { if (closeException == null) { closeException = HyracksDataException.create(th); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/TreeIndexDiskOrderScanOperatorNodePushable.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/TreeIndexDiskOrderScanOperatorNodePushable.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/TreeIndexDiskOrderScanOperatorNodePushable.java index dc86c74..7626815 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/TreeIndexDiskOrderScanOperatorNodePushable.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/TreeIndexDiskOrderScanOperatorNodePushable.java @@ -95,7 +95,7 @@ public class TreeIndexDiskOrderScanOperatorNodePushable extends AbstractUnaryOut throw new HyracksDataException(th); } finally { try { - cursor.close(); + cursor.destroy(); } catch (Exception cursorCloseException) { throw new IllegalStateException(cursorCloseException); } finally { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java index 0b8b64c..6bc5be2 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/impls/TreeIndexDiskOrderScanCursor.java @@ -48,7 +48,7 @@ public class TreeIndexDiskOrderScanCursor implements ITreeIndexCursor { } @Override - public void close() throws HyracksDataException { + public void destroy() throws HyracksDataException { page.releaseReadLatch(); bufferCache.unpin(page); page = null; @@ -130,7 +130,7 @@ public class TreeIndexDiskOrderScanCursor implements ITreeIndexCursor { } @Override - public void reset() { + public void close() { tupleIndex = 0; currentPageId = -1; maxPageId = -1; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTree.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTree.java index 5b6ff9e..280803d 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTree.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTree.java @@ -31,7 +31,6 @@ import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference; import org.apache.hyracks.storage.am.btree.impls.BTree; import org.apache.hyracks.storage.am.common.api.IIndexOperationContext; import org.apache.hyracks.storage.am.common.api.IMetadataPageManager; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory; import org.apache.hyracks.storage.am.common.api.ITwoPCIndexBulkLoader; import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallback; @@ -188,7 +187,7 @@ public class ExternalBTree extends LSMBTree implements ITwoPCIndex { returnDeletedTuples = true; } } - ITreeIndexCursor cursor = new LSMBTreeRangeSearchCursor(opCtx, returnDeletedTuples); + LSMBTreeRangeSearchCursor cursor = new LSMBTreeRangeSearchCursor(opCtx, returnDeletedTuples); BTree firstBTree = ((LSMBTreeDiskComponent) mergingComponents.get(0)).getIndex(); BTree lastBTree = ((LSMBTreeDiskComponent) mergingComponents.get(mergingComponents.size() - 1)).getIndex(); FileReference firstFile = firstBTree.getFileReference(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddy.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddy.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddy.java index c6ce339..5f04c0a 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddy.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/ExternalBTreeWithBuddy.java @@ -33,7 +33,6 @@ import org.apache.hyracks.storage.am.btree.impls.RangePredicate; import org.apache.hyracks.storage.am.common.api.IIndexOperationContext; import org.apache.hyracks.storage.am.common.api.IMetadataPageManager; import org.apache.hyracks.storage.am.common.api.ITreeIndex; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory; import org.apache.hyracks.storage.am.common.api.ITwoPCIndexBulkLoader; import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallback; @@ -273,7 +272,7 @@ public class ExternalBTreeWithBuddy extends AbstractLSMIndex implements ITreeInd ILSMIndexOperationContext bctx = createOpContext(NoOpOperationCallback.INSTANCE, 0); bctx.setOperation(IndexOperation.MERGE); List<ILSMComponent> mergingComponents = ctx.getComponentHolder(); - ITreeIndexCursor cursor = new LSMBTreeWithBuddySortedCursor(bctx, buddyBTreeFields); + LSMBTreeWithBuddySortedCursor cursor = new LSMBTreeWithBuddySortedCursor(bctx, buddyBTreeFields); LSMComponentFileReferences relMergeFileRefs = getMergeTargetFileName(mergingComponents); ILSMIndexAccessor accessor = new LSMTreeIndexAccessor(getHarness(), bctx, opCtx -> new LSMBTreeWithBuddySearchCursor(opCtx, buddyBTreeFields)); @@ -342,7 +341,7 @@ public class ExternalBTreeWithBuddy extends AbstractLSMIndex implements ITreeInd componentBulkLoader.delete(tuple); } } finally { - buddyBtreeCursor.close(); + buddyBtreeCursor.destroy(); } } else { componentBulkLoader = mergedComponent.createBulkLoader(1.0f, false, 0L, false, false, false); @@ -355,7 +354,7 @@ public class ExternalBTreeWithBuddy extends AbstractLSMIndex implements ITreeInd componentBulkLoader.add(frameTuple); } } finally { - cursor.close(); + cursor.destroy(); } componentBulkLoader.end(); return mergedComponent; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTree.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTree.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTree.java index 6929530..482ad38 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTree.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTree.java @@ -35,7 +35,6 @@ import org.apache.hyracks.storage.am.btree.impls.RangePredicate; import org.apache.hyracks.storage.am.common.api.IIndexOperationContext; import org.apache.hyracks.storage.am.common.api.IPageManager; import org.apache.hyracks.storage.am.common.api.ITreeIndex; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.common.api.ITreeIndexFrameFactory; import org.apache.hyracks.storage.am.common.impls.NoOpIndexAccessParameters; import org.apache.hyracks.storage.am.lsm.btree.tuples.LSMBTreeTupleReference; @@ -189,14 +188,14 @@ public class LSMBTree extends AbstractLSMIndex implements ITreeIndex { if (!lsmbtreeTuple.isAntimatter()) { throw HyracksDataException.create(ErrorCode.DUPLICATE_KEY); } else { - memCursor.close(); + memCursor.destroy(); ctx.getCurrentMutableBTreeAccessor().upsertIfConditionElseInsert(tuple, AntimatterAwareTupleAcceptor.INSTANCE); return true; } } } finally { - memCursor.close(); + memCursor.destroy(); } // TODO: Can we just remove the above code that search the mutable @@ -214,7 +213,7 @@ public class LSMBTree extends AbstractLSMIndex implements ITreeIndex { throw HyracksDataException.create(ErrorCode.DUPLICATE_KEY); } } finally { - searchCursor.close(); + searchCursor.destroy(); // Add the current active mutable component back ctx.getComponentHolder().add(0, firstComponent); } @@ -264,7 +263,7 @@ public class LSMBTree extends AbstractLSMIndex implements ITreeIndex { numElements = IntegerPointable.getInteger(countTuple.getFieldData(0), countTuple.getFieldStart(0)); } } finally { - countingCursor.close(); + countingCursor.destroy(); } } @@ -287,7 +286,7 @@ public class LSMBTree extends AbstractLSMIndex implements ITreeIndex { componentBulkLoader.add(scanCursor.getTuple()); } } finally { - scanCursor.close(); + scanCursor.destroy(); } if (component.getLSMComponentFilter() != null) { @@ -337,7 +336,7 @@ public class LSMBTree extends AbstractLSMIndex implements ITreeIndex { componentBulkLoader.add(frameTuple); } } finally { - cursor.close(); + cursor.destroy(); } if (mergedComponent.getLSMComponentFilter() != null) { List<ITupleReference> filterTuples = new ArrayList<>(); @@ -442,7 +441,7 @@ public class LSMBTree extends AbstractLSMIndex implements ITreeIndex { if (mergingComponents.get(mergingComponents.size() - 1) != diskComponents.get(diskComponents.size() - 1)) { returnDeletedTuples = true; } - ITreeIndexCursor cursor = new LSMBTreeRangeSearchCursor(opCtx, returnDeletedTuples); + LSMBTreeRangeSearchCursor cursor = new LSMBTreeRangeSearchCursor(opCtx, returnDeletedTuples); return new LSMBTreeMergeOperation(accessor, cursor, mergeFileRefs.getInsertIndexFileReference(), mergeFileRefs.getBloomFilterFileReference(), callback, fileManager.getBaseDir().getAbsolutePath()); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeDiskComponentScanCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeDiskComponentScanCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeDiskComponentScanCursor.java index 2f77504..efaf555 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeDiskComponentScanCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeDiskComponentScanCursor.java @@ -176,11 +176,11 @@ public class LSMBTreeDiskComponentScanCursor extends LSMIndexSearchCursor { } @Override - public void close() throws HyracksDataException { + public void destroy() throws HyracksDataException { if (lsmHarness != null) { try { for (int i = 0; i < rangeCursors.length; i++) { - rangeCursors[i].close(); + rangeCursors[i].destroy(); } rangeCursors = null; } finally { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeMergeOperation.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeMergeOperation.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeMergeOperation.java index ec96303..edfa7e1 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeMergeOperation.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeMergeOperation.java @@ -20,16 +20,16 @@ package org.apache.hyracks.storage.am.lsm.btree.impls; import org.apache.hyracks.api.io.FileReference; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallback; import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor; import org.apache.hyracks.storage.am.lsm.common.impls.MergeOperation; +import org.apache.hyracks.storage.common.IIndexCursor; public class LSMBTreeMergeOperation extends MergeOperation { private final FileReference bloomFilterMergeTarget; - public LSMBTreeMergeOperation(ILSMIndexAccessor accessor, ITreeIndexCursor cursor, FileReference target, + public LSMBTreeMergeOperation(ILSMIndexAccessor accessor, IIndexCursor cursor, FileReference target, FileReference bloomFilterMergeTarget, ILSMIOOperationCallback callback, String indexIdentifier) { super(accessor, target, callback, indexIdentifier, cursor); this.bloomFilterMergeTarget = bloomFilterMergeTarget; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreePointSearchCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreePointSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreePointSearchCursor.java index 211a233..0284ee1 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreePointSearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreePointSearchCursor.java @@ -29,7 +29,6 @@ import org.apache.hyracks.storage.am.btree.impls.BTree; import org.apache.hyracks.storage.am.btree.impls.BTree.BTreeAccessor; import org.apache.hyracks.storage.am.btree.impls.BTreeRangeSearchCursor; import org.apache.hyracks.storage.am.btree.impls.RangePredicate; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.common.impls.NoOpIndexAccessParameters; import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallback; import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent; @@ -39,11 +38,11 @@ import org.apache.hyracks.storage.am.lsm.common.api.ILSMHarness; import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext; import org.apache.hyracks.storage.am.lsm.common.api.ILSMTreeTupleReference; import org.apache.hyracks.storage.common.ICursorInitialState; +import org.apache.hyracks.storage.common.IIndexCursor; import org.apache.hyracks.storage.common.ISearchOperationCallback; import org.apache.hyracks.storage.common.ISearchPredicate; -import org.apache.hyracks.storage.common.buffercache.IBufferCache; -public class LSMBTreePointSearchCursor implements ITreeIndexCursor { +public class LSMBTreePointSearchCursor implements IIndexCursor { private BTreeRangeSearchCursor[] rangeCursors; private final ILSMIndexOperationContext opCtx; @@ -89,7 +88,7 @@ public class LSMBTreePointSearchCursor implements ITreeIndexCursor { if (reconciled) { searchCallback.cancel(predicate.getLowKey()); } - rangeCursors[i].close(); + rangeCursors[i].destroy(); return false; } else { frameTuple = rangeCursors[i].getTuple(); @@ -100,7 +99,7 @@ public class LSMBTreePointSearchCursor implements ITreeIndexCursor { } if (i == 0 && includeMutableComponent) { // unlatch/unpin - rangeCursors[i].reset(); + rangeCursors[i].close(); searchCallback.reconcile(predicate.getLowKey()); reconciled = true; @@ -110,7 +109,7 @@ public class LSMBTreePointSearchCursor implements ITreeIndexCursor { rangeCursors[i].next(); if (((ILSMTreeTupleReference) rangeCursors[i].getTuple()).isAntimatter()) { searchCallback.cancel(predicate.getLowKey()); - rangeCursors[i].close(); + rangeCursors[i].destroy(); return false; } else { frameTuple = rangeCursors[i].getTuple(); @@ -121,7 +120,7 @@ public class LSMBTreePointSearchCursor implements ITreeIndexCursor { } } else { searchCallback.cancel(predicate.getLowKey()); - rangeCursors[i].close(); + rangeCursors[i].destroy(); } } else { frameTuple = rangeCursors[i].getTuple(); @@ -132,18 +131,18 @@ public class LSMBTreePointSearchCursor implements ITreeIndexCursor { return true; } } else { - rangeCursors[i].close(); + rangeCursors[i].destroy(); } } return false; } @Override - public void reset() throws HyracksDataException { + public void close() throws HyracksDataException { try { if (rangeCursors != null) { for (int i = 0; i < rangeCursors.length; ++i) { - rangeCursors[i].reset(); + rangeCursors[i].close(); } } nextHasBeenCalled = false; @@ -182,7 +181,7 @@ public class LSMBTreePointSearchCursor implements ITreeIndexCursor { rangeCursors[i] = new BTreeRangeSearchCursor(leafFrame, false); } else { // reset - rangeCursors[i].reset(); + rangeCursors[i].close(); } btree = ((LSMBTreeMemoryComponent) component).getIndex(); // no bloom filter for in-memory BTree @@ -190,7 +189,7 @@ public class LSMBTreePointSearchCursor implements ITreeIndexCursor { } else { if (rangeCursors[i] != null) { // can re-use cursor - rangeCursors[i].reset(); + rangeCursors[i].close(); } else { // create new cursor <should be relatively rare> IBTreeLeafFrame leafFrame = (IBTreeLeafFrame) lsmInitialState.getLeafFrameFactory().createFrame(); @@ -216,7 +215,7 @@ public class LSMBTreePointSearchCursor implements ITreeIndexCursor { } @Override - public void close() throws HyracksDataException { + public void destroy() throws HyracksDataException { if (lsmHarness != null) { try { closeCursors(); @@ -253,26 +252,11 @@ public class LSMBTreePointSearchCursor implements ITreeIndexCursor { return null; } - @Override - public void setBufferCache(IBufferCache bufferCache) { - // do nothing - } - - @Override - public void setFileId(int fileId) { - // do nothing - } - - @Override - public boolean isExclusiveLatchNodes() { - return false; - } - private void closeCursors() throws HyracksDataException { if (rangeCursors != null) { for (int i = 0; i < numBTrees; ++i) { if (rangeCursors[i] != null) { - rangeCursors[i].close(); + rangeCursors[i].destroy(); } } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java index 876bc6d..36ca87f 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeRangeSearchCursor.java @@ -66,8 +66,8 @@ public class LSMBTreeRangeSearchCursor extends LSMIndexSearchCursor { } @Override - public void reset() throws HyracksDataException { - super.reset(); + public void close() throws HyracksDataException { + super.close(); canCallProceed = true; } @@ -117,7 +117,7 @@ public class LSMBTreeRangeSearchCursor extends LSMIndexSearchCursor { TupleUtils.copyTuple(tupleBuilder, queueHead.getTuple(), cmp.getKeyFieldCount()); copyTuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray()); // Unlatches/unpins the leaf page of the index. - rangeCursors[0].reset(); + rangeCursors[0].close(); // Reconcile. searchCallback.reconcile(copyTuple); // Re-traverses the index. @@ -220,7 +220,7 @@ public class LSMBTreeRangeSearchCursor extends LSMIndexSearchCursor { copyTuple.reset(switchComponentTupleBuilders[i].getFieldEndOffsets(), switchComponentTupleBuilders[i].getByteArray()); reusablePred.setLowKey(copyTuple, true); - rangeCursors[i].reset(); + rangeCursors[i].close(); btreeAccessors[i].reset(btree, NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE); btreeAccessors[i].search(rangeCursors[i], reusablePred); pushIntoQueueFromCursorAndReplaceThisElement(switchedElements[i]); @@ -268,8 +268,8 @@ public class LSMBTreeRangeSearchCursor extends LSMIndexSearchCursor { } TupleUtils.copyTuple(switchComponentTupleBuilders[i], element.getTuple(), cmp.getKeyFieldCount()); } - rangeCursors[i].reset(); rangeCursors[i].close(); + rangeCursors[i].destroy(); switchRequest[i] = true; switchedElements[i] = element; } @@ -296,7 +296,7 @@ public class LSMBTreeRangeSearchCursor extends LSMIndexSearchCursor { TupleUtils.copyTuple(tupleBuilder, mutableElement.getTuple(), cmp.getKeyFieldCount()); copyTuple.reset(tupleBuilder.getFieldEndOffsets(), tupleBuilder.getByteArray()); // Unlatches/unpins the leaf page of the index. - rangeCursors[0].reset(); + rangeCursors[0].close(); // Re-traverses the index. reusablePred.setLowKey(copyTuple, true); btreeAccessors[0].search(rangeCursors[0], reusablePred); @@ -347,7 +347,7 @@ public class LSMBTreeRangeSearchCursor extends LSMIndexSearchCursor { rangeCursors[i] = new BTreeRangeSearchCursor(leafFrame, false); } else { // re-use - rangeCursors[i].reset(); + rangeCursors[i].close(); } if (component.getType() == LSMComponentType.MEMORY) { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java index fef8afe..fa06d07 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeSearchCursor.java @@ -22,13 +22,12 @@ package org.apache.hyracks.storage.am.lsm.btree.impls; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference; import org.apache.hyracks.storage.am.btree.impls.RangePredicate; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext; import org.apache.hyracks.storage.common.ICursorInitialState; +import org.apache.hyracks.storage.common.IIndexCursor; import org.apache.hyracks.storage.common.ISearchPredicate; -import org.apache.hyracks.storage.common.buffercache.IBufferCache; -public class LSMBTreeSearchCursor implements ITreeIndexCursor { +public class LSMBTreeSearchCursor implements IIndexCursor { public enum LSMBTreeSearchType { POINT, @@ -38,7 +37,7 @@ public class LSMBTreeSearchCursor implements ITreeIndexCursor { private final LSMBTreePointSearchCursor pointCursor; private final LSMBTreeRangeSearchCursor rangeCursor; private final LSMBTreeDiskComponentScanCursor scanCursor; - private ITreeIndexCursor currentCursor; + private IIndexCursor currentCursor; public LSMBTreeSearchCursor(ILSMIndexOperationContext opCtx) { pointCursor = new LSMBTreePointSearchCursor(opCtx); @@ -72,17 +71,17 @@ public class LSMBTreeSearchCursor implements ITreeIndexCursor { } @Override - public void close() throws HyracksDataException { + public void destroy() throws HyracksDataException { if (currentCursor != null) { - currentCursor.close(); + currentCursor.destroy(); } currentCursor = null; } @Override - public void reset() throws HyracksDataException { + public void close() throws HyracksDataException { if (currentCursor != null) { - currentCursor.reset(); + currentCursor.close(); } currentCursor = null; } @@ -101,21 +100,4 @@ public class LSMBTreeSearchCursor implements ITreeIndexCursor { public ITupleReference getFilterMaxTuple() { return currentCursor.getFilterMaxTuple(); } - - @Override - public void setBufferCache(IBufferCache bufferCache) { - currentCursor.setBufferCache(bufferCache); - } - - @Override - public void setFileId(int fileId) { - currentCursor.setFileId(fileId); - - } - - @Override - public boolean isExclusiveLatchNodes() { - return currentCursor.isExclusiveLatchNodes(); - } - } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyAbstractCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyAbstractCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyAbstractCursor.java index f619a52..50aeefb 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyAbstractCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyAbstractCursor.java @@ -36,11 +36,11 @@ import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent.LSMComponentTy import org.apache.hyracks.storage.am.lsm.common.api.ILSMHarness; import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext; import org.apache.hyracks.storage.common.ICursorInitialState; +import org.apache.hyracks.storage.common.IIndexCursor; import org.apache.hyracks.storage.common.ISearchPredicate; import org.apache.hyracks.storage.common.MultiComparator; -import org.apache.hyracks.storage.common.buffercache.IBufferCache; -public abstract class LSMBTreeWithBuddyAbstractCursor implements ITreeIndexCursor { +public abstract class LSMBTreeWithBuddyAbstractCursor implements IIndexCursor { protected boolean open; protected BTreeRangeSearchCursor[] btreeCursors; @@ -107,7 +107,7 @@ public abstract class LSMBTreeWithBuddyAbstractCursor implements ITreeIndexCurso buddyBtreeCursors[i] = new BTreeRangeSearchCursor( (IBTreeLeafFrame) lsmInitialState.getBuddyBTreeLeafFrameFactory().createFrame(), false); } else { - buddyBtreeCursors[i].reset(); + buddyBtreeCursors[i].close(); } btree = ((LSMBTreeWithBuddyMemoryComponent) component).getIndex(); buddyBtree = ((LSMBTreeWithBuddyMemoryComponent) component).getBuddyIndex(); @@ -117,7 +117,7 @@ public abstract class LSMBTreeWithBuddyAbstractCursor implements ITreeIndexCurso buddyBtreeCursors[i] = new BTreeRangeSearchCursor( (IBTreeLeafFrame) lsmInitialState.getBuddyBTreeLeafFrameFactory().createFrame(), false); } else { - buddyBtreeCursors[i].reset(); + buddyBtreeCursors[i].close(); } btree = ((LSMBTreeWithBuddyDiskComponent) component).getIndex(); buddyBtree = ((LSMBTreeWithBuddyDiskComponent) component).getBuddyIndex(); @@ -129,7 +129,7 @@ public abstract class LSMBTreeWithBuddyAbstractCursor implements ITreeIndexCurso btreeAccessors[i] = btree.createAccessor(NoOpIndexAccessParameters.INSTANCE); buddyBtreeAccessors[i] = buddyBtree.createAccessor(NoOpIndexAccessParameters.INSTANCE); } else { - btreeCursors[i].reset(); + btreeCursors[i].close(); btreeAccessors[i].reset(btree, NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE); buddyBtreeAccessors[i].reset(buddyBtree, NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE); @@ -141,15 +141,15 @@ public abstract class LSMBTreeWithBuddyAbstractCursor implements ITreeIndexCurso } @Override - public void close() throws HyracksDataException { + public void destroy() throws HyracksDataException { if (!open) { return; } try { if (btreeCursors != null && buddyBtreeCursors != null) { for (int i = 0; i < numberOfTrees; i++) { - btreeCursors[i].close(); - buddyBtreeCursors[i].close(); + btreeCursors[i].destroy(); + buddyBtreeCursors[i].destroy(); } } btreeCursors = null; @@ -165,20 +165,4 @@ public abstract class LSMBTreeWithBuddyAbstractCursor implements ITreeIndexCurso public ITupleReference getTuple() { return frameTuple; } - - @Override - public void setBufferCache(IBufferCache bufferCache) { - // Do nothing - } - - @Override - public void setFileId(int fileId) { - // Do nothing - } - - @Override - public boolean isExclusiveLatchNodes() { - return false; - } - } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyMergeOperation.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyMergeOperation.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyMergeOperation.java index f682bde..14cf778 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyMergeOperation.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddyMergeOperation.java @@ -19,10 +19,10 @@ package org.apache.hyracks.storage.am.lsm.btree.impls; import org.apache.hyracks.api.io.FileReference; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.lsm.common.api.ILSMIOOperationCallback; import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexAccessor; import org.apache.hyracks.storage.am.lsm.common.impls.MergeOperation; +import org.apache.hyracks.storage.common.IIndexCursor; public class LSMBTreeWithBuddyMergeOperation extends MergeOperation { @@ -30,7 +30,7 @@ public class LSMBTreeWithBuddyMergeOperation extends MergeOperation { private final FileReference bloomFilterMergeTarget; private final boolean keepDeletedTuples; - public LSMBTreeWithBuddyMergeOperation(ILSMIndexAccessor accessor, ITreeIndexCursor cursor, FileReference target, + public LSMBTreeWithBuddyMergeOperation(ILSMIndexAccessor accessor, IIndexCursor cursor, FileReference target, FileReference buddyBtreeMergeTarget, FileReference bloomFilterMergeTarget, ILSMIOOperationCallback callback, String indexIdentifier, boolean keepDeletedTuples) { super(accessor, target, callback, indexIdentifier, cursor); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySearchCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySearchCursor.java index 503182a..c7f5cea 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySearchCursor.java @@ -37,13 +37,13 @@ public class LSMBTreeWithBuddySearchCursor extends LSMBTreeWithBuddyAbstractCurs } @Override - public void close() throws HyracksDataException { - super.close(); + public void destroy() throws HyracksDataException { + super.destroy(); currentCursor = 0; } @Override - public void reset() throws HyracksDataException { + public void close() throws HyracksDataException { if (!open) { return; } @@ -52,8 +52,8 @@ public class LSMBTreeWithBuddySearchCursor extends LSMBTreeWithBuddyAbstractCurs foundNext = false; try { for (int i = 0; i < numberOfTrees; i++) { - btreeCursors[i].close(); - buddyBtreeCursors[i].close(); + btreeCursors[i].destroy(); + buddyBtreeCursors[i].destroy(); } btreeCursors = null; buddyBtreeCursors = null; @@ -64,7 +64,7 @@ public class LSMBTreeWithBuddySearchCursor extends LSMBTreeWithBuddyAbstractCurs private void searchNextCursor() throws HyracksDataException { if (currentCursor < numberOfTrees) { - btreeCursors[currentCursor].reset(); + btreeCursors[currentCursor].close(); btreeAccessors[currentCursor].search(btreeCursors[currentCursor], btreeRangePredicate); } } @@ -85,7 +85,7 @@ public class LSMBTreeWithBuddySearchCursor extends LSMBTreeWithBuddyAbstractCurs && !buddyBtreeBloomFilters[i].contains(buddyBTreeTuple, hashes)) { continue; } - buddyBtreeCursors[i].reset(); + buddyBtreeCursors[i].close(); buddyBtreeRangePredicate.setHighKey(buddyBTreeTuple, true); buddyBtreeRangePredicate.setLowKey(buddyBTreeTuple, true); buddyBtreeAccessors[i].search(buddyBtreeCursors[i], buddyBtreeRangePredicate); @@ -94,7 +94,7 @@ public class LSMBTreeWithBuddySearchCursor extends LSMBTreeWithBuddyAbstractCurs killerTupleFound = true; } } finally { - buddyBtreeCursors[i].close(); + buddyBtreeCursors[i].destroy(); } } if (!killerTupleFound) { @@ -103,7 +103,7 @@ public class LSMBTreeWithBuddySearchCursor extends LSMBTreeWithBuddyAbstractCurs return true; } } - btreeCursors[currentCursor].close(); + btreeCursors[currentCursor].destroy(); currentCursor++; searchNextCursor(); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySortedCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySortedCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySortedCursor.java index 8fd3a83..d889622 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySortedCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree/src/main/java/org/apache/hyracks/storage/am/lsm/btree/impls/LSMBTreeWithBuddySortedCursor.java @@ -39,7 +39,7 @@ public class LSMBTreeWithBuddySortedCursor extends LSMBTreeWithBuddyAbstractCurs throws HyracksDataException { super(opCtx); this.buddyBtreeTuple = new PermutingTupleReference(buddyBTreeFields); - reset(); + close(); } public ILSMIndexOperationContext getOpCtx() { @@ -47,12 +47,12 @@ public class LSMBTreeWithBuddySortedCursor extends LSMBTreeWithBuddyAbstractCurs } @Override - public void reset() throws HyracksDataException { + public void close() throws HyracksDataException { depletedBtreeCursors = new boolean[numberOfTrees]; foundNext = false; try { for (int i = 0; i < numberOfTrees; i++) { - btreeCursors[i].reset(); + btreeCursors[i].close(); btreeAccessors[i].search(btreeCursors[i], btreeRangePredicate); if (btreeCursors[i].hasNext()) { btreeCursors[i].next(); @@ -127,7 +127,7 @@ public class LSMBTreeWithBuddySortedCursor extends LSMBTreeWithBuddyAbstractCurs boolean killed = false; buddyBtreeTuple.reset(frameTuple); for (int i = 0; i < foundIn; i++) { - buddyBtreeCursors[i].reset(); + buddyBtreeCursors[i].close(); buddyBtreeRangePredicate.setHighKey(buddyBtreeTuple, true); btreeRangePredicate.setLowKey(buddyBtreeTuple, true); btreeAccessors[i].search(btreeCursors[i], btreeRangePredicate); @@ -137,7 +137,7 @@ public class LSMBTreeWithBuddySortedCursor extends LSMBTreeWithBuddyAbstractCurs break; } } finally { - btreeCursors[i].close(); + btreeCursors[i].destroy(); } } if (!killed) { @@ -160,7 +160,7 @@ public class LSMBTreeWithBuddySortedCursor extends LSMBTreeWithBuddyAbstractCurs depletedBtreeCursors = new boolean[numberOfTrees]; foundNext = false; for (int i = 0; i < numberOfTrees; i++) { - btreeCursors[i].reset(); + btreeCursors[i].close(); btreeAccessors[i].search(btreeCursors[i], btreeRangePredicate); if (btreeCursors[i].hasNext()) { btreeCursors[i].next(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java index 6115ba6..e9f410d 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java @@ -293,7 +293,6 @@ public abstract class AbstractLSMIndex implements ILSMIndex { @Override public void getOperationalComponents(ILSMIndexOperationContext ctx) throws HyracksDataException { - List<ILSMDiskComponent> immutableComponents = diskComponents; List<ILSMComponent> operationalComponents = ctx.getComponentHolder(); int cmc = currentMutableComponentId.get(); ctx.setCurrentMutableComponentId(cmc); @@ -309,14 +308,15 @@ public abstract class AbstractLSMIndex implements ILSMIndex { break; case INSERT: addOperationalMutableComponents(operationalComponents, true); - operationalComponents.addAll(immutableComponents); + operationalComponents.addAll(diskComponents); break; case SEARCH: if (memoryComponentsAllocated) { addOperationalMutableComponents(operationalComponents, false); } if (filterManager != null) { - for (ILSMComponent c : immutableComponents) { + for (int i = 0; i < diskComponents.size(); i++) { + ILSMComponent c = diskComponents.get(i); if (c.getLSMComponentFilter().satisfy( ((AbstractSearchPredicate) ctx.getSearchPredicate()).getMinFilterTuple(), ((AbstractSearchPredicate) ctx.getSearchPredicate()).getMaxFilterTuple(), @@ -325,7 +325,7 @@ public abstract class AbstractLSMIndex implements ILSMIndex { } } } else { - operationalComponents.addAll(immutableComponents); + operationalComponents.addAll(diskComponents); } break; @@ -334,13 +334,13 @@ public abstract class AbstractLSMIndex implements ILSMIndex { operationalComponents.addAll(ctx.getComponentsToBeMerged()); break; case FULL_MERGE: - operationalComponents.addAll(immutableComponents); + operationalComponents.addAll(diskComponents); break; case REPLICATE: operationalComponents.addAll(ctx.getComponentsToBeReplicated()); break; case DISK_COMPONENT_SCAN: - operationalComponents.addAll(immutableComponents); + operationalComponents.addAll(diskComponents); break; default: throw new UnsupportedOperationException("Operation " + ctx.getOperation() + " not supported."); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java index e37669e..2ba8a88 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java @@ -26,7 +26,6 @@ import java.util.PriorityQueue; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder; import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent; import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponentFilter; import org.apache.hyracks.storage.am.lsm.common.api.ILSMHarness; @@ -34,9 +33,8 @@ import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndexOperationContext; import org.apache.hyracks.storage.am.lsm.common.api.ILSMTreeTupleReference; import org.apache.hyracks.storage.common.IIndexCursor; import org.apache.hyracks.storage.common.MultiComparator; -import org.apache.hyracks.storage.common.buffercache.IBufferCache; -public abstract class LSMIndexSearchCursor implements ITreeIndexCursor { +public abstract class LSMIndexSearchCursor implements IIndexCursor { protected static final int SWITCH_COMPONENT_CYCLE = 100; protected final ILSMIndexOperationContext opCtx; protected final boolean returnDeletedTuples; @@ -107,7 +105,7 @@ public abstract class LSMIndexSearchCursor implements ITreeIndexCursor { } @Override - public void reset() throws HyracksDataException { + public void close() throws HyracksDataException { hasNextCallCount = 0; switchPossible = true; outputElement = null; @@ -122,7 +120,7 @@ public abstract class LSMIndexSearchCursor implements ITreeIndexCursor { if (rangeCursors != null) { for (int i = 0; i < rangeCursors.length; i++) { - rangeCursors[i].reset(); + rangeCursors[i].close(); } } rangeCursors = null; @@ -147,7 +145,7 @@ public abstract class LSMIndexSearchCursor implements ITreeIndexCursor { } @Override - public void close() throws HyracksDataException { + public void destroy() throws HyracksDataException { try { if (outputPriorityQueue != null) { outputPriorityQueue.clear(); @@ -155,7 +153,7 @@ public abstract class LSMIndexSearchCursor implements ITreeIndexCursor { if (rangeCursors != null) { for (int i = 0; i < rangeCursors.length; i++) { if (rangeCursors[i] != null) { - rangeCursors[i].close(); + rangeCursors[i].destroy(); } } rangeCursors = null; @@ -168,16 +166,6 @@ public abstract class LSMIndexSearchCursor implements ITreeIndexCursor { } @Override - public void setBufferCache(IBufferCache bufferCache) { - // do nothing - } - - @Override - public void setFileId(int fileId) { - // do nothing - } - - @Override public ITupleReference getTuple() { return outputElement.getTuple(); } @@ -202,7 +190,7 @@ public abstract class LSMIndexSearchCursor implements ITreeIndexCursor { outputPriorityQueue.offer(e); return; } - rangeCursors[cursorIndex].close(); + rangeCursors[cursorIndex].destroy(); if (cursorIndex == 0) { includeMutableComponent = false; } @@ -257,11 +245,6 @@ public abstract class LSMIndexSearchCursor implements ITreeIndexCursor { } } - @Override - public boolean isExclusiveLatchNodes() { - return false; - } - public class PriorityQueueElement { private ITupleReference tuple; private int cursorIndex; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMTreeIndexAccessor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMTreeIndexAccessor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMTreeIndexAccessor.java index c0fd443..4770d7c 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMTreeIndexAccessor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMTreeIndexAccessor.java @@ -27,7 +27,6 @@ import org.apache.hyracks.data.std.api.IValueReference; import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor; import org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference; import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference; -import org.apache.hyracks.storage.am.common.api.ITreeIndexCursor; import org.apache.hyracks.storage.am.common.ophelpers.IndexOperation; import org.apache.hyracks.storage.am.lsm.common.api.IFrameOperationCallback; import org.apache.hyracks.storage.am.lsm.common.api.IFrameTupleProcessor; @@ -45,7 +44,7 @@ import org.apache.hyracks.storage.common.ISearchPredicate; public class LSMTreeIndexAccessor implements ILSMIndexAccessor { @FunctionalInterface public interface ICursorFactory { - ITreeIndexCursor create(ILSMIndexOperationContext ctx); + IIndexCursor create(ILSMIndexOperationContext ctx); } protected final ILSMHarness lsmHarness; @@ -201,7 +200,7 @@ public class LSMTreeIndexAccessor implements ILSMIndexAccessor { } @Override - public ITreeIndexCursor createSearchCursor(boolean exclusive) { + public IIndexCursor createSearchCursor(boolean exclusive) { return cursorFactory.create(ctx); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java index 01f0f1a..05561f2 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java @@ -294,7 +294,7 @@ public class LSMInvertedIndex extends AbstractLSMIndex implements IInvertedIndex numBTreeTuples = IntegerPointable.getInteger(countTuple.getFieldData(0), countTuple.getFieldStart(0)); } } finally { - btreeCountingCursor.close(); + btreeCountingCursor.destroy(); } ILSMDiskComponentBulkLoader componentBulkLoader = @@ -310,7 +310,7 @@ public class LSMInvertedIndex extends AbstractLSMIndex implements IInvertedIndex componentBulkLoader.delete(deletedKeysScanCursor.getTuple()); } } finally { - deletedKeysScanCursor.close(); + deletedKeysScanCursor.destroy(); } // Scan the in-memory inverted index @@ -327,7 +327,7 @@ public class LSMInvertedIndex extends AbstractLSMIndex implements IInvertedIndex componentBulkLoader.add(scanCursor.getTuple()); } } finally { - scanCursor.close(); + scanCursor.destroy(); } if (component.getLSMComponentFilter() != null) { List<ITupleReference> filterTuples = new ArrayList<>(); @@ -383,7 +383,7 @@ public class LSMInvertedIndex extends AbstractLSMIndex implements IInvertedIndex componentBulkLoader.delete(tuple); } } finally { - btreeCursor.close(); + btreeCursor.destroy(); } } else { componentBulkLoader = component.createBulkLoader(1.0f, false, 0L, false, false, false); @@ -396,7 +396,7 @@ public class LSMInvertedIndex extends AbstractLSMIndex implements IInvertedIndex componentBulkLoader.add(tuple); } } finally { - cursor.close(); + cursor.destroy(); } if (component.getLSMComponentFilter() != null) { List<ITupleReference> filterTuples = new ArrayList<>(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexRangeSearchCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexRangeSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexRangeSearchCursor.java index d565b9a..4afccef 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexRangeSearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexRangeSearchCursor.java @@ -106,14 +106,14 @@ public class LSMInvertedIndexRangeSearchCursor extends LSMIndexSearchCursor { if (bloomFilters[i] != null && bloomFilters[i].contains(keysOnlyTuple, hashes)) { continue; } - deletedKeysBTreeCursors[i].reset(); + deletedKeysBTreeCursors[i].close(); try { deletedKeysBTreeAccessors.get(i).search(deletedKeysBTreeCursors[i], keySearchPred); if (deletedKeysBTreeCursors[i].hasNext()) { return true; } } finally { - deletedKeysBTreeCursors[i].close(); + deletedKeysBTreeCursors[i].destroy(); } } return false; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexSearchCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexSearchCursor.java index c214a2c..14ea6e1 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexSearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndexSearchCursor.java @@ -98,7 +98,7 @@ public class LSMInvertedIndexSearchCursor implements IIndexCursor { keySearchPred.setLowKey(key, true); keySearchPred.setHighKey(key, true); for (int i = 0; i < accessorIndex; i++) { - deletedKeysBTreeCursors[i].reset(); + deletedKeysBTreeCursors[i].close(); if (deletedKeysBTreeBloomFilters[i] != null && !deletedKeysBTreeBloomFilters[i].contains(key, hashes)) { continue; } @@ -108,7 +108,7 @@ public class LSMInvertedIndexSearchCursor implements IIndexCursor { return true; } } finally { - deletedKeysBTreeCursors[i].close(); + deletedKeysBTreeCursors[i].destroy(); } } return false; @@ -147,7 +147,7 @@ public class LSMInvertedIndexSearchCursor implements IIndexCursor { if (nextValidTuple()) { return true; } - currentCursor.close(); + currentCursor.destroy(); accessorIndex++; } while (accessorIndex < indexAccessors.size()) { @@ -159,7 +159,7 @@ public class LSMInvertedIndexSearchCursor implements IIndexCursor { return true; } // Close as we go to release resources. - currentCursor.close(); + currentCursor.destroy(); accessorIndex++; } return false; @@ -172,15 +172,15 @@ public class LSMInvertedIndexSearchCursor implements IIndexCursor { } @Override - public void close() throws HyracksDataException { - reset(); + public void destroy() throws HyracksDataException { + close(); } @Override - public void reset() throws HyracksDataException { + public void close() throws HyracksDataException { try { if (currentCursor != null) { - currentCursor.close(); + currentCursor.destroy(); currentCursor = null; } accessorIndex = 0; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/inmemory/InMemoryInvertedListCursor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/inmemory/InMemoryInvertedListCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/inmemory/InMemoryInvertedListCursor.java index 7078c4b..7bf5322 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/inmemory/InMemoryInvertedListCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/inmemory/InMemoryInvertedListCursor.java @@ -91,8 +91,8 @@ public class InMemoryInvertedListCursor implements IInvertedListCursor { tokenTuple.reset(tokenTupleBuilder.getFieldEndOffsets(), tokenTupleBuilder.getByteArray()); btreeSearchTuple.reset(); btreeSearchTuple.addTuple(tokenTuple); - btreeCursor.reset(); - countingCursor.reset(); + btreeCursor.close(); + countingCursor.close(); } @Override @@ -113,7 +113,7 @@ public class InMemoryInvertedListCursor implements IInvertedListCursor { @Override public void unpinPages() throws HyracksDataException { if (cursorNeedsClose) { - btreeCursor.close(); + btreeCursor.destroy(); cursorNeedsClose = false; } } @@ -154,7 +154,7 @@ public class InMemoryInvertedListCursor implements IInvertedListCursor { e.printStackTrace(); } finally { try { - countingCursor.close(); + countingCursor.destroy(); } catch (HyracksDataException e) { e.printStackTrace(); } @@ -197,8 +197,8 @@ public class InMemoryInvertedListCursor implements IInvertedListCursor { try { containsKey = btreeCursor.hasNext(); } finally { + btreeCursor.destroy(); btreeCursor.close(); - btreeCursor.reset(); btreeSearchTuple.removeLastTuple(); } return containsKey; @@ -219,8 +219,8 @@ public class InMemoryInvertedListCursor implements IInvertedListCursor { strBuilder.append(o.toString() + " "); } } finally { + btreeCursor.destroy(); btreeCursor.close(); - btreeCursor.reset(); } btreeAccessor.search(btreeCursor, btreePred); return strBuilder.toString(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/08dc8597/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/OnDiskInvertedIndex.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/OnDiskInvertedIndex.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/OnDiskInvertedIndex.java index 5301fa1..8db298d 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/OnDiskInvertedIndex.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/ondisk/OnDiskInvertedIndex.java @@ -205,8 +205,8 @@ public class OnDiskInvertedIndex implements IInPlaceInvertedIndex { listCursor.reset(0, 0, 0, 0); } } finally { + ctx.getBtreeCursor().destroy(); ctx.getBtreeCursor().close(); - ctx.getBtreeCursor().reset(); } } @@ -589,7 +589,7 @@ public class OnDiskInvertedIndex implements IInPlaceInvertedIndex { } } } finally { - btreeCursor.close(); + btreeCursor.destroy(); } }