implemented proper (and uniform) lifecycle management for all indexes
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_lsm_tree@1652 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDataflowHelper.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDataflowHelper.java
index cbd584e..eaf1be1 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDataflowHelper.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDataflowHelper.java
@@ -34,7 +34,8 @@
try {
return BTreeUtils.createBTree(opDesc.getStorageManager().getBufferCache(ctx), opDesc.getStorageManager()
.getFileMapProvider(ctx), treeOpDesc.getTreeIndexTypeTraits(), treeOpDesc
- .getTreeIndexComparatorFactories(), BTreeLeafFrameType.REGULAR_NSM);
+ .getTreeIndexComparatorFactories(), BTreeLeafFrameType.REGULAR_NSM, opDesc.getFileSplitProvider()
+ .getFileSplits()[partition].getLocalFile());
} catch (BTreeException e) {
throw new HyracksDataException(e);
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTree.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTree.java
index 6960077..9728be8 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTree.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/BTree.java
@@ -22,6 +22,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeFrame;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeInteriorFrame;
@@ -66,9 +67,9 @@
public BTree(IBufferCache bufferCache, IFileMapProvider fileMapProvider, IFreePageManager freePageManager,
ITreeIndexFrameFactory interiorFrameFactory, ITreeIndexFrameFactory leafFrameFactory,
- IBinaryComparatorFactory[] cmpFactories, int fieldCount) {
+ IBinaryComparatorFactory[] cmpFactories, int fieldCount, FileReference file) {
super(bufferCache, fileMapProvider, freePageManager, interiorFrameFactory, leafFrameFactory, cmpFactories,
- fieldCount);
+ fieldCount, file);
this.treeLatch = new ReentrantReadWriteLock(true);
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/util/BTreeUtils.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/util/BTreeUtils.java
index 3fa1309..1009127 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/util/BTreeUtils.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/util/BTreeUtils.java
@@ -3,6 +3,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
+import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.btree.exceptions.BTreeException;
import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeFieldPrefixNSMLeafFrameFactory;
@@ -23,15 +24,15 @@
public class BTreeUtils {
public static BTree createBTree(IBufferCache bufferCache, IFileMapProvider fileMapProvider,
- ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories, BTreeLeafFrameType leafType)
- throws BTreeException {
+ ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories, BTreeLeafFrameType leafType,
+ FileReference file) throws BTreeException {
TypeAwareTupleWriterFactory tupleWriterFactory = new TypeAwareTupleWriterFactory(typeTraits);
ITreeIndexFrameFactory leafFrameFactory = getLeafFrameFactory(tupleWriterFactory, leafType);
ITreeIndexFrameFactory interiorFrameFactory = new BTreeNSMInteriorFrameFactory(tupleWriterFactory);
ITreeIndexMetaDataFrameFactory metaFrameFactory = new LIFOMetaDataFrameFactory();
IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
BTree btree = new BTree(bufferCache, fileMapProvider, freePageManager, interiorFrameFactory, leafFrameFactory,
- cmpFactories, typeTraits.length);
+ cmpFactories, typeTraits.length, file);
return btree;
}
diff --git a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IIndex.java b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IIndex.java
index 5afd0fd..91e4c94 100644
--- a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IIndex.java
+++ b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IIndex.java
@@ -16,7 +16,6 @@
package edu.uci.ics.hyracks.storage.am.common.dataflow;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexAccessor;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexBulkLoader;
import edu.uci.ics.hyracks.storage.am.common.api.IModificationOperationCallback;
@@ -35,12 +34,10 @@
* Initializes the persistent state of an index, e.g., the root page, and
* metadata pages.
*
- * @param fileReference
- * The file id to use for this index.
* @throws HyracksDataException
* If the BufferCache throws while un/pinning or un/latching.
*/
- public void create(FileReference file) throws HyracksDataException;
+ public void create() throws HyracksDataException;
/**
* Opens the index backed by the given file id.
@@ -48,13 +45,17 @@
* @param fileReference
* The file id backing this index.
*/
- public void open(FileReference file) throws HyracksDataException;
+ public void open() throws HyracksDataException;
/**
* Closes the index.
*/
public void close() throws HyracksDataException;
+ public void destroy() throws HyracksDataException;
+
+ public void clear() throws HyracksDataException;
+
/**
* Creates an index accessor for performing operations on this index.
* (insert/delete/update/search/diskorderscan). An IIndexAccessor is not
diff --git a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexDataflowHelper.java b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexDataflowHelper.java
index 95b14d5..8e8b553 100644
--- a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexDataflowHelper.java
+++ b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/dataflow/IndexDataflowHelper.java
@@ -81,7 +81,7 @@
register = true;
}
if (forceCreate) {
- index.create(fileRef);
+ index.create();
// Create new resourceId
try {
resourceId = indexArtifactMap.create(baseDir, ioDeviceHandles);
@@ -89,8 +89,8 @@
throw new HyracksDataException(e);
}
}
- index.open(fileRef);
if (register) {
+ index.open();
indexRegistry.register(resourceId, index);
}
}
@@ -108,7 +108,6 @@
}
public void deinit() throws HyracksDataException {
- index.close();
}
public IIndex getIndex() {
diff --git a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/impls/AbstractTreeIndex.java b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/impls/AbstractTreeIndex.java
index 271764b..d650802 100644
--- a/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/impls/AbstractTreeIndex.java
+++ b/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/impls/AbstractTreeIndex.java
@@ -42,26 +42,24 @@
protected final static int rootPage = 1;
protected final IBufferCache bufferCache;
-
protected final IFileMapProvider fileMapProvider;
-
protected final IFreePageManager freePageManager;
protected final ITreeIndexFrameFactory interiorFrameFactory;
-
protected final ITreeIndexFrameFactory leafFrameFactory;
protected final IBinaryComparatorFactory[] cmpFactories;
-
protected final int fieldCount;
protected FileReference file;
+ protected int fileId = -1;
- protected int fileId;
+ private boolean isOpen = false;
public AbstractTreeIndex(IBufferCache bufferCache, IFileMapProvider fileMapProvider,
IFreePageManager freePageManager, ITreeIndexFrameFactory interiorFrameFactory,
- ITreeIndexFrameFactory leafFrameFactory, IBinaryComparatorFactory[] cmpFactories, int fieldCount) {
+ ITreeIndexFrameFactory leafFrameFactory, IBinaryComparatorFactory[] cmpFactories, int fieldCount,
+ FileReference file) {
this.bufferCache = bufferCache;
this.fileMapProvider = fileMapProvider;
this.freePageManager = freePageManager;
@@ -69,11 +67,60 @@
this.leafFrameFactory = leafFrameFactory;
this.cmpFactories = cmpFactories;
this.fieldCount = fieldCount;
+ this.file = file;
}
- private void initFile(FileReference file, boolean create) throws HyracksDataException {
- this.file = file;
- fileId = -1;
+ public synchronized void create() throws HyracksDataException {
+ if (isOpen) {
+ throw new HyracksDataException("Failed to create since index is already open.");
+ }
+
+ boolean fileIsMapped = false;
+ synchronized (fileMapProvider) {
+ fileIsMapped = fileMapProvider.isMapped(file);
+ if (!fileIsMapped) {
+ bufferCache.createFile(file);
+ }
+ fileId = fileMapProvider.lookupFileId(file);
+ try {
+ // Also creates the file if it doesn't exist yet.
+ bufferCache.openFile(fileId);
+ } catch (HyracksDataException e) {
+ // Revert state of buffer cache since file failed to open.
+ if (!fileIsMapped) {
+ bufferCache.deleteFile(fileId, false);
+ }
+ throw e;
+ }
+ }
+
+ freePageManager.open(fileId);
+ initEmptyTree();
+ freePageManager.close();
+ bufferCache.closeFile(fileId);
+ }
+
+ private void initEmptyTree() throws HyracksDataException {
+ ITreeIndexFrame frame = leafFrameFactory.createFrame();
+ ITreeIndexMetaDataFrame metaFrame = freePageManager.getMetaDataFrameFactory().createFrame();
+ freePageManager.init(metaFrame, rootPage);
+
+ ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage), true);
+ rootNode.acquireWriteLatch();
+ try {
+ frame.setPage(rootNode);
+ frame.initBuffer((byte) 0);
+ } finally {
+ rootNode.releaseWriteLatch();
+ bufferCache.unpin(rootNode);
+ }
+ }
+
+ public synchronized void open() throws HyracksDataException {
+ if (isOpen) {
+ return;
+ }
+
boolean fileIsMapped = false;
synchronized (fileMapProvider) {
fileIsMapped = fileMapProvider.isMapped(file);
@@ -94,38 +141,45 @@
}
freePageManager.open(fileId);
- if (create) {
- ITreeIndexFrame frame = leafFrameFactory.createFrame();
- ITreeIndexMetaDataFrame metaFrame = freePageManager.getMetaDataFrameFactory().createFrame();
+ // TODO: Should probably have some way to check that the tree is physically consistent
+ // or that the file we just opened actually is a tree
- freePageManager.init(metaFrame, rootPage);
+ isOpen = true;
+ }
- ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage), true);
- rootNode.acquireWriteLatch();
- try {
- frame.setPage(rootNode);
- frame.initBuffer((byte) 0);
- } finally {
- rootNode.releaseWriteLatch();
- bufferCache.unpin(rootNode);
- }
+ public synchronized void close() throws HyracksDataException {
+ if (!isOpen) {
+ return;
}
- }
- public synchronized void create(FileReference file) throws HyracksDataException {
- initFile(file, true);
- }
-
- public void open(FileReference file) throws HyracksDataException {
- initFile(file, false);
- }
-
- public void close() throws HyracksDataException {
bufferCache.closeFile(fileId);
freePageManager.close();
+
+ isOpen = false;
+ }
+
+ public synchronized void destroy() throws HyracksDataException {
+ if (isOpen) {
+ throw new HyracksDataException("Failed to destroy since index is already open.");
+ }
+
+ file.getFile().delete();
+ if (fileId == -1) {
+ return;
+ }
+
+ bufferCache.deleteFile(fileId, false);
fileId = -1;
}
+ public synchronized void clear() throws HyracksDataException {
+ if (!isOpen) {
+ throw new HyracksDataException("Failed to clear since index is not open.");
+ }
+
+ initEmptyTree();
+ }
+
public boolean isEmptyTree(ITreeIndexFrame frame) throws HyracksDataException {
ICachedPage rootNode = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, rootPage), false);
rootNode.acquireReadLatch();
@@ -194,21 +248,13 @@
public abstract class AbstractTreeIndexBulkLoader implements IIndexBulkLoader {
protected final MultiComparator cmp;
-
protected final int slotSize;
-
protected final int leafMaxBytes;
-
protected final int interiorMaxBytes;
-
protected final ArrayList<NodeFrontier> nodeFrontiers = new ArrayList<NodeFrontier>();
-
protected final ITreeIndexMetaDataFrame metaFrame;
-
protected final ITreeIndexTupleWriter tupleWriter;
-
protected ITreeIndexFrame leafFrame;
-
protected ITreeIndexFrame interiorFrame;
public AbstractTreeIndexBulkLoader(float fillFactor) throws TreeIndexException, HyracksDataException {
diff --git a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexDataflowHelper.java b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexDataflowHelper.java
index f04c02c..15d73b9 100644
--- a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexDataflowHelper.java
+++ b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexDataflowHelper.java
@@ -53,6 +53,7 @@
return new InvertedIndex(opDesc.getStorageManager().getBufferCache(ctx), btree,
invIndexOpDesc.getInvListsTypeTraits(), invIndexOpDesc.getInvListsComparatorFactories(),
invListBuilder, invIndexOpDesc.getTokenizerFactory().createTokenizer(), opDesc.getStorageManager()
- .getFileMapProvider(ctx));
+ .getFileMapProvider(ctx),
+ opDesc.getFileSplitProvider().getFileSplits()[partition].getLocalFile());
}
}
\ No newline at end of file
diff --git a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/impls/InvertedIndex.java b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/impls/InvertedIndex.java
index ebd09b7..b43a594 100644
--- a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/impls/InvertedIndex.java
+++ b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/impls/InvertedIndex.java
@@ -76,9 +76,11 @@
private final int numTokenFields;
private final int numInvListKeys;
+ private boolean isOpen = false;
+
public InvertedIndex(IBufferCache bufferCache, BTree btree, ITypeTraits[] invListTypeTraits,
IBinaryComparatorFactory[] invListCmpFactories, IInvertedListBuilder invListBuilder,
- IBinaryTokenizer tokenizer, IFileMapProvider fileMapProvider) {
+ IBinaryTokenizer tokenizer, IFileMapProvider fileMapProvider, FileReference file) {
this.bufferCache = bufferCache;
this.fileMapProvider = fileMapProvider;
this.btree = btree;
@@ -88,11 +90,42 @@
this.tokenizer = tokenizer;
this.numTokenFields = btree.getComparatorFactories().length;
this.numInvListKeys = invListCmpFactories.length;
+ this.file = file;
}
- private void initFile(FileReference file, boolean create) throws HyracksDataException {
- this.file = file;
- fileId = -1;
+ @Override
+ public synchronized void create() throws HyracksDataException {
+ if (isOpen) {
+ throw new HyracksDataException("Failed to create since index is already open.");
+ }
+
+ boolean fileIsMapped = false;
+ synchronized (fileMapProvider) {
+ fileIsMapped = fileMapProvider.isMapped(file);
+ if (!fileIsMapped) {
+ bufferCache.createFile(file);
+ }
+ fileId = fileMapProvider.lookupFileId(file);
+ try {
+ // Also creates the file if it doesn't exist yet.
+ bufferCache.openFile(fileId);
+ } catch (HyracksDataException e) {
+ // Revert state of buffer cache since file failed to open.
+ if (!fileIsMapped) {
+ bufferCache.deleteFile(fileId, false);
+ }
+ throw e;
+ }
+ }
+ bufferCache.closeFile(fileId);
+ }
+
+ @Override
+ public synchronized void open() throws HyracksDataException {
+ if (isOpen) {
+ return;
+ }
+
boolean fileIsMapped = false;
synchronized (fileMapProvider) {
fileIsMapped = fileMapProvider.isMapped(file);
@@ -112,21 +145,63 @@
}
}
+ isOpen = true;
}
@Override
- public void create(FileReference file) throws HyracksDataException {
- initFile(file, true);
+ public synchronized void close() throws HyracksDataException {
+ if (!isOpen) {
+ return;
+ }
+
+ bufferCache.closeFile(fileId);
+
+ isOpen = false;
}
@Override
- public void open(FileReference file) throws HyracksDataException {
- initFile(file, false);
+ public synchronized void destroy() throws HyracksDataException {
+ if (isOpen) {
+ throw new HyracksDataException("Failed to destroy since index is already open.");
+ }
+
+ file.getFile().delete();
+ if (fileId == -1) {
+ return;
+ }
+
+ bufferCache.deleteFile(fileId, false);
+ fileId = -1;
}
@Override
- public void close() {
- this.fileId = -1;
+ public synchronized void clear() throws HyracksDataException {
+ if (!isOpen) {
+ throw new HyracksDataException("Failed to clear since index is not open.");
+ }
+ btree.clear();
+ bufferCache.closeFile(fileId);
+ bufferCache.deleteFile(fileId, false);
+ file.getFile().delete();
+
+ boolean fileIsMapped = false;
+ synchronized (fileMapProvider) {
+ fileIsMapped = fileMapProvider.isMapped(file);
+ if (!fileIsMapped) {
+ bufferCache.createFile(file);
+ }
+ fileId = fileMapProvider.lookupFileId(file);
+ try {
+ // Also creates the file if it doesn't exist yet.
+ bufferCache.openFile(fileId);
+ } catch (HyracksDataException e) {
+ // Revert state of buffer cache since file failed to open.
+ if (!fileIsMapped) {
+ bufferCache.deleteFile(fileId, false);
+ }
+ throw e;
+ }
+ }
}
public boolean openCursor(ITreeIndexCursor btreeCursor, RangePredicate btreePred, ITreeIndexAccessor btreeAccessor,
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 2565d3c..aaa497b 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
@@ -56,9 +56,9 @@
import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMOperationTracker;
import edu.uci.ics.hyracks.storage.am.lsm.common.freepage.InMemoryBufferCache;
import edu.uci.ics.hyracks.storage.am.lsm.common.freepage.InMemoryFreePageManager;
-import edu.uci.ics.hyracks.storage.am.lsm.common.impls.BTreeFactory;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.LSMHarness;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor;
+import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeFactory;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeIndexComponentFinalizer;
import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
@@ -76,10 +76,10 @@
// On-disk components.
private final ILSMFileManager fileManager;
// For creating BTree's used in flush and merge.
- private final BTreeFactory diskBTreeFactory;
+ private final TreeFactory<BTree> diskBTreeFactory;
// For creating BTree's used in bulk load. Different from diskBTreeFactory
// because it should have a different tuple writer in it's leaf frames.
- private final BTreeFactory bulkLoadBTreeFactory;
+ private final TreeFactory<BTree> bulkLoadBTreeFactory;
private final IBufferCache diskBufferCache;
private final IFileMapProvider diskFileMapProvider;
// List of BTree instances. Using Object for better sharing via ILSMTree + LSMHarness.
@@ -97,11 +97,13 @@
public LSMBTree(IBufferCache memBufferCache, InMemoryFreePageManager memFreePageManager,
ITreeIndexFrameFactory interiorFrameFactory, ITreeIndexFrameFactory insertLeafFrameFactory,
ITreeIndexFrameFactory deleteLeafFrameFactory, ILSMFileManager fileNameManager,
- BTreeFactory diskBTreeFactory, BTreeFactory bulkLoadBTreeFactory, IFileMapProvider diskFileMapProvider,
- int fieldCount, IBinaryComparatorFactory[] cmpFactories, ILSMFlushController flushController,
- ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker, ILSMIOScheduler ioScheduler) {
+ TreeFactory<BTree> diskBTreeFactory, TreeFactory<BTree> bulkLoadBTreeFactory,
+ IFileMapProvider diskFileMapProvider, int fieldCount, IBinaryComparatorFactory[] cmpFactories,
+ ILSMFlushController flushController, ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker,
+ ILSMIOScheduler ioScheduler) {
memBTree = new BTree(memBufferCache, ((InMemoryBufferCache) memBufferCache).getFileMapProvider(),
- memFreePageManager, interiorFrameFactory, insertLeafFrameFactory, cmpFactories, fieldCount);
+ memFreePageManager, interiorFrameFactory, insertLeafFrameFactory, cmpFactories, fieldCount,
+ memBtreeFile);
this.memFreePageManager = memFreePageManager;
this.insertLeafFrameFactory = insertLeafFrameFactory;
this.deleteLeafFrameFactory = deleteLeafFrameFactory;
@@ -117,8 +119,13 @@
}
@Override
- public void create(FileReference fileReference) throws HyracksDataException {
- memBTree.create(memBtreeFile);
+ public synchronized void create() throws HyracksDataException {
+ if (isOpen) {
+ throw new HyracksDataException("Failed to create since index is already open.");
+ }
+
+ memBTree.create();
+ fileManager.deleteDirs();
fileManager.createDirs();
}
@@ -131,39 +138,65 @@
* @throws HyracksDataException
*/
@Override
- public void open(FileReference fileReference) throws HyracksDataException {
- synchronized (this) {
- if (isOpen) {
- return;
- }
- memBTree.open(memBtreeFile);
- BTree dummyBTree = diskBTreeFactory.createIndexInstance();
- dummyBTree.create(new FileReference(new File("dummy")));
- List<Object> validFileNames = fileManager.cleanupAndGetValidFiles(dummyBTree, componentFinalizer);
- for (Object o : validFileNames) {
- String fileName = (String) o;
- FileReference fileRef = new FileReference(new File(fileName));
- BTree btree = createDiskBTree(diskBTreeFactory, fileRef, false);
- diskBTrees.add(btree);
- }
- isOpen = true;
+ public synchronized void open() throws HyracksDataException {
+ if (isOpen) {
+ return;
}
+
+ memBTree.open();
+ List<Object> validFileNames = fileManager.cleanupAndGetValidFiles(componentFinalizer);
+ for (Object o : validFileNames) {
+ String fileName = (String) o;
+ FileReference fileRef = new FileReference(new File(fileName));
+ BTree btree = createDiskBTree(diskBTreeFactory, fileRef, false);
+ diskBTrees.add(btree);
+ }
+ isOpen = true;
}
@Override
- public void close() throws HyracksDataException {
- synchronized (this) {
- if (!isOpen) {
- return;
- }
- for (Object o : diskBTrees) {
- BTree btree = (BTree) o;
- btree.close();
- }
- diskBTrees.clear();
- memBTree.close();
- isOpen = false;
+ public synchronized void close() throws HyracksDataException {
+ if (!isOpen) {
+ return;
}
+
+ for (Object o : diskBTrees) {
+ BTree btree = (BTree) o;
+ btree.close();
+ }
+ diskBTrees.clear();
+ memBTree.close();
+
+ isOpen = false;
+ }
+
+ @Override
+ public void destroy() throws HyracksDataException {
+ if (isOpen) {
+ throw new HyracksDataException("Failed to destroy since index is already open.");
+ }
+
+ for (Object o : diskBTrees) {
+ BTree btree = (BTree) o;
+ btree.destroy();
+ }
+ memBTree.destroy();
+ fileManager.deleteDirs();
+ }
+
+ @Override
+ public void clear() throws HyracksDataException {
+ if (!isOpen) {
+ throw new HyracksDataException("Failed to clear since index is not open.");
+ }
+
+ memBTree.clear();
+ for (Object o : diskBTrees) {
+ BTree btree = (BTree) o;
+ btree.close();
+ btree.destroy();
+ }
+ diskBTrees.clear();
}
@Override
@@ -212,7 +245,7 @@
@Override
public void resetInMemoryComponent() throws HyracksDataException {
memFreePageManager.reset();
- memBTree.create(memBTree.getFileReference());
+ memBTree.clear();
}
private BTree createBulkLoadTarget() throws HyracksDataException {
@@ -238,15 +271,15 @@
return createDiskBTree(diskBTreeFactory, fileRef, true);
}
- private BTree createDiskBTree(BTreeFactory factory, FileReference fileRef, boolean createBTree)
+ private BTree createDiskBTree(TreeFactory<BTree> factory, FileReference fileRef, boolean createBTree)
throws HyracksDataException {
// Create new BTree instance.
- BTree diskBTree = factory.createIndexInstance();
+ BTree diskBTree = factory.createIndexInstance(fileRef);
if (createBTree) {
- diskBTree.create(fileRef);
+ diskBTree.create();
}
// BTree will be closed during cleanup of merge().
- diskBTree.open(fileRef);
+ diskBTree.open();
return diskBTree;
}
diff --git a/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/util/LSMBTreeUtils.java b/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/util/LSMBTreeUtils.java
index fa47a53..626cd6f 100644
--- a/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/util/LSMBTreeUtils.java
+++ b/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/util/LSMBTreeUtils.java
@@ -21,6 +21,7 @@
import edu.uci.ics.hyracks.api.io.IIOManager;
import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory;
import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory;
+import edu.uci.ics.hyracks.storage.am.btree.impls.BTree;
import edu.uci.ics.hyracks.storage.am.common.api.IFreePageManagerFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexMetaDataFrameFactory;
@@ -38,6 +39,7 @@
import edu.uci.ics.hyracks.storage.am.lsm.common.freepage.InMemoryFreePageManager;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.BTreeFactory;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.LSMTreeFileManager;
+import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeFactory;
import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
@@ -60,11 +62,12 @@
ITreeIndexMetaDataFrameFactory metaFrameFactory = new LIFOMetaDataFrameFactory();
IFreePageManagerFactory freePageManagerFactory = new LinkedListFreePageManagerFactory(diskBufferCache,
metaFrameFactory);
- BTreeFactory diskBTreeFactory = new BTreeFactory(diskBufferCache, diskFileMapProvider, freePageManagerFactory,
- interiorFrameFactory, copyTupleLeafFrameFactory, cmpFactories, typeTraits.length);
- BTreeFactory bulkLoadBTreeFactory = new BTreeFactory(diskBufferCache, diskFileMapProvider,
+ TreeFactory<BTree> diskBTreeFactory = new BTreeFactory(diskBufferCache, diskFileMapProvider,
+ freePageManagerFactory, interiorFrameFactory, copyTupleLeafFrameFactory, cmpFactories,
+ typeTraits.length);
+ TreeFactory<BTree> bulkLoadBTreeFactory = new BTreeFactory(diskBufferCache, diskFileMapProvider,
freePageManagerFactory, interiorFrameFactory, insertLeafFrameFactory, cmpFactories, typeTraits.length);
- ILSMFileManager fileNameManager = new LSMTreeFileManager(ioManager, diskFileMapProvider, file);
+ ILSMFileManager fileNameManager = new LSMTreeFileManager(ioManager, diskFileMapProvider, file, diskBTreeFactory);
LSMBTree lsmTree = new LSMBTree(memBufferCache, memFreePageManager, interiorFrameFactory,
insertLeafFrameFactory, deleteLeafFrameFactory, fileNameManager, diskBTreeFactory,
bulkLoadBTreeFactory, diskFileMapProvider, typeTraits.length, cmpFactories, flushController,
diff --git a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMComponentFinalizer.java b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMComponentFinalizer.java
index b88560d..86f709a 100644
--- a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMComponentFinalizer.java
+++ b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMComponentFinalizer.java
@@ -15,7 +15,6 @@
package edu.uci.ics.hyracks.storage.am.lsm.common.api;
-import java.io.File;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -25,7 +24,7 @@
* Checks whether the given file is valid with respect to the given LSM component.
* Used for guaranteeing the atomicity of LSM component writes.
*/
- public boolean isValid(File file, Object lsmComponent) throws HyracksDataException;
+ public boolean isValid(Object lsmComponent) throws HyracksDataException;
/**
* Marks the given LSM component as physically valid, synchronously forcing
diff --git a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMFileManager.java b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMFileManager.java
index d37e535..8311a0f 100644
--- a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMFileManager.java
+++ b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMFileManager.java
@@ -24,7 +24,6 @@
/**
* Provides file names for LSM on-disk components. Also cleans up invalid files.
- *
* There are separate methods to get file names for merge and flush because we
* need to guarantee the correct order of on-disk components (i.e., the
* components produced by flush are always newer than those produced by a
@@ -33,6 +32,8 @@
public interface ILSMFileManager {
public void createDirs();
+ public void deleteDirs();
+
public FileReference createFlushFile(String relFlushFileName);
public FileReference createMergeFile(String relMergeFileName);
@@ -45,8 +46,7 @@
// Deletes invalid files, and returns list of valid files from baseDir.
// The returned valid files are correctly sorted (based on the recency of data).
- public List<Object> cleanupAndGetValidFiles(Object lsmComponent, ILSMComponentFinalizer componentFinalizer)
- throws HyracksDataException;
+ public List<Object> cleanupAndGetValidFiles(ILSMComponentFinalizer componentFinalizer) throws HyracksDataException;
public Comparator<String> getFileNameComparator();
diff --git a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/BTreeFactory.java b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/BTreeFactory.java
index bf642c2..a0d80c8 100644
--- a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/BTreeFactory.java
+++ b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/BTreeFactory.java
@@ -16,6 +16,7 @@
package edu.uci.ics.hyracks.storage.am.lsm.common.impls;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.btree.impls.BTree;
import edu.uci.ics.hyracks.storage.am.common.api.IFreePageManagerFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
@@ -32,9 +33,9 @@
}
@Override
- public BTree createIndexInstance() {
+ public BTree createIndexInstance(FileReference file) {
return new BTree(bufferCache, fileMapProvider, freePageManagerFactory.createFreePageManager(),
- interiorFrameFactory, leafFrameFactory, cmpFactories, fieldCount);
+ interiorFrameFactory, leafFrameFactory, cmpFactories, fieldCount, file);
}
}
diff --git a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMTreeFileManager.java b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMTreeFileManager.java
index 2f98b6f..4f2e1df 100644
--- a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMTreeFileManager.java
+++ b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMTreeFileManager.java
@@ -29,6 +29,7 @@
import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.api.io.IIOManager;
import edu.uci.ics.hyracks.api.io.IODeviceHandle;
+import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndex;
import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMComponentFinalizer;
import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMFileManager;
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
@@ -41,6 +42,7 @@
// where to flush and merge
protected final IIOManager ioManager;
protected final IFileMapProvider fileMapProvider;
+ protected final TreeFactory<? extends ITreeIndex> treeFactory;
// baseDir should reflect dataset name and partition name.
protected FileReference file;
@@ -58,7 +60,8 @@
}
};
- public LSMTreeFileManager(IIOManager ioManager, IFileMapProvider fileMapProvider, FileReference file) {
+ public LSMTreeFileManager(IIOManager ioManager, IFileMapProvider fileMapProvider, FileReference file,
+ TreeFactory<? extends ITreeIndex> treeFactory) {
this.file = file;
this.baseDir = file.getFile().getPath();
if (!baseDir.endsWith(System.getProperty("file.separator"))) {
@@ -66,6 +69,7 @@
}
this.fileMapProvider = fileMapProvider;
this.ioManager = ioManager;
+ this.treeFactory = treeFactory;
}
@Override
@@ -76,6 +80,27 @@
}
}
+ @Override
+ public void deleteDirs() {
+ for (IODeviceHandle dev : ioManager.getIODevices()) {
+ File f = new File(dev.getPath(), baseDir);
+ if (f.isDirectory()) {
+ deleteDir(f);
+ }
+ }
+ }
+
+ private void deleteDir(File dir) {
+ for (File f : dir.listFiles()) {
+ if (f.isDirectory()) {
+ deleteDir(f);
+ } else {
+ f.delete();
+ }
+ }
+ dir.delete();
+ }
+
public FileReference createFlushFile(String relFlushFileName) {
// Assigns new files to I/O devices in round-robin fashion.
IODeviceHandle dev = ioManager.getIODevices().get(ioDeviceIndex);
@@ -128,14 +153,14 @@
return baseDir;
}
- protected void cleanupAndGetValidFilesInternal(IODeviceHandle dev, FilenameFilter filter, Object lsmComponent,
- ILSMComponentFinalizer componentFinalizer, ArrayList<ComparableFileName> allFiles)
- throws HyracksDataException {
+ protected void cleanupAndGetValidFilesInternal(IODeviceHandle dev, FilenameFilter filter,
+ TreeFactory<? extends ITreeIndex> treeFactory, ILSMComponentFinalizer componentFinalizer,
+ ArrayList<ComparableFileName> allFiles) throws HyracksDataException {
File dir = new File(dev.getPath(), baseDir);
String[] files = dir.list(filter);
for (String fileName : files) {
File file = new File(dir.getPath() + File.separator + fileName);
- if (componentFinalizer.isValid(file, lsmComponent)) {
+ if (componentFinalizer.isValid(treeFactory.createIndexInstance(new FileReference(file)))) {
allFiles.add(new ComparableFileName(file.getAbsolutePath()));
} else {
file.delete();
@@ -144,8 +169,7 @@
}
@Override
- public List<Object> cleanupAndGetValidFiles(Object lsmComponent, ILSMComponentFinalizer componentFinalizer)
- throws HyracksDataException {
+ public List<Object> cleanupAndGetValidFiles(ILSMComponentFinalizer componentFinalizer) throws HyracksDataException {
List<Object> validFiles = new ArrayList<Object>();
ArrayList<ComparableFileName> allFiles = new ArrayList<ComparableFileName>();
@@ -155,7 +179,7 @@
// (2) The file's interval is contained by some other file
// Here, we only filter out (1).
for (IODeviceHandle dev : ioManager.getIODevices()) {
- cleanupAndGetValidFilesInternal(dev, fileNameFilter, lsmComponent, componentFinalizer, allFiles);
+ cleanupAndGetValidFilesInternal(dev, fileNameFilter, treeFactory, componentFinalizer, allFiles);
}
if (allFiles.isEmpty()) {
diff --git a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/TreeFactory.java b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/TreeFactory.java
index 90ef20d..7a50a3b 100644
--- a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/TreeFactory.java
+++ b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/TreeFactory.java
@@ -16,6 +16,7 @@
package edu.uci.ics.hyracks.storage.am.lsm.common.impls;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.common.api.IFreePageManagerFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndex;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
@@ -50,7 +51,7 @@
this.fieldCount = fieldCount;
}
- public abstract T createIndexInstance();
+ public abstract T createIndexInstance(FileReference file);
public IBufferCache getBufferCache() {
return bufferCache;
diff --git a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/TreeIndexComponentFinalizer.java b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/TreeIndexComponentFinalizer.java
index e6dc66b..d87bf5b 100644
--- a/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/TreeIndexComponentFinalizer.java
+++ b/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/TreeIndexComponentFinalizer.java
@@ -15,10 +15,7 @@
package edu.uci.ics.hyracks.storage.am.lsm.common.impls;
-import java.io.File;
-
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndex;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexMetaDataFrame;
import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMComponentFinalizer;
@@ -36,11 +33,10 @@
}
@Override
- public boolean isValid(File file, Object lsmComponent) throws HyracksDataException {
+ public boolean isValid(Object lsmComponent) throws HyracksDataException {
ITreeIndex treeIndex = (ITreeIndex) lsmComponent;
IBufferCache bufferCache = treeIndex.getBufferCache();
- FileReference fileRef = new FileReference(file);
- treeIndex.open(fileRef);
+ treeIndex.open();
try {
int metadataPage = treeIndex.getFreePageManager().getFirstMetadataPage();
ITreeIndexMetaDataFrame metadataFrame = treeIndex.getFreePageManager().getMetaDataFrameFactory()
diff --git a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
index 498db30..35d16a3 100644
--- a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
+++ b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
@@ -97,7 +97,7 @@
protected final IBufferCache diskBufferCache;
protected final IFileMapProvider diskFileMapProvider;
// For creating RTree's used in flush and merge.
- protected final RTreeFactory diskRTreeFactory;
+ protected final TreeFactory<RTree> diskRTreeFactory;
// List of LSMRTreeComponent instances. Using Object for better sharing via
// ILSMTree + LSMHarness.
protected final LinkedList<Object> diskComponents = new LinkedList<Object>();
@@ -113,18 +113,22 @@
protected final ITreeIndexFrameFactory rtreeLeafFrameFactory;
protected final ITreeIndexFrameFactory btreeLeafFrameFactory;
+ private boolean isOpen = false;
+
public AbstractLSMRTree(IBufferCache memBufferCache, InMemoryFreePageManager memFreePageManager,
ITreeIndexFrameFactory rtreeInteriorFrameFactory, ITreeIndexFrameFactory rtreeLeafFrameFactory,
ITreeIndexFrameFactory btreeInteriorFrameFactory, ITreeIndexFrameFactory btreeLeafFrameFactory,
- ILSMFileManager fileManager, RTreeFactory diskRTreeFactory, IFileMapProvider diskFileMapProvider,
+ ILSMFileManager fileManager, TreeFactory<RTree> diskRTreeFactory, IFileMapProvider diskFileMapProvider,
ILSMComponentFinalizer componentFinalizer, int fieldCount, IBinaryComparatorFactory[] rtreeCmpFactories,
IBinaryComparatorFactory[] btreeCmpFactories, ILinearizeComparatorFactory linearizer,
int[] comparatorFields, IBinaryComparatorFactory[] linearizerArray, ILSMFlushController flushController,
ILSMMergePolicy mergePolicy, ILSMOperationTracker opTracker, ILSMIOScheduler ioScheduler) {
RTree memRTree = new RTree(memBufferCache, ((InMemoryBufferCache) memBufferCache).getFileMapProvider(),
- memFreePageManager, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, rtreeCmpFactories, fieldCount);
+ memFreePageManager, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, rtreeCmpFactories, fieldCount,
+ memBtreeFile);
BTree memBTree = new BTree(memBufferCache, ((InMemoryBufferCache) memBufferCache).getFileMapProvider(),
- memFreePageManager, btreeInteriorFrameFactory, btreeLeafFrameFactory, btreeCmpFactories, fieldCount);
+ memFreePageManager, btreeInteriorFrameFactory, btreeLeafFrameFactory, btreeCmpFactories, fieldCount,
+ memRtreeFile);
memComponent = new LSMRTreeComponent(memRTree, memBTree);
this.memFreePageManager = memFreePageManager;
this.diskBufferCache = diskRTreeFactory.getBufferCache();
@@ -145,34 +149,71 @@
}
@Override
- public void create(FileReference fileReference) throws HyracksDataException {
- memComponent.getRTree().create(memRtreeFile);
- memComponent.getBTree().create(memBtreeFile);
+ public synchronized void create() throws HyracksDataException {
+ if (isOpen) {
+ throw new HyracksDataException("Failed to create since index is already open.");
+ }
+
+ fileManager.deleteDirs();
fileManager.createDirs();
+ memComponent.getRTree().create();
+ memComponent.getBTree().create();
}
@Override
- public void open(FileReference fileReference) throws HyracksDataException {
- memComponent.getRTree().open(memRtreeFile);
- memComponent.getBTree().open(memBtreeFile);
+ public synchronized void open() throws HyracksDataException {
+ if (isOpen) {
+ return;
+ }
+
+ memComponent.getRTree().open();
+ memComponent.getBTree().open();
+ isOpen = true;
}
@Override
- public void close() throws HyracksDataException {
+ public synchronized void close() throws HyracksDataException {
+ if (!isOpen) {
+ return;
+ }
+
+ isOpen = false;
+
memComponent.getRTree().close();
memComponent.getBTree().close();
}
+ @Override
+ public synchronized void destroy() throws HyracksDataException {
+ if (isOpen) {
+ throw new HyracksDataException("Failed to destroy since index is already open.");
+ }
+
+ memComponent.getRTree().close();
+ memComponent.getBTree().close();
+ fileManager.deleteDirs();
+ }
+
+ @Override
+ public synchronized void clear() throws HyracksDataException {
+ if (!isOpen) {
+ throw new HyracksDataException("Failed to clear since index is not open.");
+ }
+
+ memComponent.getRTree().clear();
+ memComponent.getBTree().clear();
+ }
+
@SuppressWarnings("rawtypes")
protected ITreeIndex createDiskTree(TreeFactory diskTreeFactory, FileReference fileRef, boolean createTree)
throws HyracksDataException {
// Create new tree instance.
- ITreeIndex diskTree = diskTreeFactory.createIndexInstance();
+ ITreeIndex diskTree = diskTreeFactory.createIndexInstance(fileRef);
if (createTree) {
- diskTree.create(fileRef);
+ diskTree.create();
}
// Tree will be closed during cleanup of merge().
- diskTree.open(fileRef);
+ diskTree.open();
return diskTree;
}
@@ -282,9 +323,9 @@
@Override
public void resetInMemoryComponent() throws HyracksDataException {
- memComponent.getRTree().create(memRtreeFile);
- memComponent.getBTree().create(memBtreeFile);
memFreePageManager.reset();
+ memComponent.getRTree().clear();
+ memComponent.getBTree().clear();
memRTreeTuples = 0;
memBTreeTuples = 0;
}
diff --git a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java
index 4561615..6954eb6 100644
--- a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java
+++ b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTree.java
@@ -47,9 +47,9 @@
import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMMergePolicy;
import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMOperationTracker;
import edu.uci.ics.hyracks.storage.am.lsm.common.freepage.InMemoryFreePageManager;
-import edu.uci.ics.hyracks.storage.am.lsm.common.impls.BTreeFactory;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.LSMHarness;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor;
+import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeFactory;
import edu.uci.ics.hyracks.storage.am.lsm.rtree.impls.LSMRTreeFileManager.LSMRTreeFileNameComponent;
import edu.uci.ics.hyracks.storage.am.rtree.impls.RTree;
import edu.uci.ics.hyracks.storage.am.rtree.impls.RTree.RTreeBulkLoader;
@@ -62,12 +62,12 @@
// On-disk components.
// For creating BTree's used in flush and merge.
- private final BTreeFactory diskBTreeFactory;
+ private final TreeFactory<BTree> diskBTreeFactory;
public LSMRTree(IBufferCache memBufferCache, InMemoryFreePageManager memFreePageManager,
ITreeIndexFrameFactory rtreeInteriorFrameFactory, ITreeIndexFrameFactory rtreeLeafFrameFactory,
ITreeIndexFrameFactory btreeInteriorFrameFactory, ITreeIndexFrameFactory btreeLeafFrameFactory,
- ILSMFileManager fileManager, RTreeFactory diskRTreeFactory, BTreeFactory diskBTreeFactory,
+ ILSMFileManager fileManager, TreeFactory<RTree> diskRTreeFactory, TreeFactory<BTree> diskBTreeFactory,
IFileMapProvider diskFileMapProvider, int fieldCount, IBinaryComparatorFactory[] rtreeCmpFactories,
IBinaryComparatorFactory[] btreeCmpFactories, ILinearizeComparatorFactory linearizer,
int[] comparatorFields, IBinaryComparatorFactory[] linearizerArray, ILSMFlushController flushController,
@@ -88,14 +88,9 @@
* @throws HyracksDataException
*/
@Override
- public void open(FileReference fileReference) throws HyracksDataException {
- super.open(fileReference);
- RTree dummyRTree = diskRTreeFactory.createIndexInstance();
- dummyRTree.create(new FileReference(new File("dummyrtree")));
- BTree dummyBTree = diskBTreeFactory.createIndexInstance();
- dummyBTree.create(new FileReference(new File("dummybtree")));
- LSMRTreeComponent dummyComponent = new LSMRTreeComponent(dummyRTree, dummyBTree);
- List<Object> validFileNames = fileManager.cleanupAndGetValidFiles(dummyComponent, componentFinalizer);
+ public synchronized void open() throws HyracksDataException {
+ super.open();
+ List<Object> validFileNames = fileManager.cleanupAndGetValidFiles(componentFinalizer);
for (Object o : validFileNames) {
LSMRTreeFileNameComponent component = (LSMRTreeFileNameComponent) o;
FileReference rtreeFile = new FileReference(new File(component.getRTreeFileName()));
@@ -108,7 +103,7 @@
}
@Override
- public void close() throws HyracksDataException {
+ public synchronized void close() throws HyracksDataException {
for (Object o : diskComponents) {
LSMRTreeComponent diskComponent = (LSMRTreeComponent) o;
RTree rtree = diskComponent.getRTree();
@@ -120,6 +115,29 @@
super.close();
}
+ @Override
+ public synchronized void destroy() throws HyracksDataException {
+ for (Object o : diskComponents) {
+ LSMRTreeComponent component = (LSMRTreeComponent) o;
+ component.getBTree().destroy();
+ component.getRTree().destroy();
+ }
+ super.destroy();
+ }
+
+ @Override
+ public synchronized void clear() throws HyracksDataException {
+ for (Object o : diskComponents) {
+ LSMRTreeComponent component = (LSMRTreeComponent) o;
+ component.getBTree().close();
+ component.getRTree().close();
+ component.getBTree().destroy();
+ component.getRTree().destroy();
+ }
+ diskComponents.clear();
+ super.clear();
+ }
+
private LSMRTreeFileNameComponent getMergeTargetFileName(List<Object> mergingDiskTrees) throws HyracksDataException {
RTree firstTree = ((LSMRTreeComponent) mergingDiskTrees.get(0)).getRTree();
RTree lastTree = ((LSMRTreeComponent) mergingDiskTrees.get(mergingDiskTrees.size() - 1)).getRTree();
diff --git a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeFileManager.java b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeFileManager.java
index 31b7ba8..59dcf2e 100644
--- a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeFileManager.java
+++ b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeFileManager.java
@@ -27,15 +27,19 @@
import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.api.io.IIOManager;
import edu.uci.ics.hyracks.api.io.IODeviceHandle;
+import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndex;
import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMComponentFinalizer;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.LSMTreeFileManager;
-import edu.uci.ics.hyracks.storage.am.lsm.rtree.impls.AbstractLSMRTree.LSMRTreeComponent;
+import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeFactory;
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
public class LSMRTreeFileManager extends LSMTreeFileManager {
private static final String RTREE_STRING = "r";
private static final String BTREE_STRING = "b";
+ private final TreeFactory<? extends ITreeIndex> rtreeFactory;
+ private final TreeFactory<? extends ITreeIndex> btreeFactory;
+
private static FilenameFilter btreeFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return !name.startsWith(".") && name.endsWith(BTREE_STRING);
@@ -48,8 +52,11 @@
}
};
- public LSMRTreeFileManager(IIOManager ioManager, IFileMapProvider fileMapProvider, FileReference file) {
- super(ioManager, fileMapProvider, file);
+ public LSMRTreeFileManager(IIOManager ioManager, IFileMapProvider fileMapProvider, FileReference file,
+ TreeFactory<? extends ITreeIndex> rtreeFactory, TreeFactory<? extends ITreeIndex> btreeFactory) {
+ super(ioManager, fileMapProvider, file, null);
+ this.rtreeFactory = rtreeFactory;
+ this.btreeFactory = btreeFactory;
}
@Override
@@ -68,16 +75,14 @@
}
@Override
- public List<Object> cleanupAndGetValidFiles(Object lsmComponent, ILSMComponentFinalizer componentFinalizer)
- throws HyracksDataException {
+ public List<Object> cleanupAndGetValidFiles(ILSMComponentFinalizer componentFinalizer) throws HyracksDataException {
List<Object> validFiles = new ArrayList<Object>();
ArrayList<ComparableFileName> allRTreeFiles = new ArrayList<ComparableFileName>();
ArrayList<ComparableFileName> allBTreeFiles = new ArrayList<ComparableFileName>();
- LSMRTreeComponent component = (LSMRTreeComponent) lsmComponent;
// Gather files from all IODeviceHandles.
for (IODeviceHandle dev : ioManager.getIODevices()) {
- cleanupAndGetValidFilesInternal(dev, btreeFilter, component.getBTree(), componentFinalizer, allBTreeFiles);
+ cleanupAndGetValidFilesInternal(dev, btreeFilter, btreeFactory, componentFinalizer, allBTreeFiles);
HashSet<String> btreeFilesSet = new HashSet<String>();
for (ComparableFileName cmpFileName : allBTreeFiles) {
int index = cmpFileName.fileName.lastIndexOf(SPLIT_STRING);
@@ -85,8 +90,7 @@
}
// List of valid RTree files that may or may not have a BTree buddy. Will check for buddies below.
ArrayList<ComparableFileName> tmpAllRTreeFiles = new ArrayList<ComparableFileName>();
- cleanupAndGetValidFilesInternal(dev, rtreeFilter, component.getRTree(), componentFinalizer,
- tmpAllRTreeFiles);
+ cleanupAndGetValidFilesInternal(dev, rtreeFilter, rtreeFactory, componentFinalizer, tmpAllRTreeFiles);
// Look for buddy BTrees for all valid RTrees.
// If no buddy is found, delete the file, otherwise add the RTree to allRTreeFiles.
for (ComparableFileName cmpFileName : tmpAllRTreeFiles) {
diff --git a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuples.java b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuples.java
index 3ec91b1..943a4ce 100644
--- a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuples.java
+++ b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuples.java
@@ -50,6 +50,7 @@
import edu.uci.ics.hyracks.storage.am.lsm.common.freepage.InMemoryFreePageManager;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.LSMHarness;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.LSMTreeIndexAccessor;
+import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeFactory;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeIndexComponentFinalizer;
import edu.uci.ics.hyracks.storage.am.rtree.impls.RTree;
import edu.uci.ics.hyracks.storage.am.rtree.impls.RTree.RTreeBulkLoader;
@@ -65,12 +66,12 @@
// 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.
- private final RTreeFactory bulkLoadRTreeFactory;
+ private final TreeFactory<RTree> bulkLoadRTreeFactory;
public LSMRTreeWithAntiMatterTuples(IBufferCache memBufferCache, InMemoryFreePageManager memFreePageManager,
ITreeIndexFrameFactory rtreeInteriorFrameFactory, ITreeIndexFrameFactory rtreeLeafFrameFactory,
ITreeIndexFrameFactory btreeInteriorFrameFactory, ITreeIndexFrameFactory btreeLeafFrameFactory,
- ILSMFileManager fileManager, RTreeFactory diskRTreeFactory, RTreeFactory bulkLoadRTreeFactory,
+ ILSMFileManager fileManager, TreeFactory<RTree> diskRTreeFactory, TreeFactory<RTree> bulkLoadRTreeFactory,
IFileMapProvider diskFileMapProvider, int fieldCount, IBinaryComparatorFactory[] rtreeCmpFactories,
IBinaryComparatorFactory[] btreeCmpFactories, ILinearizeComparatorFactory linearizer,
int[] comparatorFields, IBinaryComparatorFactory[] linearizerArray, ILSMFlushController flushController,
@@ -92,11 +93,9 @@
* @throws HyracksDataException
*/
@Override
- public void open(FileReference fileReference) throws HyracksDataException {
- super.open(fileReference);
- RTree dummyRTree = diskRTreeFactory.createIndexInstance();
- dummyRTree.create(new FileReference(new File("dummyrtree")));
- List<Object> validFileNames = fileManager.cleanupAndGetValidFiles(dummyRTree, componentFinalizer);
+ public synchronized void open() throws HyracksDataException {
+ super.open();
+ List<Object> validFileNames = fileManager.cleanupAndGetValidFiles(componentFinalizer);
for (Object o : validFileNames) {
String fileName = (String) o;
FileReference fileRef = new FileReference(new File(fileName));
@@ -106,7 +105,7 @@
}
@Override
- public void close() throws HyracksDataException {
+ public synchronized void close() throws HyracksDataException {
for (Object o : diskComponents) {
RTree rtree = (RTree) o;
rtree.close();
@@ -115,6 +114,26 @@
super.close();
}
+ @Override
+ public synchronized void destroy() throws HyracksDataException {
+ for (Object o : diskComponents) {
+ RTree rtree = (RTree) o;
+ rtree.destroy();
+ }
+ super.destroy();
+ }
+
+ @Override
+ public synchronized void clear() throws HyracksDataException {
+ for (Object o : diskComponents) {
+ RTree rtree = (RTree) o;
+ rtree.close();
+ rtree.destroy();
+ }
+ diskComponents.clear();
+ super.clear();
+ }
+
private RTree createFlushTarget() throws HyracksDataException {
String relFlushFileName = (String) fileManager.getRelFlushFileName();
FileReference fileRef = fileManager.createFlushFile(relFlushFileName);
diff --git a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/RTreeFactory.java b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/RTreeFactory.java
index c6ee511..1f2dabf 100644
--- a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/RTreeFactory.java
+++ b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/RTreeFactory.java
@@ -16,6 +16,7 @@
package edu.uci.ics.hyracks.storage.am.lsm.rtree.impls;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.common.api.IFreePageManagerFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeFactory;
@@ -33,9 +34,9 @@
}
@Override
- public RTree createIndexInstance() {
+ public RTree createIndexInstance(FileReference file) {
return new RTree(bufferCache, fileMapProvider, freePageManagerFactory.createFreePageManager(),
- interiorFrameFactory, leafFrameFactory, cmpFactories, fieldCount);
+ interiorFrameFactory, leafFrameFactory, cmpFactories, fieldCount, file);
}
}
diff --git a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/utils/LSMRTreeUtils.java b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/utils/LSMRTreeUtils.java
index b48190e..99c42e0 100644
--- a/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/utils/LSMRTreeUtils.java
+++ b/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/utils/LSMRTreeUtils.java
@@ -24,6 +24,7 @@
import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeNSMInteriorFrameFactory;
import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeNSMLeafFrameFactory;
+import edu.uci.ics.hyracks.storage.am.btree.impls.BTree;
import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexMetaDataFrameFactory;
@@ -38,6 +39,7 @@
import edu.uci.ics.hyracks.storage.am.lsm.common.freepage.InMemoryFreePageManager;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.BTreeFactory;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.LSMTreeFileManager;
+import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeFactory;
import edu.uci.ics.hyracks.storage.am.lsm.rtree.impls.LSMRTree;
import edu.uci.ics.hyracks.storage.am.lsm.rtree.impls.LSMRTreeFileManager;
import edu.uci.ics.hyracks.storage.am.lsm.rtree.impls.LSMRTreeWithAntiMatterTuples;
@@ -48,6 +50,7 @@
import edu.uci.ics.hyracks.storage.am.rtree.frames.RTreeNSMInteriorFrameFactory;
import edu.uci.ics.hyracks.storage.am.rtree.frames.RTreeNSMLeafFrameFactory;
import edu.uci.ics.hyracks.storage.am.rtree.frames.RTreePolicyType;
+import edu.uci.ics.hyracks.storage.am.rtree.impls.RTree;
import edu.uci.ics.hyracks.storage.am.rtree.linearize.HilbertDoubleComparatorFactory;
import edu.uci.ics.hyracks.storage.am.rtree.linearize.ZCurveDoubleComparatorFactory;
import edu.uci.ics.hyracks.storage.am.rtree.linearize.ZCurveIntComparatorFactory;
@@ -77,16 +80,19 @@
LinkedListFreePageManagerFactory freePageManagerFactory = new LinkedListFreePageManagerFactory(diskBufferCache,
metaFrameFactory);
- RTreeFactory diskRTreeFactory = new RTreeFactory(diskBufferCache, diskFileMapProvider, freePageManagerFactory,
- rtreeInteriorFrameFactory, rtreeLeafFrameFactory, rtreeCmpFactories, typeTraits.length);
- BTreeFactory diskBTreeFactory = new BTreeFactory(diskBufferCache, diskFileMapProvider, freePageManagerFactory,
- btreeInteriorFrameFactory, btreeLeafFrameFactory, btreeCmpFactories, typeTraits.length);
+ TreeFactory<RTree> diskRTreeFactory = new RTreeFactory(diskBufferCache, diskFileMapProvider,
+ freePageManagerFactory, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, rtreeCmpFactories,
+ typeTraits.length);
+ TreeFactory<BTree> diskBTreeFactory = new BTreeFactory(diskBufferCache, diskFileMapProvider,
+ freePageManagerFactory, btreeInteriorFrameFactory, btreeLeafFrameFactory, btreeCmpFactories,
+ typeTraits.length);
ILinearizeComparatorFactory linearizer = proposeBestLinearizer(typeTraits, rtreeCmpFactories.length);
int[] comparatorFields = { 0 };
IBinaryComparatorFactory[] linearizerArray = { linearizer };
- ILSMFileManager fileNameManager = new LSMRTreeFileManager(ioManager, diskFileMapProvider, file);
+ ILSMFileManager fileNameManager = new LSMRTreeFileManager(ioManager, diskFileMapProvider, file,
+ diskRTreeFactory, diskBTreeFactory);
LSMRTree lsmTree = new LSMRTree(memBufferCache, memFreePageManager, rtreeInteriorFrameFactory,
rtreeLeafFrameFactory, btreeInteriorFrameFactory, btreeLeafFrameFactory, fileNameManager,
diskRTreeFactory, diskBTreeFactory, diskFileMapProvider, typeTraits.length, rtreeCmpFactories,
@@ -123,10 +129,11 @@
LinkedListFreePageManagerFactory freePageManagerFactory = new LinkedListFreePageManagerFactory(diskBufferCache,
metaFrameFactory);
- RTreeFactory diskRTreeFactory = new RTreeFactory(diskBufferCache, diskFileMapProvider, freePageManagerFactory,
- rtreeInteriorFrameFactory, copyTupleLeafFrameFactory, rtreeCmpFactories, typeTraits.length);
+ TreeFactory<RTree> diskRTreeFactory = new RTreeFactory(diskBufferCache, diskFileMapProvider,
+ freePageManagerFactory, rtreeInteriorFrameFactory, copyTupleLeafFrameFactory, rtreeCmpFactories,
+ typeTraits.length);
- RTreeFactory bulkLoadRTreeFactory = new RTreeFactory(diskBufferCache, diskFileMapProvider,
+ TreeFactory<RTree> bulkLoadRTreeFactory = new RTreeFactory(diskBufferCache, diskFileMapProvider,
freePageManagerFactory, rtreeInteriorFrameFactory, rtreeLeafFrameFactory, rtreeCmpFactories,
typeTraits.length);
@@ -136,7 +143,7 @@
int[] comparatorFields = { 0, btreeCmpFactories.length - 1 };
IBinaryComparatorFactory[] linearizerArray = { linearizer, btreeCmpFactories[btreeCmpFactories.length - 1] };
- ILSMFileManager fileNameManager = new LSMTreeFileManager(ioManager, diskFileMapProvider, file);
+ ILSMFileManager fileNameManager = new LSMTreeFileManager(ioManager, diskFileMapProvider, file, diskRTreeFactory);
LSMRTreeWithAntiMatterTuples lsmTree = new LSMRTreeWithAntiMatterTuples(memBufferCache, memFreePageManager,
rtreeInteriorFrameFactory, rtreeLeafFrameFactory, btreeInteriorFrameFactory, btreeLeafFrameFactory,
fileNameManager, diskRTreeFactory, bulkLoadRTreeFactory, diskFileMapProvider, typeTraits.length,
diff --git a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/dataflow/RTreeDataflowHelper.java b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/dataflow/RTreeDataflowHelper.java
index c69ab9f..c3660d1 100644
--- a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/dataflow/RTreeDataflowHelper.java
+++ b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/dataflow/RTreeDataflowHelper.java
@@ -40,6 +40,7 @@
public ITreeIndex createIndexInstance() throws HyracksDataException {
return RTreeUtils.createRTree(treeOpDesc.getStorageManager().getBufferCache(ctx), treeOpDesc
.getStorageManager().getFileMapProvider(ctx), treeOpDesc.getTreeIndexTypeTraits(),
- valueProviderFactories, treeOpDesc.getTreeIndexComparatorFactories(), rtreePolicyType);
+ valueProviderFactories, treeOpDesc.getTreeIndexComparatorFactories(), rtreePolicyType, treeOpDesc
+ .getFileSplitProvider().getFileSplits()[partition].getLocalFile());
}
}
diff --git a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTree.java b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTree.java
index 6e18ad4..b8a40eb 100644
--- a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTree.java
+++ b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/RTree.java
@@ -22,6 +22,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.IFreePageManager;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexBulkLoader;
@@ -63,9 +64,9 @@
public RTree(IBufferCache bufferCache, IFileMapProvider fileMapProvider, IFreePageManager freePageManager,
ITreeIndexFrameFactory interiorFrameFactory, ITreeIndexFrameFactory leafFrameFactory,
- IBinaryComparatorFactory[] cmpFactories, int fieldCount) {
+ IBinaryComparatorFactory[] cmpFactories, int fieldCount, FileReference file) {
super(bufferCache, fileMapProvider, freePageManager, interiorFrameFactory, leafFrameFactory, cmpFactories,
- fieldCount);
+ fieldCount, file);
globalNsn = new AtomicLong();
}
diff --git a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/util/RTreeUtils.java b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/util/RTreeUtils.java
index 306d907..5889abb 100644
--- a/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/util/RTreeUtils.java
+++ b/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/util/RTreeUtils.java
@@ -18,6 +18,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
+import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.data.std.api.IPointableFactory;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.IFreePageManager;
@@ -39,7 +40,7 @@
public class RTreeUtils {
public static RTree createRTree(IBufferCache bufferCache, IFileMapProvider fileMapProvider,
ITypeTraits[] typeTraits, IPrimitiveValueProviderFactory[] valueProviderFactories,
- IBinaryComparatorFactory[] cmpFactories, RTreePolicyType rtreePolicyType) {
+ IBinaryComparatorFactory[] cmpFactories, RTreePolicyType rtreePolicyType, FileReference file) {
RTreeTypeAwareTupleWriterFactory tupleWriterFactory = new RTreeTypeAwareTupleWriterFactory(typeTraits);
ITreeIndexFrameFactory interiorFrameFactory = new RTreeNSMInteriorFrameFactory(tupleWriterFactory,
@@ -50,7 +51,7 @@
IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
RTree rtree = new RTree(bufferCache, fileMapProvider, freePageManager, interiorFrameFactory, leafFrameFactory,
- cmpFactories, typeTraits.length);
+ cmpFactories, typeTraits.length, file);
return rtree;
}
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexBulkLoadTest.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexBulkLoadTest.java
index 85bfdd2..6c6327a 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexBulkLoadTest.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexBulkLoadTest.java
@@ -56,6 +56,7 @@
}
}
ctx.getIndex().close();
+ ctx.getIndex().destroy();
}
@Override
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexDeleteTest.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexDeleteTest.java
index 0935315..25086ff 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexDeleteTest.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexDeleteTest.java
@@ -62,6 +62,7 @@
}
}
ctx.getIndex().close();
+ ctx.getIndex().destroy();
}
@Override
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexExamplesTest.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexExamplesTest.java
index cf5f69c..841b892 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexExamplesTest.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexExamplesTest.java
@@ -24,7 +24,6 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
-import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
@@ -55,8 +54,6 @@
protected abstract ITreeIndex createTreeIndex(ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories)
throws TreeIndexException;
- protected abstract FileReference getFileReference();
-
/**
* Fixed-Length Key,Value Example.
* Create a tree index with one fixed-length key field and one fixed-length value
@@ -83,10 +80,9 @@
IBinaryComparatorFactory[] cmpFactories = new IBinaryComparatorFactory[keyFieldCount];
cmpFactories[0] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, cmpFactories);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
long start = System.currentTimeMillis();
if (LOGGER.isLoggable(Level.INFO)) {
@@ -132,6 +128,7 @@
rangeSearch(cmpFactories, indexAccessor, fieldSerdes, lowKey, highKey);
treeIndex.close();
+ treeIndex.destroy();
}
/**
@@ -162,10 +159,9 @@
cmpFactories[0] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
cmpFactories[1] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, cmpFactories);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
long start = System.currentTimeMillis();
if (LOGGER.isLoggable(Level.INFO)) {
@@ -213,6 +209,7 @@
rangeSearch(cmpFactories, indexAccessor, fieldSerdes, lowKey, highKey);
treeIndex.close();
+ treeIndex.destroy();
}
/**
@@ -240,10 +237,9 @@
IBinaryComparatorFactory[] cmpFactories = new IBinaryComparatorFactory[keyFieldCount];
cmpFactories[0] = PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, cmpFactories);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
long start = System.currentTimeMillis();
if (LOGGER.isLoggable(Level.INFO)) {
@@ -291,6 +287,7 @@
rangeSearch(cmpFactories, indexAccessor, fieldSerdes, lowKey, highKey);
treeIndex.close();
+ treeIndex.destroy();
}
/**
@@ -319,10 +316,9 @@
IBinaryComparatorFactory[] cmpFactories = new IBinaryComparatorFactory[keyFieldCount];
cmpFactories[0] = PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, cmpFactories);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
ArrayTupleBuilder tb = new ArrayTupleBuilder(fieldCount);
ArrayTupleReference tuple = new ArrayTupleReference();
@@ -392,6 +388,7 @@
}
}
treeIndex.close();
+ treeIndex.destroy();
}
/**
@@ -420,10 +417,9 @@
IBinaryComparatorFactory[] cmpFactories = new IBinaryComparatorFactory[keyFieldCount];
cmpFactories[0] = PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, cmpFactories);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Inserting into tree...");
@@ -478,6 +474,7 @@
orderedScan(indexAccessor, fieldSerdes);
}
treeIndex.close();
+ treeIndex.destroy();
}
/**
@@ -506,10 +503,9 @@
cmpFactories[0] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
cmpFactories[1] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, cmpFactories);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
// Load sorted records.
int ins = 100000;
@@ -547,6 +543,7 @@
rangeSearch(cmpFactories, indexAccessor, fieldSerdes, lowKey, highKey);
treeIndex.close();
+ treeIndex.destroy();
}
private void orderedScan(IIndexAccessor indexAccessor, ISerializerDeserializer[] fieldSerdes) throws Exception {
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexInsertTest.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexInsertTest.java
index d12603b..41191fc 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexInsertTest.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexInsertTest.java
@@ -24,12 +24,10 @@
/**
* Tests the BTree insert operation with strings and integer fields using
* various numbers of key and payload fields.
- *
* Each tests first fills a BTree with randomly generated tuples. We compare the
* following operations against expected results: 1. Point searches for all
* tuples. 2. Ordered scan. 3. Disk-order scan. 4. Range search (and prefix
* search for composite keys).
- *
*/
@SuppressWarnings("rawtypes")
public abstract class OrderedIndexInsertTest extends OrderedIndexTestDriver {
@@ -63,6 +61,7 @@
orderedIndexTestUtils.checkRangeSearch(ctx, prefixLowKey, prefixHighKey, true, true);
}
ctx.getIndex().close();
+ ctx.getIndex().destroy();
}
@Override
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexUpsertTest.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexUpsertTest.java
index 0d94a18..8718758 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexUpsertTest.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/OrderedIndexUpsertTest.java
@@ -24,12 +24,10 @@
/**
* Tests the BTree insert operation with strings and integer fields using
* various numbers of key and payload fields.
- *
* Each tests first fills a BTree with randomly generated tuples. We compare the
* following operations against expected results: 1. Point searches for all
* tuples. 2. Ordered scan. 3. Disk-order scan. 4. Range search (and prefix
* search for composite keys).
- *
*/
@SuppressWarnings("rawtypes")
public abstract class OrderedIndexUpsertTest extends OrderedIndexTestDriver {
@@ -63,6 +61,7 @@
orderedIndexTestUtils.checkRangeSearch(ctx, prefixLowKey, prefixHighKey, true, true);
}
ctx.getIndex().close();
+ ctx.getIndex().destroy();
}
@Override
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/common/TreeIndexMultiThreadTestDriver.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/common/TreeIndexMultiThreadTestDriver.java
index 12596f3..0e925ec 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/common/TreeIndexMultiThreadTestDriver.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/common/TreeIndexMultiThreadTestDriver.java
@@ -42,8 +42,8 @@
}
public void init(FileReference file) throws HyracksDataException {
- index.create(file);
- index.open(file);
+ index.create();
+ index.open();
}
public long[] run(int numThreads, int numRepeats, int numOps, int batchSize) throws InterruptedException,
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeDeleteTest.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeDeleteTest.java
index eb22b9c..6414a14 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeDeleteTest.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeDeleteTest.java
@@ -59,6 +59,7 @@
}
}
ctx.getIndex().close();
+ ctx.getIndex().destroy();
}
@Override
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeExamplesTest.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeExamplesTest.java
index f5753f1..8a41eee 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeExamplesTest.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeExamplesTest.java
@@ -24,7 +24,6 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
-import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
import edu.uci.ics.hyracks.data.std.primitive.DoublePointable;
import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
@@ -58,8 +57,6 @@
IPrimitiveValueProviderFactory[] valueProviderFactories, RTreePolicyType rtreePolicyType)
throws TreeIndexException;
- protected abstract FileReference getFileReference();
-
/**
* Two Dimensions Example.
* Create an RTree index of two dimensions, where they keys are of type
@@ -109,11 +106,10 @@
IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils.createPrimitiveValueProviderFactories(
rtreeCmpFactories.length, IntegerPointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, rtreeCmpFactories, btreeCmpFactories,
valueProviderFactories, RTreePolicyType.RTREE);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
long start = System.currentTimeMillis();
if (LOGGER.isLoggable(Level.INFO)) {
@@ -162,6 +158,7 @@
rangeSearch(rtreeCmpFactories, indexAccessor, fieldSerdes, key);
treeIndex.close();
+ treeIndex.destroy();
}
/**
@@ -217,11 +214,10 @@
IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils.createPrimitiveValueProviderFactories(
rtreeCmpFactories.length, DoublePointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, rtreeCmpFactories, btreeCmpFactories,
valueProviderFactories, RTreePolicyType.RTREE);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
long start = System.currentTimeMillis();
if (LOGGER.isLoggable(Level.INFO)) {
@@ -272,6 +268,7 @@
rangeSearch(rtreeCmpFactories, indexAccessor, fieldSerdes, key);
treeIndex.close();
+ treeIndex.destroy();
}
/**
@@ -317,11 +314,10 @@
IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils.createPrimitiveValueProviderFactories(
rtreeCmpFactories.length, IntegerPointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, rtreeCmpFactories, btreeCmpFactories,
valueProviderFactories, RTreePolicyType.RTREE);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
ArrayTupleBuilder tb = new ArrayTupleBuilder(fieldCount);
ArrayTupleReference tuple = new ArrayTupleReference();
@@ -403,6 +399,7 @@
}
}
treeIndex.close();
+ treeIndex.destroy();
}
/**
@@ -449,11 +446,10 @@
IPrimitiveValueProviderFactory[] valueProviderFactories = RTreeUtils.createPrimitiveValueProviderFactories(
rtreeCmpFactories.length, IntegerPointable.FACTORY);
- FileReference file = getFileReference();
ITreeIndex treeIndex = createTreeIndex(typeTraits, rtreeCmpFactories, btreeCmpFactories,
valueProviderFactories, RTreePolicyType.RTREE);
- treeIndex.create(file);
- treeIndex.open(file);
+ treeIndex.create();
+ treeIndex.open();
// Load records.
int numInserts = 10000;
@@ -495,6 +491,7 @@
rangeSearch(rtreeCmpFactories, indexAccessor, fieldSerdes, key);
treeIndex.close();
+ treeIndex.destroy();
}
private void scan(IIndexAccessor indexAccessor, ISerializerDeserializer[] fieldSerdes) throws Exception {
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeInsertTest.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeInsertTest.java
index 2a5ff21..90a85da 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeInsertTest.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/AbstractRTreeInsertTest.java
@@ -25,11 +25,9 @@
/**
* Tests the RTree insert operation with integer and double fields using various
* numbers of dimensions and payload fields.
- *
* Each tests first fills an RTree with randomly generated tuples. We compare
* the following operations against expected results: 1. RTree scan. 3.
* Disk-order scan. 4. Range search.
- *
*/
@SuppressWarnings("rawtypes")
public abstract class AbstractRTreeInsertTest extends AbstractRTreeTestDriver {
@@ -58,6 +56,7 @@
rTreeTestUtils.checkDiskOrderScan(ctx);
rTreeTestUtils.checkRangeSearch(ctx, key);
ctx.getIndex().close();
+ ctx.getIndex().destroy();
}
@Override
diff --git a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeTestUtils.java b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeTestUtils.java
index 9f5e861..784d4bc 100644
--- a/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeTestUtils.java
+++ b/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeTestUtils.java
@@ -112,7 +112,7 @@
fieldValues[k] = secondValue;
}
}
-
+
private void setDoublePayloadFields(double[] fieldValues, int numKeyFields, int numFields) {
for (int j = numKeyFields; j < numFields; j++) {
fieldValues[j] = doublePayloadValue++;
@@ -214,7 +214,7 @@
fieldValues[k] = secondValue;
}
}
-
+
@Override
protected void setIntPayloadFields(int[] fieldValues, int numKeyFields, int numFields) {
for (int j = numKeyFields; j < numFields; j++) {
diff --git a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeExamplesTest.java b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeExamplesTest.java
index 2d1b46c..6d9d565 100644
--- a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeExamplesTest.java
+++ b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeExamplesTest.java
@@ -21,7 +21,6 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeLeafFrameType;
import edu.uci.ics.hyracks.storage.am.btree.util.BTreeTestHarness;
import edu.uci.ics.hyracks.storage.am.btree.util.BTreeUtils;
@@ -44,11 +43,7 @@
protected ITreeIndex createTreeIndex(ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories)
throws TreeIndexException {
return BTreeUtils.createBTree(harness.getBufferCache(), harness.getFileMapProvider(), typeTraits, cmpFactories,
- BTreeLeafFrameType.REGULAR_NSM);
+ BTreeLeafFrameType.REGULAR_NSM, harness.getFileReference());
}
- @Override
- protected FileReference getFileReference() {
- return harness.getFileReference();
- }
}
diff --git a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeSearchCursorTest.java b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeSearchCursorTest.java
index 55df7b8..0e2314a 100644
--- a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeSearchCursorTest.java
+++ b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeSearchCursorTest.java
@@ -100,9 +100,9 @@
IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
BTree btree = new BTree(bufferCache, harness.getFileMapProvider(), freePageManager, interiorFrameFactory,
- leafFrameFactory, cmpFactories, fieldCount);
- btree.create(harness.getFileReference());
- btree.open(harness.getFileReference());
+ leafFrameFactory, cmpFactories, fieldCount, harness.getFileReference());
+ btree.create();
+ btree.open();
ArrayTupleBuilder tupleBuilder = new ArrayTupleBuilder(fieldCount);
ArrayTupleReference tuple = new ArrayTupleReference();
@@ -149,6 +149,7 @@
performSearches(keys, btree, leafFrame, interiorFrame, minSearchKey, maxSearchKey, true, true, false);
btree.close();
+ btree.destroy();
}
@Test
@@ -174,9 +175,9 @@
IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
BTree btree = new BTree(bufferCache, harness.getFileMapProvider(), freePageManager, interiorFrameFactory,
- leafFrameFactory, cmpFactories, fieldCount);
- btree.create(harness.getFileReference());
- btree.open(harness.getFileReference());
+ leafFrameFactory, cmpFactories, fieldCount, harness.getFileReference());
+ btree.create();
+ btree.open();
ArrayTupleBuilder tupleBuilder = new ArrayTupleBuilder(fieldCount);
ArrayTupleReference tuple = new ArrayTupleReference();
@@ -220,6 +221,7 @@
performSearches(keys, btree, leafFrame, interiorFrame, minSearchKey, maxSearchKey, true, true, false);
btree.close();
+ btree.destroy();
}
@Test
@@ -245,9 +247,9 @@
IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
BTree btree = new BTree(bufferCache, harness.getFileMapProvider(), freePageManager, interiorFrameFactory,
- leafFrameFactory, cmpFactories, fieldCount);
- btree.create(harness.getFileReference());
- btree.open(harness.getFileReference());
+ leafFrameFactory, cmpFactories, fieldCount, harness.getFileReference());
+ btree.create();
+ btree.open();
ArrayTupleBuilder tupleBuilder = new ArrayTupleBuilder(fieldCount);
ArrayTupleReference tuple = new ArrayTupleReference();
@@ -291,6 +293,7 @@
performSearches(keys, btree, leafFrame, interiorFrame, minSearchKey, maxSearchKey, true, true, false);
btree.close();
+ btree.destroy();
}
public RangePredicate createRangePredicate(int lk, int hk, boolean lowKeyInclusive, boolean highKeyInclusive)
diff --git a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeStatsTest.java b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeStatsTest.java
index bb9fb5f..290683a 100644
--- a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeStatsTest.java
+++ b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeStatsTest.java
@@ -82,9 +82,9 @@
IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
BTree btree = new BTree(bufferCache, fmp, freePageManager, interiorFrameFactory, leafFrameFactory,
- cmpFactories, fieldCount);
- btree.create(harness.getFileReference());
- btree.open(harness.getFileReference());
+ cmpFactories, fieldCount, harness.getFileReference());
+ btree.create();
+ btree.open();
Random rnd = new Random();
rnd.setSeed(50);
@@ -154,6 +154,7 @@
bufferCacheWarmup.warmup(leafFrame, metaFrame, new int[] { 1, 2 }, new int[] { 2, 5 });
btree.close();
+ btree.destroy();
bufferCache.close();
}
}
diff --git a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeUpdateSearchTest.java b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeUpdateSearchTest.java
index 998a7b5..5ac1cdb 100644
--- a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeUpdateSearchTest.java
+++ b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/BTreeUpdateSearchTest.java
@@ -65,9 +65,9 @@
IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
BTree btree = new BTree(bufferCache, harness.getFileMapProvider(), freePageManager, interiorFrameFactory,
- leafFrameFactory, cmpFactories, fieldCount);
- btree.create(harness.getFileReference());
- btree.open(harness.getFileReference());
+ leafFrameFactory, cmpFactories, fieldCount, harness.getFileReference());
+ btree.create();
+ btree.open();
Random rnd = new Random();
rnd.setSeed(50);
@@ -151,5 +151,6 @@
scanCursor.close();
}
btree.close();
+ btree.destroy();
}
}
diff --git a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/StorageManagerTest.java b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/StorageManagerTest.java
index ef4e2a8..d273a12 100644
--- a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/StorageManagerTest.java
+++ b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/StorageManagerTest.java
@@ -27,7 +27,6 @@
import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.buffercache.ICachedPage;
import edu.uci.ics.hyracks.storage.common.file.BufferedFileHandle;
-import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
import edu.uci.ics.hyracks.storage.common.sync.LatchType;
public class StorageManagerTest extends AbstractBTreeTest {
@@ -255,7 +254,6 @@
@Test
public void oneThreadOneFileTest() throws Exception {
IBufferCache bufferCache = harness.getBufferCache();
- IFileMapProvider fmp = harness.getFileMapProvider();
bufferCache.createFile(harness.getFileReference());
int btreeFileId = harness.getFileMapProvider().lookupFileId(harness.getFileReference());
bufferCache.openFile(btreeFileId);
diff --git a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/multithread/BTreeMultiThreadTest.java b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/multithread/BTreeMultiThreadTest.java
index 9fd7c16..e42abdf 100644
--- a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/multithread/BTreeMultiThreadTest.java
+++ b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/multithread/BTreeMultiThreadTest.java
@@ -51,7 +51,7 @@
protected ITreeIndex createTreeIndex(ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories)
throws TreeIndexException {
return BTreeUtils.createBTree(harness.getBufferCache(), harness.getFileMapProvider(), typeTraits, cmpFactories,
- BTreeLeafFrameType.REGULAR_NSM);
+ BTreeLeafFrameType.REGULAR_NSM, harness.getFileReference());
}
@Override
@@ -86,7 +86,7 @@
return workloadConfs;
}
-
+
@Override
protected FileReference getFileReference() {
return harness.getFileReference();
diff --git a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/util/BTreeTestContext.java b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/util/BTreeTestContext.java
index 7950084..993d33d 100644
--- a/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/util/BTreeTestContext.java
+++ b/hyracks-tests/hyracks-storage-am-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/btree/util/BTreeTestContext.java
@@ -51,9 +51,9 @@
throws Exception {
ITypeTraits[] typeTraits = SerdeUtils.serdesToTypeTraits(fieldSerdes);
IBinaryComparatorFactory[] cmpFactories = SerdeUtils.serdesToComparatorFactories(fieldSerdes, numKeyFields);
- BTree btree = BTreeUtils.createBTree(bufferCache, fileMapProvider, typeTraits, cmpFactories, leafType);
- btree.create(file);
- btree.open(file);
+ BTree btree = BTreeUtils.createBTree(bufferCache, fileMapProvider, typeTraits, cmpFactories, leafType, file);
+ btree.create();
+ btree.open();
BTreeTestContext testCtx = new BTreeTestContext(fieldSerdes, btree);
return testCtx;
}
diff --git a/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/AbstractInvIndexSearchTest.java b/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/AbstractInvIndexSearchTest.java
index 52b0925..0c2c2fe 100644
--- a/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/AbstractInvIndexSearchTest.java
+++ b/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/AbstractInvIndexSearchTest.java
@@ -154,9 +154,10 @@
freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
btree = new BTree(bufferCache, fmp, freePageManager, interiorFrameFactory, leafFrameFactory, btreeCmpFactories,
- btreeTypeTraits.length);
- btree.create(btreeFile);
- btree.open(btreeFile);
+ btreeTypeTraits.length, btreeFile);
+
+ btree.create();
+ btree.open();
// --- INVERTED INDEX ---
@@ -167,9 +168,9 @@
IInvertedListBuilder invListBuilder = new FixedSizeElementInvertedListBuilder(invListTypeTraits);
invIndex = new InvertedIndex(bufferCache, btree, invListTypeTraits, invListCmpFactories, invListBuilder,
- tokenizer, fmp);
- invIndex.create(invListsFile);
- invIndex.open(invListsFile);
+ tokenizer, fmp, invListsFile);
+ invIndex.create();
+ invIndex.open();
rnd.setSeed(50);
}
@@ -178,7 +179,9 @@
public void deinit() throws HyracksDataException {
AbstractInvIndexTest.tearDown();
btree.close();
+ btree.destroy();
invIndex.close();
+ invIndex.destroy();
bufferCache.close();
}
}
diff --git a/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/BulkLoadTest.java b/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/BulkLoadTest.java
index 731ebb1..645a851 100644
--- a/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/BulkLoadTest.java
+++ b/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/BulkLoadTest.java
@@ -118,10 +118,9 @@
IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
BTree btree = new BTree(bufferCache, fmp, freePageManager, interiorFrameFactory, leafFrameFactory,
- cmpFactories, btreeTypeTraits.length);
- btree.create(btreeFile);
- btree.open(btreeFile);
-
+ cmpFactories, btreeTypeTraits.length, btreeFile);
+ btree.create();
+ btree.open();
int invListFields = 1;
ITypeTraits[] invListTypeTraits = new ITypeTraits[invListFields];
invListTypeTraits[0] = IntegerPointable.TYPE_TRAITS;
@@ -132,9 +131,9 @@
IInvertedListBuilder invListBuilder = new FixedSizeElementInvertedListBuilder(invListTypeTraits);
InvertedIndex invIndex = new InvertedIndex(bufferCache, btree, invListTypeTraits, invListCmpFactories,
- invListBuilder, null, fmp);
- invIndex.create(invListsFile);
- invIndex.open(invListsFile);
+ invListBuilder, null, fmp, invListsFile);
+ invIndex.create();
+ invIndex.open();
Random rnd = new Random();
rnd.setSeed(50);
@@ -279,6 +278,9 @@
}
btree.close();
+ btree.destroy();
+ invIndex.close();
+ invIndex.destroy();
bufferCache.close();
}
diff --git a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/LSMBTreeExamplesTest.java b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/LSMBTreeExamplesTest.java
index 7a8929e..66e24ea 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/LSMBTreeExamplesTest.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/LSMBTreeExamplesTest.java
@@ -22,7 +22,6 @@
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.api.exceptions.HyracksException;
-import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.btree.OrderedIndexExamplesTest;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndex;
import edu.uci.ics.hyracks.storage.am.common.api.TreeIndexException;
@@ -51,8 +50,4 @@
harness.tearDown();
}
- @Override
- protected FileReference getFileReference() {
- return harness.getFileReference();
- }
}
diff --git a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/BTreeBulkLoadRunner.java b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/BTreeBulkLoadRunner.java
index 8af29ed..2953226 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/BTreeBulkLoadRunner.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/BTreeBulkLoadRunner.java
@@ -35,7 +35,7 @@
@Override
public long runExperiment(DataGenThread dataGen, int numThreads) throws Exception {
- btree.create(file);
+ btree.create();
long start = System.currentTimeMillis();
IIndexBulkLoader bulkLoader = btree.createBulkLoader(1.0f);
for (int i = 0; i < numBatches; i++) {
diff --git a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/BTreeRunner.java b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/BTreeRunner.java
index ba0fd31..8658919 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/BTreeRunner.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/BTreeRunner.java
@@ -42,6 +42,7 @@
TestStorageManagerComponentHolder.init(pageSize, numPages, MAX_OPEN_FILES);
bufferCache = TestStorageManagerComponentHolder.getBufferCache(ctx);
IFileMapProvider fmp = TestStorageManagerComponentHolder.getFileMapProvider(ctx);
- btree = BTreeUtils.createBTree(bufferCache, fmp, typeTraits, cmpFactories, BTreeLeafFrameType.REGULAR_NSM);
+ btree = BTreeUtils
+ .createBTree(bufferCache, fmp, typeTraits, cmpFactories, BTreeLeafFrameType.REGULAR_NSM, file);
}
}
diff --git a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/InMemoryBTreeRunner.java b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/InMemoryBTreeRunner.java
index a23ad43..5817d8a 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/InMemoryBTreeRunner.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/InMemoryBTreeRunner.java
@@ -74,7 +74,7 @@
ITreeIndexMetaDataFrameFactory metaFrameFactory = new LIFOMetaDataFrameFactory();
IFreePageManager freePageManager = new InMemoryFreePageManager(bufferCache.getNumPages(), metaFrameFactory);
btree = new BTree(bufferCache, new TransientFileMapManager(), freePageManager, interiorFrameFactory,
- leafFrameFactory, cmpFactories, typeTraits.length);
+ leafFrameFactory, cmpFactories, typeTraits.length, file);
}
@Override
@@ -112,7 +112,7 @@
@Override
public void reset() throws Exception {
- btree.create(file);
+ btree.create();
}
public class BTreeThread extends Thread {
diff --git a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/LSMTreeRunner.java b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/LSMTreeRunner.java
index a1b5f8a..2b3e104 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/LSMTreeRunner.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/LSMTreeRunner.java
@@ -127,7 +127,7 @@
@Override
public void reset() throws Exception {
- lsmtree.create(file);
+ lsmtree.create();
}
@Override
diff --git a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/util/LSMBTreeTestContext.java b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/util/LSMBTreeTestContext.java
index 556a960..a6b6640 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/util/LSMBTreeTestContext.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/util/LSMBTreeTestContext.java
@@ -73,8 +73,8 @@
LSMBTree lsmTree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file,
diskBufferCache, diskFileMapProvider, typeTraits, cmpFactories, flushController, mergePolicy,
opTracker, ioScheduler);
- lsmTree.create(file);
- lsmTree.open(file);
+ lsmTree.create();
+ lsmTree.open();
LSMBTreeTestContext testCtx = new LSMBTreeTestContext(fieldSerdes, lsmTree);
return testCtx;
}
diff --git a/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/DummyLSMComponentFinalizer.java b/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/DummyLSMComponentFinalizer.java
index 4a43f9b..5b3a0b5 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/DummyLSMComponentFinalizer.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/DummyLSMComponentFinalizer.java
@@ -15,7 +15,6 @@
package edu.uci.ics.hyracks.storage.am.lsm.common;
-import java.io.File;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.storage.am.lsm.common.api.ILSMComponentFinalizer;
@@ -23,7 +22,7 @@
public class DummyLSMComponentFinalizer implements ILSMComponentFinalizer {
@Override
- public boolean isValid(File file, Object lsmComponent)
+ public boolean isValid(Object lsmComponent)
throws HyracksDataException {
return true;
}
diff --git a/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/DummyTreeFactory.java b/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/DummyTreeFactory.java
new file mode 100644
index 0000000..0b955cd
--- /dev/null
+++ b/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/DummyTreeFactory.java
@@ -0,0 +1,18 @@
+package edu.uci.ics.hyracks.storage.am.lsm.common;
+
+import edu.uci.ics.hyracks.api.io.FileReference;
+import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndex;
+import edu.uci.ics.hyracks.storage.am.lsm.common.impls.TreeFactory;
+
+public class DummyTreeFactory extends TreeFactory<ITreeIndex> {
+
+ public DummyTreeFactory() {
+ super(null, null, null, null, null, null, 0);
+ }
+
+ @Override
+ public ITreeIndex createIndexInstance(FileReference file) {
+ return null;
+ }
+
+}
diff --git a/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/LSMTreeFileManagerTest.java b/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/LSMTreeFileManagerTest.java
index a87db81..feb9822 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/LSMTreeFileManagerTest.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-common-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/common/LSMTreeFileManagerTest.java
@@ -75,7 +75,7 @@
}
public void sortOrderTest(boolean testFlushFileName) throws InterruptedException, HyracksDataException {
- ILSMFileManager fileManager = new LSMTreeFileManager(ioManager, fileMapProvider, file);
+ ILSMFileManager fileManager = new LSMTreeFileManager(ioManager, fileMapProvider, file, new DummyTreeFactory());
LinkedList<String> fileNames = new LinkedList<String>();
int numFileNames = 100;
@@ -113,7 +113,7 @@
}
public void cleanInvalidFilesTest(IOManager ioManager) throws InterruptedException, IOException {
- ILSMFileManager fileManager = new LSMTreeFileManager(ioManager, fileMapProvider, file);
+ ILSMFileManager fileManager = new LSMTreeFileManager(ioManager, fileMapProvider, file, new DummyTreeFactory());
fileManager.createDirs();
List<FileReference> flushFiles = new ArrayList<FileReference>();
@@ -177,7 +177,7 @@
Collections.sort(expectedValidFiles, fileManager.getFileNameComparator());
// Pass null and a dummy component finalizer. We don't test for physical consistency in this test.
- List<Object> validFiles = fileManager.cleanupAndGetValidFiles(null, componentFinalizer);
+ List<Object> validFiles = fileManager.cleanupAndGetValidFiles(componentFinalizer);
// Check actual files against expected files.
assertEquals(expectedValidFiles.size(), validFiles.size());
diff --git a/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/LSMRTreeExamplesTest.java b/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/LSMRTreeExamplesTest.java
index 377e630..c8bf1c8 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/LSMRTreeExamplesTest.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/LSMRTreeExamplesTest.java
@@ -22,7 +22,6 @@
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.api.exceptions.HyracksException;
-import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndex;
import edu.uci.ics.hyracks.storage.am.common.api.TreeIndexException;
@@ -55,9 +54,4 @@
harness.tearDown();
}
- @Override
- protected FileReference getFileReference() {
- return harness.getFileReference();
- }
-
}
diff --git a/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/LSMRTreeWithAntiMatterTuplesExamplesTest.java b/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/LSMRTreeWithAntiMatterTuplesExamplesTest.java
index ddfd314..bb2c5cf 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/LSMRTreeWithAntiMatterTuplesExamplesTest.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/LSMRTreeWithAntiMatterTuplesExamplesTest.java
@@ -22,7 +22,6 @@
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.api.exceptions.HyracksException;
-import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndex;
import edu.uci.ics.hyracks.storage.am.common.api.TreeIndexException;
@@ -55,8 +54,4 @@
harness.tearDown();
}
- @Override
- protected FileReference getFileReference() {
- return harness.getFileReference();
- }
}
diff --git a/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/util/LSMRTreeTestContext.java b/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/util/LSMRTreeTestContext.java
index 7b92cce..65349a8 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/util/LSMRTreeTestContext.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/util/LSMRTreeTestContext.java
@@ -81,8 +81,8 @@
LSMRTree lsmTree = LSMRTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file,
diskBufferCache, diskFileMapProvider, typeTraits, rtreeCmpFactories, btreeCmpFactories,
valueProviderFactories, rtreePolicyType, flushController, mergePolicy, opTracker, ioScheduler);
- lsmTree.create(file);
- lsmTree.open(file);
+ lsmTree.create();
+ lsmTree.open();
LSMRTreeTestContext testCtx = new LSMRTreeTestContext(fieldSerdes, lsmTree);
return testCtx;
}
diff --git a/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/util/LSMRTreeWithAntiMatterTuplesTestContext.java b/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/util/LSMRTreeWithAntiMatterTuplesTestContext.java
index 15a06c5..cbbe5ed 100644
--- a/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/util/LSMRTreeWithAntiMatterTuplesTestContext.java
+++ b/hyracks-tests/hyracks-storage-am-lsm-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/util/LSMRTreeWithAntiMatterTuplesTestContext.java
@@ -82,8 +82,8 @@
memFreePageManager, ioManager, file, diskBufferCache, diskFileMapProvider, typeTraits,
rtreeCmpFactories, btreeCmpFactories, valueProviderFactories, rtreePolicyType, flushController,
mergePolicy, opTracker, ioScheduler);
- lsmTree.create(file);
- lsmTree.open(file);
+ lsmTree.create();
+ lsmTree.open();
LSMRTreeWithAntiMatterTuplesTestContext testCtx = new LSMRTreeWithAntiMatterTuplesTestContext(fieldSerdes,
lsmTree);
return testCtx;
diff --git a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeExamplesTest.java b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeExamplesTest.java
index e6900e5..84c8642 100644
--- a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeExamplesTest.java
+++ b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeExamplesTest.java
@@ -21,7 +21,6 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProviderFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndex;
import edu.uci.ics.hyracks.storage.am.common.api.TreeIndexException;
@@ -47,11 +46,7 @@
IBinaryComparatorFactory[] btreeCmpFactories, IPrimitiveValueProviderFactory[] valueProviderFactories,
RTreePolicyType rtreePolicyType) throws TreeIndexException {
return RTreeUtils.createRTree(harness.getBufferCache(), harness.getFileMapProvider(), typeTraits,
- valueProviderFactories, rtreeCmpFactories, rtreePolicyType);
+ valueProviderFactories, rtreeCmpFactories, rtreePolicyType, harness.getFileReference());
}
- @Override
- protected FileReference getFileReference() {
- return harness.getFileReference();
- }
}
diff --git a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeSearchCursorTest.java b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeSearchCursorTest.java
index 799cdaa..4662813 100644
--- a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeSearchCursorTest.java
+++ b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/RTreeSearchCursorTest.java
@@ -118,9 +118,9 @@
IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
RTree rtree = new RTree(bufferCache, harness.getFileMapProvider(), freePageManager, interiorFrameFactory,
- leafFrameFactory, cmpFactories, fieldCount);
- rtree.create(harness.getFileReference());
- rtree.open(harness.getFileReference());
+ leafFrameFactory, cmpFactories, fieldCount, harness.getFileReference());
+ rtree.create();
+ rtree.open();
ArrayTupleBuilder tb = new ArrayTupleBuilder(fieldCount);
ArrayTupleReference tuple = new ArrayTupleReference();
@@ -163,7 +163,8 @@
RTreeCheckTuple keyCheck = (RTreeCheckTuple) rTreeTestUtils.createCheckTupleFromTuple(key, fieldSerdes,
keyFieldCount);
- HashMultiSet<RTreeCheckTuple> expectedResult = rTreeTestUtils.getRangeSearchExpectedResults(checkTuples, keyCheck);
+ HashMultiSet<RTreeCheckTuple> expectedResult = rTreeTestUtils.getRangeSearchExpectedResults(checkTuples,
+ keyCheck);
rTreeTestUtils.getRangeSearchExpectedResults(checkTuples, keyCheck);
indexAccessor.search(searchCursor, searchPredicate);
@@ -171,6 +172,7 @@
rTreeTestUtils.checkExpectedResults(searchCursor, expectedResult, fieldSerdes, keyFieldCount, null);
rtree.close();
+ rtree.destroy();
}
}
diff --git a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/multithread/RTreeMultiThreadTest.java b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/multithread/RTreeMultiThreadTest.java
index f753b5e..c40f218 100644
--- a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/multithread/RTreeMultiThreadTest.java
+++ b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/multithread/RTreeMultiThreadTest.java
@@ -57,7 +57,7 @@
IBinaryComparatorFactory[] btreeCmpFactories, IPrimitiveValueProviderFactory[] valueProviderFactories,
RTreePolicyType rtreePolicyType) throws TreeIndexException {
return RTreeUtils.createRTree(harness.getBufferCache(), harness.getFileMapProvider(), typeTraits,
- valueProviderFactories, rtreeCmpFactories, rtreePolicyType);
+ valueProviderFactories, rtreeCmpFactories, rtreePolicyType, harness.getFileReference());
}
diff --git a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/utils/RTreeTestContext.java b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/utils/RTreeTestContext.java
index de69e72..f363cbe 100644
--- a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/utils/RTreeTestContext.java
+++ b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/utils/RTreeTestContext.java
@@ -48,15 +48,16 @@
return rtree.getComparatorFactories();
}
- public static RTreeTestContext create(IBufferCache bufferCache, IFileMapProvider fileMapProvider, FileReference file,
- ISerializerDeserializer[] fieldSerdes, IPrimitiveValueProviderFactory[] valueProviderFactories,
- int numKeyFields, RTreePolicyType rtreePolicyType) throws Exception {
+ public static RTreeTestContext create(IBufferCache bufferCache, IFileMapProvider fileMapProvider,
+ FileReference file, ISerializerDeserializer[] fieldSerdes,
+ IPrimitiveValueProviderFactory[] valueProviderFactories, int numKeyFields, RTreePolicyType rtreePolicyType)
+ throws Exception {
ITypeTraits[] typeTraits = SerdeUtils.serdesToTypeTraits(fieldSerdes);
IBinaryComparatorFactory[] cmpFactories = SerdeUtils.serdesToComparatorFactories(fieldSerdes, numKeyFields);
RTree rtree = RTreeUtils.createRTree(bufferCache, fileMapProvider, typeTraits, valueProviderFactories,
- cmpFactories, rtreePolicyType);
- rtree.create(file);
- rtree.open(file);
+ cmpFactories, rtreePolicyType, file);
+ rtree.create();
+ rtree.open();
RTreeTestContext testCtx = new RTreeTestContext(fieldSerdes, rtree);
return testCtx;
}
diff --git a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/utils/RTreeTestHarness.java b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/utils/RTreeTestHarness.java
index 210c2b0..e324a7f 100644
--- a/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/utils/RTreeTestHarness.java
+++ b/hyracks-tests/hyracks-storage-am-rtree-test/src/test/java/edu/uci/ics/hyracks/storage/am/rtree/utils/RTreeTestHarness.java
@@ -71,15 +71,10 @@
TestStorageManagerComponentHolder.init(pageSize, numPages, maxOpenFiles);
bufferCache = TestStorageManagerComponentHolder.getBufferCache(ctx);
fileMapProvider = TestStorageManagerComponentHolder.getFileMapProvider(ctx);
- FileReference file = new FileReference(new File(fileName));
- bufferCache.createFile(file);
- treeFileId = fileMapProvider.lookupFileId(file);
- bufferCache.openFile(treeFileId);
rnd.setSeed(RANDOM_SEED);
}
public void tearDown() throws HyracksDataException {
- bufferCache.closeFile(treeFileId);
bufferCache.close();
File f = new File(fileName);
f.deleteOnExit();