- Fixed Type Casting issue
- Reorganized duplicated internal class in the DelimitedDataParser and DelimitedDataParserFactory
- Prevented a user from creating an inverted index on a dataset with a variable-length PK
Change-Id: Ic5606501223b8d860b49a258ff49afacd7d76b9a
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/191
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <westmann@gmail.com>
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java
index ac45ac3..3abdec9 100644
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java
+++ b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java
@@ -3,9 +3,9 @@
* 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.
@@ -253,7 +253,8 @@
}
@Override
- public int compare(IFrameTupleAccessor accessor0, int tIndex0, IFrameTupleAccessor accessor1, int tIndex1) {
+ public int compare(IFrameTupleAccessor accessor0, int tIndex0, IFrameTupleAccessor accessor1, int tIndex1)
+ throws HyracksDataException {
int tStart0 = accessor0.getTupleStartOffset(tIndex0);
int fStartOffset0 = accessor0.getFieldSlotsLength() + tStart0;
diff --git a/algebricks/algebricks-data/src/main/java/edu/uci/ics/hyracks/algebricks/data/IBinaryIntegerInspector.java b/algebricks/algebricks-data/src/main/java/edu/uci/ics/hyracks/algebricks/data/IBinaryIntegerInspector.java
index 31f82ed..3707912 100644
--- a/algebricks/algebricks-data/src/main/java/edu/uci/ics/hyracks/algebricks/data/IBinaryIntegerInspector.java
+++ b/algebricks/algebricks-data/src/main/java/edu/uci/ics/hyracks/algebricks/data/IBinaryIntegerInspector.java
@@ -3,9 +3,9 @@
* 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.
@@ -14,6 +14,8 @@
*/
package edu.uci.ics.hyracks.algebricks.data;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
public interface IBinaryIntegerInspector {
- public int getIntegerValue(byte[] bytes, int offset, int length);
+ public int getIntegerValue(byte[] bytes, int offset, int length) throws HyracksDataException;
}
diff --git a/algebricks/algebricks-runtime/src/main/java/edu/uci/ics/hyracks/algebricks/runtime/base/IUnnestingPositionWriter.java b/algebricks/algebricks-runtime/src/main/java/edu/uci/ics/hyracks/algebricks/runtime/base/IUnnestingPositionWriter.java
index b8d549a..65f5083 100644
--- a/algebricks/algebricks-runtime/src/main/java/edu/uci/ics/hyracks/algebricks/runtime/base/IUnnestingPositionWriter.java
+++ b/algebricks/algebricks-runtime/src/main/java/edu/uci/ics/hyracks/algebricks/runtime/base/IUnnestingPositionWriter.java
@@ -3,9 +3,9 @@
* 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.
@@ -18,5 +18,5 @@
import java.io.IOException;
public interface IUnnestingPositionWriter {
- public void write(DataOutput dataOutput, int position) throws IOException;
+ public void write(DataOutput dataOutput, long position) throws IOException;
}
\ No newline at end of file
diff --git a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/BinaryComparatorConstant.java b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/BinaryComparatorConstant.java
new file mode 100644
index 0000000..998ecd4
--- /dev/null
+++ b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/BinaryComparatorConstant.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2009-2013 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.api.dataflow.value;
+
+public final class BinaryComparatorConstant {
+
+ // Result code for isComparable()
+ // TRUE: can be comparable
+ // FALSE: can not be comparable
+ // UNKNOWN: can not be decided whether two arguments are comparable or not - usually NULL
+
+ public static enum ComparableResultCode {
+ TRUE,
+ FALSE,
+ UNKNOWN
+ }
+
+}
\ No newline at end of file
diff --git a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/IBinaryComparator.java b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/IBinaryComparator.java
index 8e63fff..e6d8312 100644
--- a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/IBinaryComparator.java
+++ b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/IBinaryComparator.java
@@ -3,9 +3,9 @@
* 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.
@@ -14,6 +14,8 @@
*/
package edu.uci.ics.hyracks.api.dataflow.value;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
public interface IBinaryComparator {
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2);
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException;
}
\ No newline at end of file
diff --git a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/IBinaryHashFunction.java b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/IBinaryHashFunction.java
index 744e948..377cfe9 100644
--- a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/IBinaryHashFunction.java
+++ b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/dataflow/value/IBinaryHashFunction.java
@@ -3,9 +3,9 @@
* 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.
@@ -14,6 +14,8 @@
*/
package edu.uci.ics.hyracks.api.dataflow.value;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
public interface IBinaryHashFunction {
- int hash(byte[] bytes, int offset, int length);
+ int hash(byte[] bytes, int offset, int length) throws HyracksDataException;
}
\ No newline at end of file
diff --git a/hyracks/hyracks-data/hyracks-data-std/src/main/java/edu/uci/ics/hyracks/data/std/accessors/MurmurHash3BinaryHash.java b/hyracks/hyracks-data/hyracks-data-std/src/main/java/edu/uci/ics/hyracks/data/std/accessors/MurmurHash3BinaryHash.java
new file mode 100644
index 0000000..9763445
--- /dev/null
+++ b/hyracks/hyracks-data/hyracks-data-std/src/main/java/edu/uci/ics/hyracks/data/std/accessors/MurmurHash3BinaryHash.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2009-2013 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.data.std.accessors;
+
+/**
+ * An implementation of the Murmur3 hash family. The code is implemented based
+ * on the original <a
+ * href=http://code.google.com/p/guava-libraries/source/browse
+ * /guava/src/com/google/common/hash/Murmur3_32HashFunction.java>guava
+ * implementation</a> from Google Guava library.
+ */
+public class MurmurHash3BinaryHash {
+
+ private MurmurHash3BinaryHash() {
+ }
+
+ private static final int C1 = 0xcc9e2d51;
+ private static final int C2 = 0x1b873593;
+ private static final int C3 = 5;
+ private static final int C4 = 0xe6546b64;
+ private static final int C5 = 0x85ebca6b;
+ private static final int C6 = 0xc2b2ae35;
+
+ public static int hash(byte[] bytes, int offset, int length, int seed) {
+ int h = seed;
+ int p = offset;
+ int remain = length;
+
+ while (remain >= 4) {
+ int k = (bytes[p] & 0xff) | ((bytes[p + 1] & 0xff) << 8) | ((bytes[p + 2] & 0xff) << 16)
+ | ((bytes[p + 3] & 0xff) << 24);
+ k *= C1;
+ k = Integer.rotateLeft(k, 15);
+ k *= C2;
+ h ^= k;
+ h = Integer.rotateLeft(h, 13);
+ h = h * C3 + C4;
+ p += 4;
+ remain -= 4;
+ }
+ if (remain > 0) {
+ int k = 0;
+ for (int i = 0; remain > 0; i += 8) {
+ k ^= (bytes[p++] & 0xff) << i;
+ remain--;
+ }
+ k *= C1;
+ k = Integer.rotateLeft(k, 15);
+ k *= C2;
+ h ^= k;
+ }
+ h ^= length;
+ h ^= (h >>> 16);
+ h *= C5;
+ h ^= (h >>> 13);
+ h *= C6;
+ h ^= (h >>> 16);
+ return h;
+ }
+}
\ No newline at end of file
diff --git a/hyracks/hyracks-data/hyracks-data-std/src/main/java/edu/uci/ics/hyracks/data/std/accessors/MurmurHash3BinaryHashFunctionFamily.java b/hyracks/hyracks-data/hyracks-data-std/src/main/java/edu/uci/ics/hyracks/data/std/accessors/MurmurHash3BinaryHashFunctionFamily.java
index 8512287..c1c72b5 100644
--- a/hyracks/hyracks-data/hyracks-data-std/src/main/java/edu/uci/ics/hyracks/data/std/accessors/MurmurHash3BinaryHashFunctionFamily.java
+++ b/hyracks/hyracks-data/hyracks-data-std/src/main/java/edu/uci/ics/hyracks/data/std/accessors/MurmurHash3BinaryHashFunctionFamily.java
@@ -3,9 +3,9 @@
* 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.
@@ -24,8 +24,7 @@
* /guava/src/com/google/common/hash/Murmur3_32HashFunction.java>guava
* implementation</a> from Google Guava library.
*/
-public class MurmurHash3BinaryHashFunctionFamily implements
- IBinaryHashFunctionFamily {
+public class MurmurHash3BinaryHashFunctionFamily implements IBinaryHashFunctionFamily {
public static final IBinaryHashFunctionFamily INSTANCE = new MurmurHash3BinaryHashFunctionFamily();
@@ -34,51 +33,12 @@
private MurmurHash3BinaryHashFunctionFamily() {
}
- private static final int C1 = 0xcc9e2d51;
- private static final int C2 = 0x1b873593;
- private static final int C3 = 5;
- private static final int C4 = 0xe6546b64;
- private static final int C5 = 0x85ebca6b;
- private static final int C6 = 0xc2b2ae35;
-
@Override
public IBinaryHashFunction createBinaryHashFunction(final int seed) {
return new IBinaryHashFunction() {
@Override
public int hash(byte[] bytes, int offset, int length) {
- int h = seed;
- int p = offset;
- int remain = length;
- while (remain >= 4) {
- int k = (bytes[p] & 0xff) | ((bytes[p + 1] & 0xff) << 8)
- | ((bytes[p + 2] & 0xff) << 16)
- | ((bytes[p + 3] & 0xff) << 24);
- k *= C1;
- k = Integer.rotateLeft(k, 15);
- k *= C2;
- h ^= k;
- h = Integer.rotateLeft(h, 13);
- h = h * C3 + C4;
- p += 4;
- remain -= 4;
- }
- if (remain > 0) {
- int k = 0;
- for (int i = 0; remain > 0; i += 8) {
- k ^= (bytes[p++] & 0xff) << i;
- remain--;
- }
- k *= C1;
- k = Integer.rotateLeft(k, 15);
- k *= C2;
- h ^= k;
- }
- h ^= length;
- h ^= (h >>> 16);
- h *= C5;
- h ^= (h >>> 13);
- h *= C6;
- h ^= (h >>> 16);
+ int h = MurmurHash3BinaryHash.hash(bytes, offset, length, seed);
return h;
}
};
diff --git a/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTuplePairComparator.java b/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTuplePairComparator.java
index e89fd09..15039ca 100644
--- a/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTuplePairComparator.java
+++ b/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTuplePairComparator.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.dataflow.common.comm.io;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
public class FrameTuplePairComparator {
private final int[] keys0;
@@ -27,7 +28,8 @@
this.comparators = comparators;
}
- public int compare(FrameTupleAccessor accessor0, int tIndex0, FrameTupleAccessor accessor1, int tIndex1) {
+ public int compare(FrameTupleAccessor accessor0, int tIndex0, FrameTupleAccessor accessor1, int tIndex1)
+ throws HyracksDataException {
int tStart0 = accessor0.getTupleStartOffset(tIndex0);
int fStartOffset0 = accessor0.getFieldSlotsLength() + tStart0;
diff --git a/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/partition/FieldHashPartitionComputerFactory.java b/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/partition/FieldHashPartitionComputerFactory.java
index a1084fe..ef010f9 100644
--- a/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/partition/FieldHashPartitionComputerFactory.java
+++ b/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/partition/FieldHashPartitionComputerFactory.java
@@ -3,9 +3,9 @@
* 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.
@@ -19,6 +19,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
import edu.uci.ics.hyracks.api.dataflow.value.ITuplePartitionComputer;
import edu.uci.ics.hyracks.api.dataflow.value.ITuplePartitionComputerFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
public class FieldHashPartitionComputerFactory implements ITuplePartitionComputerFactory {
private static final long serialVersionUID = 1L;
@@ -38,7 +39,7 @@
}
return new ITuplePartitionComputer() {
@Override
- public int partition(IFrameTupleAccessor accessor, int tIndex, int nParts) {
+ public int partition(IFrameTupleAccessor accessor, int tIndex, int nParts) throws HyracksDataException {
if (nParts == 1) {
return 0;
}
diff --git a/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/partition/FieldHashPartitionComputerFamily.java b/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/partition/FieldHashPartitionComputerFamily.java
index 590184c..a224f56 100644
--- a/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/partition/FieldHashPartitionComputerFamily.java
+++ b/hyracks/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/partition/FieldHashPartitionComputerFamily.java
@@ -3,9 +3,9 @@
* 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.
@@ -19,6 +19,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFamily;
import edu.uci.ics.hyracks.api.dataflow.value.ITuplePartitionComputer;
import edu.uci.ics.hyracks.api.dataflow.value.ITuplePartitionComputerFamily;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
public class FieldHashPartitionComputerFamily implements ITuplePartitionComputerFamily {
private static final long serialVersionUID = 1L;
@@ -38,7 +39,7 @@
}
return new ITuplePartitionComputer() {
@Override
- public int partition(IFrameTupleAccessor accessor, int tIndex, int nParts) {
+ public int partition(IFrameTupleAccessor accessor, int tIndex, int nParts) throws HyracksDataException {
int h = 0;
int startOffset = accessor.getTupleStartOffset(tIndex);
int slotLength = accessor.getFieldSlotsLength();
@@ -52,7 +53,7 @@
h += fh;
}
if (h < 0) {
- h = -(h+1);
+ h = -(h + 1);
}
return h % nParts;
}
diff --git a/hyracks/hyracks-dataflow-hadoop/src/main/java/edu/uci/ics/hyracks/dataflow/hadoop/mapreduce/ReduceWriter.java b/hyracks/hyracks-dataflow-hadoop/src/main/java/edu/uci/ics/hyracks/dataflow/hadoop/mapreduce/ReduceWriter.java
index af1b731..8877df4 100644
--- a/hyracks/hyracks-dataflow-hadoop/src/main/java/edu/uci/ics/hyracks/dataflow/hadoop/mapreduce/ReduceWriter.java
+++ b/hyracks/hyracks-dataflow-hadoop/src/main/java/edu/uci/ics/hyracks/dataflow/hadoop/mapreduce/ReduceWriter.java
@@ -3,9 +3,9 @@
* 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.
@@ -146,10 +146,10 @@
private void reduce() throws HyracksDataException {
kvi.reset(group, bPtr + 1);
try {
- Reducer<K2, V2, K3, V3>.Context rCtx = new MRContextUtil().createReduceContext(helper.getConfiguration(), taId, kvi,
- keyCounter, valueCounter, recordWriter, null, null,
- (RawComparator<K2>) helper.getRawGroupingComparator(), (Class<K2>) helper.getJob()
- .getMapOutputKeyClass(), (Class<V2>) helper.getJob().getMapOutputValueClass());
+ Reducer<K2, V2, K3, V3>.Context rCtx = new MRContextUtil().createReduceContext(helper.getConfiguration(),
+ taId, kvi, keyCounter, valueCounter, recordWriter, null, null, (RawComparator<K2>) helper
+ .getRawGroupingComparator(), (Class<K2>) helper.getJob().getMapOutputKeyClass(),
+ (Class<V2>) helper.getJob().getMapOutputValueClass());
reducer.run(rCtx);
} catch (Exception e) {
throw new HyracksDataException(e);
@@ -157,7 +157,8 @@
groupStarted = false;
}
- private boolean sameGroup(FrameTupleAccessor a1, int t1Idx, FrameTupleAccessor a2, int t2Idx) {
+ private boolean sameGroup(FrameTupleAccessor a1, int t1Idx, FrameTupleAccessor a2, int t2Idx)
+ throws HyracksDataException {
for (int i = 0; i < comparators.length; ++i) {
int fIdx = groupFields[i];
int s1 = a1.getTupleStartOffset(t1Idx) + a1.getFieldSlotsLength() + a1.getFieldStartOffset(t1Idx, fIdx);
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/file/DelimitedDataTupleParserFactory.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/file/DelimitedDataTupleParserFactory.java
index dd1343d..6fd38d2 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/file/DelimitedDataTupleParserFactory.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/file/DelimitedDataTupleParserFactory.java
@@ -37,14 +37,10 @@
private char fieldDelimiter;
private char quote;
- private boolean isDoubleQuoteIncludedInThisField;
- private int doubleQuoteCount;
-
- private int lineCount;
private int fieldCount;
public DelimitedDataTupleParserFactory(IValueParserFactory[] fieldParserFactories, char fieldDelimiter) {
- this(fieldParserFactories,fieldDelimiter, '\"');
+ this(fieldParserFactories, fieldDelimiter, '\"');
}
public DelimitedDataTupleParserFactory(IValueParserFactory[] fieldParserFactories, char fieldDelimiter, char quote) {
@@ -52,7 +48,6 @@
this.fieldDelimiter = fieldDelimiter;
this.quote = quote;
this.fieldCount = 0;
- this.lineCount = 1;
}
@Override
@@ -71,18 +66,19 @@
ArrayTupleBuilder tb = new ArrayTupleBuilder(valueParsers.length);
DataOutput dos = tb.getDataOutput();
- FieldCursor cursor = new FieldCursor(new InputStreamReader(in));
+ FieldCursorForDelimitedDataParser cursor = new FieldCursorForDelimitedDataParser(
+ new InputStreamReader(in), fieldDelimiter, quote);
while (cursor.nextRecord()) {
tb.reset();
for (int i = 0; i < valueParsers.length; ++i) {
- if (!cursor.nextField()) {
+ if (!cursor.nextField(fieldCount)) {
break;
}
- // Eliminate doule quotes in the field that we are going to parse
- if (isDoubleQuoteIncludedInThisField) {
- eliminateDoulbleQuote(cursor.buffer, cursor.fStart, cursor.fEnd - cursor.fStart);
- cursor.fEnd -= doubleQuoteCount;
- isDoubleQuoteIncludedInThisField = false;
+ // Eliminate double quotes in the field that we are going to parse
+ if (cursor.isDoubleQuoteIncludedInThisField) {
+ cursor.eliminateDoubleQuote(cursor.buffer, cursor.fStart, cursor.fEnd - cursor.fStart);
+ cursor.fEnd -= cursor.doubleQuoteCount;
+ cursor.isDoubleQuoteIncludedInThisField = false;
}
valueParsers[i].parse(cursor.buffer, cursor.fStart, cursor.fEnd - cursor.fStart, dos);
tb.addFieldEndOffset();
@@ -108,336 +104,4 @@
};
}
- private enum State {
- INIT,
- IN_RECORD,
- EOR,
- CR,
- EOF
- }
-
- protected class FieldCursor {
- private static final int INITIAL_BUFFER_SIZE = 4096;
- private static final int INCREMENT = 4096;
-
- private final Reader in;
-
- private char[] buffer;
- private int start;
- private int end;
- private State state;
-
- private int fStart;
- private int fEnd;
-
- private int lastQuotePosition;
- private int lastDoubleQuotePosition;
- private int lastDelimiterPosition;
- private int quoteCount;
- private boolean startedQuote;
-
- public FieldCursor(Reader in) {
- this.in = in;
- buffer = new char[INITIAL_BUFFER_SIZE];
- start = 0;
- end = 0;
- state = State.INIT;
- lastDelimiterPosition = -99;
- lastQuotePosition = -99;
- lastDoubleQuotePosition = -99;
- quoteCount = 0;
- startedQuote = false;
- }
-
- public boolean nextRecord() throws IOException {
- while (true) {
- switch (state) {
- case INIT:
- boolean eof = !readMore();
- if (eof) {
- state = State.EOF;
- return false;
- } else {
- state = State.IN_RECORD;
- return true;
- }
-
- case IN_RECORD:
- int p = start;
- while (true) {
- if (p >= end) {
- int s = start;
- eof = !readMore();
- if (eof) {
- state = State.EOF;
- return start < end;
- }
- p -= (s - start);
- lastQuotePosition -= (s - start);
- lastDoubleQuotePosition -= (s - start);
- lastDelimiterPosition -= (s - start);
- }
- char ch = buffer[p];
- // We perform rough format correctness (delimiter, quote) check here
- // to set the starting position of a record.
- // In the field level, more checking will be conducted.
- if (ch == quote) {
- startedQuote = true;
- // check two quotes in a row - "". This is an escaped quote
- if (lastQuotePosition == p - 1 && start != p - 1 && lastDoubleQuotePosition != p - 1) {
- lastDoubleQuotePosition = p;
- }
- lastQuotePosition = p;
- } else if (ch == fieldDelimiter) {
- if (startedQuote && lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1) {
- startedQuote = false;
- lastDelimiterPosition = p;
- }
- } else if (ch == '\n' && !startedQuote) {
- start = p + 1;
- state = State.EOR;
- lastDelimiterPosition = p;
- break;
- } else if (ch == '\r' && !startedQuote) {
- start = p + 1;
- state = State.CR;
- break;
- }
- ++p;
- }
- break;
-
- case CR:
- if (start >= end) {
- eof = !readMore();
- if (eof) {
- state = State.EOF;
- return false;
- }
- }
- char ch = buffer[start];
- if (ch == '\n' && !startedQuote) {
- ++start;
- state = State.EOR;
- } else {
- state = State.IN_RECORD;
- return true;
- }
-
- case EOR:
- if (start >= end) {
- eof = !readMore();
- if (eof) {
- state = State.EOF;
- return false;
- }
- }
- state = State.IN_RECORD;
- lastDelimiterPosition = start;
- return start < end;
-
- case EOF:
- return false;
- }
- }
- }
-
- public boolean nextField() throws IOException {
- switch (state) {
- case INIT:
- case EOR:
- case EOF:
- case CR:
- return false;
-
- case IN_RECORD:
- boolean eof;
- // reset quote related values
- startedQuote = false;
- isDoubleQuoteIncludedInThisField = false;
- lastQuotePosition = -99;
- lastDoubleQuotePosition = -99;
- quoteCount = 0;
- doubleQuoteCount = 0;
-
- int p = start;
- while (true) {
- if (p >= end) {
- int s = start;
- eof = !readMore();
- p -= (s - start);
- lastQuotePosition -= (s - start);
- lastDoubleQuotePosition -= (s - start);
- lastDelimiterPosition -= (s - start);
- if (eof) {
- state = State.EOF;
- if (startedQuote && lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1
- && quoteCount == doubleQuoteCount * 2 + 2) {
- // set the position of fStart to +1, fEnd to -1 to remove quote character
- fStart = start + 1;
- fEnd = p - 1;
- } else {
- fStart = start;
- fEnd = p;
- }
- return true;
- }
- }
- char ch = buffer[p];
- if (ch == quote) {
- // If this is first quote in the field, then it needs to be placed in the beginning.
- if (!startedQuote) {
- if (lastDelimiterPosition == p - 1 || lastDelimiterPosition == -99) {
- startedQuote = true;
- } else {
- // In this case, we don't have a quote in the beginning of a field.
- throw new IOException(
- "At line: "
- + lineCount
- + ", field#: "
- + (fieldCount+1)
- + " - a quote enclosing a field needs to be placed in the beginning of that field.");
- }
- }
- // Check double quotes - "". We check [start != p-2]
- // to avoid false positive where there is no value in a field,
- // since it looks like a double quote. However, it's not a double quote.
- // (e.g. if field2 has no value:
- // field1,"",field3 ... )
- if (lastQuotePosition == p - 1 && lastDelimiterPosition != p - 2
- && lastDoubleQuotePosition != p - 1) {
- isDoubleQuoteIncludedInThisField = true;
- doubleQuoteCount++;
- lastDoubleQuotePosition = p;
- }
- lastQuotePosition = p;
- quoteCount++;
- } else if (ch == fieldDelimiter) {
- // If there was no quote in the field,
- // then we assume that the field contains a valid string.
- if (!startedQuote) {
- fStart = start;
- fEnd = p;
- start = p + 1;
- lastDelimiterPosition = p;
- return true;
- } else if (startedQuote) {
- if (lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1) {
- // There is a quote right before the delimiter (e.g. ",) and it is not two quote,
- // then the field contains a valid string.
- // We set the position of fStart to +1, fEnd to -1 to remove quote character
- fStart = start + 1;
- fEnd = p - 1;
- start = p + 1;
- lastDelimiterPosition = p;
- return true;
- } else if (lastQuotePosition < p - 1 && lastQuotePosition != lastDoubleQuotePosition
- && quoteCount == doubleQuoteCount * 2 + 2) {
- // There is a quote before the delimiter, however it is not directly placed before the delimiter.
- // In this case, we throw an exception.
- // quoteCount == doubleQuoteCount * 2 + 2 : only true when we have two quotes except double-quotes.
- throw new IOException("At line: " + lineCount + ", field#: " + (fieldCount+1)
- + " - A quote enclosing a field needs to be followed by the delimiter.");
- }
- }
- // If the control flow reaches here: we have a delimiter in this field and
- // there should be a quote in the beginning and the end of
- // this field. So, just continue reading next character
- } else if (ch == '\n') {
- if (!startedQuote) {
- fStart = start;
- fEnd = p;
- start = p + 1;
- state = State.EOR;
- lineCount++;
- lastDelimiterPosition = p;
- return true;
- } else if (startedQuote && lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1
- && quoteCount == doubleQuoteCount * 2 + 2) {
- // set the position of fStart to +1, fEnd to -1 to remove quote character
- fStart = start + 1;
- fEnd = p - 1;
- lastDelimiterPosition = p;
- start = p + 1;
- state = State.EOR;
- lineCount++;
- return true;
- }
- } else if (ch == '\r') {
- if (!startedQuote) {
- fStart = start;
- fEnd = p;
- start = p + 1;
- state = State.CR;
- lastDelimiterPosition = p;
- return true;
- } else if (startedQuote && lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1
- && quoteCount == doubleQuoteCount * 2 + 2) {
- // set the position of fStart to +1, fEnd to -1 to remove quote character
- fStart = start + 1;
- fEnd = p - 1;
- lastDelimiterPosition = p;
- start = p + 1;
- state = State.CR;
- return true;
- }
- }
- ++p;
- }
- }
- throw new IllegalStateException();
- }
-
- protected void resetQuoteRelatedValue() {
- startedQuote = false;
- isDoubleQuoteIncludedInThisField = false;
- lastQuotePosition = -99;
- lastDoubleQuotePosition = -99;
- quoteCount = 0;
- doubleQuoteCount = 0;
- }
-
- protected boolean readMore() throws IOException {
- if (start > 0) {
- System.arraycopy(buffer, start, buffer, 0, end - start);
- }
- end -= start;
- start = 0;
-
- if (end == buffer.length) {
- buffer = Arrays.copyOf(buffer, buffer.length + INCREMENT);
- }
-
- int n = in.read(buffer, end, buffer.length - end);
- if (n < 0) {
- return false;
- }
- end += n;
- return true;
- }
-
- }
-
- // Eliminate escaped double quotes("") in a field
- protected void eliminateDoulbleQuote(char[] buffer, int start, int length) {
- int lastDoubleQuotePosition = -99;
- int writepos = start;
- int readpos = start;
- // Find positions where double quotes appear
- for (int i = 0; i < length; i++) {
- // Skip double quotes
- if (buffer[readpos] == quote && lastDoubleQuotePosition != readpos - 1) {
- lastDoubleQuotePosition = readpos;
- readpos++;
- } else {
- // Moving characters except double quote to the front
- if (writepos != readpos) {
- buffer[writepos] = buffer[readpos];
- }
- writepos++;
- readpos++;
- }
- }
- }
}
-
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/file/FieldCursorForDelimitedDataParser.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/file/FieldCursorForDelimitedDataParser.java
new file mode 100644
index 0000000..c6fd654
--- /dev/null
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/file/FieldCursorForDelimitedDataParser.java
@@ -0,0 +1,357 @@
+/*
+ * Copyright 2009-2013 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.dataflow.std.file;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Arrays;
+
+public class FieldCursorForDelimitedDataParser {
+
+ private enum State {
+ INIT,
+ IN_RECORD,
+ EOR,
+ CR,
+ EOF
+ }
+
+ // public variables will be used by delimited data parser
+ public char[] buffer;
+ public int fStart;
+ public int fEnd;
+ public int lineCount;
+ public int doubleQuoteCount;
+ public boolean isDoubleQuoteIncludedInThisField;
+
+ private static final int INITIAL_BUFFER_SIZE = 4096;
+ private static final int INCREMENT = 4096;
+
+ private final Reader in;
+
+ private int start;
+ private int end;
+ private State state;
+
+ private int lastQuotePosition;
+ private int lastDoubleQuotePosition;
+ private int lastDelimiterPosition;
+ private int quoteCount;
+ private boolean startedQuote;
+
+ private char quote;
+ private char fieldDelimiter;
+
+ public FieldCursorForDelimitedDataParser(Reader in, char fieldDelimiter, char quote) {
+ this.in = in;
+ buffer = new char[INITIAL_BUFFER_SIZE];
+ start = 0;
+ end = 0;
+ state = State.INIT;
+ this.quote = quote;
+ this.fieldDelimiter = fieldDelimiter;
+ lastDelimiterPosition = -99;
+ lastQuotePosition = -99;
+ lastDoubleQuotePosition = -99;
+ quoteCount = 0;
+ doubleQuoteCount = 0;
+ startedQuote = false;
+ isDoubleQuoteIncludedInThisField = false;
+ lineCount = 1;
+ }
+
+ public boolean nextRecord() throws IOException {
+ while (true) {
+ switch (state) {
+ case INIT:
+ boolean eof = !readMore();
+ if (eof) {
+ state = State.EOF;
+ return false;
+ } else {
+ state = State.IN_RECORD;
+ return true;
+ }
+
+ case IN_RECORD:
+ int p = start;
+ while (true) {
+ if (p >= end) {
+ int s = start;
+ eof = !readMore();
+ if (eof) {
+ state = State.EOF;
+ return start < end;
+ }
+ p -= (s - start);
+ lastQuotePosition -= (s - start);
+ lastDoubleQuotePosition -= (s - start);
+ lastDelimiterPosition -= (s - start);
+ }
+ char ch = buffer[p];
+ // We perform rough format correctness (delimiter, quote) check here
+ // to set the starting position of a record.
+ // In the field level, more checking will be conducted.
+ if (ch == quote) {
+ startedQuote = true;
+ // check two quotes in a row - "". This is an escaped quote
+ if (lastQuotePosition == p - 1 && start != p - 1 && lastDoubleQuotePosition != p - 1) {
+ lastDoubleQuotePosition = p;
+ }
+ lastQuotePosition = p;
+ } else if (ch == fieldDelimiter) {
+ if (startedQuote && lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1) {
+ startedQuote = false;
+ lastDelimiterPosition = p;
+ }
+ } else if (ch == '\n' && !startedQuote) {
+ start = p + 1;
+ state = State.EOR;
+ lastDelimiterPosition = p;
+ break;
+ } else if (ch == '\r' && !startedQuote) {
+ start = p + 1;
+ state = State.CR;
+ break;
+ }
+ ++p;
+ }
+ break;
+
+ case CR:
+ if (start >= end) {
+ eof = !readMore();
+ if (eof) {
+ state = State.EOF;
+ return false;
+ }
+ }
+ char ch = buffer[start];
+ if (ch == '\n' && !startedQuote) {
+ ++start;
+ state = State.EOR;
+ } else {
+ state = State.IN_RECORD;
+ return true;
+ }
+
+ case EOR:
+ if (start >= end) {
+ eof = !readMore();
+ if (eof) {
+ state = State.EOF;
+ return false;
+ }
+ }
+ state = State.IN_RECORD;
+ lastDelimiterPosition = start;
+ return start < end;
+
+ case EOF:
+ return false;
+ }
+ }
+ }
+
+ public boolean nextField(int fieldCount) throws IOException {
+ switch (state) {
+ case INIT:
+ case EOR:
+ case EOF:
+ case CR:
+ return false;
+
+ case IN_RECORD:
+ boolean eof;
+ // reset quote related values
+ startedQuote = false;
+ isDoubleQuoteIncludedInThisField = false;
+ lastQuotePosition = -99;
+ lastDoubleQuotePosition = -99;
+ quoteCount = 0;
+ doubleQuoteCount = 0;
+
+ int p = start;
+ while (true) {
+ if (p >= end) {
+ int s = start;
+ eof = !readMore();
+ p -= (s - start);
+ lastQuotePosition -= (s - start);
+ lastDoubleQuotePosition -= (s - start);
+ lastDelimiterPosition -= (s - start);
+ if (eof) {
+ state = State.EOF;
+ if (startedQuote && lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1
+ && quoteCount == doubleQuoteCount * 2 + 2) {
+ // set the position of fStart to +1, fEnd to -1 to remove quote character
+ fStart = start + 1;
+ fEnd = p - 1;
+ } else {
+ fStart = start;
+ fEnd = p;
+ }
+ return true;
+ }
+ }
+ char ch = buffer[p];
+ if (ch == quote) {
+ // If this is first quote in the field, then it needs to be placed in the beginning.
+ if (!startedQuote) {
+ if (lastDelimiterPosition == p - 1 || lastDelimiterPosition == -99) {
+ startedQuote = true;
+ } else {
+ // In this case, we don't have a quote in the beginning of a field.
+ throw new IOException(
+ "At line: "
+ + lineCount
+ + ", field#: "
+ + (fieldCount + 1)
+ + " - a quote enclosing a field needs to be placed in the beginning of that field.");
+ }
+ }
+ // Check double quotes - "". We check [start != p-2]
+ // to avoid false positive where there is no value in a field,
+ // since it looks like a double quote. However, it's not a double quote.
+ // (e.g. if field2 has no value:
+ // field1,"",field3 ... )
+ if (lastQuotePosition == p - 1 && lastDelimiterPosition != p - 2
+ && lastDoubleQuotePosition != p - 1) {
+ isDoubleQuoteIncludedInThisField = true;
+ doubleQuoteCount++;
+ lastDoubleQuotePosition = p;
+ }
+ lastQuotePosition = p;
+ quoteCount++;
+ } else if (ch == fieldDelimiter) {
+ // If there was no quote in the field,
+ // then we assume that the field contains a valid string.
+ if (!startedQuote) {
+ fStart = start;
+ fEnd = p;
+ start = p + 1;
+ lastDelimiterPosition = p;
+ return true;
+ } else if (startedQuote) {
+ if (lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1) {
+ // There is a quote right before the delimiter (e.g. ",) and it is not two quote,
+ // then the field contains a valid string.
+ // We set the position of fStart to +1, fEnd to -1 to remove quote character
+ fStart = start + 1;
+ fEnd = p - 1;
+ start = p + 1;
+ lastDelimiterPosition = p;
+ startedQuote = false;
+ return true;
+ } else if (lastQuotePosition < p - 1 && lastQuotePosition != lastDoubleQuotePosition
+ && quoteCount == doubleQuoteCount * 2 + 2) {
+ // There is a quote before the delimiter, however it is not directly placed before the delimiter.
+ // In this case, we throw an exception.
+ // quoteCount == doubleQuoteCount * 2 + 2 : only true when we have two quotes except double-quotes.
+ throw new IOException("At line: " + lineCount + ", field#: " + (fieldCount + 1)
+ + " - A quote enclosing a field needs to be followed by the delimiter.");
+ }
+ }
+ // If the control flow reaches here: we have a delimiter in this field and
+ // there should be a quote in the beginning and the end of
+ // this field. So, just continue reading next character
+ } else if (ch == '\n') {
+ if (!startedQuote) {
+ fStart = start;
+ fEnd = p;
+ start = p + 1;
+ state = State.EOR;
+ lineCount++;
+ lastDelimiterPosition = p;
+ return true;
+ } else if (startedQuote && lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1
+ && quoteCount == doubleQuoteCount * 2 + 2) {
+ // set the position of fStart to +1, fEnd to -1 to remove quote character
+ fStart = start + 1;
+ fEnd = p - 1;
+ lastDelimiterPosition = p;
+ start = p + 1;
+ state = State.EOR;
+ lineCount++;
+ startedQuote = false;
+ return true;
+ }
+ } else if (ch == '\r') {
+ if (!startedQuote) {
+ fStart = start;
+ fEnd = p;
+ start = p + 1;
+ state = State.CR;
+ lastDelimiterPosition = p;
+ return true;
+ } else if (startedQuote && lastQuotePosition == p - 1 && lastDoubleQuotePosition != p - 1
+ && quoteCount == doubleQuoteCount * 2 + 2) {
+ // set the position of fStart to +1, fEnd to -1 to remove quote character
+ fStart = start + 1;
+ fEnd = p - 1;
+ lastDelimiterPosition = p;
+ start = p + 1;
+ state = State.CR;
+ startedQuote = false;
+ return true;
+ }
+ }
+ ++p;
+ }
+ }
+ throw new IllegalStateException();
+ }
+
+ protected boolean readMore() throws IOException {
+ if (start > 0) {
+ System.arraycopy(buffer, start, buffer, 0, end - start);
+ }
+ end -= start;
+ start = 0;
+
+ if (end == buffer.length) {
+ buffer = Arrays.copyOf(buffer, buffer.length + INCREMENT);
+ }
+
+ int n = in.read(buffer, end, buffer.length - end);
+ if (n < 0) {
+ return false;
+ }
+ end += n;
+ return true;
+ }
+
+ // Eliminate escaped double quotes("") in a field
+ public void eliminateDoubleQuote(char[] buffer, int start, int length) {
+ int lastDoubleQuotePosition = -99;
+ int writepos = start;
+ int readpos = start;
+ // Find positions where double quotes appear
+ for (int i = 0; i < length; i++) {
+ // Skip double quotes
+ if (buffer[readpos] == quote && lastDoubleQuotePosition != readpos - 1) {
+ lastDoubleQuotePosition = readpos;
+ readpos++;
+ } else {
+ // Moving characters except double quote to the front
+ if (writepos != readpos) {
+ buffer[writepos] = buffer[readpos];
+ }
+ writepos++;
+ readpos++;
+ }
+ }
+ }
+}
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/HashSpillableTableFactory.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/HashSpillableTableFactory.java
index df74a93..a4970ea 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/HashSpillableTableFactory.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/HashSpillableTableFactory.java
@@ -3,9 +3,9 @@
* 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.
@@ -51,7 +51,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see
* edu.uci.ics.hyracks.dataflow.std.aggregations.ISpillableTableFactory#
* buildSpillableTable(edu.uci.ics.hyracks.api.context.IHyracksTaskContext,
@@ -135,7 +135,7 @@
private int[] tPointers;
@Override
- public void sortFrames() {
+ public void sortFrames() throws HyracksDataException {
int sfIdx = storedKeys[0];
int totalTCount = table.getTupleCount();
tPointers = new int[totalTCount * 3];
@@ -361,7 +361,7 @@
* list. There are two cases:<br>
* 1) If the next frame is not initialized, allocate a new frame. 2)
* When frames are already created, they are recycled.
- *
+ *
* @return Whether a new frame is added successfully.
* @throws HyracksDataException
*/
@@ -389,7 +389,7 @@
return true;
}
- private void sort(int[] tPointers, int offset, int length) {
+ private void sort(int[] tPointers, int offset, int length) throws HyracksDataException {
int m = offset + (length >> 1);
int mTable = tPointers[m * 3];
int mRow = tPointers[m * 3 + 1];
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/ISpillableTable.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/ISpillableTable.java
index 65f71a3..6ac2a6d 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/ISpillableTable.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/ISpillableTable.java
@@ -3,9 +3,9 @@
* 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.
@@ -31,7 +31,7 @@
public List<ByteBuffer> getFrames();
- public void sortFrames();
+ public void sortFrames() throws HyracksDataException;
public boolean insert(FrameTupleAccessor accessor, int tIndex) throws HyracksDataException;
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/external/ExternalGroupMergeOperatorNodePushable.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/external/ExternalGroupMergeOperatorNodePushable.java
index fdb59a4..a55443c 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/external/ExternalGroupMergeOperatorNodePushable.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/external/ExternalGroupMergeOperatorNodePushable.java
@@ -3,9 +3,9 @@
* 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.
@@ -397,7 +397,7 @@
/**
* Close the run file, and also the corresponding readers and
* input frame.
- *
+ *
* @param index
* @param runCursors
* @param tupleAccessor
@@ -415,7 +415,8 @@
}
}
- private int compareFrameTuples(IFrameTupleAccessor fta1, int j1, IFrameTupleAccessor fta2, int j2) {
+ private int compareFrameTuples(IFrameTupleAccessor fta1, int j1, IFrameTupleAccessor fta2, int j2)
+ throws HyracksDataException {
byte[] b1 = fta1.getBuffer().array();
byte[] b2 = fta2.getBuffer().array();
for (int f = 0; f < keyFields.length; ++f) {
@@ -434,7 +435,8 @@
return 0;
}
- private Comparator<ReferenceEntry> createEntryComparator(final IBinaryComparator[] comparators) {
+ private Comparator<ReferenceEntry> createEntryComparator(final IBinaryComparator[] comparators)
+ throws HyracksDataException {
return new Comparator<ReferenceEntry>() {
@Override
@@ -453,10 +455,16 @@
int s2 = fta2.getTupleStartOffset(j2) + fta2.getFieldSlotsLength()
+ fta2.getFieldStartOffset(j2, fIdx);
int l2 = fta2.getFieldEndOffset(j2, fIdx) - fta2.getFieldStartOffset(j2, fIdx);
- int c = comparators[f].compare(b1, s1, l1, b2, s2, l2);
- if (c != 0) {
- return c;
+ int c;
+ try {
+ c = comparators[f].compare(b1, s1, l1, b2, s2, l2);
+ if (c != 0) {
+ return c;
+ }
+ } catch (HyracksDataException e) {
+ throw new IllegalArgumentException(e);
}
+
}
return 0;
}
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/preclustered/PreclusteredGroupWriter.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/preclustered/PreclusteredGroupWriter.java
index b67e236..45f0488 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/preclustered/PreclusteredGroupWriter.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/group/preclustered/PreclusteredGroupWriter.java
@@ -3,9 +3,9 @@
* 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.
@@ -141,7 +141,8 @@
}
- private boolean sameGroup(FrameTupleAccessor a1, int t1Idx, FrameTupleAccessor a2, int t2Idx) {
+ private boolean sameGroup(FrameTupleAccessor a1, int t1Idx, FrameTupleAccessor a2, int t2Idx)
+ throws HyracksDataException {
for (int i = 0; i < comparators.length; ++i) {
int fIdx = groupFields[i];
int s1 = a1.getTupleStartOffset(t1Idx) + a1.getFieldSlotsLength() + a1.getFieldStartOffset(t1Idx, fIdx);
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/join/JoinComparator.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/join/JoinComparator.java
index 3256d2e..e393d49 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/join/JoinComparator.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/join/JoinComparator.java
@@ -3,9 +3,9 @@
* 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.
@@ -17,39 +17,41 @@
import edu.uci.ics.hyracks.api.comm.IFrameTupleAccessor;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
import edu.uci.ics.hyracks.api.dataflow.value.ITuplePairComparator;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
class JoinComparator implements ITuplePairComparator {
- private final IBinaryComparator bComparator;
- private final int field0;
- private final int field1;
+ private final IBinaryComparator bComparator;
+ private final int field0;
+ private final int field1;
- public JoinComparator(IBinaryComparator bComparator, int field0, int field1) {
- this.bComparator = bComparator;
- this.field0 = field0;
- this.field1 = field1;
- }
+ public JoinComparator(IBinaryComparator bComparator, int field0, int field1) {
+ this.bComparator = bComparator;
+ this.field0 = field0;
+ this.field1 = field1;
+ }
- @Override
- public int compare(IFrameTupleAccessor accessor0, int tIndex0, IFrameTupleAccessor accessor1, int tIndex1) {
- int tStart0 = accessor0.getTupleStartOffset(tIndex0);
- int fStartOffset0 = accessor0.getFieldSlotsLength() + tStart0;
+ @Override
+ public int compare(IFrameTupleAccessor accessor0, int tIndex0, IFrameTupleAccessor accessor1, int tIndex1)
+ throws HyracksDataException {
+ int tStart0 = accessor0.getTupleStartOffset(tIndex0);
+ int fStartOffset0 = accessor0.getFieldSlotsLength() + tStart0;
- int tStart1 = accessor1.getTupleStartOffset(tIndex1);
- int fStartOffset1 = accessor1.getFieldSlotsLength() + tStart1;
+ int tStart1 = accessor1.getTupleStartOffset(tIndex1);
+ int fStartOffset1 = accessor1.getFieldSlotsLength() + tStart1;
- int fStart0 = accessor0.getFieldStartOffset(tIndex0, field0);
- int fEnd0 = accessor0.getFieldEndOffset(tIndex0, field0);
- int fLen0 = fEnd0 - fStart0;
+ int fStart0 = accessor0.getFieldStartOffset(tIndex0, field0);
+ int fEnd0 = accessor0.getFieldEndOffset(tIndex0, field0);
+ int fLen0 = fEnd0 - fStart0;
- int fStart1 = accessor1.getFieldStartOffset(tIndex1, field1);
- int fEnd1 = accessor1.getFieldEndOffset(tIndex1, field1);
- int fLen1 = fEnd1 - fStart1;
+ int fStart1 = accessor1.getFieldStartOffset(tIndex1, field1);
+ int fEnd1 = accessor1.getFieldEndOffset(tIndex1, field1);
+ int fLen1 = fEnd1 - fStart1;
- int c = bComparator.compare(accessor0.getBuffer().array(), fStart0 + fStartOffset0, fLen0, accessor1
- .getBuffer().array(), fStart1 + fStartOffset1, fLen1);
- if (c != 0) {
- return c;
- }
- return 0;
- }
+ int c = bComparator.compare(accessor0.getBuffer().array(), fStart0 + fStartOffset0, fLen0, accessor1
+ .getBuffer().array(), fStart1 + fStartOffset1, fLen1);
+ if (c != 0) {
+ return c;
+ }
+ return 0;
+ }
}
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/FrameSorterMergeSort.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/FrameSorterMergeSort.java
index cc0f1ef..8dbdbd4 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/FrameSorterMergeSort.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/FrameSorterMergeSort.java
@@ -3,9 +3,9 @@
* 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.
@@ -94,7 +94,7 @@
}
@Override
- public void sortFrames() {
+ public void sortFrames() throws HyracksDataException {
int nBuffers = dataFrameCount;
tupleCount = 0;
for (int i = 0; i < nBuffers; ++i) {
@@ -150,7 +150,7 @@
}
}
- private void sort(int offset, int length) {
+ private void sort(int offset, int length) throws HyracksDataException {
int step = 1;
int len = length;
int end = offset + len;
@@ -173,8 +173,12 @@
}
}
- /** Merge two subarrays into one */
- private void merge(int start1, int start2, int len1, int len2) {
+ /**
+ * Merge two subarrays into one
+ *
+ * @throws HyracksDataException
+ */
+ private void merge(int start1, int start2, int len1, int len2) throws HyracksDataException {
int targetPos = start1;
int pos1 = start1;
int pos2 = start2;
@@ -208,7 +212,7 @@
tPointersTemp[dest * 4 + 3] = tPointers[src * 4 + 3];
}
- private int compare(int tp1, int tp2) {
+ private int compare(int tp1, int tp2) throws HyracksDataException {
int i1 = tPointers[tp1 * 4];
int j1 = tPointers[tp1 * 4 + 1];
int v1 = tPointers[tp1 * 4 + 3];
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/FrameSorterQuickSort.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/FrameSorterQuickSort.java
index 083f4a7..d607a51 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/FrameSorterQuickSort.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/FrameSorterQuickSort.java
@@ -3,9 +3,9 @@
* 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.
@@ -92,7 +92,7 @@
}
@Override
- public void sortFrames() {
+ public void sortFrames() throws HyracksDataException {
int nBuffers = dataFrameCount;
tupleCount = 0;
for (int i = 0; i < nBuffers; ++i) {
@@ -147,7 +147,7 @@
}
}
- private void sort(int[] tPointers, int offset, int length) {
+ private void sort(int[] tPointers, int offset, int length) throws HyracksDataException {
int m = offset + (length >> 1);
int mi = tPointers[m * 4];
int mj = tPointers[m * 4 + 1];
@@ -212,7 +212,7 @@
}
}
- private int compare(int[] tPointers, int tp1, int tp2i, int tp2j, int tp2v) {
+ private int compare(int[] tPointers, int tp1, int tp2i, int tp2j, int tp2v) throws HyracksDataException {
int i1 = tPointers[tp1 * 4];
int j1 = tPointers[tp1 * 4 + 1];
int v1 = tPointers[tp1 * 4 + 3];
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/IFrameSorter.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/IFrameSorter.java
index 6778852..d9b8d37 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/IFrameSorter.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/IFrameSorter.java
@@ -3,9 +3,9 @@
* 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.
@@ -28,7 +28,7 @@
public void insertFrame(ByteBuffer buffer) throws HyracksDataException;
- public void sortFrames();
+ public void sortFrames() throws HyracksDataException;
public void flushFrames(IFrameWriter writer) throws HyracksDataException;
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/ISelectionTree.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/ISelectionTree.java
index 54dc4b9..8cff0df 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/ISelectionTree.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/ISelectionTree.java
@@ -3,9 +3,9 @@
* 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.
@@ -14,6 +14,8 @@
*/
package edu.uci.ics.hyracks.dataflow.std.sort;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
/**
* @author pouria
* Defines the selection tree, used in sorting with replacement
@@ -27,30 +29,33 @@
/**
* Inserts a new element into the selectionTree
- *
+ *
* @param element
* contains the pointer to the memory slot, containing the tuple,
* along with its run number
+ * @throws HyracksDataException
*/
- void insert(int[] element);
+ void insert(int[] element) throws HyracksDataException;
/**
* Removes and returns the smallest element in the tree
- *
+ *
* @param result
* is the array that will eventually contain minimum entry
* pointer
+ * @throws HyracksDataException
*/
- void getMin(int[] result);
+ void getMin(int[] result) throws HyracksDataException;
/**
* Removes and returns the largest element in the tree
- *
+ *
* @param result
* is the array that will eventually contain maximum entry
* pointer
+ * @throws HyracksDataException
*/
- void getMax(int[] result);
+ void getMax(int[] result) throws HyracksDataException;
/**
* @return True of the selection tree does not have any element, false
@@ -65,7 +70,7 @@
/**
* Returns (and does NOT remove) the smallest element in the tree
- *
+ *
* @param result
* is the array that will eventually contain minimum entry
* pointer
@@ -74,11 +79,12 @@
/**
* Returns (and does NOT remove) the largest element in the tree
- *
+ *
* @param result
* is the array that will eventually contain maximum entry
* pointer
+ * @throws HyracksDataException
*/
- void peekMax(int[] result);
+ void peekMax(int[] result) throws HyracksDataException;
}
\ No newline at end of file
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/OptimizedExternalSortRunGenerator.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/OptimizedExternalSortRunGenerator.java
index ab237a3..d78af12 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/OptimizedExternalSortRunGenerator.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/OptimizedExternalSortRunGenerator.java
@@ -3,9 +3,9 @@
* 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.
@@ -211,19 +211,8 @@
}
- private int getPNK(FrameTupleAccessor fta, int tIx, byte[] buffInArray) { // Moved
- // buffInArray
- // out
- // for
- // better
- // performance
- // (not
- // converting
- // for
- // each
- // and
- // every
- // tuple)
+ private int getPNK(FrameTupleAccessor fta, int tIx, byte[] buffInArray) {
+ // Moved buffInArray out for better performance (not converting for each and every tuple)
int sfIdx = sortFields[0];
int tStart = fta.getTupleStartOffset(tIx);
int f0StartRel = fta.getFieldStartOffset(tIx, sfIdx);
@@ -232,15 +221,8 @@
return (nkc == null ? 0 : nkc.normalize(buffInArray, f0Start, f0EndRel - f0StartRel));
}
- private int getRunId(FrameTupleAccessor fta, int tupIx) { // Comparing
- // current
- // record to
- // last output
- // record, it
- // decides about
- // current
- // record's
- // runId
+ private int getRunId(FrameTupleAccessor fta, int tupIx) throws HyracksDataException {
+ // Comparing current record to last output record, it decides about current record's runId
if (newRun) { // Very first record for a new run
return curRunId;
}
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/OptimizedExternalSortRunGeneratorWithLimit.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/OptimizedExternalSortRunGeneratorWithLimit.java
index cb629bc..5b01fb8 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/OptimizedExternalSortRunGeneratorWithLimit.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/OptimizedExternalSortRunGeneratorWithLimit.java
@@ -3,9 +3,9 @@
* 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.
@@ -331,19 +331,8 @@
}
}
- private int getPNK(FrameTupleAccessor fta, int tIx, byte[] buffInArray) { // Moved
- // buffInArray
- // out
- // for
- // better
- // performance
- // (not
- // converting
- // for
- // each
- // and
- // every
- // tuple)
+ private int getPNK(FrameTupleAccessor fta, int tIx, byte[] buffInArray) {
+ // Moved buffInArray out for better performance (not converting for each and every tuple)
int sfIdx = sortFields[0];
int tStart = fta.getTupleStartOffset(tIx);
int f0StartRel = fta.getFieldStartOffset(tIx, sfIdx);
@@ -352,15 +341,8 @@
return (nkc == null ? 0 : nkc.normalize(buffInArray, f0Start, f0EndRel - f0StartRel));
}
- private int getRunId(FrameTupleAccessor fta, int tupIx) { // Comparing
- // current
- // record to
- // last output
- // record, it
- // decides about
- // current
- // record's
- // runId
+ private int getRunId(FrameTupleAccessor fta, int tupIx) throws HyracksDataException {
+ // Comparing current record to last output record, it decides about current record's runId
if (newRun) { // Very first record for a new run
return curRunId;
}
@@ -396,7 +378,7 @@
}
// first<sec : -1
- private int compareRecords(FrameTupleAccessor fta1, int ix1, int fix2, int offset2) {
+ private int compareRecords(FrameTupleAccessor fta1, int ix1, int fix2, int offset2) throws HyracksDataException {
ByteBuffer buff1 = fta1.getBuffer();
byte[] recBuff1 = buff1.array();
int offset1 = fta1.getTupleStartOffset(ix1);
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/RunMergingFrameReader.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/RunMergingFrameReader.java
index 24c8cb9..cf0d0ad 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/RunMergingFrameReader.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/RunMergingFrameReader.java
@@ -3,9 +3,9 @@
* 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.
@@ -161,11 +161,17 @@
int[] tPointers2 = tp2.getTPointers();
for (int f = 0; f < sortFields.length; ++f) {
- int c = comparators[f].compare(b1, tPointers1[2 * f + 1], tPointers1[2 * f + 2], b2,
- tPointers2[2 * f + 1], tPointers2[2 * f + 2]);
- if (c != 0) {
- return c;
+ int c;
+ try {
+ c = comparators[f].compare(b1, tPointers1[2 * f + 1], tPointers1[2 * f + 2], b2,
+ tPointers2[2 * f + 1], tPointers2[2 * f + 2]);
+ if (c != 0) {
+ return c;
+ }
+ } catch (HyracksDataException e) {
+ throw new IllegalArgumentException(e);
}
+
}
int runid1 = tp1.getRunid();
int runid2 = tp2.getRunid();
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/SortMinHeap.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/SortMinHeap.java
index 5938be9..1cde75f 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/SortMinHeap.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/SortMinHeap.java
@@ -3,9 +3,9 @@
* 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.
@@ -21,6 +21,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
/**
@@ -76,7 +77,7 @@
* Assumption (element structure): [RunId][FrameIx][Offset][Poorman NK]
*/
@Override
- public void getMin(int[] result) {
+ public void getMin(int[] result) throws HyracksDataException {
if (nextIx == 0) {
result[0] = result[1] = result[2] = result[3] = -1;
return;
@@ -100,7 +101,7 @@
}
@Override
- public void insert(int[] e) {
+ public void insert(int[] e) throws HyracksDataException {
if (nextIx >= elements.length) {
elements = Arrays.copyOf(elements, elements.length * 2);
}
@@ -127,7 +128,7 @@
return (nextIx > 0 ? (nextIx - 1) / 4 : 0);
}
- private int[] delete(int nix) {
+ private int[] delete(int nix) throws HyracksDataException {
int[] nv = Arrays.copyOfRange(elements, nix, nix + ELEMENT_SIZE);
int[] lastElem = removeLast();
@@ -157,7 +158,7 @@
return l;
}
- private void siftUp(int nodeIx) {
+ private void siftUp(int nodeIx) throws HyracksDataException {
int p = getParent(nodeIx);
if (p < 0) {
return;
@@ -172,7 +173,7 @@
}
}
- private void siftDown(int nodeIx) {
+ private void siftDown(int nodeIx) throws HyracksDataException {
int mix = getMinOfChildren(nodeIx);
if (mix < 0) {
return;
@@ -188,14 +189,14 @@
}
// first < sec : -1
- private int compare(int nodeSIx1, int nodeSIx2) {
+ private int compare(int nodeSIx1, int nodeSIx2) throws HyracksDataException {
int[] n1 = Arrays.copyOfRange(elements, nodeSIx1, nodeSIx1 + ELEMENT_SIZE);
int[] n2 = Arrays.copyOfRange(elements, nodeSIx2, nodeSIx2 + ELEMENT_SIZE);
return (compare(n1, n2));
}
// first < sec : -1
- private int compare(int[] n1, int[] n2) {
+ private int compare(int[] n1, int[] n2) throws HyracksDataException {
// Compare Run Numbers
if (n1[RUN_ID_IX] != n2[RUN_ID_IX]) {
return (n1[RUN_ID_IX] < n2[RUN_ID_IX] ? -1 : 1);
@@ -209,7 +210,8 @@
return compare(getFrame(n1[FRAME_IX]), getFrame(n2[FRAME_IX]), n1[OFFSET_IX], n2[OFFSET_IX]);
}
- private int compare(ByteBuffer fr1, ByteBuffer fr2, int r1StartOffset, int r2StartOffset) {
+ private int compare(ByteBuffer fr1, ByteBuffer fr2, int r1StartOffset, int r2StartOffset)
+ throws HyracksDataException {
byte[] b1 = fr1.array();
byte[] b2 = fr2.array();
fta1.reset(fr1);
@@ -237,7 +239,7 @@
return 0;
}
- private int getMinOfChildren(int nix) { // returns index of min child
+ private int getMinOfChildren(int nix) throws HyracksDataException { // returns index of min child
int lix = getLeftChild(nix);
if (lix < 0) {
return -1;
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/SortMinMaxHeap.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/SortMinMaxHeap.java
index c05c7c0..12aa8a1 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/SortMinMaxHeap.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/sort/SortMinMaxHeap.java
@@ -3,9 +3,9 @@
* 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.
@@ -21,6 +21,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
/**
@@ -66,7 +67,7 @@
}
@Override
- public void insert(int[] element) {
+ public void insert(int[] element) throws HyracksDataException {
if (nextIx >= elements.length) {
elements = Arrays.copyOf(elements, elements.length * 2);
}
@@ -78,7 +79,7 @@
}
@Override
- public void getMin(int[] result) {
+ public void getMin(int[] result) throws HyracksDataException {
if (nextIx == 0) {
result[0] = result[1] = result[2] = result[3] = -1;
return;
@@ -114,7 +115,7 @@
}
@Override
- public void getMax(int[] result) {
+ public void getMax(int[] result) throws HyracksDataException {
if (nextIx == ELEMENT_SIZE) {
int[] topElement = removeLast();
for (int x = 0; x < ELEMENT_SIZE; x++) {
@@ -144,7 +145,7 @@
}
@Override
- public void peekMax(int[] result) {
+ public void peekMax(int[] result) throws HyracksDataException {
if (nextIx == ELEMENT_SIZE) {
for (int i = 0; i < ELEMENT_SIZE; i++) {
result[i] = elements[i];
@@ -169,7 +170,7 @@
result[0] = result[1] = result[2] = result[3] = -1;
}
- private int[] delete(int delIx) {
+ private int[] delete(int delIx) throws HyracksDataException {
int s = nextIx;
if (nextIx > ELEMENT_SIZE) {
int[] delEntry = Arrays.copyOfRange(elements, delIx, delIx + ELEMENT_SIZE);
@@ -197,7 +198,7 @@
return l;
}
- private void bubbleUp(int ix) {
+ private void bubbleUp(int ix) throws HyracksDataException {
int p = getParentIx(ix);
if (isAtMinLevel(ix)) {
if (p != NOT_EXIST && compare(p, ix) < 0) {
@@ -216,7 +217,7 @@
}
}
- private void bubbleUpMax(int ix) {
+ private void bubbleUpMax(int ix) throws HyracksDataException {
int gp = getGrandParent(ix);
if (gp != NOT_EXIST && compare(gp, ix) < 0) {
swap(ix, gp);
@@ -224,7 +225,7 @@
}
}
- private void bubbleUpMin(int ix) {
+ private void bubbleUpMin(int ix) throws HyracksDataException {
int gp = getGrandParent(ix);
if (gp != NOT_EXIST && compare(ix, gp) < 0) {
swap(ix, gp);
@@ -232,7 +233,7 @@
}
}
- private void trickleDown(int ix) {
+ private void trickleDown(int ix) throws HyracksDataException {
if (isAtMinLevel(ix)) {
trickleDownMin(ix);
} else {
@@ -240,7 +241,7 @@
}
}
- private void trickleDownMax(int ix) {
+ private void trickleDownMax(int ix) throws HyracksDataException {
int maxIx = getMaxOfDescendents(ix);
if (maxIx == NOT_EXIST) {
return;
@@ -262,7 +263,7 @@
}
}
- private void trickleDownMin(int ix) {
+ private void trickleDownMin(int ix) throws HyracksDataException {
int minIx = getMinOfDescendents(ix);
if (minIx == NOT_EXIST) {
return;
@@ -285,7 +286,7 @@
}
// Min among children and grand children
- private int getMinOfDescendents(int ix) {
+ private int getMinOfDescendents(int ix) throws HyracksDataException {
int lc = getLeftChild(ix);
if (lc == NOT_EXIST) {
return NOT_EXIST;
@@ -309,7 +310,7 @@
}
// Max among children and grand children
- private int getMaxOfDescendents(int ix) {
+ private int getMaxOfDescendents(int ix) throws HyracksDataException {
int lc = getLeftChild(ix);
if (lc == NOT_EXIST) {
return NOT_EXIST;
@@ -395,14 +396,14 @@
}
// first < sec : -1
- private int compare(int nodeSIx1, int nodeSIx2) {
+ private int compare(int nodeSIx1, int nodeSIx2) throws HyracksDataException {
int[] n1 = Arrays.copyOfRange(elements, nodeSIx1, nodeSIx1 + ELEMENT_SIZE); //tree.get(nodeSIx1);
int[] n2 = Arrays.copyOfRange(elements, nodeSIx2, nodeSIx2 + ELEMENT_SIZE); //tree.get(nodeSIx2);
return (compare(n1, n2));
}
// first < sec : -1
- private int compare(int[] n1, int[] n2) {
+ private int compare(int[] n1, int[] n2) throws HyracksDataException {
// Compare Run Numbers
if (n1[RUN_ID_IX] != n2[RUN_ID_IX]) {
return (n1[RUN_ID_IX] < n2[RUN_ID_IX] ? -1 : 1);
@@ -416,7 +417,8 @@
return compare(getFrame(n1[FRAME_IX]), getFrame(n2[FRAME_IX]), n1[OFFSET_IX], n2[OFFSET_IX]);
}
- private int compare(ByteBuffer fr1, ByteBuffer fr2, int r1StartOffset, int r2StartOffset) {
+ private int compare(ByteBuffer fr1, ByteBuffer fr2, int r1StartOffset, int r2StartOffset)
+ throws HyracksDataException {
byte[] b1 = fr1.array();
byte[] b2 = fr2.array();
fta1.reset(fr1);
diff --git a/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/integration/TPCHCustomerOrderNestedLoopJoinTest.java b/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/integration/TPCHCustomerOrderNestedLoopJoinTest.java
index daab141..ef423b5 100644
--- a/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/integration/TPCHCustomerOrderNestedLoopJoinTest.java
+++ b/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/integration/TPCHCustomerOrderNestedLoopJoinTest.java
@@ -3,9 +3,9 @@
* 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.
@@ -31,6 +31,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.ITuplePairComparatorFactory;
import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
import edu.uci.ics.hyracks.api.dataset.ResultSetId;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.api.io.FileReference;
import edu.uci.ics.hyracks.api.job.JobSpecification;
import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
@@ -83,7 +84,8 @@
}
@Override
- public int compare(IFrameTupleAccessor accessor0, int tIndex0, IFrameTupleAccessor accessor1, int tIndex1) {
+ public int compare(IFrameTupleAccessor accessor0, int tIndex0, IFrameTupleAccessor accessor1, int tIndex1)
+ throws HyracksDataException {
int tStart0 = accessor0.getTupleStartOffset(tIndex0);
int fStartOffset0 = accessor0.getFieldSlotsLength() + tStart0;
diff --git a/hyracks/hyracks-examples/tpch-example/tpchclient/src/main/java/edu/uci/ics/hyracks/examples/tpch/client/Main.java b/hyracks/hyracks-examples/tpch-example/tpchclient/src/main/java/edu/uci/ics/hyracks/examples/tpch/client/Main.java
index a54e940..1d4e6ce 100644
--- a/hyracks/hyracks-examples/tpch-example/tpchclient/src/main/java/edu/uci/ics/hyracks/examples/tpch/client/Main.java
+++ b/hyracks/hyracks-examples/tpch-example/tpchclient/src/main/java/edu/uci/ics/hyracks/examples/tpch/client/Main.java
@@ -3,9 +3,9 @@
* 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.
@@ -109,7 +109,7 @@
// Whether group-by is processed after the join
@Option(name = "-has-groupby", usage = "Whether to have group-by operation after join (default: disabled)", required = false)
public boolean hasGroupBy = false;
-
+
@Option(name = "-frame-size", usage = "Hyracks frame size (default: 32768)", required = false)
public int frameSize = 32768;
}
@@ -150,7 +150,8 @@
private static JobSpecification createJob(FileSplit[] customerSplits, FileSplit[] orderSplits,
FileSplit[] resultSplits, int numJoinPartitions, String algo, int graceInputSize, int graceRecordsPerFrame,
- double graceFactor, int memSize, int tableSize, boolean hasGroupBy, int frameSize) throws HyracksDataException {
+ double graceFactor, int memSize, int tableSize, boolean hasGroupBy, int frameSize)
+ throws HyracksDataException {
JobSpecification spec = new JobSpecification(frameSize);
IFileSplitProvider custSplitsProvider = new ConstantFileSplitProvider(customerSplits);
@@ -199,7 +200,8 @@
if ("nestedloop".equalsIgnoreCase(algo)) {
join = new NestedLoopJoinOperatorDescriptor(spec, new JoinComparatorFactory(
- PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY), 0, 1), custOrderJoinDesc, memSize, false, null);
+ PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY), 0, 1), custOrderJoinDesc,
+ memSize, false, null);
} else if ("gracehash".equalsIgnoreCase(algo)) {
join = new GraceHashJoinOperatorDescriptor(
@@ -333,7 +335,8 @@
}
@Override
- public int compare(IFrameTupleAccessor accessor0, int tIndex0, IFrameTupleAccessor accessor1, int tIndex1) {
+ public int compare(IFrameTupleAccessor accessor0, int tIndex0, IFrameTupleAccessor accessor1, int tIndex1)
+ throws HyracksDataException {
int tStart0 = accessor0.getTupleStartOffset(tIndex0);
int fStartOffset0 = accessor0.getFieldSlotsLength() + tStart0;
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IBTreeFrame.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IBTreeFrame.java
index fb730fe..dbb4a5f 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IBTreeFrame.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IBTreeFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -26,7 +26,7 @@
public int findDeleteTupleIndex(ITupleReference tuple) throws TreeIndexException;
- public void insertSorted(ITupleReference tuple);
+ public void insertSorted(ITupleReference tuple) throws HyracksDataException;
public void setSmFlag(boolean smFlag);
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IBTreeLeafFrame.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IBTreeLeafFrame.java
index 196f691..5b17ae6 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IBTreeLeafFrame.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IBTreeLeafFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -32,11 +32,15 @@
public int findUpsertTupleIndex(ITupleReference tuple) throws TreeIndexException;
/**
- * @param searchTuple the tuple to match
- * @param targetTupleIndex the index of the tuple to check
- * @return the tuple at targetTupleIndex if its keys match searchTuple's keys, otherwise null
+ * @param searchTuple
+ * the tuple to match
+ * @param targetTupleIndex
+ * the index of the tuple to check
+ * @return the tuple at targetTupleIndex if its keys match searchTuple's keys, otherwise null
+ * @throws HyracksDataException
*/
- public ITupleReference getMatchingKeyTuple(ITupleReference searchTuple, int targetTupleIndex);
+ public ITupleReference getMatchingKeyTuple(ITupleReference searchTuple, int targetTupleIndex)
+ throws HyracksDataException;
public void setNextLeaf(int nextPage);
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IPrefixSlotManager.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IPrefixSlotManager.java
index 08ebf18..d6b34de 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IPrefixSlotManager.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/api/IPrefixSlotManager.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.btree.api;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.ISlotManager;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexTupleReference;
@@ -23,23 +24,19 @@
import edu.uci.ics.hyracks.storage.am.common.ophelpers.MultiComparator;
/**
- * A slot consists of two fields. The first field is 1 byte and it indicates the slot number of
- * a prefix tuple that is called the first field prefixSlotOff. The second field is 3 bytes and
- * it points to the start offset of a tuple that is called the second field tupleOff.
- *
- * We distinguish between two slot types:
- * 1) prefix slots that point to prefix tuples (a frame is assumed to have a field numPrefixTuples)
- * 2) tuple slots that point to data tuples (a frame is assumed to have a field numTuples)
- *
- * A tuple slot contains a tuple pointer and a pointer to a prefix slot (prefix slot number).
- *
- * INSERT procedure:
- * - A tuple insertion may use an existing prefix tuple
- * - A tuple insertion may never create a new prefix tuple
- *
- * Modifying the prefix slots would be extremely expensive because potentially all tuples slots
- * would have to change their prefix slot pointers. All prefixes are recomputed during a reorg
- * or compaction.
+ * A slot consists of two fields. The first field is 1 byte and it indicates the slot number of
+ * a prefix tuple that is called the first field prefixSlotOff. The second field is 3 bytes and
+ * it points to the start offset of a tuple that is called the second field tupleOff.
+ * We distinguish between two slot types:
+ * 1) prefix slots that point to prefix tuples (a frame is assumed to have a field numPrefixTuples)
+ * 2) tuple slots that point to data tuples (a frame is assumed to have a field numTuples)
+ * A tuple slot contains a tuple pointer and a pointer to a prefix slot (prefix slot number).
+ * INSERT procedure:
+ * - A tuple insertion may use an existing prefix tuple
+ * - A tuple insertion may never create a new prefix tuple
+ * Modifying the prefix slots would be extremely expensive because potentially all tuples slots
+ * would have to change their prefix slot pointers. All prefixes are recomputed during a reorg
+ * or compaction.
*/
public interface IPrefixSlotManager extends ISlotManager {
// TODO: Clean up interface after extending ISlotManager.
@@ -52,14 +49,15 @@
public int findSlot(ITupleReference searchKey, ITreeIndexTupleReference frameTuple,
ITreeIndexTupleReference framePrefixTuple, MultiComparator multiCmp, FindTupleMode mode,
- FindTupleNoExactMatchPolicy matchPolicy);
+ FindTupleNoExactMatchPolicy matchPolicy) throws HyracksDataException;
public int insertSlot(int slot, int tupleOff);
- /**
+ /**
* @return the prefix slot number or FieldPrefixSlotManager.TUPLE_UNCOMPRESSED if none found
+ * @throws HyracksDataException
*/
- public int findPrefix(ITupleReference tuple, ITreeIndexTupleReference framePrefixTuple);
+ public int findPrefix(ITupleReference tuple, ITreeIndexTupleReference framePrefixTuple) throws HyracksDataException;
public int getTupleSlotStartOff();
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/compressors/FieldPrefixCompressor.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/compressors/FieldPrefixCompressor.java
index ea2cca3..84369f8 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/compressors/FieldPrefixCompressor.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/compressors/FieldPrefixCompressor.java
@@ -3,9 +3,9 @@
* 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.
@@ -22,6 +22,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.storage.am.btree.api.IPrefixSlotManager;
import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeFieldPrefixNSMLeafFrame;
import edu.uci.ics.hyracks.storage.am.btree.impls.FieldPrefixSlotManager;
@@ -151,7 +152,7 @@
ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
// perform compression, and reorg
- // we assume that the keyPartitions are sorted by the prefixes
+ // we assume that the keyPartitions are sorted by the prefixes
// (i.e., in the logical target order)
int kpIndex = 0;
int tupleIndex = 0;
@@ -194,7 +195,7 @@
break;
}
- // the two tuples must match in exactly the number of fields we decided
+ // the two tuples must match in exactly the number of fields we decided
// to compress for this keyPartition
int processSegments = 0;
if (prefixFieldsMatch == fieldCountToCompress)
@@ -208,7 +209,7 @@
for (int r = 0; r < processSegments; r++) {
// compress current segment and then start new segment
if (tuplesInSegment < occurrenceThreshold || fieldCountToCompress <= 0) {
- // segment does not have at least occurrenceThreshold tuples, so
+ // segment does not have at least occurrenceThreshold tuples, so
// write tuples uncompressed
for (int j = 0; j < tuplesInSegment; j++) {
int slotNum = segmentStart + j;
@@ -219,7 +220,7 @@
}
uncompressedTupleCount += tuplesInSegment;
} else {
- // segment has enough tuples: compress segment, extract prefix,
+ // segment has enough tuples: compress segment, extract prefix,
// write prefix tuple to buffer, and set prefix slot
newPrefixSlots[newPrefixSlots.length - 1 - prefixTupleIndex] = slotManager
.encodeSlotFields(fieldCountToCompress, prefixFreeSpace);
@@ -273,7 +274,7 @@
// in some rare instances our procedure could even increase the space requirement which is very dangerous
// this can happen to to the greedy solution of the knapsack-like problem
- // therefore, we check if the new space exceeds the page size to avoid the only danger of
+ // therefore, we check if the new space exceeds the page size to avoid the only danger of
// an increasing space
int totalSpace = tupleFreeSpace + newTupleSlots.length * slotManager.getSlotSize() + newPrefixSlots.length
* slotManager.getSlotSize();
@@ -319,7 +320,7 @@
// the occurrenceThreshold determines the minimum number of tuples that must
// share a common prefix in order for us to consider compressing them
private ArrayList<KeyPartition> getKeyPartitions(BTreeFieldPrefixNSMLeafFrame frame, MultiComparator cmp,
- int occurrenceThreshold) {
+ int occurrenceThreshold) throws HyracksDataException {
IBinaryComparator[] cmps = cmp.getComparators();
int fieldCount = typeTraits.length;
@@ -360,14 +361,14 @@
- prefixFieldsMatch);
if (kp.pmi[j].matches == occurrenceThreshold) {
- // if we compress this prefix, we pay the cost of storing it once, plus
+ // if we compress this prefix, we pay the cost of storing it once, plus
// the size for one prefix slot
kp.pmi[j].prefixBytes += prefixBytes;
kp.pmi[j].spaceCost += prefixBytes + slotManager.getSlotSize();
kp.pmi[j].prefixSlotsNeeded++;
kp.pmi[j].spaceBenefit += occurrenceThreshold * spaceBenefit;
} else if (kp.pmi[j].matches > occurrenceThreshold) {
- // we are beyond the occurrence threshold, every additional tuple with a
+ // we are beyond the occurrence threshold, every additional tuple with a
// matching prefix increases the benefit
kp.pmi[j].spaceBenefit += spaceBenefit;
}
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
index 93cde3d..e320c26 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeFieldPrefixNSMLeafFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -213,7 +213,7 @@
}
@Override
- public FrameOpSpaceStatus hasSpaceInsert(ITupleReference tuple) {
+ public FrameOpSpaceStatus hasSpaceInsert(ITupleReference tuple) throws HyracksDataException {
int freeContiguous = buf.capacity() - buf.getInt(freeSpaceOff)
- ((buf.getInt(tupleCountOff) + buf.getInt(prefixTupleCountOff)) * slotManager.getSlotSize());
@@ -365,8 +365,13 @@
@Override
public int findInsertTupleIndex(ITupleReference tuple) throws TreeIndexException {
- int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp,
- FindTupleMode.EXCLUSIVE_ERROR_IF_EXISTS, FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ int slot;
+ try {
+ slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp,
+ FindTupleMode.EXCLUSIVE_ERROR_IF_EXISTS, FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
int tupleIndex = slotManager.decodeSecondSlotField(slot);
// Error indicator is set if there is an exact match.
if (tupleIndex == slotManager.getErrorIndicator()) {
@@ -377,8 +382,13 @@
@Override
public int findUpsertTupleIndex(ITupleReference tuple) throws TreeIndexException {
- int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.INCLUSIVE,
- FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ int slot;
+ try {
+ slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.INCLUSIVE,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
int tupleIndex = slotManager.decodeSecondSlotField(slot);
// Error indicator is set if there is an exact match.
if (tupleIndex == slotManager.getErrorIndicator()) {
@@ -388,7 +398,8 @@
}
@Override
- public ITupleReference getMatchingKeyTuple(ITupleReference searchTuple, int targetTupleIndex) {
+ public ITupleReference getMatchingKeyTuple(ITupleReference searchTuple, int targetTupleIndex)
+ throws HyracksDataException {
int tupleIndex = slotManager.decodeSecondSlotField(targetTupleIndex);
// Examine the tuple index to determine whether it is valid or not.
if (tupleIndex != slotManager.getGreatestKeyIndicator()) {
@@ -406,8 +417,13 @@
@Override
public int findUpdateTupleIndex(ITupleReference tuple) throws TreeIndexException {
- int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.EXACT,
- FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ int slot;
+ try {
+ slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.EXACT,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
int tupleIndex = slotManager.decodeSecondSlotField(slot);
// Error indicator is set if there is no exact match.
if (tupleIndex == slotManager.getErrorIndicator()) {
@@ -418,8 +434,13 @@
@Override
public int findDeleteTupleIndex(ITupleReference tuple) throws TreeIndexException {
- int slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.EXACT,
- FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ int slot;
+ try {
+ slot = slotManager.findSlot(tuple, frameTuple, framePrefixTuple, cmp, FindTupleMode.EXACT,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
int tupleIndex = slotManager.decodeSecondSlotField(slot);
// Error indicator is set if there is no exact match.
if (tupleIndex == slotManager.getErrorIndicator()) {
@@ -516,7 +537,7 @@
}
@Override
- public void insertSorted(ITupleReference tuple) {
+ public void insertSorted(ITupleReference tuple) throws HyracksDataException {
int freeSpace = buf.getInt(freeSpaceOff);
int fieldsToTruncate = 0;
@@ -547,7 +568,8 @@
}
@Override
- public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey) {
+ public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey)
+ throws HyracksDataException {
BTreeFieldPrefixNSMLeafFrame rf = (BTreeFieldPrefixNSMLeafFrame) rightFrame;
@@ -726,7 +748,7 @@
@Override
public int findTupleIndex(ITupleReference searchKey, ITreeIndexTupleReference pageTuple, MultiComparator cmp,
- FindTupleMode ftm, FindTupleNoExactMatchPolicy ftp) {
+ FindTupleMode ftm, FindTupleNoExactMatchPolicy ftp) throws HyracksDataException {
int slot = slotManager.findSlot(searchKey, pageTuple, framePrefixTuple, cmp, ftm, ftp);
int tupleIndex = slotManager.decodeSecondSlotField(slot);
// TODO: Revisit this one. Maybe there is a cleaner way to solve this in the RangeSearchCursor.
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java
index ffbf79a..562511d 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMInteriorFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -67,8 +67,12 @@
@Override
public int findInsertTupleIndex(ITupleReference tuple) throws TreeIndexException {
- return slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.INCLUSIVE,
- FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ try {
+ return slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.INCLUSIVE,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
}
@Override
@@ -114,8 +118,12 @@
@Override
public int findDeleteTupleIndex(ITupleReference tuple) throws TreeIndexException {
- return slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.INCLUSIVE,
- FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ try {
+ return slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.INCLUSIVE,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
}
@Override
@@ -182,11 +190,12 @@
}
@Override
- public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey) {
+ public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey)
+ throws HyracksDataException {
ByteBuffer right = rightFrame.getBuffer();
int tupleCount = getTupleCount();
- // Find split point, and determine into which frame the new tuple should be inserted into.
+ // Find split point, and determine into which frame the new tuple should be inserted into.
ITreeIndexFrame targetFrame = null;
frameTuple.resetByTupleIndex(this, tupleCount - 1);
int tuplesToLeft;
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
index 995e8a7..2fa5b5d 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/BTreeNSMLeafFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -68,8 +68,13 @@
@Override
public int findInsertTupleIndex(ITupleReference tuple) throws TreeIndexException {
- int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.EXCLUSIVE_ERROR_IF_EXISTS,
- FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ int tupleIndex;
+ try {
+ tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.EXCLUSIVE_ERROR_IF_EXISTS,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
// Error indicator is set if there is an exact match.
if (tupleIndex == slotManager.getErrorIndicator()) {
throw new TreeIndexDuplicateKeyException("Trying to insert duplicate key into leaf node.");
@@ -79,8 +84,13 @@
@Override
public int findUpdateTupleIndex(ITupleReference tuple) throws TreeIndexException {
- int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.EXACT,
- FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ int tupleIndex;
+ try {
+ tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.EXACT,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
// Error indicator is set if there is no exact match.
if (tupleIndex == slotManager.getErrorIndicator() || tupleIndex == slotManager.getGreatestKeyIndicator()) {
throw new TreeIndexNonExistentKeyException("Trying to update a tuple with a nonexistent key in leaf node.");
@@ -90,15 +100,21 @@
@Override
public int findUpsertTupleIndex(ITupleReference tuple) throws TreeIndexException {
- int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.INCLUSIVE,
- FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ int tupleIndex;
+ try {
+ tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.INCLUSIVE,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
// Just return the found tupleIndex. The caller will make the final
// decision whether to insert or update.
return tupleIndex;
}
@Override
- public ITupleReference getMatchingKeyTuple(ITupleReference searchTuple, int targetTupleIndex) {
+ public ITupleReference getMatchingKeyTuple(ITupleReference searchTuple, int targetTupleIndex)
+ throws HyracksDataException {
// Examine the tuple index to determine whether it is valid or not.
if (targetTupleIndex != slotManager.getGreatestKeyIndicator()) {
// We need to check the key to determine whether it's an insert or
@@ -117,8 +133,13 @@
@Override
public int findDeleteTupleIndex(ITupleReference tuple) throws TreeIndexException {
- int tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.EXACT,
- FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ int tupleIndex;
+ try {
+ tupleIndex = slotManager.findTupleIndex(tuple, frameTuple, cmp, FindTupleMode.EXACT,
+ FindTupleNoExactMatchPolicy.HIGHER_KEY);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
// Error indicator is set if there is no exact match.
if (tupleIndex == slotManager.getErrorIndicator() || tupleIndex == slotManager.getGreatestKeyIndicator()) {
throw new TreeIndexNonExistentKeyException("Trying to delete a tuple with a nonexistent key in leaf node.");
@@ -142,7 +163,8 @@
}
@Override
- public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey) {
+ public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey)
+ throws HyracksDataException {
ByteBuffer right = rightFrame.getBuffer();
int tupleCount = getTupleCount();
@@ -227,7 +249,7 @@
@Override
public int findTupleIndex(ITupleReference searchKey, ITreeIndexTupleReference pageTuple, MultiComparator cmp,
- FindTupleMode ftm, FindTupleNoExactMatchPolicy ftp) {
+ FindTupleMode ftm, FindTupleNoExactMatchPolicy ftp) throws HyracksDataException {
return slotManager.findTupleIndex(searchKey, pageTuple, cmp, ftm, ftp);
}
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/OrderedSlotManager.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/OrderedSlotManager.java
index 2316c6b..42af3e9 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/OrderedSlotManager.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/frames/OrderedSlotManager.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.btree.frames;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexTupleReference;
import edu.uci.ics.hyracks.storage.am.common.frames.AbstractSlotManager;
@@ -26,7 +27,7 @@
@Override
public int findTupleIndex(ITupleReference searchKey, ITreeIndexTupleReference frameTuple, MultiComparator multiCmp,
- FindTupleMode mode, FindTupleNoExactMatchPolicy matchPolicy) {
+ FindTupleMode mode, FindTupleNoExactMatchPolicy matchPolicy) throws HyracksDataException {
int tupleCount = frame.getTupleCount();
if (tupleCount <= 0) {
return GREATEST_KEY_INDICATOR;
diff --git a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldPrefixSlotManager.java b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldPrefixSlotManager.java
index d34284d..e814087 100644
--- a/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldPrefixSlotManager.java
+++ b/hyracks/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/impls/FieldPrefixSlotManager.java
@@ -3,9 +3,9 @@
* 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.
@@ -17,6 +17,7 @@
import java.nio.ByteBuffer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.btree.api.IPrefixSlotManager;
import edu.uci.ics.hyracks.storage.am.btree.frames.BTreeFieldPrefixNSMLeafFrame;
@@ -52,7 +53,7 @@
}
// returns prefix slot number, or TUPLE_UNCOMPRESSED of no match was found
- public int findPrefix(ITupleReference tuple, ITreeIndexTupleReference framePrefixTuple) {
+ public int findPrefix(ITupleReference tuple, ITreeIndexTupleReference framePrefixTuple) throws HyracksDataException {
int prefixMid;
int prefixBegin = 0;
int prefixEnd = frame.getPrefixTupleCount() - 1;
@@ -77,7 +78,7 @@
@Override
public int findSlot(ITupleReference searchKey, ITreeIndexTupleReference frameTuple,
ITreeIndexTupleReference framePrefixTuple, MultiComparator multiCmp, FindTupleMode mode,
- FindTupleNoExactMatchPolicy matchPolicy) {
+ FindTupleNoExactMatchPolicy matchPolicy) throws HyracksDataException {
if (frame.getTupleCount() <= 0)
encodeSlotFields(TUPLE_UNCOMPRESSED, GREATEST_KEY_INDICATOR);
diff --git a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ISlotManager.java b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ISlotManager.java
index 2376c32..e913d8f 100644
--- a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ISlotManager.java
+++ b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ISlotManager.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.common.api;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.FindTupleMode;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.FindTupleNoExactMatchPolicy;
@@ -22,7 +23,7 @@
public interface ISlotManager {
public int findTupleIndex(ITupleReference searchKey, ITreeIndexTupleReference frameTuple, MultiComparator multiCmp,
- FindTupleMode mode, FindTupleNoExactMatchPolicy matchPolicy);
+ FindTupleMode mode, FindTupleNoExactMatchPolicy matchPolicy) throws HyracksDataException;
public int getGreatestKeyIndicator();
diff --git a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ITreeIndexFrame.java b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ITreeIndexFrame.java
index b987971..83613d7 100644
--- a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ITreeIndexFrame.java
+++ b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/api/ITreeIndexFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -27,7 +27,7 @@
public void initBuffer(byte level);
- public FrameOpSpaceStatus hasSpaceInsert(ITupleReference tuple);
+ public FrameOpSpaceStatus hasSpaceInsert(ITupleReference tuple) throws HyracksDataException;
public void insert(ITupleReference tuple, int tupleIndex);
@@ -66,7 +66,8 @@
// for debugging
public String printHeader();
- public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey);
+ public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey)
+ throws HyracksDataException;
public ISlotManager getSlotManager();
diff --git a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/MultiComparator.java b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/MultiComparator.java
index 2c59a4e..f9e7313 100644
--- a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/MultiComparator.java
+++ b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/MultiComparator.java
@@ -3,9 +3,9 @@
* 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.
@@ -17,6 +17,7 @@
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
public class MultiComparator {
@@ -27,7 +28,7 @@
this.cmps = cmps;
}
- public int compare(ITupleReference tupleA, ITupleReference tupleB) {
+ public int compare(ITupleReference tupleA, ITupleReference tupleB) throws HyracksDataException {
for (int i = 0; i < cmps.length; i++) {
int cmp = cmps[i].compare(tupleA.getFieldData(i), tupleA.getFieldStart(i), tupleA.getFieldLength(i),
tupleB.getFieldData(i), tupleB.getFieldStart(i), tupleB.getFieldLength(i));
@@ -38,7 +39,8 @@
return 0;
}
- public int selectiveFieldCompare(ITupleReference tupleA, ITupleReference tupleB, int[] fields) {
+ public int selectiveFieldCompare(ITupleReference tupleA, ITupleReference tupleB, int[] fields)
+ throws HyracksDataException {
for (int j = 0; j < cmps.length; j++) {
int i = fields[j];
int cmp = cmps[j].compare(tupleA.getFieldData(i), tupleA.getFieldStart(i), tupleA.getFieldLength(i),
@@ -50,7 +52,7 @@
return 0;
}
- public int compare(ITupleReference tupleA, ITupleReference tupleB, int startFieldIndex) {
+ public int compare(ITupleReference tupleA, ITupleReference tupleB, int startFieldIndex) throws HyracksDataException {
for (int i = 0; i < cmps.length; i++) {
int ix = startFieldIndex + i;
int cmp = cmps[i].compare(tupleA.getFieldData(ix), tupleA.getFieldStart(ix), tupleA.getFieldLength(ix),
@@ -62,7 +64,8 @@
return 0;
}
- public int fieldRangeCompare(ITupleReference tupleA, ITupleReference tupleB, int startFieldIndex, int numFields) {
+ public int fieldRangeCompare(ITupleReference tupleA, ITupleReference tupleB, int startFieldIndex, int numFields)
+ throws HyracksDataException {
for (int i = startFieldIndex; i < startFieldIndex + numFields; i++) {
int cmp = cmps[i].compare(tupleA.getFieldData(i), tupleA.getFieldStart(i), tupleA.getFieldLength(i),
tupleB.getFieldData(i), tupleB.getFieldStart(i), tupleB.getFieldLength(i));
diff --git a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/SingleComparator.java b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/SingleComparator.java
index 654f20b..f32c4dd 100644
--- a/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/SingleComparator.java
+++ b/hyracks/hyracks-storage-am-common/src/main/java/edu/uci/ics/hyracks/storage/am/common/ophelpers/SingleComparator.java
@@ -3,9 +3,9 @@
* 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.
@@ -16,6 +16,7 @@
package edu.uci.ics.hyracks.storage.am.common.ophelpers;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
/**
@@ -30,7 +31,7 @@
this.cmp = cmps[0];
}
- public int compare(ITupleReference tupleA, ITupleReference tupleB) {
+ public int compare(ITupleReference tupleA, ITupleReference tupleB) throws HyracksDataException {
return cmp.compare(tupleA.getFieldData(0), tupleA.getFieldStart(0), tupleA.getFieldLength(0),
tupleB.getFieldData(0), tupleB.getFieldStart(0), tupleB.getFieldLength(0));
}
diff --git a/hyracks/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java b/hyracks/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
index ee2cb32..2899eff 100644
--- a/hyracks/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
+++ b/hyracks/hyracks-storage-am-lsm-btree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/btree/impls/LSMBTree.java
@@ -3,9 +3,9 @@
* 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.
@@ -273,7 +273,7 @@
}
@Override
- public void getOperationalComponents(ILSMIndexOperationContext ctx) {
+ public void getOperationalComponents(ILSMIndexOperationContext ctx) throws HyracksDataException {
List<ILSMComponent> immutableComponents = diskComponents;
List<ILSMComponent> operationalComponents = ctx.getComponentHolder();
int cmc = currentMutableComponentId.get();
diff --git a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMComponentFilter.java b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMComponentFilter.java
index 9039ab5..6654db0 100644
--- a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMComponentFilter.java
+++ b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMComponentFilter.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,14 +15,16 @@
package edu.uci.ics.hyracks.storage.am.lsm.common.api;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.MultiComparator;
public interface ILSMComponentFilter {
- public void update(ITupleReference tuple, MultiComparator cmp);
+ public void update(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException;
- public boolean satisfy(ITupleReference minTuple, ITupleReference maxTuple, MultiComparator filterCmp);
+ public boolean satisfy(ITupleReference minTuple, ITupleReference maxTuple, MultiComparator filterCmp)
+ throws HyracksDataException;
public ITupleReference getMinTuple();
diff --git a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMIndexInternal.java b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMIndexInternal.java
index bf82c31..a8e00ae 100644
--- a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMIndexInternal.java
+++ b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/api/ILSMIndexInternal.java
@@ -3,9 +3,9 @@
* 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.
@@ -47,7 +47,8 @@
public void addComponent(ILSMComponent index) throws HyracksDataException;
- public void subsumeMergedComponents(ILSMComponent newComponent, List<ILSMComponent> mergedComponents) throws HyracksDataException;
+ public void subsumeMergedComponents(ILSMComponent newComponent, List<ILSMComponent> mergedComponents)
+ throws HyracksDataException;
public void changeMutableComponent();
@@ -57,14 +58,15 @@
/**
* Populates the context's component holder with a snapshot of the components involved in the operation.
- *
+ *
* @param ctx
* - the operation's context
+ * @throws HyracksDataException
*/
- public void getOperationalComponents(ILSMIndexOperationContext ctx);
+ public void getOperationalComponents(ILSMIndexOperationContext ctx) throws HyracksDataException;
public void markAsValid(ILSMComponent lsmComponent) throws HyracksDataException;
-
+
public boolean isCurrentMutableComponentEmpty() throws HyracksDataException;
}
diff --git a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMComponentFilter.java b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMComponentFilter.java
index 8cb66c1..0e853cf 100644
--- a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMComponentFilter.java
+++ b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMComponentFilter.java
@@ -3,9 +3,9 @@
* 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.
@@ -17,6 +17,7 @@
import java.nio.ByteBuffer;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexTupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexTupleWriter;
@@ -58,7 +59,7 @@
}
@Override
- public void update(ITupleReference tuple, MultiComparator cmp) {
+ public void update(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException {
if (minTuple == null) {
int numBytes = tupleWriter.bytesRequired(tuple);
minTupleBytes = new byte[numBytes];
@@ -114,7 +115,8 @@
}
@Override
- public boolean satisfy(ITupleReference minTuple, ITupleReference maxTuple, MultiComparator filterCmp) {
+ public boolean satisfy(ITupleReference minTuple, ITupleReference maxTuple, MultiComparator filterCmp)
+ throws HyracksDataException {
if (maxTuple != null && this.minTuple != null) {
int c = filterCmp.compare(maxTuple, this.minTuple);
if (c < 0) {
diff --git a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java
index 5a4699e..be8000c 100644
--- a/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java
+++ b/hyracks/hyracks-storage-am-lsm-common/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java
@@ -3,9 +3,9 @@
* 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.
@@ -238,10 +238,16 @@
@Override
public int compare(PriorityQueueElement elementA, PriorityQueueElement elementB) {
- int result = cmp.compare(elementA.getTuple(), elementB.getTuple());
- if (result != 0) {
- return result;
+ int result;
+ try {
+ result = cmp.compare(elementA.getTuple(), elementB.getTuple());
+ if (result != 0) {
+ return result;
+ }
+ } catch (HyracksDataException e) {
+ throw new IllegalArgumentException(e);
}
+
if (elementA.getCursorIndex() > elementB.getCursorIndex()) {
return 1;
} else {
@@ -260,10 +266,11 @@
}
}
- protected int compare(MultiComparator cmp, ITupleReference tupleA, ITupleReference tupleB) {
+ protected int compare(MultiComparator cmp, ITupleReference tupleA, ITupleReference tupleB)
+ throws HyracksDataException {
return cmp.compare(tupleA, tupleB);
}
-
+
@Override
public void markCurrentTupleAsUpdated() throws HyracksDataException {
throw new HyracksDataException("Updating tuples is not supported with this cursor.");
diff --git a/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java b/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java
index a6e7579..0376f26 100644
--- a/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java
+++ b/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/impls/LSMInvertedIndex.java
@@ -3,9 +3,9 @@
* 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.
@@ -279,7 +279,7 @@
}
@Override
- public void getOperationalComponents(ILSMIndexOperationContext ctx) {
+ public void getOperationalComponents(ILSMIndexOperationContext ctx) throws HyracksDataException {
List<ILSMComponent> immutableComponents = diskComponents;
List<ILSMComponent> operationalComponents = ctx.getComponentHolder();
int cmc = currentMutableComponentId.get();
@@ -347,10 +347,10 @@
public void modify(IIndexOperationContext ictx, ITupleReference tuple) throws HyracksDataException, IndexException {
LSMInvertedIndexOpContext ctx = (LSMInvertedIndexOpContext) ictx;
// TODO: This is a hack to support logging properly in ASTERIX.
- // The proper undo operations are only dependent on the after image so
- // it is correct to say we found nothing (null) as the before image (at least
- // in the perspective of ASTERIX). The semantics for the operation callbacks
- // are violated here (and they are somewhat unclear in the first place as to
+ // The proper undo operations are only dependent on the after image so
+ // it is correct to say we found nothing (null) as the before image (at least
+ // in the perspective of ASTERIX). The semantics for the operation callbacks
+ // are violated here (and they are somewhat unclear in the first place as to
// what they should be for an inverted index).
ITupleReference indexTuple;
@@ -365,7 +365,7 @@
ctx.modificationCallback.found(null, indexTuple);
switch (ctx.getOperation()) {
case INSERT: {
- // Insert into the in-memory inverted index.
+ // Insert into the in-memory inverted index.
ctx.currentMutableInvIndexAccessors.insert(indexTuple);
break;
}
diff --git a/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/ondisk/FixedSizeElementInvertedListCursor.java b/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/ondisk/FixedSizeElementInvertedListCursor.java
index 1cd4a86..c3eb3d5 100644
--- a/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/ondisk/FixedSizeElementInvertedListCursor.java
+++ b/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/invertedindex/ondisk/FixedSizeElementInvertedListCursor.java
@@ -3,9 +3,9 @@
* 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.
@@ -46,7 +46,7 @@
private final FixedSizeTupleReference tuple;
private ICachedPage[] pages = new ICachedPage[10];
private int[] elementIndexes = new int[10];
-
+
private boolean pinned = false;
public FixedSizeElementInvertedListCursor(IBufferCache bufferCache, int fileId, ITypeTraits[] invListFields) {
@@ -129,7 +129,7 @@
}
@Override
- public boolean containsKey(ITupleReference searchTuple, MultiComparator invListCmp) {
+ public boolean containsKey(ITupleReference searchTuple, MultiComparator invListCmp) throws HyracksDataException {
int mid;
int begin = 0;
int end = numElements - 1;
diff --git a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
index e6eaba6..ebfa8f5 100644
--- a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
+++ b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/AbstractLSMRTree.java
@@ -3,9 +3,9 @@
* 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.
@@ -227,7 +227,7 @@
}
@Override
- public void getOperationalComponents(ILSMIndexOperationContext ctx) {
+ public void getOperationalComponents(ILSMIndexOperationContext ctx) throws HyracksDataException {
List<ILSMComponent> operationalComponents = ctx.getComponentHolder();
List<ILSMComponent> immutableComponents = diskComponents;
int cmc = currentMutableComponentId.get();
diff --git a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java
index c0c52b30..d140b69 100644
--- a/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java
+++ b/hyracks/hyracks-storage-am-lsm-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/lsm/rtree/impls/LSMRTreeWithAntiMatterTuplesSearchCursor.java
@@ -3,9 +3,9 @@
* 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.
@@ -224,7 +224,8 @@
}
@Override
- protected int compare(MultiComparator cmp, ITupleReference tupleA, ITupleReference tupleB) {
+ protected int compare(MultiComparator cmp, ITupleReference tupleA, ITupleReference tupleB)
+ throws HyracksDataException {
return cmp.selectiveFieldCompare(tupleA, tupleB, comparatorFields);
}
@@ -264,10 +265,16 @@
@Override
public int compare(PriorityQueueElement elementA, PriorityQueueElement elementB) {
- int result = cmp.selectiveFieldCompare(elementA.getTuple(), elementB.getTuple(), comparatorFields);
- if (result != 0) {
- return result;
+ int result;
+ try {
+ result = cmp.selectiveFieldCompare(elementA.getTuple(), elementB.getTuple(), comparatorFields);
+ if (result != 0) {
+ return result;
+ }
+ } catch (HyracksDataException e) {
+ throw new IllegalArgumentException(e);
}
+
if (elementA.getCursorIndex() > elementB.getCursorIndex()) {
return 1;
} else {
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeInteriorFrame.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeInteriorFrame.java
index f6d4fe2..e47f512 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeInteriorFrame.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeInteriorFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.rtree.api;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.TreeIndexException;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.MultiComparator;
@@ -22,20 +23,22 @@
public interface IRTreeInteriorFrame extends IRTreeFrame {
- public int findBestChild(ITupleReference tuple, MultiComparator cmp);
+ public int findBestChild(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException;
- public boolean checkIfEnlarementIsNeeded(ITupleReference tuple, MultiComparator cmp);
+ public boolean checkIfEnlarementIsNeeded(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException;
public int getChildPageId(int tupleIndex);
- public int getChildPageIdIfIntersect(ITupleReference tuple, int tupleIndex, MultiComparator cmp);
+ public int getChildPageIdIfIntersect(ITupleReference tuple, int tupleIndex, MultiComparator cmp)
+ throws HyracksDataException;
- public int findTupleByPointer(ITupleReference tuple, MultiComparator cmp);
+ public int findTupleByPointer(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException;
- public int findTupleByPointer(ITupleReference tuple, PathList traverseList, int parentIndex, MultiComparator cmp);
+ public int findTupleByPointer(ITupleReference tuple, PathList traverseList, int parentIndex, MultiComparator cmp)
+ throws HyracksDataException;
public void adjustKey(ITupleReference tuple, int tupleIndex, MultiComparator cmp) throws TreeIndexException;
- public void enlarge(ITupleReference tuple, MultiComparator cmp);
+ public void enlarge(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException;
}
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeLeafFrame.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeLeafFrame.java
index ff730bb..13c2f2b 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeLeafFrame.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreeLeafFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,14 +15,16 @@
package edu.uci.ics.hyracks.storage.am.rtree.api;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.MultiComparator;
public interface IRTreeLeafFrame extends IRTreeFrame {
- public int findTupleIndex(ITupleReference tuple, MultiComparator cmp);
+ public int findTupleIndex(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException;
- public boolean intersect(ITupleReference tuple, int tupleIndex, MultiComparator cmp);
+ public boolean intersect(ITupleReference tuple, int tupleIndex, MultiComparator cmp) throws HyracksDataException;
- public ITupleReference getBeforeTuple(ITupleReference tuple, int targetTupleIndex, MultiComparator cmp);
+ public ITupleReference getBeforeTuple(ITupleReference tuple, int targetTupleIndex, MultiComparator cmp)
+ throws HyracksDataException;
}
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreePolicy.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreePolicy.java
index 4e05630..a731255 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreePolicy.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/api/IRTreePolicy.java
@@ -3,9 +3,9 @@
* 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.
@@ -17,6 +17,7 @@
import java.nio.ByteBuffer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.ISlotManager;
import edu.uci.ics.hyracks.storage.am.common.api.ISplitKey;
@@ -26,8 +27,8 @@
public interface IRTreePolicy {
public void split(ITreeIndexFrame leftFrame, ByteBuffer buf, ITreeIndexFrame rightFrame, ISlotManager slotManager,
- ITreeIndexTupleReference frameTuple, ITupleReference tuple, ISplitKey splitKey);
+ ITreeIndexTupleReference frameTuple, ITupleReference tuple, ISplitKey splitKey) throws HyracksDataException;
public int findBestChildPosition(ITreeIndexFrame frame, ITupleReference tuple, ITreeIndexTupleReference frameTuple,
- MultiComparator cmp);
+ MultiComparator cmp) throws HyracksDataException;
}
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RStarTreePolicy.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RStarTreePolicy.java
index 8900134..38bd313 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RStarTreePolicy.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RStarTreePolicy.java
@@ -3,9 +3,9 @@
* 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.
@@ -17,6 +17,7 @@
import java.nio.ByteBuffer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProvider;
import edu.uci.ics.hyracks.storage.am.common.api.ISlotManager;
@@ -66,7 +67,7 @@
@Override
public void split(ITreeIndexFrame leftFrame, ByteBuffer buf, ITreeIndexFrame rightFrame, ISlotManager slotManager,
- ITreeIndexTupleReference frameTuple, ITupleReference tuple, ISplitKey splitKey) {
+ ITreeIndexTupleReference frameTuple, ITupleReference tuple, ISplitKey splitKey) throws HyracksDataException {
RTreeSplitKey rTreeSplitKey = ((RTreeSplitKey) splitKey);
RTreeTypeAwareTupleWriter rTreeTupleWriterleftRTreeFrame = ((RTreeTypeAwareTupleWriter) tupleWriter);
RTreeTypeAwareTupleWriter rTreeTupleWriterRightFrame = ((RTreeTypeAwareTupleWriter) rightFrame.getTupleWriter());
@@ -255,7 +256,7 @@
@Override
public int findBestChildPosition(ITreeIndexFrame frame, ITupleReference tuple, ITreeIndexTupleReference frameTuple,
- MultiComparator cmp) {
+ MultiComparator cmp) throws HyracksDataException {
cmpFrameTuple.setFieldCount(cmp.getKeyFieldCount());
frameTuple.setFieldCount(cmp.getKeyFieldCount());
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeComputationUtils.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeComputationUtils.java
index 2bc51e0..b11dbfc 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeComputationUtils.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeComputationUtils.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.rtree.frames;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProvider;
import edu.uci.ics.hyracks.storage.am.common.ophelpers.MultiComparator;
@@ -22,7 +23,7 @@
public class RTreeComputationUtils {
public static double enlargedArea(ITupleReference tuple, ITupleReference tupleToBeInserted, MultiComparator cmp,
- IPrimitiveValueProvider[] keyValueProviders) {
+ IPrimitiveValueProvider[] keyValueProviders) throws HyracksDataException {
double areaBeforeEnlarge = RTreeComputationUtils.area(tuple, cmp, keyValueProviders);
double areaAfterEnlarge = 1.0;
@@ -55,7 +56,8 @@
}
public static double overlappedArea(ITupleReference tuple1, ITupleReference tupleToBeInserted,
- ITupleReference tuple2, MultiComparator cmp, IPrimitiveValueProvider[] keyValueProviders) {
+ ITupleReference tuple2, MultiComparator cmp, IPrimitiveValueProvider[] keyValueProviders)
+ throws HyracksDataException {
double area = 1.0;
double f1, f2;
@@ -114,7 +116,7 @@
}
public static boolean containsRegion(ITupleReference tuple1, ITupleReference tuple2, MultiComparator cmp,
- IPrimitiveValueProvider[] keyValueProviders) {
+ IPrimitiveValueProvider[] keyValueProviders) throws HyracksDataException {
int maxFieldPos = cmp.getKeyFieldCount() / 2;
for (int i = 0; i < maxFieldPos; i++) {
int j = maxFieldPos + i;
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMFrame.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMFrame.java
index df647e3..0af8c78 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMFrame.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.rtree.frames;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProvider;
import edu.uci.ics.hyracks.storage.am.common.api.ISplitKey;
@@ -111,7 +112,8 @@
}
@Override
- public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey) {
+ public void split(ITreeIndexFrame rightFrame, ITupleReference tuple, ISplitKey splitKey)
+ throws HyracksDataException {
rtreePolicy.split(this, buf, rightFrame, slotManager, frameTuple, tuple, splitKey);
}
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMInteriorFrame.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMInteriorFrame.java
index edb255e..399fd61 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMInteriorFrame.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMInteriorFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -19,6 +19,7 @@
import java.util.Collections;
import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
import edu.uci.ics.hyracks.data.std.primitive.IntegerPointable;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -53,7 +54,7 @@
}
@Override
- public int findBestChild(ITupleReference tuple, MultiComparator cmp) {
+ public int findBestChild(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException {
int bestChild = rtreePolicy.findBestChildPosition(this, tuple, frameTuple, cmp);
frameTuple.resetByTupleIndex(this, bestChild);
return buf.getInt(getChildPointerOff(frameTuple));
@@ -61,7 +62,7 @@
// frameTuple is assumed to have the tuple to be tested against.
@Override
- public boolean checkIfEnlarementIsNeeded(ITupleReference tuple, MultiComparator cmp) {
+ public boolean checkIfEnlarementIsNeeded(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException {
return !RTreeComputationUtils.containsRegion(frameTuple, tuple, cmp, keyValueProviders);
}
@@ -73,7 +74,7 @@
}
@Override
- public int findTupleByPointer(ITupleReference tuple, MultiComparator cmp) {
+ public int findTupleByPointer(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException {
frameTuple.setFieldCount(cmp.getKeyFieldCount());
for (int i = 0; i < getTupleCount(); i++) {
frameTuple.resetByTupleIndex(this, i);
@@ -92,7 +93,8 @@
}
@Override
- public int getChildPageIdIfIntersect(ITupleReference tuple, int tupleIndex, MultiComparator cmp) {
+ public int getChildPageIdIfIntersect(ITupleReference tuple, int tupleIndex, MultiComparator cmp)
+ throws HyracksDataException {
frameTuple.setFieldCount(cmp.getKeyFieldCount());
frameTuple.resetByTupleIndex(this, tupleIndex);
int maxFieldPos = cmp.getKeyFieldCount() / 2;
@@ -114,7 +116,8 @@
}
@Override
- public int findTupleByPointer(ITupleReference tuple, PathList traverseList, int parentIndex, MultiComparator cmp) {
+ public int findTupleByPointer(ITupleReference tuple, PathList traverseList, int parentIndex, MultiComparator cmp)
+ throws HyracksDataException {
frameTuple.setFieldCount(cmp.getKeyFieldCount());
for (int i = 0; i < getTupleCount(); i++) {
frameTuple.resetByTupleIndex(this, i);
@@ -181,7 +184,11 @@
public void adjustKey(ITupleReference tuple, int tupleIndex, MultiComparator cmp) throws TreeIndexException {
frameTuple.setFieldCount(cmp.getKeyFieldCount());
if (tupleIndex == -1) {
- tupleIndex = findTupleByPointer(tuple, cmp);
+ try {
+ tupleIndex = findTupleByPointer(tuple, cmp);
+ } catch (HyracksDataException e) {
+ throw new TreeIndexException(e);
+ }
}
if (tupleIndex != -1) {
tupleWriter.writeTuple(tuple, buf.array(), getTupleOffset(tupleIndex));
@@ -192,7 +199,8 @@
}
- protected int pointerCmp(ITupleReference tupleA, ITupleReference tupleB, MultiComparator cmp) {
+ protected int pointerCmp(ITupleReference tupleA, ITupleReference tupleB, MultiComparator cmp)
+ throws HyracksDataException {
return childPtrCmp
.compare(tupleA.getFieldData(cmp.getKeyFieldCount() - 1), getChildPointerOff(tupleA), childPtrSize,
tupleB.getFieldData(cmp.getKeyFieldCount() - 1), getChildPointerOff(tupleB), childPtrSize);
@@ -243,7 +251,7 @@
}
@Override
- public void enlarge(ITupleReference tuple, MultiComparator cmp) {
+ public void enlarge(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException {
int maxFieldPos = cmp.getKeyFieldCount() / 2;
for (int i = 0; i < maxFieldPos; i++) {
int j = maxFieldPos + i;
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMLeafFrame.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMLeafFrame.java
index cde1aea..b9f9e47 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMLeafFrame.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreeNSMLeafFrame.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.rtree.frames;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProvider;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexTupleReference;
@@ -40,12 +41,12 @@
}
@Override
- public int findTupleIndex(ITupleReference tuple, MultiComparator cmp) {
+ public int findTupleIndex(ITupleReference tuple, MultiComparator cmp) throws HyracksDataException {
return slotManager.findTupleIndex(tuple, frameTuple, cmp, null, null);
}
@Override
- public boolean intersect(ITupleReference tuple, int tupleIndex, MultiComparator cmp) {
+ public boolean intersect(ITupleReference tuple, int tupleIndex, MultiComparator cmp) throws HyracksDataException {
frameTuple.resetByTupleIndex(this, tupleIndex);
int maxFieldPos = cmp.getKeyFieldCount() / 2;
for (int i = 0; i < maxFieldPos; i++) {
@@ -103,7 +104,8 @@
return frameTuple.getFieldCount();
}
- public ITupleReference getBeforeTuple(ITupleReference tuple, int targetTupleIndex, MultiComparator cmp) {
+ public ITupleReference getBeforeTuple(ITupleReference tuple, int targetTupleIndex, MultiComparator cmp)
+ throws HyracksDataException {
// Examine the tuple index to determine whether it is valid or not.
if (targetTupleIndex != slotManager.getGreatestKeyIndicator()) {
// We need to check the key to determine whether it's an insert or an update.
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreePolicy.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreePolicy.java
index 0c977cc..4f88787 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreePolicy.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/frames/RTreePolicy.java
@@ -3,9 +3,9 @@
* 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.
@@ -17,6 +17,7 @@
import java.nio.ByteBuffer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.IPrimitiveValueProvider;
import edu.uci.ics.hyracks.storage.am.common.api.ISlotManager;
@@ -57,7 +58,7 @@
@Override
public void split(ITreeIndexFrame leftFrame, ByteBuffer buf, ITreeIndexFrame rightFrame, ISlotManager slotManager,
- ITreeIndexTupleReference frameTuple, ITupleReference tuple, ISplitKey splitKey) {
+ ITreeIndexTupleReference frameTuple, ITupleReference tuple, ISplitKey splitKey) throws HyracksDataException {
RTreeSplitKey rTreeSplitKey = ((RTreeSplitKey) splitKey);
RTreeTypeAwareTupleWriter rTreeTupleWriterLeftFrame = ((RTreeTypeAwareTupleWriter) tupleWriter);
RTreeTypeAwareTupleWriter rTreeTupleWriterRightFrame = ((RTreeTypeAwareTupleWriter) rightFrame.getTupleWriter());
@@ -202,7 +203,7 @@
@Override
public int findBestChildPosition(ITreeIndexFrame frame, ITupleReference tuple, ITreeIndexTupleReference frameTuple,
- MultiComparator cmp) {
+ MultiComparator cmp) throws HyracksDataException {
cmpFrameTuple.setFieldCount(cmp.getKeyFieldCount());
frameTuple.setFieldCount(cmp.getKeyFieldCount());
diff --git a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/UnorderedSlotManager.java b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/UnorderedSlotManager.java
index 204def1..fdb6763 100644
--- a/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/UnorderedSlotManager.java
+++ b/hyracks/hyracks-storage-am-rtree/src/main/java/edu/uci/ics/hyracks/storage/am/rtree/impls/UnorderedSlotManager.java
@@ -3,9 +3,9 @@
* 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.
@@ -15,6 +15,7 @@
package edu.uci.ics.hyracks.storage.am.rtree.impls;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.api.ITreeIndexTupleReference;
import edu.uci.ics.hyracks.storage.am.common.frames.AbstractSlotManager;
@@ -27,7 +28,7 @@
@Override
public int findTupleIndex(ITupleReference searchKey, ITreeIndexTupleReference frameTuple, MultiComparator multiCmp,
- FindTupleMode mode, FindTupleNoExactMatchPolicy matchPolicy) {
+ FindTupleMode mode, FindTupleNoExactMatchPolicy matchPolicy) throws HyracksDataException {
if (searchKey.getFieldCount() == frameTuple.getFieldCount()) {
int maxFieldPos = multiCmp.getKeyFieldCount() / 2;
for (int i = 0; i < frame.getTupleCount(); i++) {
diff --git a/hyracks/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/AbstractModificationOperationCallbackTest.java b/hyracks/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/AbstractModificationOperationCallbackTest.java
index e1a4ec8..8c2054b 100644
--- a/hyracks/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/AbstractModificationOperationCallbackTest.java
+++ b/hyracks/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/AbstractModificationOperationCallbackTest.java
@@ -3,9 +3,9 @@
* 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.
@@ -19,6 +19,7 @@
import org.junit.Before;
import org.junit.Test;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
import edu.uci.ics.hyracks.dataflow.common.comm.io.ArrayTupleReference;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
@@ -79,12 +80,12 @@
private class VeriyfingModificationCallback implements IModificationOperationCallback {
@Override
- public void before(ITupleReference tuple) {
+ public void before(ITupleReference tuple) throws HyracksDataException {
Assert.assertEquals(0, cmp.compare(AbstractModificationOperationCallbackTest.this.tuple, tuple));
}
@Override
- public void found(ITupleReference before, ITupleReference after) {
+ public void found(ITupleReference before, ITupleReference after) throws HyracksDataException {
if (isFoundNull) {
Assert.assertEquals(null, before);
} else {
diff --git a/hyracks/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/AbstractSearchOperationCallbackTest.java b/hyracks/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/AbstractSearchOperationCallbackTest.java
index 4c158ce..a574ba5 100644
--- a/hyracks/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/AbstractSearchOperationCallbackTest.java
+++ b/hyracks/hyracks-test-support/src/main/java/edu/uci/ics/hyracks/storage/am/btree/AbstractSearchOperationCallbackTest.java
@@ -3,9 +3,9 @@
* 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.
@@ -155,13 +155,13 @@
private class SynchronizingSearchOperationCallback implements ISearchOperationCallback {
@Override
- public boolean proceed(ITupleReference tuple) {
+ public boolean proceed(ITupleReference tuple) throws HyracksDataException {
Assert.assertEquals(0, cmp.compare(SearchTask.this.tuple, tuple));
return false;
}
@Override
- public void reconcile(ITupleReference tuple) {
+ public void reconcile(ITupleReference tuple) throws HyracksDataException {
Assert.assertEquals(0, cmp.compare(SearchTask.this.tuple, tuple));
if (blockOnHigh) {
try {
diff --git a/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/LSMBTreeSearchOperationCallbackTest.java b/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/LSMBTreeSearchOperationCallbackTest.java
index a4dd7b2..00c4d17 100644
--- a/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/LSMBTreeSearchOperationCallbackTest.java
+++ b/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/LSMBTreeSearchOperationCallbackTest.java
@@ -3,9 +3,9 @@
* 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.
@@ -165,7 +165,7 @@
private class SynchronizingSearchOperationCallback implements ISearchOperationCallback {
@Override
- public boolean proceed(ITupleReference tuple) {
+ public boolean proceed(ITupleReference tuple) throws HyracksDataException {
Assert.assertEquals(0, cmp.compare(SearchTask.this.expectedTupleToBeLocked, tuple));
return false;
}
@@ -222,7 +222,7 @@
try {
insertTaskStarted = true;
- // bulkload [101, 150] and then insert [151, 200] and make sure it reaches disk, thus we will have two separate disk components
+ // bulkload [101, 150] and then insert [151, 200] and make sure it reaches disk, thus we will have two separate disk components
// insert [50, 100] & [301, 350] to the in-memory component
// delete tuple 151
bulkloadIntTupleRange(101, 150);
diff --git a/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/ConcurrentSkipListRunner.java b/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/ConcurrentSkipListRunner.java
index 61c6ad3..4f09faa 100644
--- a/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/ConcurrentSkipListRunner.java
+++ b/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/ConcurrentSkipListRunner.java
@@ -3,9 +3,9 @@
* 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.
@@ -20,6 +20,7 @@
import java.util.concurrent.ConcurrentSkipListSet;
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.datagen.DataGenThread;
import edu.uci.ics.hyracks.storage.am.common.datagen.TupleBatch;
@@ -38,37 +39,42 @@
@Override
public int compare(ITupleReference o1, ITupleReference o2) {
- return cmp.compare(o1, o2);
+ try {
+ return cmp.compare(o1, o2);
+ } catch (HyracksDataException e) {
+ throw new IllegalArgumentException(e);
+ }
}
}
-
+
private final TupleComparator tupleCmp;
private final int numBatches;
private final int batchSize;
private final int tupleSize;
private final ITypeTraits[] typeTraits;
-
- public ConcurrentSkipListRunner(int numBatches, int batchSize, int tupleSize, ITypeTraits[] typeTraits, MultiComparator cmp) {
+
+ public ConcurrentSkipListRunner(int numBatches, int batchSize, int tupleSize, ITypeTraits[] typeTraits,
+ MultiComparator cmp) {
this.numBatches = numBatches;
this.tupleSize = tupleSize;
this.batchSize = batchSize;
this.typeTraits = typeTraits;
tupleCmp = new TupleComparator(cmp);
}
-
+
@Override
public long runExperiment(DataGenThread dataGen, int numThreads) throws InterruptedException {
ConcurrentSkipListSet<ITupleReference> skipList = new ConcurrentSkipListSet<ITupleReference>(tupleCmp);
SkipListThread[] threads = new SkipListThread[numThreads];
int threadNumBatches = numBatches / numThreads;
for (int i = 0; i < numThreads; i++) {
- threads[i] = new SkipListThread(dataGen, skipList, threadNumBatches, batchSize);
+ threads[i] = new SkipListThread(dataGen, skipList, threadNumBatches, batchSize);
}
// Wait until the tupleBatchQueue is completely full.
while (dataGen.tupleBatchQueue.remainingCapacity() != 0) {
Thread.sleep(10);
}
-
+
long start = System.currentTimeMillis();
for (int i = 0; i < numThreads; i++) {
threads[i].start();
@@ -88,20 +94,21 @@
@Override
public void deinit() throws Exception {
}
-
+
public void reset() throws Exception {
}
-
+
public class SkipListThread extends Thread {
- private final DataGenThread dataGen;
- private final ConcurrentSkipListSet<ITupleReference> skipList;
- private final int numBatches;
+ private final DataGenThread dataGen;
+ private final ConcurrentSkipListSet<ITupleReference> skipList;
+ private final int numBatches;
public final TypeAwareTupleWriterFactory tupleWriterFactory;
public final TypeAwareTupleWriter tupleWriter;
- public final TypeAwareTupleReference[] tuples;
- public final ByteBuffer tupleBuf;
+ public final TypeAwareTupleReference[] tuples;
+ public final ByteBuffer tupleBuf;
- public SkipListThread(DataGenThread dataGen, ConcurrentSkipListSet<ITupleReference> skipList, int numBatches, int batchSize) {
+ public SkipListThread(DataGenThread dataGen, ConcurrentSkipListSet<ITupleReference> skipList, int numBatches,
+ int batchSize) {
this.dataGen = dataGen;
this.numBatches = numBatches;
this.skipList = skipList;
@@ -114,15 +121,15 @@
tuples[i] = (TypeAwareTupleReference) tupleWriter.createTupleReference();
}
}
-
+
@Override
public void run() {
int tupleIndex = 0;
- try {
+ try {
for (int i = 0; i < numBatches; i++) {
TupleBatch batch = dataGen.tupleBatchQueue.take();
for (int j = 0; j < batch.size(); j++) {
- // Copy the tuple to the buffer and set the pre-created tuple ref.
+ // Copy the tuple to the buffer and set the pre-created tuple ref.
tupleWriter.writeTuple(batch.get(j), tupleBuf.array(), tupleIndex * tupleSize);
tuples[tupleIndex].resetByTupleOffset(tupleBuf, tupleIndex * tupleSize);
skipList.add(tuples[tupleIndex]);
diff --git a/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/InMemorySortRunner.java b/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/InMemorySortRunner.java
index 3cca7ed..116862e 100644
--- a/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/InMemorySortRunner.java
+++ b/hyracks/hyracks-tests/hyracks-storage-am-lsm-btree-test/src/test/java/edu/uci/ics/hyracks/storage/am/lsm/btree/perf/InMemorySortRunner.java
@@ -3,9 +3,9 @@
* 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.
@@ -22,6 +22,7 @@
import java.util.concurrent.ConcurrentSkipListSet;
import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
import edu.uci.ics.hyracks.storage.am.common.datagen.DataGenThread;
import edu.uci.ics.hyracks.storage.am.common.datagen.TupleBatch;
@@ -40,22 +41,27 @@
@Override
public int compare(ITupleReference o1, ITupleReference o2) {
- return cmp.compare(o1, o2);
+ try {
+ return cmp.compare(o1, o2);
+ } catch (HyracksDataException e) {
+ throw new IllegalArgumentException(e);
+ }
}
}
-
+
private final TupleComparator tupleCmp;
private final int numBatches;
private final int batchSize;
private final int tupleSize;
private final ITypeTraits[] typeTraits;
-
+
private final TypeAwareTupleWriterFactory tupleWriterFactory;
private final TypeAwareTupleWriter tupleWriter;
- private final ArrayList<TypeAwareTupleReference> tuples;
- private final ByteBuffer tupleBuf;
-
- public InMemorySortRunner(int numBatches, int batchSize, int tupleSize, ITypeTraits[] typeTraits, MultiComparator cmp) {
+ private final ArrayList<TypeAwareTupleReference> tuples;
+ private final ByteBuffer tupleBuf;
+
+ public InMemorySortRunner(int numBatches, int batchSize, int tupleSize, ITypeTraits[] typeTraits,
+ MultiComparator cmp) {
this.numBatches = numBatches;
this.tupleSize = tupleSize;
this.batchSize = batchSize;
@@ -70,26 +76,26 @@
tuples.add((TypeAwareTupleReference) tupleWriter.createTupleReference());
}
}
-
+
@Override
public long runExperiment(DataGenThread dataGen, int numThreads) throws InterruptedException {
// Wait until the tupleBatchQueue is completely full.
while (dataGen.tupleBatchQueue.remainingCapacity() != 0) {
Thread.sleep(10);
}
-
+
long start = System.currentTimeMillis();
int tupleIndex = 0;
for (int i = 0; i < numBatches; i++) {
TupleBatch batch = dataGen.tupleBatchQueue.take();
for (int j = 0; j < batch.size(); j++) {
- // Copy the tuple to the buffer and set the pre-created tuple ref.
+ // Copy the tuple to the buffer and set the pre-created tuple ref.
tupleWriter.writeTuple(batch.get(j), tupleBuf.array(), tupleIndex * tupleSize);
tuples.get(tupleIndex).resetByTupleOffset(tupleBuf, tupleIndex * tupleSize);
tupleIndex++;
}
}
- // Perform the sort.
+ // Perform the sort.
Collections.sort(tuples, tupleCmp);
long end = System.currentTimeMillis();
long time = end - start;
@@ -103,20 +109,21 @@
@Override
public void deinit() throws Exception {
}
-
+
public void reset() throws Exception {
}
-
+
public class SkipListThread extends Thread {
- private final DataGenThread dataGen;
- private final ConcurrentSkipListSet<ITupleReference> skipList;
- private final int numBatches;
+ private final DataGenThread dataGen;
+ private final ConcurrentSkipListSet<ITupleReference> skipList;
+ private final int numBatches;
public final TypeAwareTupleWriterFactory tupleWriterFactory;
public final TypeAwareTupleWriter tupleWriter;
- public final TypeAwareTupleReference[] tuples;
- public final ByteBuffer tupleBuf;
+ public final TypeAwareTupleReference[] tuples;
+ public final ByteBuffer tupleBuf;
- public SkipListThread(DataGenThread dataGen, ConcurrentSkipListSet<ITupleReference> skipList, int numBatches, int batchSize) {
+ public SkipListThread(DataGenThread dataGen, ConcurrentSkipListSet<ITupleReference> skipList, int numBatches,
+ int batchSize) {
this.dataGen = dataGen;
this.numBatches = numBatches;
this.skipList = skipList;
@@ -129,15 +136,15 @@
tuples[i] = (TypeAwareTupleReference) tupleWriter.createTupleReference();
}
}
-
+
@Override
public void run() {
int tupleIndex = 0;
- try {
+ try {
for (int i = 0; i < numBatches; i++) {
TupleBatch batch = dataGen.tupleBatchQueue.take();
for (int j = 0; j < batch.size(); j++) {
- // Copy the tuple to the buffer and set the pre-created tuple ref.
+ // Copy the tuple to the buffer and set the pre-created tuple ref.
tupleWriter.writeTuple(batch.get(j), tupleBuf.array(), tupleIndex * tupleSize);
tuples[tupleIndex].resetByTupleOffset(tupleBuf, tupleIndex * tupleSize);
skipList.add(tuples[tupleIndex]);