added drop btree operator and added isLocalCluster flag to btree operators to simplify testing
git-svn-id: https://hyracks.googlecode.com/svn/trunk/hyracks@123 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/btree/BTreeOperatorsTest.java b/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/btree/BTreeOperatorsTest.java
index 00fe7e7..b468204 100644
--- a/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/btree/BTreeOperatorsTest.java
+++ b/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/btree/BTreeOperatorsTest.java
@@ -124,7 +124,7 @@
int[] fieldPermutation = { 0, 4, 5 };
int btreeFileId = 0;
- BTreeBulkLoadOperatorDescriptor btreeBulkLoad = new BTreeBulkLoadOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, btreeFileId, "/tmp/btreetest.bin", interiorFrameFactory, leafFrameFactory, fieldCount, comparatorFactories, fieldPermutation, 0.7f);
+ BTreeBulkLoadOperatorDescriptor btreeBulkLoad = new BTreeBulkLoadOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, btreeFileId, "/tmp/btreetest.bin", interiorFrameFactory, leafFrameFactory, fieldCount, comparatorFactories, fieldPermutation, 0.7f, true);
PartitionConstraint btreePartitionConstraintA = new ExplicitPartitionConstraint(new LocationConstraint[] { new AbsoluteLocationConstraint(NC1_ID) });
btreeBulkLoad.setPartitionConstraint(btreePartitionConstraintA);
@@ -221,7 +221,7 @@
new ISerializerDeserializer[] { IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.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);
+ BTreeSearchOperatorDescriptor btreeSearchOp = new BTreeSearchOperatorDescriptor(spec, splitProvider, recDesc, bufferCacheProvider, btreeRegistryProvider, btreeFileId, "/tmp/btreetest.bin", interiorFrameFactory, leafFrameFactory, fieldCount, comparatorFactories, true, searchKeys, comparatorFactories.length, true);
//BTreeDiskOrderScanOperatorDescriptor btreeSearchOp = new BTreeDiskOrderScanOperatorDescriptor(spec, splitProvider, recDesc, bufferCacheProvider, btreeRegistryProvider, 0, "/tmp/btreetest.bin", interiorFrameFactory, leafFrameFactory, cmp);
PartitionConstraint btreePartitionConstraint = new ExplicitPartitionConstraint(new LocationConstraint[] { new AbsoluteLocationConstraint(NC1_ID) });
@@ -343,19 +343,19 @@
// 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);
+ BTreeInsertUpdateDeleteOperatorDescriptor insertOpA = new BTreeInsertUpdateDeleteOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, fileIdA, "/tmp/btreetestA.ix", interiorFrameFactory, leafFrameFactory, primaryFieldCount, primaryComparatorFactories, fieldPermutationA, BTreeOp.BTO_INSERT, true);
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);
+ BTreeInsertUpdateDeleteOperatorDescriptor insertOpB = new BTreeInsertUpdateDeleteOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, fileIdB, "/tmp/btreetestB.ix", interiorFrameFactory, leafFrameFactory, secondaryFieldCount, secondaryComparatorFactories, fieldPermutationB, BTreeOp.BTO_INSERT, true);
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);
+ BTreeInsertUpdateDeleteOperatorDescriptor insertOpC = new BTreeInsertUpdateDeleteOperatorDescriptor(spec, ordersSplitProvider, ordersDesc, bufferCacheProvider, btreeRegistryProvider, fileIdC, "/tmp/btreetestC.ix", interiorFrameFactory, leafFrameFactory, secondaryFieldCount, secondaryComparatorFactories, fieldPermutationC, BTreeOp.BTO_INSERT, true);
PartitionConstraint insertPartitionConstraintC = new ExplicitPartitionConstraint(new LocationConstraint[] { new AbsoluteLocationConstraint(NC1_ID) });
insertOpC.setPartitionConstraint(insertPartitionConstraintC);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/AbstractBTreeOperatorDescriptor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/AbstractBTreeOperatorDescriptor.java
index 54a86a4..a12c9ca 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/AbstractBTreeOperatorDescriptor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/AbstractBTreeOperatorDescriptor.java
@@ -39,7 +39,9 @@
protected IBufferCacheProvider bufferCacheProvider;
protected IBTreeRegistryProvider btreeRegistryProvider;
- 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) {
+ 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) {
super(spec, inputArity, outputArity);
this.btreeFileId = btreeFileId;
this.btreeFileName = btreeFileName;
@@ -48,7 +50,8 @@
this.interiorFrameFactory = interiorFactory;
this.leafFrameFactory = leafFactory;
this.fieldCount = fieldCount;
- this.comparatorFactories = comparatorFactories;
+ this.comparatorFactories = comparatorFactories;
+ this.isLocalCluster = isLocalCluster;
if(outputArity > 0) recordDescriptors[0] = recDesc;
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorDescriptor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorDescriptor.java
index 403da8f..aa43d88 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorDescriptor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorDescriptor.java
@@ -32,7 +32,7 @@
private int[] fieldPermutation;
private float fillFactor;
-
+
public BTreeBulkLoadOperatorDescriptor(JobSpecification spec,
IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc,
IBufferCacheProvider bufferCacheProvider,
@@ -40,10 +40,10 @@
String btreeFileName, IBTreeInteriorFrameFactory interiorFactory,
IBTreeLeafFrameFactory leafFactory, int fieldCount,
IBinaryComparatorFactory[] comparatorFactories,
- int[] fieldPermutation, float fillFactor) {
+ int[] fieldPermutation, float fillFactor, boolean isLocalCluster) {
super(spec, 1, 0, fileSplitProvider, recDesc, bufferCacheProvider,
btreeRegistryProvider, btreeFileId, btreeFileName, interiorFactory,
- leafFactory, fieldCount, comparatorFactories);
+ leafFactory, fieldCount, comparatorFactories, isLocalCluster);
this.fieldPermutation = fieldPermutation;
this.fillFactor = fillFactor;
}
@@ -53,6 +53,6 @@
IOperatorEnvironment env,
IRecordDescriptorProvider recordDescProvider, int partition,
int nPartitions) {
- return new BTreeBulkLoadOperatorNodePushable(this, ctx, fieldPermutation, fillFactor, recordDescProvider);
+ return new BTreeBulkLoadOperatorNodePushable(this, ctx, fieldPermutation, fillFactor, recordDescProvider, isLocalCluster);
}
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorNodePushable.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorNodePushable.java
index 39bf987..7e0f737 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeBulkLoadOperatorNodePushable.java
+++ b/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) {
- btreeOpHelper = new BTreeOpHelper(opDesc, ctx, true);
+ int[] fieldPermutation, float fillFactor, IRecordDescriptorProvider recordDescProvider, boolean isLocalCluster) {
+ btreeOpHelper = new BTreeOpHelper(opDesc, ctx, true, isLocalCluster);
this.fillFactor = fillFactor;
this.recordDescProvider = recordDescProvider;
tuple.setFieldPermutation(fieldPermutation);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorDescriptor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorDescriptor.java
index 28f5648..018625a 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorDescriptor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorDescriptor.java
@@ -29,6 +29,7 @@
public class BTreeDiskOrderScanOperatorDescriptor extends AbstractBTreeOperatorDescriptor {
private static final long serialVersionUID = 1L;
+ private boolean isLocalCluster;
public BTreeDiskOrderScanOperatorDescriptor(JobSpecification spec,
IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc,
@@ -36,10 +37,10 @@
IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId,
String btreeFileName, IBTreeInteriorFrameFactory interiorFactory,
IBTreeLeafFrameFactory leafFactory,
- int fieldCount, IBinaryComparatorFactory[] comparatorFactories) {
+ int fieldCount, IBinaryComparatorFactory[] comparatorFactories, boolean isLocalCluster) {
super(spec, 0, 1, fileSplitProvider, recDesc, bufferCacheProvider,
btreeRegistryProvider, btreeFileId, btreeFileName, interiorFactory,
- leafFactory, fieldCount, comparatorFactories);
+ leafFactory, fieldCount, comparatorFactories, isLocalCluster);
}
@Override
@@ -47,6 +48,6 @@
IOperatorEnvironment env,
IRecordDescriptorProvider recordDescProvider, int partition,
int nPartitions) {
- return new BTreeDiskOrderScanOperatorNodePushable(this, ctx);
+ return new BTreeDiskOrderScanOperatorNodePushable(this, ctx, isLocalCluster);
}
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorNodePushable.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorNodePushable.java
index 13b27b6..c289171 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDiskOrderScanOperatorNodePushable.java
+++ b/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) {
- btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false);
+ public BTreeDiskOrderScanOperatorNodePushable(AbstractBTreeOperatorDescriptor opDesc, IHyracksContext ctx, boolean isLocalCluster) {
+ btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false, isLocalCluster);
}
@Override
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorDescriptor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorDescriptor.java
new file mode 100644
index 0000000..f8dd007
--- /dev/null
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorDescriptor.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009-2010 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package edu.uci.ics.hyracks.storage.am.btree.dataflow;
+
+import edu.uci.ics.hyracks.api.context.IHyracksContext;
+import edu.uci.ics.hyracks.api.dataflow.IOperatorNodePushable;
+import edu.uci.ics.hyracks.api.dataflow.value.IRecordDescriptorProvider;
+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;
+
+public class BTreeDropOperatorDescriptor extends AbstractSingleActivityOperatorDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private String btreeFileName;
+ private IBufferCacheProvider bufferCacheProvider;
+ private IBTreeRegistryProvider btreeRegistryProvider;
+ private int btreeFileId;
+ private boolean isLocalCluster;
+
+ public BTreeDropOperatorDescriptor(JobSpecification spec,
+ IBufferCacheProvider bufferCacheProvider,
+ IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId,
+ String btreeFileName, boolean isLocalCluster) {
+ super(spec, 0, 0);
+ this.btreeFileName = btreeFileName;
+ this.btreeFileId = btreeFileId;
+ this.bufferCacheProvider = bufferCacheProvider;
+ this.btreeRegistryProvider = btreeRegistryProvider;
+ this.isLocalCluster = isLocalCluster;
+ }
+
+ @Override
+ public IOperatorNodePushable createPushRuntime(IHyracksContext ctx,
+ IOperatorEnvironment env,
+ IRecordDescriptorProvider recordDescProvider, int partition,
+ int nPartitions) {
+ return new BTreeDropOperatorNodePushable(bufferCacheProvider, btreeRegistryProvider, btreeFileId, btreeFileName, isLocalCluster);
+ }
+}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorNodePushable.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorNodePushable.java
new file mode 100644
index 0000000..b83175e
--- /dev/null
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeDropOperatorNodePushable.java
@@ -0,0 +1,78 @@
+package edu.uci.ics.hyracks.storage.am.btree.dataflow;
+
+import java.io.File;
+
+import edu.uci.ics.hyracks.api.comm.IFrameWriter;
+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;
+
+public class BTreeDropOperatorNodePushable implements IOperatorNodePushable {
+
+ private String btreeFileName;
+ private IBTreeRegistryProvider btreeRegistryProvider;
+ private IBufferCacheProvider bufferCacheProvider;
+ private int btreeFileId;
+ private boolean isLocalCluster;
+
+ public BTreeDropOperatorNodePushable(IBufferCacheProvider bufferCacheProvider, IBTreeRegistryProvider btreeRegistryProvider, int btreeFileId, String btreeFileName, boolean isLocalCluster) {
+ this.btreeFileName = btreeFileName;
+ this.btreeFileId = btreeFileId;
+ this.bufferCacheProvider = bufferCacheProvider;
+ this.btreeRegistryProvider = btreeRegistryProvider;
+ this.isLocalCluster = isLocalCluster;
+ }
+
+ @Override
+ public void deinitialize() throws HyracksDataException {
+ }
+
+ @Override
+ public int getInputArity() {
+ return 0;
+ }
+
+ @Override
+ public IFrameWriter getInputFrameWriter(int index) {
+ return null;
+ }
+
+ @Override
+ public void initialize() throws HyracksDataException {
+
+ BTreeRegistry btreeRegistry = btreeRegistryProvider.getBTreeRegistry();
+ FileManager fileManager = bufferCacheProvider.getFileManager();
+ IBufferCache bufferCache = bufferCacheProvider.getBufferCache();
+
+ // unregister btree instance
+ btreeRegistry.lock();
+ try {
+ btreeRegistry.unregister(btreeFileId);
+ } finally {
+ btreeRegistry.unlock();
+ }
+
+ // 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;
+ }
+
+ File f = new File(fileName);
+ if (f.exists()) {
+ f.delete();
+ }
+ }
+
+ @Override
+ public void setOutputFrameWriter(int index, IFrameWriter writer, RecordDescriptor recordDesc) {
+ }
+}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorDescriptor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorDescriptor.java
index 8352b2a..79ee493 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorDescriptor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorDescriptor.java
@@ -35,6 +35,8 @@
private BTreeOp op;
+ private boolean isLocalCluster;
+
public BTreeInsertUpdateDeleteOperatorDescriptor(JobSpecification spec,
IFileSplitProvider fileSplitProvider, RecordDescriptor recDesc,
IBufferCacheProvider bufferCacheProvider,
@@ -42,10 +44,10 @@
String btreeFileName, IBTreeInteriorFrameFactory interiorFactory,
IBTreeLeafFrameFactory leafFactory, int fieldCount,
IBinaryComparatorFactory[] comparatorFactories,
- int[] fieldPermutation, BTreeOp op) {
+ int[] fieldPermutation, BTreeOp op, boolean isLocalCluster) {
super(spec, 1, 1, fileSplitProvider, recDesc, bufferCacheProvider,
btreeRegistryProvider, btreeFileId, btreeFileName, interiorFactory,
- leafFactory, fieldCount, comparatorFactories);
+ leafFactory, fieldCount, comparatorFactories, isLocalCluster);
this.fieldPermutation = fieldPermutation;
this.op = op;
}
@@ -55,6 +57,6 @@
IOperatorEnvironment env,
IRecordDescriptorProvider recordDescProvider, int partition,
int nPartitions) {
- return new BTreeInsertUpdateDeleteOperatorNodePushable(this, ctx, fieldPermutation, recordDescProvider, op);
+ return new BTreeInsertUpdateDeleteOperatorNodePushable(this, ctx, fieldPermutation, recordDescProvider, op, isLocalCluster);
}
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorNodePushable.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorNodePushable.java
index ad35a93..bf97f95 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeInsertUpdateDeleteOperatorNodePushable.java
+++ b/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) {
- btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false);
+ int[] fieldPermutation, IRecordDescriptorProvider recordDescProvider, BTreeOp op, boolean isLocalCluster) {
+ btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false, isLocalCluster);
this.recordDescProvider = recordDescProvider;
this.op = op;
tuple.setFieldPermutation(fieldPermutation);
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java
index 08f9e1e..79bc4f5 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java
@@ -50,24 +50,29 @@
private boolean createBTree;
- BTreeOpHelper(AbstractBTreeOperatorDescriptor opDesc, final IHyracksContext ctx, boolean createBTree) {
+ private boolean isLocalCluster;
+
+ BTreeOpHelper(AbstractBTreeOperatorDescriptor opDesc, final IHyracksContext ctx, boolean createBTree, boolean isLocalCluster) {
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;
+ }
- // hack for testing
- //String s = bufferCache.toString();
- //String[] splits = s.split("\\.");
- //System.out.println(splits[splits.length-1]);
- //File f = new File("/tmp/" + splits[splits.length-1]);
-
- File f = new File(opDesc.getBtreeFileName());
+ File f = new File(fileName);
RandomAccessFile raf = new RandomAccessFile(f, "rw");
if (!f.exists() && !createBTree) {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeRegistry.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeRegistry.java
index 7f551d0..61491b1 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeRegistry.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeRegistry.java
@@ -44,7 +44,11 @@
}
public void unregister(int fileId) {
- map.remove(fileId);
+ try {
+ map.remove(fileId);
+ }
+ catch (Exception e) {
+ }
}
public int size() {
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
index 7f2f6d1..6dfd780 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
@@ -34,8 +34,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) {
- super(spec, 0, 1, fileSplitProvider, recDesc, bufferCacheProvider, btreeRegistryProvider, btreeFileId, btreeFileName, interiorFactory, leafFactory, fieldCount, comparatorFactories);
+ 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);
this.isForward = isForward;
this.searchKeys = searchKeys;
this.searchKeyFieldCount = searchKeyFields;
@@ -44,6 +44,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);
+ return new BTreeSearchOperatorNodePushable(this, ctx, isForward, searchKeys, searchKeyFieldCount, isLocalCluster);
}
}
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorNodePushable.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorNodePushable.java
index cdc6a73..ce1a63d 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorNodePushable.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorNodePushable.java
@@ -39,10 +39,10 @@
private boolean isForward;
private ITupleReferenceFactory[] searchKeys;
private int searchKeyFieldCount;
-
+
public BTreeSearchOperatorNodePushable(AbstractBTreeOperatorDescriptor opDesc, IHyracksContext ctx,
- boolean isForward, ITupleReferenceFactory[] searchKeys, int searchKeyFields) {
- btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false);
+ boolean isForward, ITupleReferenceFactory[] searchKeys, int searchKeyFields, boolean isLocalCluster) {
+ btreeOpHelper = new BTreeOpHelper(opDesc, ctx, false, isLocalCluster);
this.isForward = isForward;
this.searchKeys = searchKeys;
this.searchKeyFieldCount = searchKeyFields;