Merged trunk -r 363:437 into branch
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_indexes@468 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-dataflow-common/.settings/org.eclipse.jdt.core.prefs b/hyracks-dataflow-common/.settings/org.eclipse.jdt.core.prefs
index 8496bf4..450f5c4 100644
--- a/hyracks-dataflow-common/.settings/org.eclipse.jdt.core.prefs
+++ b/hyracks-dataflow-common/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Thu Jul 29 14:49:35 PDT 2010
+#Fri May 20 19:34:04 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
diff --git a/hyracks-dataflow-common/pom.xml b/hyracks-dataflow-common/pom.xml
index edc19cb..d28d2bd 100644
--- a/hyracks-dataflow-common/pom.xml
+++ b/hyracks-dataflow-common/pom.xml
@@ -2,12 +2,12 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.uci.ics.hyracks</groupId>
<artifactId>hyracks-dataflow-common</artifactId>
- <version>0.1.4</version>
+ <version>0.1.5</version>
<parent>
<groupId>edu.uci.ics.hyracks</groupId>
<artifactId>hyracks</artifactId>
- <version>0.1.4</version>
+ <version>0.1.5</version>
</parent>
<build>
@@ -27,7 +27,7 @@
<dependency>
<groupId>edu.uci.ics.hyracks</groupId>
<artifactId>hyracks-api</artifactId>
- <version>0.1.4</version>
+ <version>0.1.5</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
diff --git a/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTupleAccessor.java b/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTupleAccessor.java
index c132032..8ab5d4f 100644
--- a/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTupleAccessor.java
+++ b/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTupleAccessor.java
@@ -28,7 +28,7 @@
* A frame is formatted with tuple data concatenated starting at offset 0, one tuple after another.
* Offset FS - 4 holds an int indicating the number of tuples (N) in the frame. FS - ((i + 1) * 4) for i from
* 0 to N - 1 holds an int indicating the offset of the (i + 1)^th tuple.
- * Every tuple is organized as a sequence of shorts indicating the end of each field in the tuple relative to the end of the
+ * Every tuple is organized as a sequence of ints indicating the end of each field in the tuple relative to the end of the
* field slots.
*
* @author vinayakb
@@ -71,12 +71,12 @@
@Override
public int getFieldStartOffset(int tupleIndex, int fIdx) {
- return fIdx == 0 ? 0 : buffer.getShort(getTupleStartOffset(tupleIndex) + (fIdx - 1) * 2);
+ return fIdx == 0 ? 0 : buffer.getInt(getTupleStartOffset(tupleIndex) + (fIdx - 1) * 4);
}
@Override
public int getFieldEndOffset(int tupleIndex, int fIdx) {
- return buffer.getShort(getTupleStartOffset(tupleIndex) + fIdx * 2);
+ return buffer.getInt(getTupleStartOffset(tupleIndex) + fIdx * 4);
}
@Override
@@ -86,7 +86,7 @@
@Override
public int getFieldSlotsLength() {
- return recordDescriptor.getFields().length * 2;
+ return recordDescriptor.getFields().length * 4;
}
public void prettyPrint() {
diff --git a/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTupleAppender.java b/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTupleAppender.java
index 2e9daf3..7647e50 100644
--- a/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTupleAppender.java
+++ b/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/comm/io/FrameTupleAppender.java
@@ -46,12 +46,12 @@
}
public boolean append(int[] fieldSlots, byte[] bytes, int offset, int length) {
- if (tupleDataEndOffset + fieldSlots.length * 2 + length + 4 + (tupleCount + 1) * 4 <= frameSize) {
+ if (tupleDataEndOffset + fieldSlots.length * 4 + length + 4 + (tupleCount + 1) * 4 <= frameSize) {
for (int i = 0; i < fieldSlots.length; ++i) {
- buffer.putShort(tupleDataEndOffset + i * 2, (short) fieldSlots[i]);
+ buffer.putInt(tupleDataEndOffset + i * 4, fieldSlots[i]);
}
- System.arraycopy(bytes, offset, buffer.array(), tupleDataEndOffset + fieldSlots.length * 2, length);
- tupleDataEndOffset += fieldSlots.length * 2 + length;
+ System.arraycopy(bytes, offset, buffer.array(), tupleDataEndOffset + fieldSlots.length * 4, length);
+ tupleDataEndOffset += fieldSlots.length * 4 + length;
buffer.putInt(FrameHelper.getTupleCountOffset(frameSize) - 4 * (tupleCount + 1), tupleDataEndOffset);
++tupleCount;
buffer.putInt(FrameHelper.getTupleCountOffset(frameSize), tupleCount);
@@ -99,9 +99,9 @@
// Copy slots from accessor0 verbatim
System.arraycopy(src0.array(), startOffset0, buffer.array(), tupleDataEndOffset, slotsLen0);
// Copy slots from accessor1 with the following transformation: newSlotIdx = oldSlotIdx + dataLen0
- for (int i = 0; i < slotsLen1 / 2; ++i) {
- buffer.putShort(tupleDataEndOffset + slotsLen0 + i * 2,
- (short) (src1.getShort(startOffset1 + i * 2) + dataLen0));
+ for (int i = 0; i < slotsLen1 / 4; ++i) {
+ buffer.putInt(tupleDataEndOffset + slotsLen0 + i * 4,
+ src1.getInt(startOffset1 + i * 4) + dataLen0);
}
// Copy data0
System.arraycopy(src0.array(), startOffset0 + slotsLen0, buffer.array(), tupleDataEndOffset + slotsLen0
@@ -117,9 +117,78 @@
}
return false;
}
+
+ public boolean appendConcat(IFrameTupleAccessor accessor0, int tIndex0, int[] fieldSlots1, byte[] bytes1, int offset1,
+ int dataLen1) {
+ int startOffset0 = accessor0.getTupleStartOffset(tIndex0);
+ int endOffset0 = accessor0.getTupleEndOffset(tIndex0);
+ int length0 = endOffset0 - startOffset0;
+ int slotsLen1 = fieldSlots1.length * 4;
+ int length1 = slotsLen1 + dataLen1;
+
+ if (tupleDataEndOffset + length0 + length1 + 4 + (tupleCount + 1) * 4 <= frameSize) {
+ ByteBuffer src0 = accessor0.getBuffer();
+ int slotsLen0 = accessor0.getFieldSlotsLength();
+ int dataLen0 = length0 - slotsLen0;
+ // Copy slots from accessor0 verbatim
+ System.arraycopy(src0.array(), startOffset0, buffer.array(), tupleDataEndOffset, slotsLen0);
+ // Copy fieldSlots1 with the following transformation: newSlotIdx = oldSlotIdx + dataLen0
+ for (int i = 0; i < fieldSlots1.length; ++i) {
+ buffer.putInt(tupleDataEndOffset + slotsLen0 + i * 4, (fieldSlots1[i] + dataLen0));
+ }
+ // Copy data0
+ System.arraycopy(src0.array(), startOffset0 + slotsLen0, buffer.array(), tupleDataEndOffset + slotsLen0
+ + slotsLen1, dataLen0);
+ // Copy bytes1
+ System.arraycopy(bytes1, offset1, buffer.array(), tupleDataEndOffset + slotsLen0 + fieldSlots1.length * 4
+ + dataLen0, dataLen1);
+ tupleDataEndOffset += (length0 + length1);
+ buffer.putInt(FrameHelper.getTupleCountOffset(frameSize) - 4 * (tupleCount + 1), tupleDataEndOffset);
+ ++tupleCount;
+ buffer.putInt(FrameHelper.getTupleCountOffset(frameSize), tupleCount);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean appendConcat(int[] fieldSlots0, byte[] bytes0, int offset0, int dataLen0, IFrameTupleAccessor accessor1,
+ int tIndex1) {
+ int slotsLen0 = fieldSlots0.length * 4;
+ int length0 = slotsLen0 + dataLen0;
+
+ int startOffset1 = accessor1.getTupleStartOffset(tIndex1);
+ int endOffset1 = accessor1.getTupleEndOffset(tIndex1);
+ int length1 = endOffset1 - startOffset1;
+
+ if (tupleDataEndOffset + length0 + length1 + 4 + (tupleCount + 1) * 4 <= frameSize) {
+ ByteBuffer src1 = accessor1.getBuffer();
+ int slotsLen1 = accessor1.getFieldSlotsLength();
+ int dataLen1 = length1 - slotsLen1;
+ // Copy fieldSlots0 verbatim
+ for (int i = 0; i < fieldSlots0.length; ++i) {
+ buffer.putInt(tupleDataEndOffset + i * 4, fieldSlots0[i]);
+ }
+ // Copy slots from accessor1 with the following transformation: newSlotIdx = oldSlotIdx + dataLen0
+ for (int i = 0; i < slotsLen1 / 4; ++i) {
+ buffer.putInt(tupleDataEndOffset + slotsLen0 + i * 4, src1.getInt(startOffset1 + i * 4) + dataLen0);
+ }
+ // Copy bytes0
+ System.arraycopy(bytes0, offset0, buffer.array(), tupleDataEndOffset + slotsLen0 + slotsLen1,
+ dataLen0);
+ // Copy data1
+ System.arraycopy(src1.array(), startOffset1 + slotsLen1, buffer.array(), tupleDataEndOffset + slotsLen0
+ + slotsLen1 + dataLen0, dataLen1);
+ tupleDataEndOffset += (length0 + length1);
+ buffer.putInt(FrameHelper.getTupleCountOffset(frameSize) - 4 * (tupleCount + 1), tupleDataEndOffset);
+ ++tupleCount;
+ buffer.putInt(FrameHelper.getTupleCountOffset(frameSize), tupleCount);
+ return true;
+ }
+ return false;
+ }
public boolean appendProjection(IFrameTupleAccessor accessor, int tIndex, int[] fields) {
- int fTargetSlotsLength = fields.length * 2;
+ int fTargetSlotsLength = fields.length * 4;
int length = fTargetSlotsLength;
for (int i = 0; i < fields.length; ++i) {
length += (accessor.getFieldEndOffset(tIndex, fields[i]) - accessor.getFieldStartOffset(tIndex, fields[i]));
@@ -138,7 +207,7 @@
System.arraycopy(accessor.getBuffer().array(), fSrcStart, buffer.array(), tupleDataEndOffset
+ fTargetSlotsLength + fStartOffset, fLen);
fEndOffset += fLen;
- buffer.putShort(tupleDataEndOffset + i * 2, (short) fEndOffset);
+ buffer.putInt(tupleDataEndOffset + i * 4, fEndOffset);
fStartOffset = fEndOffset;
}
tupleDataEndOffset += length;
diff --git a/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/marshalling/BooleanSerializerDeserializer.java b/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/marshalling/BooleanSerializerDeserializer.java
new file mode 100644
index 0000000..7667d2e
--- /dev/null
+++ b/hyracks-dataflow-common/src/main/java/edu/uci/ics/hyracks/dataflow/common/data/marshalling/BooleanSerializerDeserializer.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2009-2010 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.hyracks.dataflow.common.data.marshalling;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
+public class BooleanSerializerDeserializer implements ISerializerDeserializer<Boolean> {
+ private static final long serialVersionUID = 1L;
+
+ public static final BooleanSerializerDeserializer INSTANCE = new BooleanSerializerDeserializer();
+
+ private BooleanSerializerDeserializer() {
+ }
+
+ @Override
+ public Boolean deserialize(DataInput in) throws HyracksDataException {
+ try {
+ return in.readBoolean();
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+
+ @Override
+ public void serialize(Boolean instance, DataOutput out) throws HyracksDataException {
+ try {
+ out.writeBoolean(instance.booleanValue());
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
+ }
+
+ public static boolean getBoolean(byte[] bytes, int offset) {
+ return (bytes[offset] != (byte)0) ? true : false;
+ }
+}
\ No newline at end of file