changed the inverted index to manage the lifecycle of its btree on its own
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_lsm_tree@1706 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/am/invertedindex/WordInvertedIndexTest.java b/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/am/invertedindex/WordInvertedIndexTest.java
index e250b1f..a807b1e 100644
--- a/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/am/invertedindex/WordInvertedIndexTest.java
+++ b/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/am/invertedindex/WordInvertedIndexTest.java
@@ -62,6 +62,7 @@
import edu.uci.ics.hyracks.storage.am.invertedindex.dataflow.BinaryTokenizerOperatorDescriptor;
import edu.uci.ics.hyracks.storage.am.invertedindex.dataflow.InvertedIndexBulkLoadOperatorDescriptor;
import edu.uci.ics.hyracks.storage.am.invertedindex.dataflow.InvertedIndexCreateOperatorDescriptor;
+import edu.uci.ics.hyracks.storage.am.invertedindex.dataflow.InvertedIndexDataflowHelperFactory;
import edu.uci.ics.hyracks.storage.am.invertedindex.dataflow.InvertedIndexSearchOperatorDescriptor;
import edu.uci.ics.hyracks.storage.am.invertedindex.searchmodifiers.ConjunctiveSearchModifierFactory;
import edu.uci.ics.hyracks.storage.am.invertedindex.tokenizers.DelimitedUTF8StringBinaryTokenizerFactory;
@@ -82,6 +83,7 @@
private IStorageManagerInterface storageManager = new TestStorageManagerInterface();
private IIndexRegistryProvider<IIndex> indexRegistryProvider = new TestIndexRegistryProvider();
private IIndexDataflowHelperFactory btreeDataflowHelperFactory = new BTreeDataflowHelperFactory();
+ private IIndexDataflowHelperFactory invertedIndexDataflowHelperFactory = new InvertedIndexDataflowHelperFactory();
private final static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("ddMMyy-hhmmssSS");
private final static String sep = System.getProperty("file.separator");
@@ -160,7 +162,7 @@
InvertedIndexCreateOperatorDescriptor invIndexCreateOp = new InvertedIndexCreateOperatorDescriptor(spec,
storageManager, btreeFileSplitProvider, invListsFileSplitProvider, indexRegistryProvider,
tokenTypeTraits, tokenComparatorFactories, invListsTypeTraits, invListsComparatorFactories,
- tokenizerFactory, btreeDataflowHelperFactory, NoOpOperationCallbackProvider.INSTANCE);
+ tokenizerFactory, invertedIndexDataflowHelperFactory, NoOpOperationCallbackProvider.INSTANCE);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, invIndexCreateOp, NC1_ID);
spec.addRoot(invIndexCreateOp);
runTest(spec);
@@ -268,7 +270,7 @@
InvertedIndexBulkLoadOperatorDescriptor invIndexBulkLoadOp = new InvertedIndexBulkLoadOperatorDescriptor(spec,
fieldPermutation, storageManager, btreeFileSplitProvider, invListsFileSplitProvider,
indexRegistryProvider, tokenTypeTraits, tokenComparatorFactories, invListsTypeTraits,
- invListsComparatorFactories, tokenizerFactory, btreeDataflowHelperFactory,
+ invListsComparatorFactories, tokenizerFactory, invertedIndexDataflowHelperFactory,
NoOpOperationCallbackProvider.INSTANCE);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, invIndexBulkLoadOp, NC1_ID);
return invIndexBulkLoadOp;
@@ -314,7 +316,7 @@
InvertedIndexSearchOperatorDescriptor invIndexSearchOp = new InvertedIndexSearchOperatorDescriptor(spec, 0,
storageManager, btreeFileSplitProvider, invListsFileSplitProvider, indexRegistryProvider,
tokenTypeTraits, tokenComparatorFactories, invListsTypeTraits, invListsComparatorFactories,
- btreeDataflowHelperFactory, tokenizerFactory, searchModifierFactory, invListsRecDesc, false,
+ invertedIndexDataflowHelperFactory, tokenizerFactory, searchModifierFactory, invListsRecDesc, false,
NoOpOperationCallbackProvider.INSTANCE);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, invIndexSearchOp, NC1_ID);
return invIndexSearchOp;
diff --git a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/AbstractInvertedIndexOperatorDescriptor.java b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/AbstractInvertedIndexOperatorDescriptor.java
index 117f96f..06334b3 100644
--- a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/AbstractInvertedIndexOperatorDescriptor.java
+++ b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/AbstractInvertedIndexOperatorDescriptor.java
@@ -21,19 +21,13 @@
import edu.uci.ics.hyracks.api.job.IOperatorDescriptorRegistry;
import edu.uci.ics.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescriptor;
import edu.uci.ics.hyracks.dataflow.std.file.IFileSplitProvider;
-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.common.api.IOperationCallbackProvider;
-import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
-import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexTupleWriterFactory;
import edu.uci.ics.hyracks.storage.am.common.api.ITupleFilterFactory;
import edu.uci.ics.hyracks.storage.am.common.dataflow.IIndex;
import edu.uci.ics.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
import edu.uci.ics.hyracks.storage.am.common.dataflow.IIndexRegistryProvider;
-import edu.uci.ics.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory;
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedIndexOperatorDescriptor;
import edu.uci.ics.hyracks.storage.am.invertedindex.tokenizers.IBinaryTokenizerFactory;
-import edu.uci.ics.hyracks.storage.am.invertedindex.util.InvertedIndexUtils;
import edu.uci.ics.hyracks.storage.common.IStorageManagerInterface;
public abstract class AbstractInvertedIndexOperatorDescriptor extends AbstractSingleActivityOperatorDescriptor
@@ -46,13 +40,10 @@
protected final IIndexRegistryProvider<IIndex> indexRegistryProvider;
protected final boolean retainInput;
protected final IOperationCallbackProvider opCallbackProvider;
-
+
// Btree.
- protected final ITreeIndexFrameFactory btreeInteriorFrameFactory;
- protected final ITreeIndexFrameFactory btreeLeafFrameFactory;
- protected final ITypeTraits[] btreeTypeTraits;
+ protected final ITypeTraits[] tokenTypeTraits;
protected final IBinaryComparatorFactory[] btreeComparatorFactories;
- protected final IIndexDataflowHelperFactory btreeDataflowHelperFactory;
protected final IFileSplitProvider btreeFileSplitProvider;
// Inverted index.
@@ -60,6 +51,7 @@
protected final IBinaryComparatorFactory[] invListComparatorFactories;
protected final IBinaryTokenizerFactory tokenizerFactory;
protected final IFileSplitProvider invListsFileSplitProvider;
+ protected final IIndexDataflowHelperFactory invertedIndexDataflowHelperFactory;
public AbstractInvertedIndexOperatorDescriptor(IOperatorDescriptorRegistry spec, int inputArity, int outputArity,
RecordDescriptor recDesc, IStorageManagerInterface storageManager,
@@ -67,7 +59,8 @@
IIndexRegistryProvider<IIndex> indexRegistryProvider, ITypeTraits[] tokenTypeTraits,
IBinaryComparatorFactory[] tokenComparatorFactories, ITypeTraits[] invListsTypeTraits,
IBinaryComparatorFactory[] invListComparatorFactories, IBinaryTokenizerFactory tokenizerFactory,
- IIndexDataflowHelperFactory btreeDataflowHelperFactory, boolean retainInput, IOperationCallbackProvider opCallbackProvider) {
+ IIndexDataflowHelperFactory invertedIndexDataflowHelperFactory, boolean retainInput,
+ IOperationCallbackProvider opCallbackProvider) {
super(spec, inputArity, outputArity);
// General.
@@ -75,14 +68,10 @@
this.indexRegistryProvider = indexRegistryProvider;
this.retainInput = retainInput;
this.opCallbackProvider = opCallbackProvider;
-
+
// Btree.
- this.btreeTypeTraits = InvertedIndexUtils.getBTreeTypeTraits(tokenTypeTraits);
- ITreeIndexTupleWriterFactory tupleWriterFactory = new TypeAwareTupleWriterFactory(btreeTypeTraits);
- this.btreeInteriorFrameFactory = new BTreeNSMInteriorFrameFactory(tupleWriterFactory);
- this.btreeLeafFrameFactory = new BTreeNSMLeafFrameFactory(tupleWriterFactory);
+ this.tokenTypeTraits = tokenTypeTraits;
this.btreeComparatorFactories = tokenComparatorFactories;
- this.btreeDataflowHelperFactory = btreeDataflowHelperFactory;
this.btreeFileSplitProvider = btreeFileSplitProvider;
// Inverted index.
@@ -90,6 +79,7 @@
this.invListComparatorFactories = invListComparatorFactories;
this.tokenizerFactory = tokenizerFactory;
this.invListsFileSplitProvider = invListsFileSplitProvider;
+ this.invertedIndexDataflowHelperFactory = invertedIndexDataflowHelperFactory;
if (outputArity > 0) {
recordDescriptors[0] = recDesc;
@@ -97,10 +87,15 @@
}
@Override
+ public IIndexDataflowHelperFactory getIndexDataflowHelperFactory() {
+ return invertedIndexDataflowHelperFactory;
+ }
+
+ @Override
public IFileSplitProvider getFileSplitProvider() {
return btreeFileSplitProvider;
}
-
+
@Override
public IFileSplitProvider getInvListsFileSplitProvider() {
return invListsFileSplitProvider;
@@ -113,7 +108,7 @@
@Override
public ITypeTraits[] getTreeIndexTypeTraits() {
- return btreeTypeTraits;
+ return tokenTypeTraits;
}
@Override
@@ -135,7 +130,7 @@
public IBinaryTokenizerFactory getTokenizerFactory() {
return tokenizerFactory;
}
-
+
@Override
public ITypeTraits[] getInvListsTypeTraits() {
return invListsTypeTraits;
@@ -145,24 +140,19 @@
public IIndexRegistryProvider<IIndex> getIndexRegistryProvider() {
return indexRegistryProvider;
}
-
- @Override
- public IIndexDataflowHelperFactory getIndexDataflowHelperFactory() {
- return btreeDataflowHelperFactory;
- }
-
+
@Override
public boolean getRetainInput() {
- return retainInput;
+ return retainInput;
}
-
+
@Override
public IOperationCallbackProvider getOpCallbackProvider() {
- return opCallbackProvider;
+ return opCallbackProvider;
}
-
+
@Override
- public ITupleFilterFactory getTupleFilterFactory() {
- return null;
- }
+ public ITupleFilterFactory getTupleFilterFactory() {
+ return null;
+ }
}
\ No newline at end of file
diff --git a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexBulkLoadOperatorDescriptor.java b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexBulkLoadOperatorDescriptor.java
index 7ffec4d..fd0adfe 100644
--- a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexBulkLoadOperatorDescriptor.java
+++ b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexBulkLoadOperatorDescriptor.java
@@ -40,11 +40,11 @@
IFileSplitProvider invListsFileSplitProvider, IIndexRegistryProvider<IIndex> indexRegistryProvider,
ITypeTraits[] tokenTypeTraits, IBinaryComparatorFactory[] tokenComparatorFactories,
ITypeTraits[] invListsTypeTraits, IBinaryComparatorFactory[] invListComparatorFactories,
- IBinaryTokenizerFactory tokenizerFactory, IIndexDataflowHelperFactory btreeDataflowHelperFactory,
+ IBinaryTokenizerFactory tokenizerFactory, IIndexDataflowHelperFactory invertedIndexDataflowHelperFactory,
IOperationCallbackProvider opCallbackProvider) {
super(spec, 1, 0, null, storageManager, btreeFileSplitProvider, invListsFileSplitProvider,
indexRegistryProvider, tokenTypeTraits, tokenComparatorFactories, invListsTypeTraits,
- invListComparatorFactories, tokenizerFactory, btreeDataflowHelperFactory, false,
+ invListComparatorFactories, tokenizerFactory, invertedIndexDataflowHelperFactory, false,
opCallbackProvider);
this.fieldPermutation = fieldPermutation;
}
diff --git a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexBulkLoadOperatorNodePushable.java b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexBulkLoadOperatorNodePushable.java
index 62e6b31..3642da0 100644
--- a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexBulkLoadOperatorNodePushable.java
+++ b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexBulkLoadOperatorNodePushable.java
@@ -25,11 +25,9 @@
import edu.uci.ics.hyracks.storage.am.btree.impls.BTree;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexBulkLoader;
import edu.uci.ics.hyracks.storage.am.common.dataflow.PermutingFrameTupleReference;
-import edu.uci.ics.hyracks.storage.am.common.dataflow.TreeIndexDataflowHelper;
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.InvertedIndex;
public class InvertedIndexBulkLoadOperatorNodePushable extends AbstractUnaryInputSinkOperatorNodePushable {
- private final TreeIndexDataflowHelper btreeDataflowHelper;
private final InvertedIndexDataflowHelper invIndexDataflowHelper;
private InvertedIndex invIndex;
private IIndexBulkLoader bulkLoader;
@@ -41,32 +39,17 @@
public InvertedIndexBulkLoadOperatorNodePushable(AbstractInvertedIndexOperatorDescriptor opDesc,
IHyracksTaskContext ctx, int partition, int[] fieldPermutation, IRecordDescriptorProvider recordDescProvider) {
- btreeDataflowHelper = (TreeIndexDataflowHelper) opDesc.getIndexDataflowHelperFactory()
- .createIndexDataflowHelper(opDesc, ctx, partition);
- invIndexDataflowHelper = new InvertedIndexDataflowHelper(btreeDataflowHelper, opDesc, ctx, partition);
+ this.invIndexDataflowHelper = new InvertedIndexDataflowHelper(opDesc, ctx, partition);
this.recordDescProvider = recordDescProvider;
tuple.setFieldPermutation(fieldPermutation);
}
@Override
public void open() throws HyracksDataException {
- AbstractInvertedIndexOperatorDescriptor opDesc = (AbstractInvertedIndexOperatorDescriptor) btreeDataflowHelper
+ AbstractInvertedIndexOperatorDescriptor opDesc = (AbstractInvertedIndexOperatorDescriptor) invIndexDataflowHelper
.getOperatorDescriptor();
RecordDescriptor recDesc = recordDescProvider.getInputRecordDescriptor(opDesc.getActivityId(), 0);
- accessor = new FrameTupleAccessor(btreeDataflowHelper.getHyracksTaskContext().getFrameSize(), recDesc);
-
- // BTree.
- try {
- btreeDataflowHelper.init(false);
- } catch (Exception e) {
- // Cleanup in case of failure.
- btreeDataflowHelper.deinit();
- if (e instanceof HyracksDataException) {
- throw (HyracksDataException) e;
- } else {
- throw new HyracksDataException(e);
- }
- }
+ accessor = new FrameTupleAccessor(invIndexDataflowHelper.getHyracksTaskContext().getFrameSize(), recDesc);
// Inverted Index.
try {
@@ -102,11 +85,7 @@
} catch (Exception e) {
throw new HyracksDataException(e);
} finally {
- try {
- btreeDataflowHelper.deinit();
- } finally {
- invIndexDataflowHelper.deinit();
- }
+ invIndexDataflowHelper.deinit();
}
}
diff --git a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexCreateOperatorNodePushable.java b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexCreateOperatorNodePushable.java
index eb909d8..bd25746 100644
--- a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexCreateOperatorNodePushable.java
+++ b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexCreateOperatorNodePushable.java
@@ -19,17 +19,13 @@
import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.std.base.AbstractOperatorNodePushable;
-import edu.uci.ics.hyracks.storage.am.common.dataflow.TreeIndexDataflowHelper;
public class InvertedIndexCreateOperatorNodePushable extends AbstractOperatorNodePushable {
- private final TreeIndexDataflowHelper btreeDataflowHelper;
private final InvertedIndexDataflowHelper invIndexDataflowHelper;
public InvertedIndexCreateOperatorNodePushable(AbstractInvertedIndexOperatorDescriptor opDesc,
IHyracksTaskContext ctx, int partition) {
- btreeDataflowHelper = (TreeIndexDataflowHelper) opDesc.getIndexDataflowHelperFactory()
- .createIndexDataflowHelper(opDesc, ctx, partition);
- invIndexDataflowHelper = new InvertedIndexDataflowHelper(btreeDataflowHelper, opDesc, ctx, partition);
+ invIndexDataflowHelper = new InvertedIndexDataflowHelper(opDesc, ctx, partition);
}
@Override
@@ -48,18 +44,12 @@
@Override
public void initialize() throws HyracksDataException {
- // BTree.
- try {
- btreeDataflowHelper.init(true);
- } finally {
- btreeDataflowHelper.deinit();
- }
- // Inverted Index.
- try {
- invIndexDataflowHelper.init(true);
- } finally {
- invIndexDataflowHelper.deinit();
- }
+ // Inverted Index.
+ try {
+ invIndexDataflowHelper.init(true);
+ } finally {
+ invIndexDataflowHelper.deinit();
+ }
}
@Override
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 e769016..7409b2a 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
@@ -18,23 +18,18 @@
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.dataflow.std.file.IFileSplitProvider;
-import edu.uci.ics.hyracks.storage.am.btree.impls.BTree;
import edu.uci.ics.hyracks.storage.am.common.dataflow.IIndex;
import edu.uci.ics.hyracks.storage.am.common.dataflow.IIndexOperatorDescriptor;
import edu.uci.ics.hyracks.storage.am.common.dataflow.IndexDataflowHelper;
-import edu.uci.ics.hyracks.storage.am.common.dataflow.TreeIndexDataflowHelper;
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedIndexOperatorDescriptor;
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedListBuilder;
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.FixedSizeElementInvertedListBuilder;
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.InvertedIndex;
public final class InvertedIndexDataflowHelper extends IndexDataflowHelper {
- private final TreeIndexDataflowHelper btreeDataflowHelper;
- public InvertedIndexDataflowHelper(TreeIndexDataflowHelper btreeDataflowHelper, IIndexOperatorDescriptor opDesc,
- IHyracksTaskContext ctx, int partition) {
+ public InvertedIndexDataflowHelper(IIndexOperatorDescriptor opDesc, IHyracksTaskContext ctx, int partition) {
super(opDesc, ctx, partition);
- this.btreeDataflowHelper = btreeDataflowHelper;
}
public FileReference getFilereference() {
@@ -46,13 +41,12 @@
@Override
public IIndex createIndexInstance() throws HyracksDataException {
IInvertedIndexOperatorDescriptor invIndexOpDesc = (IInvertedIndexOperatorDescriptor) opDesc;
- // Assumes btreeDataflowHelper.init() has already been called.
- BTree btree = (BTree) btreeDataflowHelper.getIndex();
IInvertedListBuilder invListBuilder = new FixedSizeElementInvertedListBuilder(
invIndexOpDesc.getInvListsTypeTraits());
- return new InvertedIndex(opDesc.getStorageManager().getBufferCache(ctx), btree,
- invIndexOpDesc.getInvListsTypeTraits(), invIndexOpDesc.getInvListsComparatorFactories(),
- invListBuilder, opDesc.getStorageManager().getFileMapProvider(ctx), opDesc.getFileSplitProvider()
- .getFileSplits()[partition].getLocalFile());
+ return new InvertedIndex(opDesc.getStorageManager().getBufferCache(ctx), opDesc.getStorageManager()
+ .getFileMapProvider(ctx), invListBuilder, invIndexOpDesc.getInvListsTypeTraits(),
+ invIndexOpDesc.getInvListsComparatorFactories(), invIndexOpDesc.getTreeIndexTypeTraits(),
+ invIndexOpDesc.getTreeIndexComparatorFactories(),
+ 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/dataflow/InvertedIndexDataflowHelperFactory.java b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexDataflowHelperFactory.java
new file mode 100644
index 0000000..52326b4
--- /dev/null
+++ b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexDataflowHelperFactory.java
@@ -0,0 +1,18 @@
+package edu.uci.ics.hyracks.storage.am.invertedindex.dataflow;
+
+import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
+import edu.uci.ics.hyracks.storage.am.common.dataflow.IIndexDataflowHelperFactory;
+import edu.uci.ics.hyracks.storage.am.common.dataflow.IIndexOperatorDescriptor;
+import edu.uci.ics.hyracks.storage.am.common.dataflow.IndexDataflowHelper;
+
+public class InvertedIndexDataflowHelperFactory implements IIndexDataflowHelperFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IndexDataflowHelper createIndexDataflowHelper(IIndexOperatorDescriptor opDesc, IHyracksTaskContext ctx,
+ int partition) {
+ return new InvertedIndexDataflowHelper(opDesc, ctx, partition);
+ }
+
+}
diff --git a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexSearchOperatorNodePushable.java b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexSearchOperatorNodePushable.java
index 8fcd2a4..4b932b1 100644
--- a/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexSearchOperatorNodePushable.java
+++ b/hyracks-storage-am-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/invertedindex/dataflow/InvertedIndexSearchOperatorNodePushable.java
@@ -31,7 +31,6 @@
import edu.uci.ics.hyracks.dataflow.std.base.AbstractUnaryInputUnaryOutputOperatorNodePushable;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexAccessor;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexCursor;
-import edu.uci.ics.hyracks.storage.am.common.dataflow.TreeIndexDataflowHelper;
import edu.uci.ics.hyracks.storage.am.common.impls.NoOpOperationCallback;
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedIndexSearchModifier;
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.InvertedIndex;
@@ -39,7 +38,6 @@
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.OccurrenceThresholdPanicException;
public class InvertedIndexSearchOperatorNodePushable extends AbstractUnaryInputUnaryOutputOperatorNodePushable {
- private final TreeIndexDataflowHelper btreeDataflowHelper;
private final InvertedIndexDataflowHelper invIndexDataflowHelper;
private final int queryField;
private FrameTupleAccessor accessor;
@@ -63,9 +61,7 @@
IHyracksTaskContext ctx, int partition, int queryField, IInvertedIndexSearchModifier searchModifier,
IRecordDescriptorProvider recordDescProvider) {
this.opDesc = opDesc;
- btreeDataflowHelper = (TreeIndexDataflowHelper) opDesc.getIndexDataflowHelperFactory()
- .createIndexDataflowHelper(opDesc, ctx, partition);
- invIndexDataflowHelper = new InvertedIndexDataflowHelper(btreeDataflowHelper, opDesc, ctx, partition);
+ this.invIndexDataflowHelper = new InvertedIndexDataflowHelper(opDesc, ctx, partition);
this.queryField = queryField;
this.searchPred = new InvertedIndexSearchPredicate(opDesc.getTokenizerFactory().createTokenizer(),
searchModifier);
@@ -76,20 +72,9 @@
@Override
public void open() throws HyracksDataException {
RecordDescriptor inputRecDesc = recordDescProvider.getInputRecordDescriptor(opDesc.getActivityId(), 0);
- accessor = new FrameTupleAccessor(btreeDataflowHelper.getHyracksTaskContext().getFrameSize(), inputRecDesc);
+ accessor = new FrameTupleAccessor(invIndexDataflowHelper.getHyracksTaskContext().getFrameSize(), inputRecDesc);
tuple = new FrameTupleReference();
- // BTree.
- try {
- btreeDataflowHelper.init(false);
- } catch (Exception e) {
- // Cleanup in case of failure/
- btreeDataflowHelper.deinit();
- if (e instanceof HyracksDataException) {
- throw (HyracksDataException) e;
- } else {
- throw new HyracksDataException(e);
- }
- }
+
// Inverted Index.
try {
invIndexDataflowHelper.init(false);
@@ -104,10 +89,10 @@
}
}
- writeBuffer = btreeDataflowHelper.getHyracksTaskContext().allocateFrame();
+ writeBuffer = invIndexDataflowHelper.getHyracksTaskContext().allocateFrame();
tb = new ArrayTupleBuilder(recordDesc.getFieldCount());
dos = tb.getDataOutput();
- appender = new FrameTupleAppender(btreeDataflowHelper.getHyracksTaskContext().getFrameSize());
+ appender = new FrameTupleAppender(invIndexDataflowHelper.getHyracksTaskContext().getFrameSize());
appender.reset(writeBuffer, true);
indexAccessor = invIndex.createAccessor(NoOpOperationCallback.INSTANCE, NoOpOperationCallback.INSTANCE);
@@ -177,11 +162,7 @@
}
writer.close();
} finally {
- try {
- btreeDataflowHelper.deinit();
- } finally {
- invIndexDataflowHelper.deinit();
- }
+ invIndexDataflowHelper.deinit();
}
}
}
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 b775bac..d65952a 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
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.invertedindex.impls;
+import java.io.File;
import java.nio.ByteBuffer;
import edu.uci.ics.hyracks.api.context.IHyracksCommonContext;
@@ -27,8 +28,11 @@
import edu.uci.ics.hyracks.dataflow.common.comm.io.ArrayTupleReference;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.dataflow.common.data.marshalling.IntegerSerializerDeserializer;
+import edu.uci.ics.hyracks.storage.am.btree.exceptions.BTreeException;
+import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeLeafFrameType;
import edu.uci.ics.hyracks.storage.am.btree.impls.BTree;
import edu.uci.ics.hyracks.storage.am.btree.impls.RangePredicate;
+import edu.uci.ics.hyracks.storage.am.btree.util.BTreeUtils;
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.IIndexCursor;
@@ -45,6 +49,7 @@
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedIndexSearcher;
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedListBuilder;
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedListCursor;
+import edu.uci.ics.hyracks.storage.am.invertedindex.util.InvertedIndexUtils;
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;
@@ -74,15 +79,23 @@
private boolean isOpen = false;
- public InvertedIndex(IBufferCache bufferCache, BTree btree, ITypeTraits[] invListTypeTraits,
- IBinaryComparatorFactory[] invListCmpFactories, IInvertedListBuilder invListBuilder,
- IFileMapProvider fileMapProvider, FileReference file) {
+ public InvertedIndex(IBufferCache bufferCache, IFileMapProvider fileMapProvider,
+ IInvertedListBuilder invListBuilder, ITypeTraits[] invListTypeTraits,
+ IBinaryComparatorFactory[] invListCmpFactories, ITypeTraits[] tokenTypeTraits,
+ IBinaryComparatorFactory[] tokenCmpFactories, FileReference file) throws HyracksDataException {
this.bufferCache = bufferCache;
this.fileMapProvider = fileMapProvider;
- this.btree = btree;
+ this.invListBuilder = invListBuilder;
+
this.invListTypeTraits = invListTypeTraits;
this.invListCmpFactories = invListCmpFactories;
- this.invListBuilder = invListBuilder;
+ try {
+ this.btree = BTreeUtils.createBTree(bufferCache, fileMapProvider,
+ InvertedIndexUtils.getBTreeTypeTraits(tokenTypeTraits), tokenCmpFactories,
+ BTreeLeafFrameType.REGULAR_NSM, new FileReference(new File(file.getFile().getPath() + "_btree")));
+ } catch (BTreeException e) {
+ throw new HyracksDataException(e);
+ }
this.numTokenFields = btree.getComparatorFactories().length;
this.numInvListKeys = invListCmpFactories.length;
this.file = file;
@@ -93,6 +106,7 @@
if (isOpen) {
throw new HyracksDataException("Failed to create since index is already open.");
}
+ btree.create();
boolean fileIsMapped = false;
synchronized (fileMapProvider) {
@@ -121,6 +135,7 @@
return;
}
+ btree.activate();
boolean fileIsMapped = false;
synchronized (fileMapProvider) {
fileIsMapped = fileMapProvider.isMapped(file);
@@ -149,6 +164,7 @@
return;
}
+ btree.deactivate();
bufferCache.closeFile(fileId);
isOpen = false;
@@ -160,6 +176,7 @@
throw new HyracksDataException("Failed to destroy since index is already open.");
}
+ btree.destroy();
file.getFile().delete();
if (fileId == -1) {
return;
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 c60d57f..ee954d3 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
@@ -36,24 +36,12 @@
import edu.uci.ics.hyracks.dataflow.common.comm.io.ArrayTupleReference;
import edu.uci.ics.hyracks.dataflow.common.data.marshalling.IntegerSerializerDeserializer;
import edu.uci.ics.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer;
-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.IFreePageManager;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexCursor;
-import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrame;
-import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
-import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexMetaDataFrame;
-import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexMetaDataFrameFactory;
-import edu.uci.ics.hyracks.storage.am.common.frames.LIFOMetaDataFrameFactory;
-import edu.uci.ics.hyracks.storage.am.common.freepage.LinkedListFreePageManager;
-import edu.uci.ics.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory;
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedListBuilder;
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.FixedSizeElementInvertedListBuilder;
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.InvertedIndex;
import edu.uci.ics.hyracks.storage.am.invertedindex.tokenizers.IBinaryTokenizer;
import edu.uci.ics.hyracks.storage.am.invertedindex.tokenizers.ITokenFactory;
-import edu.uci.ics.hyracks.storage.am.invertedindex.util.InvertedIndexUtils;
import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
import edu.uci.ics.hyracks.test.support.TestStorageManagerComponentHolder;
@@ -69,44 +57,14 @@
protected IBufferCache bufferCache;
protected IFileMapProvider fmp;
- // --- BTREE ---
-
- // create file refs
- protected FileReference btreeFile = new FileReference(new File(btreeFileName));
- protected int btreeFileId;
-
- // declare token type traits
- protected ITypeTraits[] tokenTypeTraits = new ITypeTraits[] { UTF8StringPointable.TYPE_TRAITS };
- protected ITypeTraits[] btreeTypeTraits = InvertedIndexUtils.getBTreeTypeTraits(tokenTypeTraits);
-
- // declare btree keys
- protected int btreeKeyFieldCount = 1;
- protected IBinaryComparatorFactory[] btreeCmpFactories = new IBinaryComparatorFactory[btreeKeyFieldCount];
-
- // btree frame factories
- protected TypeAwareTupleWriterFactory tupleWriterFactory = new TypeAwareTupleWriterFactory(btreeTypeTraits);
- protected ITreeIndexFrameFactory leafFrameFactory = new BTreeNSMLeafFrameFactory(tupleWriterFactory);
- protected ITreeIndexFrameFactory interiorFrameFactory = new BTreeNSMInteriorFrameFactory(tupleWriterFactory);
- protected ITreeIndexMetaDataFrameFactory metaFrameFactory = new LIFOMetaDataFrameFactory();
-
- // btree frames
- protected ITreeIndexFrame leafFrame = leafFrameFactory.createFrame();
- protected ITreeIndexMetaDataFrame metaFrame = metaFrameFactory.createFrame();
-
- protected IFreePageManager freePageManager;
-
- protected BTree btree;
-
- // --- INVERTED INDEX ---
-
protected FileReference invListsFile = new FileReference(new File(invListsFileName));
- protected int invListsFileId;
- protected int invListFields = 1;
- protected ITypeTraits[] invListTypeTraits = new ITypeTraits[invListFields];
-
- protected int invListKeys = 1;
- protected IBinaryComparatorFactory[] invListCmpFactories = new IBinaryComparatorFactory[invListKeys];
+ protected ITypeTraits[] tokenTypeTraits = new ITypeTraits[] { UTF8StringPointable.TYPE_TRAITS };
+ protected IBinaryComparatorFactory[] tokenCmpFactories = new IBinaryComparatorFactory[] { PointableBinaryComparatorFactory
+ .of(UTF8StringPointable.FACTORY) };
+ protected ITypeTraits[] invListTypeTraits = new ITypeTraits[] { IntegerPointable.TYPE_TRAITS };
+ protected IBinaryComparatorFactory[] invListCmpFactories = new IBinaryComparatorFactory[] { PointableBinaryComparatorFactory
+ .of(IntegerPointable.FACTORY) };
protected InvertedIndex invIndex;
@@ -147,28 +105,11 @@
bufferCache = TestStorageManagerComponentHolder.getBufferCache(taskCtx);
fmp = TestStorageManagerComponentHolder.getFileMapProvider(taskCtx);
- // --- BTREE ---
-
- btreeCmpFactories[0] = PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY);
-
- freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
-
- btree = new BTree(bufferCache, fmp, freePageManager, interiorFrameFactory, leafFrameFactory, btreeCmpFactories,
- btreeTypeTraits.length, btreeFile);
-
- btree.create();
- btree.activate();
-
- // --- INVERTED INDEX ---
-
setTokenizer();
- invListTypeTraits[0] = IntegerPointable.TYPE_TRAITS;
- invListCmpFactories[0] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
-
IInvertedListBuilder invListBuilder = new FixedSizeElementInvertedListBuilder(invListTypeTraits);
- invIndex = new InvertedIndex(bufferCache, btree, invListTypeTraits, invListCmpFactories, invListBuilder, fmp,
- invListsFile);
+ invIndex = new InvertedIndex(bufferCache, fmp, invListBuilder, invListTypeTraits, invListCmpFactories,
+ tokenTypeTraits, tokenCmpFactories, invListsFile);
invIndex.create();
invIndex.activate();
@@ -177,11 +118,9 @@
@After
public void deinit() throws HyracksDataException {
- AbstractInvIndexTest.tearDown();
- btree.deactivate();
- btree.destroy();
invIndex.deactivate();
invIndex.destroy();
bufferCache.close();
+ AbstractInvIndexTest.tearDown();
}
}
diff --git a/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/AbstractInvIndexTest.java b/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/AbstractInvIndexTest.java
index cc8ab15..cdc17cf 100644
--- a/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/AbstractInvIndexTest.java
+++ b/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/AbstractInvIndexTest.java
@@ -22,22 +22,16 @@
public abstract class AbstractInvIndexTest {
- protected static final Logger LOGGER = Logger
- .getLogger(AbstractInvIndexTest.class.getName());
+ protected static final Logger LOGGER = Logger.getLogger(AbstractInvIndexTest.class.getName());
- protected final static SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
- "ddMMyy-hhmmssSS");
- protected final static String tmpDir = System.getProperty("java.io.tmpdir");
- protected final static String sep = System.getProperty("file.separator");
- protected final static String baseFileName = tmpDir + sep
- + simpleDateFormat.format(new Date());
- protected final static String btreeFileName = baseFileName + "btree";
- protected final static String invListsFileName = baseFileName + "invlists";
+ protected final static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("ddMMyy-hhmmssSS");
+ protected final static String tmpDir = System.getProperty("java.io.tmpdir");
+ protected final static String sep = System.getProperty("file.separator");
+ protected final static String baseFileName = tmpDir + sep + simpleDateFormat.format(new Date());
+ protected final static String invListsFileName = baseFileName + "invlists";
- public static void tearDown() {
- File btreeFile = new File(btreeFileName);
- btreeFile.deleteOnExit();
- File invListsFile = new File(invListsFileName);
- invListsFile.deleteOnExit();
- }
+ public static void tearDown() {
+ File invListsFile = new File(invListsFileName);
+ invListsFile.deleteOnExit();
+ }
}
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 cc8a503..6b29edc 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
@@ -44,30 +44,18 @@
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.dataflow.common.data.marshalling.IntegerSerializerDeserializer;
import edu.uci.ics.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer;
-import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeLeafFrame;
-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.btree.impls.BTreeRangeSearchCursor;
import edu.uci.ics.hyracks.storage.am.btree.impls.RangePredicate;
-import edu.uci.ics.hyracks.storage.am.common.api.IFreePageManager;
import edu.uci.ics.hyracks.storage.am.common.api.IIndexBulkLoader;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexAccessor;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexCursor;
-import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrame;
-import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexFrameFactory;
-import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexMetaDataFrameFactory;
-import edu.uci.ics.hyracks.storage.am.common.frames.LIFOMetaDataFrameFactory;
-import edu.uci.ics.hyracks.storage.am.common.freepage.LinkedListFreePageManager;
import edu.uci.ics.hyracks.storage.am.common.impls.NoOpOperationCallback;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.MultiComparator;
-import edu.uci.ics.hyracks.storage.am.common.tuples.TypeAwareTupleWriterFactory;
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedListBuilder;
import edu.uci.ics.hyracks.storage.am.invertedindex.api.IInvertedListCursor;
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.FixedSizeElementInvertedListBuilder;
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.FixedSizeElementInvertedListCursor;
import edu.uci.ics.hyracks.storage.am.invertedindex.impls.InvertedIndex;
-import edu.uci.ics.hyracks.storage.am.invertedindex.util.InvertedIndexUtils;
import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
import edu.uci.ics.hyracks.test.support.TestStorageManagerComponentHolder;
@@ -89,38 +77,17 @@
*/
@Test
public void singleFieldPayloadTest() throws Exception {
-
TestStorageManagerComponentHolder.init(PAGE_SIZE, NUM_PAGES, MAX_OPEN_FILES);
IBufferCache bufferCache = TestStorageManagerComponentHolder.getBufferCache(stageletCtx);
IFileMapProvider fmp = TestStorageManagerComponentHolder.getFileMapProvider(stageletCtx);
- // create file refs
- FileReference btreeFile = new FileReference(new File(btreeFileName));
-
FileReference invListsFile = new FileReference(new File(invListsFileName));
- // Declare token type traits, and compute BTree type traits.
ITypeTraits[] tokenTypeTraits = new ITypeTraits[] { UTF8StringPointable.TYPE_TRAITS };
- ITypeTraits[] btreeTypeTraits = InvertedIndexUtils.getBTreeTypeTraits(tokenTypeTraits);
- // declare btree keys
- int keyFieldCount = 1;
- IBinaryComparatorFactory[] cmpFactories = new IBinaryComparatorFactory[keyFieldCount];
- cmpFactories[0] = PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY);
+ IBinaryComparatorFactory[] cmpFactories = new IBinaryComparatorFactory[] { PointableBinaryComparatorFactory
+ .of(UTF8StringPointable.FACTORY) };
- TypeAwareTupleWriterFactory tupleWriterFactory = new TypeAwareTupleWriterFactory(btreeTypeTraits);
- ITreeIndexFrameFactory leafFrameFactory = new BTreeNSMLeafFrameFactory(tupleWriterFactory);
- ITreeIndexFrameFactory interiorFrameFactory = new BTreeNSMInteriorFrameFactory(tupleWriterFactory);
- ITreeIndexMetaDataFrameFactory metaFrameFactory = new LIFOMetaDataFrameFactory();
-
- ITreeIndexFrame leafFrame = leafFrameFactory.createFrame();
-
- IFreePageManager freePageManager = new LinkedListFreePageManager(bufferCache, 0, metaFrameFactory);
-
- BTree btree = new BTree(bufferCache, fmp, freePageManager, interiorFrameFactory, leafFrameFactory,
- cmpFactories, btreeTypeTraits.length, btreeFile);
- btree.create();
- btree.activate();
int invListFields = 1;
ITypeTraits[] invListTypeTraits = new ITypeTraits[invListFields];
invListTypeTraits[0] = IntegerPointable.TYPE_TRAITS;
@@ -130,8 +97,8 @@
invListCmpFactories[0] = PointableBinaryComparatorFactory.of(IntegerPointable.FACTORY);
IInvertedListBuilder invListBuilder = new FixedSizeElementInvertedListBuilder(invListTypeTraits);
- InvertedIndex invIndex = new InvertedIndex(bufferCache, btree, invListTypeTraits, invListCmpFactories,
- invListBuilder, fmp, invListsFile);
+ InvertedIndex invIndex = new InvertedIndex(bufferCache, fmp, invListBuilder, invListTypeTraits,
+ invListCmpFactories, tokenTypeTraits, cmpFactories, invListsFile);
invIndex.create();
invIndex.activate();
@@ -203,7 +170,9 @@
// ------- START VERIFICATION -----------
- ITreeIndexCursor btreeCursor = new BTreeRangeSearchCursor((IBTreeLeafFrame) leafFrame, false);
+ ITreeIndexAccessor btreeAccessor = invIndex.getBTree().createAccessor(NoOpOperationCallback.INSTANCE,
+ NoOpOperationCallback.INSTANCE);
+ ITreeIndexCursor btreeCursor = (ITreeIndexCursor) btreeAccessor.createSearchCursor();
FrameTupleReference searchKey = new FrameTupleReference();
MultiComparator btreeCmp = MultiComparator.create(cmpFactories);
RangePredicate btreePred = new RangePredicate(searchKey, searchKey, true, true, btreeCmp, btreeCmp);
@@ -219,9 +188,6 @@
IFrameTupleAccessor tokenAccessor = new FrameTupleAccessor(stageletCtx.getFrameSize(), tokenRecDesc);
tokenAccessor.reset(frame);
- ITreeIndexAccessor btreeAccessor = invIndex.getBTree().createAccessor(NoOpOperationCallback.INSTANCE,
- NoOpOperationCallback.INSTANCE);
-
// verify created inverted lists one-by-one
for (int i = 0; i < tokens.size(); i++) {
@@ -277,8 +243,6 @@
invListCursor.unpinPages();
}
- btree.deactivate();
- btree.destroy();
invIndex.deactivate();
invIndex.destroy();
bufferCache.close();
diff --git a/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/SearchTest.java b/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/SearchTest.java
index 53d2cab..104a47d 100644
--- a/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/SearchTest.java
+++ b/hyracks-tests/hyracks-storage-am-invertedindex-test/src/test/java/edu/uci/ics/hyracks/storage/am/invertedindex/SearchTest.java
@@ -62,9 +62,9 @@
@Before
public void start() throws Exception {
super.start();
- btreeBinCmps = new IBinaryComparator[btreeCmpFactories.length];
- for (int i = 0; i < btreeCmpFactories.length; i++) {
- btreeBinCmps[i] = btreeCmpFactories[i].createBinaryComparator();
+ btreeBinCmps = new IBinaryComparator[tokenCmpFactories.length];
+ for (int i = 0; i < tokenCmpFactories.length; i++) {
+ btreeBinCmps[i] = tokenCmpFactories[i].createBinaryComparator();
}
generateDataStrings();
loadData();