using IFileMappingProvider instead of fileId in btree ops
git-svn-id: https://hyracks.googlecode.com/svn/trunk@128 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/btree/BTreeOperatorsTest.java b/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/btree/BTreeOperatorsTest.java
index 509efda..38c2899 100644
--- a/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/btree/BTreeOperatorsTest.java
+++ b/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/btree/BTreeOperatorsTest.java
@@ -37,9 +37,7 @@
import edu.uci.ics.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
import edu.uci.ics.hyracks.dataflow.common.comm.io.FrameTupleAppender;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
-import edu.uci.ics.hyracks.dataflow.common.data.comparators.IntegerBinaryComparatorFactory;
import edu.uci.ics.hyracks.dataflow.common.data.comparators.UTF8StringBinaryComparatorFactory;
-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.dataflow.common.data.parsers.IValueParserFactory;
import edu.uci.ics.hyracks.dataflow.common.data.parsers.UTF8StringParserFactory;
@@ -61,6 +59,7 @@
import edu.uci.ics.hyracks.storage.am.btree.dataflow.BTreeRegistryProvider;
import edu.uci.ics.hyracks.storage.am.btree.dataflow.BTreeSearchOperatorDescriptor;
import edu.uci.ics.hyracks.storage.am.btree.dataflow.BufferCacheProvider;
+import edu.uci.ics.hyracks.storage.am.btree.dataflow.FileMappingProvider;
import edu.uci.ics.hyracks.storage.am.btree.dataflow.FrameTupleReferenceFactory;
import edu.uci.ics.hyracks.storage.am.btree.dataflow.IBTreeRegistryProvider;
import edu.uci.ics.hyracks.storage.am.btree.dataflow.IBufferCacheProvider;
@@ -76,12 +75,16 @@
import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.file.FileInfo;
import edu.uci.ics.hyracks.storage.common.file.FileManager;
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
import edu.uci.ics.hyracks.tests.integration.AbstractIntegrationTest;
public class BTreeOperatorsTest extends AbstractIntegrationTest {
-
+
@Test
- public void bulkLoadTest() throws Exception {
+ public void bulkLoadTest() throws Exception {
+ // relies on the fact that NCs are run from same process
+ System.setProperty("NodeControllerDataPath", "/tmp/");
+
JobSpecification spec = new JobSpecification();
FileSplit[] ordersSplits = new FileSplit[] {
@@ -115,16 +118,16 @@
IBufferCacheProvider bufferCacheProvider = new BufferCacheProvider();
IBTreeRegistryProvider btreeRegistryProvider = new BTreeRegistryProvider();
-
+ IFileMappingProvider fileMappingProvider = new FileMappingProvider();
+
int fieldCount = 3;
int keyFieldCount = 1;
IBinaryComparatorFactory[] comparatorFactories = new IBinaryComparatorFactory[keyFieldCount];
comparatorFactories[0] = UTF8StringBinaryComparatorFactory.INSTANCE;
- int[] fieldPermutation = { 0, 4, 5 };
- int btreeFileId = 0;
+ int[] fieldPermutation = { 0, 4, 5 };
- BTreeBulkLoadOperatorDescriptor btreeBulkLoad = new BTreeBulkLoadOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, btreeFileId, "/tmp/btreetest.bin", interiorFrameFactory, leafFrameFactory, fieldCount, comparatorFactories, fieldPermutation, 0.7f, false);
+ BTreeBulkLoadOperatorDescriptor btreeBulkLoad = new BTreeBulkLoadOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, "btreetest.bin", fileMappingProvider, interiorFrameFactory, leafFrameFactory, fieldCount, comparatorFactories, fieldPermutation, 0.7f);
PartitionConstraint btreePartitionConstraintA = new ExplicitPartitionConstraint(new LocationConstraint[] { new AbsoluteLocationConstraint(NC1_ID) });
btreeBulkLoad.setPartitionConstraint(btreePartitionConstraintA);
@@ -142,12 +145,14 @@
}
MultiComparator cmp = new MultiComparator(fieldCount, comparators);
-
+
+
// try an ordered scan on the bulk-loaded btree
- BTree btreeA = btreeRegistryProvider.getBTreeRegistry().get(btreeFileId);
+ int btreeFileId = 0; // TODO: this relies on the way FileMappingProvider assignds ids (in sequence starting from 0)
+ BTree btree = btreeRegistryProvider.getBTreeRegistry().get(btreeFileId);
IBTreeCursor scanCursor = new RangeSearchCursor(leafFrameFactory.getFrame());
RangePredicate nullPred = new RangePredicate(true, null, null, null);
- btreeA.search(scanCursor, nullPred, leafFrameFactory.getFrame(), interiorFrameFactory.getFrame());
+ btree.search(scanCursor, nullPred, leafFrameFactory.getFrame(), interiorFrameFactory.getFrame());
try {
while (scanCursor.hasNext()) {
scanCursor.next();
@@ -164,6 +169,9 @@
@Test
public void btreeSearchTest() throws Exception {
+ // relies on the fact that NCs are run from same process
+ System.setProperty("NodeControllerDataPath", "/tmp/");
+
JobSpecification spec = new JobSpecification();
IFileSplitProvider splitProvider = new ConstantFileSplitProvider(new FileSplit[] {
@@ -172,17 +180,16 @@
IBTreeInteriorFrameFactory interiorFrameFactory = new NSMInteriorFrameFactory();
IBTreeLeafFrameFactory leafFrameFactory = new NSMLeafFrameFactory();
- int fieldCount = 2;
+ int fieldCount = 3;
int keyFieldCount = 1;
IBinaryComparatorFactory[] comparatorFactories = new IBinaryComparatorFactory[keyFieldCount];
- comparatorFactories[0] = IntegerBinaryComparatorFactory.INSTANCE;
+ comparatorFactories[0] = UTF8StringBinaryComparatorFactory.INSTANCE;
// construct a multicomparator from the factories (only for printing purposes)
IBinaryComparator[] comparators = new IBinaryComparator[comparatorFactories.length];
for(int i = 0; i < comparatorFactories.length; i++) {
comparators[i] = comparatorFactories[i].createBinaryComparator();
- }
-
+ }
MultiComparator cmp = new MultiComparator(fieldCount, comparators);
@@ -194,35 +201,43 @@
ArrayTupleBuilder tb = new ArrayTupleBuilder(cmp.getKeyFieldCount());
DataOutput dos = tb.getDataOutput();
- ISerializerDeserializer[] keyRecDescSers = { IntegerSerializerDeserializer.INSTANCE};
+ ISerializerDeserializer[] keyRecDescSers = { UTF8StringSerializerDeserializer.INSTANCE};
RecordDescriptor keyRecDesc = new RecordDescriptor(keyRecDescSers);
// build low key
tb.reset();
- IntegerSerializerDeserializer.INSTANCE.serialize(-1000, dos);
+ UTF8StringSerializerDeserializer.INSTANCE.serialize("100", dos);
tb.addFieldEndOffset();
appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize());
// build high key
tb.reset();
- IntegerSerializerDeserializer.INSTANCE.serialize(1000, dos);
+ UTF8StringSerializerDeserializer.INSTANCE.serialize("200", dos);
tb.addFieldEndOffset();
+ appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize());
+
// build search key factories
ITupleReferenceFactory[] searchKeys = new ITupleReferenceFactory[2];
searchKeys[0] = new FrameTupleReferenceFactory(keyFrame.array(), 0, keyRecDesc);
searchKeys[1] = new FrameTupleReferenceFactory(keyFrame.array(), 1, keyRecDesc);
IBufferCacheProvider bufferCacheProvider = new BufferCacheProvider();
- IBTreeRegistryProvider btreeRegistryProvider = new BTreeRegistryProvider();
+ IBTreeRegistryProvider btreeRegistryProvider = new BTreeRegistryProvider();
+ IFileMappingProvider fileMappingProvider = new FileMappingProvider();
RecordDescriptor recDesc = new RecordDescriptor(
- new ISerializerDeserializer[] { IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE });
+ new ISerializerDeserializer[] { UTF8StringSerializerDeserializer.INSTANCE, UTF8StringSerializerDeserializer.INSTANCE, UTF8StringSerializerDeserializer.INSTANCE });
- int btreeFileId = 2;
- BTreeSearchOperatorDescriptor btreeSearchOp = new BTreeSearchOperatorDescriptor(spec, splitProvider, recDesc, bufferCacheProvider, btreeRegistryProvider, btreeFileId, "/tmp/btreetest.bin", interiorFrameFactory, leafFrameFactory, fieldCount, comparatorFactories, true, searchKeys, comparatorFactories.length, false);
- //BTreeDiskOrderScanOperatorDescriptor btreeSearchOp = new BTreeDiskOrderScanOperatorDescriptor(spec, splitProvider, recDesc, bufferCacheProvider, btreeRegistryProvider, 0, "/tmp/btreetest.bin", interiorFrameFactory, leafFrameFactory, cmp);
+ // TODO: hacky, manually adding file
+ String ncDataPath = System.getProperty("NodeControllerDataPath");
+ String fileName = ncDataPath + "btreetest.bin";
+ int blubb = fileMappingProvider.mapNameToFileId(fileName, true);
+ System.out.println("BLUBB: " + blubb + " " + fileName);
+
+ BTreeSearchOperatorDescriptor btreeSearchOp = new BTreeSearchOperatorDescriptor(spec, splitProvider, recDesc, bufferCacheProvider, btreeRegistryProvider, "btreetest.bin", fileMappingProvider, interiorFrameFactory, leafFrameFactory, fieldCount, comparatorFactories, true, searchKeys, comparatorFactories.length);
+ //BTreeDiskOrderScanOperatorDescriptor btreeSearchOp = new BTreeDiskOrderScanOperatorDescriptor(spec, splitProvider, recDesc, bufferCacheProvider, btreeRegistryProvider, 0, "btreetest.bin", interiorFrameFactory, leafFrameFactory, cmp);
PartitionConstraint btreePartitionConstraint = new ExplicitPartitionConstraint(new LocationConstraint[] { new AbsoluteLocationConstraint(NC1_ID) });
btreeSearchOp.setPartitionConstraint(btreePartitionConstraint);
@@ -238,9 +253,11 @@
runTest(spec);
}
-
@Test
public void insertTest() throws Exception {
+ // relies on the fact that NCs are run from same process
+ System.setProperty("NodeControllerDataPath", "/tmp/");
+
JobSpecification spec = new JobSpecification();
FileSplit[] ordersSplits = new FileSplit[] {
@@ -267,7 +284,11 @@
IBTreeLeafFrameFactory leafFrameFactory = new NSMLeafFrameFactory();
IBufferCacheProvider bufferCacheProvider = new BufferCacheProvider();
- IBTreeRegistryProvider btreeRegistryProvider = new BTreeRegistryProvider();
+ IBTreeRegistryProvider btreeRegistryProvider = new BTreeRegistryProvider();
+
+ // trick to clear pages of old fileids
+ BufferCacheProvider tmp = (BufferCacheProvider)bufferCacheProvider;
+ tmp.reset();
// we will create a primary index and 2 secondary indexes
// first create comparators for primary index
@@ -304,9 +325,10 @@
IBufferCache bufferCache = bufferCacheProvider.getBufferCache();
BTreeRegistry btreeRegistry = btreeRegistryProvider.getBTreeRegistry();
FileManager fileManager = bufferCacheProvider.getFileManager();
+ IFileMappingProvider fileMappingProvider = new FileMappingProvider();
// primary index
- int fileIdA = 3;
+ int fileIdA = fileMappingProvider.mapNameToFileId("/tmp/btreetestA.ix", true);
File fA = new File("/tmp/btreetestA.ix");
RandomAccessFile rafA = new RandomAccessFile(fA, "rw");
FileInfo fiA = new FileInfo(fileIdA, rafA);
@@ -317,7 +339,7 @@
btreeRegistry.register(fileIdA, btreeA);
// first secondary index
- int fileIdB = 4;
+ int fileIdB = fileMappingProvider.mapNameToFileId("/tmp/btreetestB.ix", true);
File fB = new File("/tmp/btreetestB.ix");
RandomAccessFile rafB = new RandomAccessFile(fB, "rw");
FileInfo fiB = new FileInfo(fileIdB, rafB);
@@ -328,7 +350,7 @@
btreeRegistry.register(fileIdB, btreeB);
// second secondary index
- int fileIdC = 5;
+ int fileIdC = fileMappingProvider.mapNameToFileId("/tmp/btreetestC.ix", true);
File fC = new File("/tmp/btreetestC.ix");
RandomAccessFile rafC = new RandomAccessFile(fC, "rw");
FileInfo fiC = new FileInfo(fileIdC, rafC);
@@ -337,25 +359,24 @@
btreeC.create(fileIdC, leafFrameFactory.getFrame(), new MetaDataFrame());
btreeC.open(fileIdC);
btreeRegistry.register(fileIdC, btreeC);
-
-
+
// create insert operators
// primary index
int[] fieldPermutationA = { 0,1,2,3,4,5 };
- BTreeInsertUpdateDeleteOperatorDescriptor insertOpA = new BTreeInsertUpdateDeleteOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, fileIdA, "/tmp/btreetestA.ix", interiorFrameFactory, leafFrameFactory, primaryFieldCount, primaryComparatorFactories, fieldPermutationA, BTreeOp.BTO_INSERT, true);
+ BTreeInsertUpdateDeleteOperatorDescriptor insertOpA = new BTreeInsertUpdateDeleteOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, "btreetestA.ix", fileMappingProvider, interiorFrameFactory, leafFrameFactory, primaryFieldCount, primaryComparatorFactories, fieldPermutationA, BTreeOp.BTO_INSERT);
PartitionConstraint insertPartitionConstraintA = new ExplicitPartitionConstraint(new LocationConstraint[] { new AbsoluteLocationConstraint(NC1_ID) });
insertOpA.setPartitionConstraint(insertPartitionConstraintA);
// first secondary index
int[] fieldPermutationB = { 3, 0 };
- BTreeInsertUpdateDeleteOperatorDescriptor insertOpB = new BTreeInsertUpdateDeleteOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, fileIdB, "/tmp/btreetestB.ix", interiorFrameFactory, leafFrameFactory, secondaryFieldCount, secondaryComparatorFactories, fieldPermutationB, BTreeOp.BTO_INSERT, true);
+ BTreeInsertUpdateDeleteOperatorDescriptor insertOpB = new BTreeInsertUpdateDeleteOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, "btreetestB.ix", fileMappingProvider, interiorFrameFactory, leafFrameFactory, secondaryFieldCount, secondaryComparatorFactories, fieldPermutationB, BTreeOp.BTO_INSERT);
PartitionConstraint insertPartitionConstraintB = new ExplicitPartitionConstraint(new LocationConstraint[] { new AbsoluteLocationConstraint(NC1_ID) });
insertOpB.setPartitionConstraint(insertPartitionConstraintB);
// second secondary index
int[] fieldPermutationC = { 4, 0 };
- BTreeInsertUpdateDeleteOperatorDescriptor insertOpC = new BTreeInsertUpdateDeleteOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, fileIdC, "/tmp/btreetestC.ix", interiorFrameFactory, leafFrameFactory, secondaryFieldCount, secondaryComparatorFactories, fieldPermutationC, BTreeOp.BTO_INSERT, true);
+ BTreeInsertUpdateDeleteOperatorDescriptor insertOpC = new BTreeInsertUpdateDeleteOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, "btreetestC.ix", fileMappingProvider, interiorFrameFactory, leafFrameFactory, secondaryFieldCount, secondaryComparatorFactories, fieldPermutationC, BTreeOp.BTO_INSERT);
PartitionConstraint insertPartitionConstraintC = new ExplicitPartitionConstraint(new LocationConstraint[] { new AbsoluteLocationConstraint(NC1_ID) });
insertOpC.setPartitionConstraint(insertPartitionConstraintC);
@@ -372,7 +393,7 @@
spec.connect(new OneToOneConnectorDescriptor(spec), insertOpC, 0, nullSink, 0);
spec.addRoot(nullSink);
- runTest(spec);
+ runTest(spec);
// scan primary index
System.out.println("PRINTING PRIMARY INDEX");
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/AbstractBTreeOperatorDescriptor.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/AbstractBTreeOperatorDescriptor.java
index a12c9ca..8200c82 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/AbstractBTreeOperatorDescriptor.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/AbstractBTreeOperatorDescriptor.java
@@ -22,14 +22,15 @@
import edu.uci.ics.hyracks.dataflow.std.file.IFileSplitProvider;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeInteriorFrameFactory;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeLeafFrameFactory;
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
public abstract class AbstractBTreeOperatorDescriptor extends AbstractSingleActivityOperatorDescriptor {
private static final long serialVersionUID = 1L;
protected String btreeFileName;
- protected int btreeFileId;
-
+ protected IFileMappingProvider fileMappingProvider;
+
protected int fieldCount;
protected IBinaryComparatorFactory[] comparatorFactories;
@@ -38,29 +39,26 @@
protected IBufferCacheProvider bufferCacheProvider;
protected IBTreeRegistryProvider btreeRegistryProvider;
-
- protected boolean isLocalCluster;
-
- public AbstractBTreeOperatorDescriptor(JobSpecification spec, int inputArity, int outputArity, IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc, IBufferCacheProvider bufferCacheProvider, IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId, String btreeFileName, IBTreeInteriorFrameFactory interiorFactory, IBTreeLeafFrameFactory leafFactory, int fieldCount, IBinaryComparatorFactory[] comparatorFactories, boolean isLocalCluster) {
+
+ public AbstractBTreeOperatorDescriptor(JobSpecification spec, int inputArity, int outputArity, IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc, IBufferCacheProvider bufferCacheProvider, IBTreeRegistryProvider btreeRegistryProvider, String btreeFileName, IFileMappingProvider fileMappingProvider, IBTreeInteriorFrameFactory interiorFactory, IBTreeLeafFrameFactory leafFactory, int fieldCount, IBinaryComparatorFactory[] comparatorFactories) {
super(spec, inputArity, outputArity);
- this.btreeFileId = btreeFileId;
this.btreeFileName = btreeFileName;
+ this.fileMappingProvider = fileMappingProvider;
this.bufferCacheProvider = bufferCacheProvider;
this.btreeRegistryProvider = btreeRegistryProvider;
this.interiorFrameFactory = interiorFactory;
this.leafFrameFactory = leafFactory;
this.fieldCount = fieldCount;
- this.comparatorFactories = comparatorFactories;
- this.isLocalCluster = isLocalCluster;
- if(outputArity > 0) recordDescriptors[0] = recDesc;
+ this.comparatorFactories = comparatorFactories;
+ if(outputArity > 0) recordDescriptors[0] = recDesc;
}
public String getBtreeFileName() {
return btreeFileName;
}
- public int getBtreeFileId() {
- return btreeFileId;
+ public IFileMappingProvider getFileMappingProvider() {
+ return fileMappingProvider;
}
public IBinaryComparatorFactory[] getComparatorFactories() {
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorDescriptor.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorDescriptor.java
index aa43d88..13ded9a 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorDescriptor.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorDescriptor.java
@@ -25,6 +25,7 @@
import edu.uci.ics.hyracks.dataflow.std.file.IFileSplitProvider;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeInteriorFrameFactory;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeLeafFrameFactory;
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
public class BTreeBulkLoadOperatorDescriptor extends AbstractBTreeOperatorDescriptor {
@@ -36,14 +37,14 @@
public BTreeBulkLoadOperatorDescriptor(JobSpecification spec,
IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc,
IBufferCacheProvider bufferCacheProvider,
- IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId,
- String btreeFileName, IBTreeInteriorFrameFactory interiorFactory,
+ IBTreeRegistryProvider btreeRegistryProvider,
+ String btreeFileName, IFileMappingProvider fileMappingProvider, IBTreeInteriorFrameFactory interiorFactory,
IBTreeLeafFrameFactory leafFactory, int fieldCount,
IBinaryComparatorFactory[] comparatorFactories,
- int[] fieldPermutation, float fillFactor, boolean isLocalCluster) {
+ int[] fieldPermutation, float fillFactor) {
super(spec, 1, 0, fileSplitProvider, recDesc, bufferCacheProvider,
- btreeRegistryProvider, btreeFileId, btreeFileName, interiorFactory,
- leafFactory, fieldCount, comparatorFactories, isLocalCluster);
+ btreeRegistryProvider, btreeFileName, fileMappingProvider, interiorFactory,
+ leafFactory, fieldCount, comparatorFactories);
this.fieldPermutation = fieldPermutation;
this.fillFactor = fillFactor;
}
@@ -53,6 +54,6 @@
IOperatorEnvironment env,
IRecordDescriptorProvider recordDescProvider, int partition,
int nPartitions) {
- return new BTreeBulkLoadOperatorNodePushable(this, ctx, fieldPermutation, fillFactor, recordDescProvider, isLocalCluster);
+ return new BTreeBulkLoadOperatorNodePushable(this, ctx, fieldPermutation, fillFactor, recordDescProvider);
}
}
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorNodePushable.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorNodePushable.java
index 7e0f737..1ca2be9 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorNodePushable.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorNodePushable.java
@@ -37,8 +37,8 @@
private PermutingFrameTupleReference tuple = new PermutingFrameTupleReference();
public BTreeBulkLoadOperatorNodePushable(AbstractBTreeOperatorDescriptor opDesc, IHyracksContext ctx,
- int[] fieldPermutation, float fillFactor, IRecordDescriptorProvider recordDescProvider, boolean isLocalCluster) {
- btreeOpHelper = new BTreeOpHelper(opDesc, ctx, true, isLocalCluster);
+ int[] fieldPermutation, float fillFactor, IRecordDescriptorProvider recordDescProvider) {
+ btreeOpHelper = new BTreeOpHelper(opDesc, ctx, true);
this.fillFactor = fillFactor;
this.recordDescProvider = recordDescProvider;
tuple.setFieldPermutation(fieldPermutation);
@@ -71,14 +71,13 @@
@Override
public void open() throws HyracksDataException {
AbstractBTreeOperatorDescriptor opDesc = btreeOpHelper.getOperatorDescriptor();
- RecordDescriptor recDesc = recordDescProvider.getInputRecordDescriptor(opDesc.getOperatorId(), 0);
+ RecordDescriptor recDesc = recordDescProvider.getInputRecordDescriptor(opDesc.getOperatorId(), 0);
accessor = new FrameTupleAccessor(btreeOpHelper.getHyracksContext(), recDesc);
IBTreeMetaDataFrame metaFrame = new MetaDataFrame();
try {
btreeOpHelper.init();
- btreeOpHelper.getBTree().open(opDesc.getBtreeFileId());
- bulkLoadCtx = btreeOpHelper.getBTree().beginBulkLoad(fillFactor, btreeOpHelper.getLeafFrame(),
- btreeOpHelper.getInteriorFrame(), metaFrame);
+ btreeOpHelper.getBTree().open(btreeOpHelper.getBTreeFileId());
+ bulkLoadCtx = btreeOpHelper.getBTree().beginBulkLoad(fillFactor, btreeOpHelper.getLeafFrame(), btreeOpHelper.getInteriorFrame(), metaFrame);
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorDescriptor.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorDescriptor.java
index 018625a..9d1247f 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorDescriptor.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorDescriptor.java
@@ -25,22 +25,22 @@
import edu.uci.ics.hyracks.dataflow.std.file.IFileSplitProvider;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeInteriorFrameFactory;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeLeafFrameFactory;
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
public class BTreeDiskOrderScanOperatorDescriptor extends AbstractBTreeOperatorDescriptor {
private static final long serialVersionUID = 1L;
- private boolean isLocalCluster;
public BTreeDiskOrderScanOperatorDescriptor(JobSpecification spec,
IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc,
IBufferCacheProvider bufferCacheProvider,
- IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId,
- String btreeFileName, IBTreeInteriorFrameFactory interiorFactory,
+ IBTreeRegistryProvider btreeRegistryProvider,
+ String btreeFileName, IFileMappingProvider fileMappingProvider, IBTreeInteriorFrameFactory interiorFactory,
IBTreeLeafFrameFactory leafFactory,
- int fieldCount, IBinaryComparatorFactory[] comparatorFactories, boolean isLocalCluster) {
+ int fieldCount, IBinaryComparatorFactory[] comparatorFactories) {
super(spec, 0, 1, fileSplitProvider, recDesc, bufferCacheProvider,
- btreeRegistryProvider, btreeFileId, btreeFileName, interiorFactory,
- leafFactory, fieldCount, comparatorFactories, isLocalCluster);
+ btreeRegistryProvider, btreeFileName, fileMappingProvider, interiorFactory,
+ leafFactory, fieldCount, comparatorFactories);
}
@Override
@@ -48,6 +48,6 @@
IOperatorEnvironment env,
IRecordDescriptorProvider recordDescProvider, int partition,
int nPartitions) {
- return new BTreeDiskOrderScanOperatorNodePushable(this, ctx, isLocalCluster);
+ return new BTreeDiskOrderScanOperatorNodePushable(this, ctx);
}
}
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorNodePushable.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorNodePushable.java
index c289171..13b27b6 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorNodePushable.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorNodePushable.java
@@ -34,8 +34,8 @@
public class BTreeDiskOrderScanOperatorNodePushable extends AbstractUnaryOutputSourceOperatorNodePushable {
private final BTreeOpHelper btreeOpHelper;
- public BTreeDiskOrderScanOperatorNodePushable(AbstractBTreeOperatorDescriptor opDesc, IHyracksContext ctx, boolean isLocalCluster) {
- btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false, isLocalCluster);
+ public BTreeDiskOrderScanOperatorNodePushable(AbstractBTreeOperatorDescriptor opDesc, IHyracksContext ctx) {
+ btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false);
}
@Override
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorDescriptor.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorDescriptor.java
index f8dd007..d597530 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorDescriptor.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorDescriptor.java
@@ -21,6 +21,7 @@
import edu.uci.ics.hyracks.api.job.IOperatorEnvironment;
import edu.uci.ics.hyracks.api.job.JobSpecification;
import edu.uci.ics.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescriptor;
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
public class BTreeDropOperatorDescriptor extends AbstractSingleActivityOperatorDescriptor {
@@ -29,19 +30,17 @@
private String btreeFileName;
private IBufferCacheProvider bufferCacheProvider;
private IBTreeRegistryProvider btreeRegistryProvider;
- private int btreeFileId;
- private boolean isLocalCluster;
+ private IFileMappingProvider fileMappingProvider;
public BTreeDropOperatorDescriptor(JobSpecification spec,
IBufferCacheProvider bufferCacheProvider,
- IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId,
- String btreeFileName, boolean isLocalCluster) {
+ IBTreeRegistryProvider btreeRegistryProvider,
+ String btreeFileName, IFileMappingProvider fileMappingProvider) {
super(spec, 0, 0);
this.btreeFileName = btreeFileName;
- this.btreeFileId = btreeFileId;
+ this.fileMappingProvider = fileMappingProvider;
this.bufferCacheProvider = bufferCacheProvider;
this.btreeRegistryProvider = btreeRegistryProvider;
- this.isLocalCluster = isLocalCluster;
}
@Override
@@ -49,6 +48,6 @@
IOperatorEnvironment env,
IRecordDescriptorProvider recordDescProvider, int partition,
int nPartitions) {
- return new BTreeDropOperatorNodePushable(bufferCacheProvider, btreeRegistryProvider, btreeFileId, btreeFileName, isLocalCluster);
+ return new BTreeDropOperatorNodePushable(bufferCacheProvider, btreeRegistryProvider, btreeFileName, fileMappingProvider);
}
}
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorNodePushable.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorNodePushable.java
index b83175e..d0b8c40 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorNodePushable.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorNodePushable.java
@@ -6,29 +6,27 @@
import edu.uci.ics.hyracks.api.dataflow.IOperatorNodePushable;
import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.file.FileManager;
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
public class BTreeDropOperatorNodePushable implements IOperatorNodePushable {
-
+
private String btreeFileName;
private IBTreeRegistryProvider btreeRegistryProvider;
private IBufferCacheProvider bufferCacheProvider;
- private int btreeFileId;
- private boolean isLocalCluster;
+ private IFileMappingProvider fileMappingProvider;
- public BTreeDropOperatorNodePushable(IBufferCacheProvider bufferCacheProvider, IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId, String btreeFileName, boolean isLocalCluster) {
+ public BTreeDropOperatorNodePushable(IBufferCacheProvider bufferCacheProvider, IBTreeRegistryProvider btreeRegistryProvider, String btreeFileName, IFileMappingProvider fileMappingProvider) {
this.btreeFileName = btreeFileName;
- this.btreeFileId = btreeFileId;
+ this.fileMappingProvider = fileMappingProvider;
this.bufferCacheProvider = bufferCacheProvider;
this.btreeRegistryProvider = btreeRegistryProvider;
- this.isLocalCluster = isLocalCluster;
}
@Override
public void deinitialize() throws HyracksDataException {
}
-
+
@Override
public int getInputArity() {
return 0;
@@ -43,9 +41,13 @@
public void initialize() throws HyracksDataException {
BTreeRegistry btreeRegistry = btreeRegistryProvider.getBTreeRegistry();
- FileManager fileManager = bufferCacheProvider.getFileManager();
- IBufferCache bufferCache = bufferCacheProvider.getBufferCache();
+ FileManager fileManager = bufferCacheProvider.getFileManager();
+ String ncDataPath = System.getProperty("NodeControllerDataPath");
+ String fileName = ncDataPath + btreeFileName;
+
+ int btreeFileId = fileMappingProvider.mapNameToFileId(fileName, false);
+
// unregister btree instance
btreeRegistry.lock();
try {
@@ -55,17 +57,8 @@
}
// unregister file
- fileManager.unregisterFile(btreeFileId);
-
-
- String fileName = btreeFileName;
- if(isLocalCluster) {
- String s = bufferCache.toString();
- String[] splits = s.split("\\.");
- String bufferCacheAddr = splits[splits.length-1].replaceAll("BufferCache@", "");
- fileName = fileName + bufferCacheAddr;
- }
-
+ fileManager.unregisterFile(btreeFileId);
+
File f = new File(fileName);
if (f.exists()) {
f.delete();
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorDescriptor.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorDescriptor.java
index 79ee493..9118b96 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorDescriptor.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorDescriptor.java
@@ -26,6 +26,7 @@
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeInteriorFrameFactory;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeLeafFrameFactory;
import edu.uci.ics.hyracks.storage.am.btree.impls.BTreeOp;
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
public class BTreeInsertUpdateDeleteOperatorDescriptor extends AbstractBTreeOperatorDescriptor {
@@ -35,19 +36,17 @@
private BTreeOp op;
- private boolean isLocalCluster;
-
public BTreeInsertUpdateDeleteOperatorDescriptor(JobSpecification spec,
IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc,
IBufferCacheProvider bufferCacheProvider,
- IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId,
- String btreeFileName, IBTreeInteriorFrameFactory interiorFactory,
+ IBTreeRegistryProvider btreeRegistryProvider,
+ String btreeFileName, IFileMappingProvider fileMappingProvider, IBTreeInteriorFrameFactory interiorFactory,
IBTreeLeafFrameFactory leafFactory, int fieldCount,
IBinaryComparatorFactory[] comparatorFactories,
- int[] fieldPermutation, BTreeOp op, boolean isLocalCluster) {
+ int[] fieldPermutation, BTreeOp op) {
super(spec, 1, 1, fileSplitProvider, recDesc, bufferCacheProvider,
- btreeRegistryProvider, btreeFileId, btreeFileName, interiorFactory,
- leafFactory, fieldCount, comparatorFactories, isLocalCluster);
+ btreeRegistryProvider, btreeFileName, fileMappingProvider, interiorFactory,
+ leafFactory, fieldCount, comparatorFactories);
this.fieldPermutation = fieldPermutation;
this.op = op;
}
@@ -57,6 +56,6 @@
IOperatorEnvironment env,
IRecordDescriptorProvider recordDescProvider, int partition,
int nPartitions) {
- return new BTreeInsertUpdateDeleteOperatorNodePushable(this, ctx, fieldPermutation, recordDescProvider, op, isLocalCluster);
+ return new BTreeInsertUpdateDeleteOperatorNodePushable(this, ctx, fieldPermutation, recordDescProvider, op);
}
}
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorNodePushable.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorNodePushable.java
index bf97f95..9516dda 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorNodePushable.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorNodePushable.java
@@ -44,8 +44,8 @@
private PermutingFrameTupleReference tuple = new PermutingFrameTupleReference();
public BTreeInsertUpdateDeleteOperatorNodePushable(AbstractBTreeOperatorDescriptor opDesc, IHyracksContext ctx,
- int[] fieldPermutation, IRecordDescriptorProvider recordDescProvider, BTreeOp op, boolean isLocalCluster) {
- btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false, isLocalCluster);
+ int[] fieldPermutation, IRecordDescriptorProvider recordDescProvider, BTreeOp op) {
+ btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false);
this.recordDescProvider = recordDescProvider;
this.op = op;
tuple.setFieldPermutation(fieldPermutation);
@@ -64,6 +64,8 @@
accessor.reset(buffer);
+ System.out.println("TUPLECOUNT: " + accessor.getTupleCount());
+
int tupleCount = accessor.getTupleCount();
for (int i = 0; i < tupleCount; i++) {
tuple.reset(accessor, i);
@@ -82,8 +84,7 @@
break;
default: {
- throw new HyracksDataException("Unsupported operation " + op
- + " in BTree InsertUpdateDelete operator");
+ throw new HyracksDataException("Unsupported operation " + op + " in BTree InsertUpdateDelete operator");
}
}
@@ -104,7 +105,7 @@
accessor = new FrameTupleAccessor(btreeOpHelper.getHyracksContext(), recDesc);
try {
btreeOpHelper.init();
- btreeOpHelper.getBTree().open(opDesc.getBtreeFileId());
+ btreeOpHelper.getBTree().open(btreeOpHelper.getBTreeFileId());
metaFrame = new MetaDataFrame();
} catch (Exception e) {
e.printStackTrace();
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java
index 79bc4f5..1db6bcd 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java
@@ -38,39 +38,36 @@
import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.file.FileInfo;
import edu.uci.ics.hyracks.storage.common.file.FileManager;
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
final class BTreeOpHelper {
private IBTreeInteriorFrame interiorFrame;
private IBTreeLeafFrame leafFrame;
private BTree btree;
-
+ private int btreeFileId = -1;
+
private AbstractBTreeOperatorDescriptor opDesc;
private IHyracksContext ctx;
private boolean createBTree;
-
- private boolean isLocalCluster;
- BTreeOpHelper(AbstractBTreeOperatorDescriptor opDesc, final IHyracksContext ctx, boolean createBTree, boolean isLocalCluster) {
+ BTreeOpHelper(AbstractBTreeOperatorDescriptor opDesc, final IHyracksContext ctx, boolean createBTree) {
this.opDesc = opDesc;
this.ctx = ctx;
this.createBTree = createBTree;
- this.isLocalCluster = isLocalCluster;
}
void init() throws Exception {
IBufferCache bufferCache = opDesc.getBufferCacheProvider().getBufferCache();
FileManager fileManager = opDesc.getBufferCacheProvider().getFileManager();
-
- String fileName = opDesc.getBtreeFileName();
- if(isLocalCluster) {
- String s = bufferCache.toString();
- String[] splits = s.split("\\.");
- String bufferCacheAddr = splits[splits.length-1].replaceAll("BufferCache@", "");
- fileName = fileName + bufferCacheAddr;
- }
+ IFileMappingProvider fileMappingProvider = opDesc.getFileMappingProvider();
+
+ String ncDataPath = System.getProperty("NodeControllerDataPath");
+ String fileName = ncDataPath + opDesc.getBtreeFileName();
+
+ btreeFileId = fileMappingProvider.mapNameToFileId(fileName, createBTree);
File f = new File(fileName);
RandomAccessFile raf = new RandomAccessFile(f, "rw");
@@ -80,7 +77,7 @@
}
try {
- FileInfo fi = new FileInfo(opDesc.getBtreeFileId(), raf);
+ FileInfo fi = new FileInfo(btreeFileId, raf);
fileManager.registerFile(fi);
} catch (Exception e) {
}
@@ -89,14 +86,14 @@
leafFrame = opDesc.getLeafFactory().getFrame();
BTreeRegistry btreeRegistry = opDesc.getBtreeRegistryProvider().getBTreeRegistry();
- btree = btreeRegistry.get(opDesc.getBtreeFileId());
+ btree = btreeRegistry.get(btreeFileId);
if (btree == null) {
// create new btree and register it
btreeRegistry.lock();
try {
// check if btree has already been registered by another thread
- btree = btreeRegistry.get(opDesc.getBtreeFileId());
+ btree = btreeRegistry.get(btreeFileId);
if (btree == null) {
// this thread should create and register the btee
@@ -110,10 +107,10 @@
btree = new BTree(bufferCache, opDesc.getInteriorFactory(), opDesc.getLeafFactory(), cmp);
if (createBTree) {
MetaDataFrame metaFrame = new MetaDataFrame();
- btree.create(opDesc.getBtreeFileId(), leafFrame, metaFrame);
+ btree.create(btreeFileId, leafFrame, metaFrame);
}
- btree.open(opDesc.getBtreeFileId());
- btreeRegistry.register(opDesc.getBtreeFileId(), btree);
+ btree.open(btreeFileId);
+ btreeRegistry.register(btreeFileId, btree);
}
} finally {
btreeRegistry.unlock();
@@ -126,7 +123,7 @@
// TODO: uncomment and fix
MetaDataFrame metaFrame = new MetaDataFrame();
- btree.create(opDesc.getBtreeFileId(), leafFrame, metaFrame);
+ btree.create(btreeFileId, leafFrame, metaFrame);
Random rnd = new Random();
rnd.setSeed(50);
@@ -230,4 +227,8 @@
public IBTreeInteriorFrame getInteriorFrame() {
return interiorFrame;
}
+
+ public int getBTreeFileId() {
+ return btreeFileId;
+ }
}
\ No newline at end of file
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
index 6dfd780..1e21510 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
@@ -25,6 +25,7 @@
import edu.uci.ics.hyracks.dataflow.std.file.IFileSplitProvider;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeInteriorFrameFactory;
import edu.uci.ics.hyracks.storage.am.btree.api.IBTreeLeafFrameFactory;
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
public class BTreeSearchOperatorDescriptor extends AbstractBTreeOperatorDescriptor {
@@ -34,8 +35,8 @@
private ITupleReferenceFactory[] searchKeys; // create tuples for low and high keys
private int searchKeyFieldCount;
- public BTreeSearchOperatorDescriptor(JobSpecification spec, IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc, IBufferCacheProvider bufferCacheProvider, IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId, String btreeFileName, IBTreeInteriorFrameFactory interiorFactory, IBTreeLeafFrameFactory leafFactory, int fieldCount, IBinaryComparatorFactory[] comparatorFactories, boolean isForward, ITupleReferenceFactory[] searchKeys, int searchKeyFields, boolean isLocalCluster) {
- super(spec, 0, 1, fileSplitProvider, recDesc, bufferCacheProvider, btreeRegistryProvider, btreeFileId, btreeFileName, interiorFactory, leafFactory, fieldCount, comparatorFactories, isLocalCluster);
+ public BTreeSearchOperatorDescriptor(JobSpecification spec, IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc, IBufferCacheProvider bufferCacheProvider, IBTreeRegistryProvider btreeRegistryProvider, String btreeFileName, IFileMappingProvider fileMappingProvider, IBTreeInteriorFrameFactory interiorFactory, IBTreeLeafFrameFactory leafFactory, int fieldCount, IBinaryComparatorFactory[] comparatorFactories, boolean isForward, ITupleReferenceFactory[] searchKeys, int searchKeyFields) {
+ super(spec, 0, 1, fileSplitProvider, recDesc, bufferCacheProvider, btreeRegistryProvider, btreeFileName, fileMappingProvider, interiorFactory, leafFactory, fieldCount, comparatorFactories);
this.isForward = isForward;
this.searchKeys = searchKeys;
this.searchKeyFieldCount = searchKeyFields;
@@ -44,6 +45,6 @@
@Override
public IOperatorNodePushable createPushRuntime(final IHyracksContext ctx, final IOperatorEnvironment env,
IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) {
- return new BTreeSearchOperatorNodePushable(this, ctx, isForward, searchKeys, searchKeyFieldCount, isLocalCluster);
+ return new BTreeSearchOperatorNodePushable(this, ctx, isForward, searchKeys, searchKeyFieldCount);
}
}
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorNodePushable.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorNodePushable.java
index ce1a63d..7268dc7 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorNodePushable.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorNodePushable.java
@@ -41,8 +41,8 @@
private int searchKeyFieldCount;
public BTreeSearchOperatorNodePushable(AbstractBTreeOperatorDescriptor opDesc, IHyracksContext ctx,
- boolean isForward, ITupleReferenceFactory[] searchKeys, int searchKeyFields, boolean isLocalCluster) {
- btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false, isLocalCluster);
+ boolean isForward, ITupleReferenceFactory[] searchKeys, int searchKeyFields) {
+ btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false);
this.isForward = isForward;
this.searchKeys = searchKeys;
this.searchKeyFieldCount = searchKeyFields;
@@ -61,7 +61,7 @@
btreeOpHelper.init();
//btreeOpHelper.fill();
btree = btreeOpHelper.getBTree();
-
+
IBTreeLeafFrame leafFrame = btreeOpHelper.getLeafFrame();
IBTreeInteriorFrame interiorFrame = btreeOpHelper.getInteriorFrame();
@@ -91,10 +91,10 @@
appender.reset(frame, true);
ArrayTupleBuilder tb = new ArrayTupleBuilder(cmp.getFieldCount());
DataOutput dos = tb.getDataOutput();
-
+
try {
while (cursor.hasNext()) {
- tb.reset();
+ tb.reset();
cursor.next();
ITupleReference frameTuple = cursor.getTuple();
@@ -123,6 +123,6 @@
} catch (Exception e) {
e.printStackTrace();
- }
+ }
}
}
\ No newline at end of file
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BufferCacheProvider.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BufferCacheProvider.java
index bc64d81..289d99a 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BufferCacheProvider.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BufferCacheProvider.java
@@ -33,6 +33,11 @@
private static final int PAGE_SIZE = 8192;
private static final int NUM_PAGES = 40;
+ public void reset() {
+ bufferCache = null;
+ fileManager = null;
+ }
+
@Override
public synchronized IBufferCache getBufferCache() {
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/FileMappingProvider.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/FileMappingProvider.java
new file mode 100644
index 0000000..0d1b9c1
--- /dev/null
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/FileMappingProvider.java
@@ -0,0 +1,31 @@
+package edu.uci.ics.hyracks.storage.am.btree.dataflow;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import edu.uci.ics.hyracks.storage.common.file.IFileMappingProvider;
+
+public class FileMappingProvider implements IFileMappingProvider {
+
+ private static final long serialVersionUID = 1L;
+ private int nextFileId = 0;
+ private Map<String, Integer> map = new Hashtable<String, Integer>();
+
+ @Override
+ public Integer mapNameToFileId(String name, boolean create) {
+ Integer val = map.get(name);
+ if(create) {
+ if(val == null) {
+ int ret = nextFileId;
+ map.put(name, nextFileId++);
+ return ret;
+ }
+ else {
+ return null; // create requested but value already exists
+ }
+ }
+ else {
+ return val; // just return value
+ }
+ }
+}