checkpoint for adding partial comparators
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..06a6e53
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java
@@ -0,0 +1,58 @@
+/*
+ * 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.asterix.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+
+public class ACirclePartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ACirclePartialBinaryComparatorFactory INSTANCE = new ACirclePartialBinaryComparatorFactory();
+
+ private ACirclePartialBinaryComparatorFactory() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+ */
+ @Override
+ public IBinaryComparator createBinaryComparator() {
+ return new IBinaryComparator() {
+
+ @Override
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ // center.x
+ int c = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1),
+ ADoubleSerializerDeserializer.getDouble(b2, s2));
+ if (c == 0) {
+ // center.y
+ c = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 8),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 8));
+ if (c == 0) {
+ // radius
+ return Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 16),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 16));
+ }
+ }
+ return c;
+ }
+ };
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..39fc655
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java
@@ -0,0 +1,52 @@
+/*
+ * 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.asterix.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+
+public class ADurationPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ADurationPartialBinaryComparatorFactory INSTANCE = new ADurationPartialBinaryComparatorFactory();
+
+ private ADurationPartialBinaryComparatorFactory() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+ */
+ @Override
+ public IBinaryComparator createBinaryComparator() {
+ return new IBinaryComparator() {
+
+ @Override
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int c = Integer.compare(AInt32SerializerDeserializer.getInt(b1, s1),
+ AInt32SerializerDeserializer.getInt(b2, s2));
+ if (c == 0) {
+ return Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 4),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 4));
+ }
+ return c;
+ }
+ };
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..a20a860
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java
@@ -0,0 +1,54 @@
+/*
+ * 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.asterix.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+
+public class AIntervalPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final AIntervalPartialBinaryComparatorFactory INSTANCE = new AIntervalPartialBinaryComparatorFactory();
+
+ private AIntervalPartialBinaryComparatorFactory() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+ */
+ @Override
+ public IBinaryComparator createBinaryComparator() {
+ return new IBinaryComparator() {
+
+ @Override
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int c = Double.compare(AInt64SerializerDeserializer.getLong(b1, s1),
+ AInt64SerializerDeserializer.getLong(b2, s2));
+ if (c == 0) {
+ c = Double.compare(AInt64SerializerDeserializer.getLong(b1, s1 + 8),
+ AInt64SerializerDeserializer.getLong(b2, s2 + 8));
+ if (c == 0) {
+ c = Byte.compare(b1[s1 + 16], b2[s2 + 16]);
+ }
+ }
+ return c;
+ }
+ };
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..e604c6a
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java
@@ -0,0 +1,59 @@
+/*
+ * 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.asterix.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+
+public class ALinePartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ALinePartialBinaryComparatorFactory INSTANCE = new ALinePartialBinaryComparatorFactory();
+
+ private ALinePartialBinaryComparatorFactory(){
+
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+ */
+ @Override
+ public IBinaryComparator createBinaryComparator() {
+ return new IBinaryComparator() {
+
+ @Override
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int c = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1),
+ ADoubleSerializerDeserializer.getDouble(b2, s2));
+ if (c == 0) {
+ c = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 8),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 8));
+ if (c == 0) {
+ c = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 16),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 16));
+ if(c == 0){
+ return Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 24),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 24));
+ }
+ }
+ }
+ return c;
+ }
+ };
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
index c00a0e1..87acbc0 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
@@ -35,9 +35,18 @@
.createBinaryComparator();
final IBinaryComparator ascRectangleComp = RectangleBinaryComparatorFactory.INSTANCE
.createBinaryComparator();
- final IBinaryComparator ascDateTimeComp = ADateTimeAscBinaryComparatorFactory.INSTANCE
+ final IBinaryComparator ascCircleComp = ACirclePartialBinaryComparatorFactory.INSTANCE
.createBinaryComparator();
- final IBinaryComparator ascDateOrTimeComp = ADateOrTimeAscBinaryComparatorFactory.INSTANCE
+ final IBinaryComparator ascDurationComp = ADurationPartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ final IBinaryComparator ascIntervalComp = AIntervalPartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ final IBinaryComparator ascLineComp = ALinePartialBinaryComparatorFactory.INSTANCE.createBinaryComparator();
+ final IBinaryComparator ascPointComp = APointPartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ final IBinaryComparator ascPoint3DComp = APoint3DPartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ final IBinaryComparator ascPolygonComp = APolygonPartialBinaryComparatorFactory.INSTANCE
.createBinaryComparator();
@Override
@@ -58,10 +67,13 @@
case BOOLEAN: {
return ascBoolComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
}
+ case TIME:
+ case DATE:
case YEARMONTHDURATION:
case INT32: {
return ascIntComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
}
+ case DATETIME:
case DAYTIMEDURATION:
case INT64: {
return ascLongComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
@@ -78,12 +90,26 @@
case RECTANGLE: {
return ascRectangleComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
}
- case DATETIME: {
- return ascDateTimeComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+ case CIRCLE: {
+ return ascCircleComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
}
- case TIME:
- case DATE: {
- return ascDateOrTimeComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+ case POINT: {
+ return ascPointComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+ }
+ case POINT3D: {
+ return ascPoint3DComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+ }
+ case LINE: {
+ return ascLineComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+ }
+ case POLYGON: {
+ return ascPolygonComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+ }
+ case DURATION: {
+ return ascDurationComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+ }
+ case INTERVAL: {
+ return ascIntervalComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
}
default: {
throw new NotImplementedException("Comparison for type " + tag + " is not implemented");
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..32c335b
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java
@@ -0,0 +1,55 @@
+/*
+ * 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.asterix.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+
+public class APoint3DPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final APoint3DPartialBinaryComparatorFactory INSTANCE = new APoint3DPartialBinaryComparatorFactory();
+
+ private APoint3DPartialBinaryComparatorFactory() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+ */
+ @Override
+ public IBinaryComparator createBinaryComparator() {
+ return new IBinaryComparator() {
+
+ @Override
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int c = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1),
+ ADoubleSerializerDeserializer.getDouble(b2, s2));
+ if (c == 0) {
+ c = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 8),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 8));
+ if (c == 0) {
+ return Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 16),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 16));
+ }
+ }
+ return c;
+ }
+ };
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..3de6df8
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java
@@ -0,0 +1,48 @@
+/*
+ * 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.asterix.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+
+public class APointPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public final static APointPartialBinaryComparatorFactory INSTANCE = new APointPartialBinaryComparatorFactory();
+
+ private APointPartialBinaryComparatorFactory() {
+
+ }
+
+ @Override
+ public IBinaryComparator createBinaryComparator() {
+ return new IBinaryComparator() {
+
+ @Override
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int c = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1),
+ ADoubleSerializerDeserializer.getDouble(b2, s2));
+ if (c == 0) {
+ return Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 8),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 8));
+ }
+ return c;
+ }
+ };
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java
new file mode 100644
index 0000000..74ffb3f
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java
@@ -0,0 +1,65 @@
+/*
+ * 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.asterix.dataflow.data.nontagged.comparators;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
+import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.DoubleSerializerDeserializer;
+
+public class APolygonPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ public final static APolygonPartialBinaryComparatorFactory INSTANCE = new APolygonPartialBinaryComparatorFactory();
+
+ private APolygonPartialBinaryComparatorFactory() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
+ */
+ @Override
+ public IBinaryComparator createBinaryComparator() {
+ return new IBinaryComparator() {
+
+ @Override
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ short pointCount1 = AInt8SerializerDeserializer.getByte(b1, s1);
+ int c = Short.compare(pointCount1, AInt8SerializerDeserializer.getByte(b2, s2));
+
+ if (c == 0) {
+ int ci = 0;
+ for (int i = 0; i < pointCount1; i++) {
+ ci = Double.compare(DoubleSerializerDeserializer.getDouble(b1, s1 + 3 + i * 16),
+ DoubleSerializerDeserializer.getDouble(b2, s1 + 3 + i * 16));
+ if (ci == 0) {
+ ci = Double.compare(DoubleSerializerDeserializer.getDouble(b1, s1 + 11 + i * 16),
+ DoubleSerializerDeserializer.getDouble(b2, s1 + 11 + i * 16));
+ if(ci == 0){
+ continue;
+ }
+ }
+ return ci;
+ }
+ }
+
+ return c;
+ }
+ };
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
index a9ef041..18b31ec1 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
@@ -2,10 +2,17 @@
import java.io.Serializable;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ACirclePartialBinaryComparatorFactory;
import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADateOrTimeAscBinaryComparatorFactory;
import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADateTimeAscBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADurationPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.AIntervalPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ALinePartialBinaryComparatorFactory;
import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.AObjectAscBinaryComparatorFactory;
import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.AObjectDescBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APoint3DPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APointPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APolygonPartialBinaryComparatorFactory;
import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.BooleanBinaryComparatorFactory;
import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.RectangleBinaryComparatorFactory;
import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -102,10 +109,13 @@
case INT16: {
return addOffset(SHORT_POINTABLE_INSTANCE, ascending);
}
+ case DATE:
+ case TIME:
case YEARMONTHDURATION:
case INT32: {
return addOffset(INTEGER_POINTABLE_INSTANCE, ascending);
}
+ case DATETIME:
case DAYTIMEDURATION:
case INT64: {
return addOffset(LONG_POINTABLE_INSTANCE, ascending);
@@ -122,12 +132,26 @@
case RECTANGLE: {
return addOffset(RectangleBinaryComparatorFactory.INSTANCE, ascending);
}
- case DATE:
- case TIME: {
- return addOffset(ADateOrTimeAscBinaryComparatorFactory.INSTANCE, ascending);
+ case CIRCLE: {
+ return addOffset(ACirclePartialBinaryComparatorFactory.INSTANCE, ascending);
}
- case DATETIME: {
- return addOffset(ADateTimeAscBinaryComparatorFactory.INSTANCE, ascending);
+ case POINT: {
+ return addOffset(APointPartialBinaryComparatorFactory.INSTANCE, ascending);
+ }
+ case POINT3D: {
+ return addOffset(APoint3DPartialBinaryComparatorFactory.INSTANCE, ascending);
+ }
+ case LINE: {
+ return addOffset(ALinePartialBinaryComparatorFactory.INSTANCE, ascending);
+ }
+ case POLYGON: {
+ return addOffset(APolygonPartialBinaryComparatorFactory.INSTANCE, ascending);
+ }
+ case DURATION: {
+ return addOffset(ADurationPartialBinaryComparatorFactory.INSTANCE, ascending);
+ }
+ case INTERVAL: {
+ return addOffset(AIntervalPartialBinaryComparatorFactory.INSTANCE, ascending);
}
default: {
throw new NotImplementedException("No binary comparator factory implemented for type " + type + " .");
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
index b7ef163..e88596d 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
@@ -1,6 +1,4 @@
-/**
- *
- */
+
package edu.uci.ics.asterix.om.types;
/**
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
index 1565cb9..283eca3 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
@@ -2,8 +2,14 @@
import java.io.DataOutput;
-import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADateOrTimeAscBinaryComparatorFactory;
-import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADateTimeAscBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ACirclePartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ADurationPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.AIntervalPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.ALinePartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APoint3DPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APointPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.APolygonPartialBinaryComparatorFactory;
+import edu.uci.ics.asterix.dataflow.data.nontagged.comparators.RectangleBinaryComparatorFactory;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -49,9 +55,21 @@
.getSerializerDeserializer(BuiltinType.ANULL);
protected IBinaryComparator strBinaryComp = AqlBinaryComparatorFactoryProvider.UTF8STRING_POINTABLE_INSTANCE
.createBinaryComparator();
- protected IBinaryComparator dateTimeBinaryComp = ADateTimeAscBinaryComparatorFactory.INSTANCE
+ protected IBinaryComparator circleBinaryComp = ACirclePartialBinaryComparatorFactory.INSTANCE
.createBinaryComparator();
- protected IBinaryComparator dateOrTimeBinaryComp = ADateOrTimeAscBinaryComparatorFactory.INSTANCE
+ protected IBinaryComparator durationBinaryComp = ADurationPartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ protected IBinaryComparator intervalBinaryComp = AIntervalPartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ protected IBinaryComparator lineBinaryComparator = ALinePartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ protected IBinaryComparator pointBinaryComparator = APointPartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ protected IBinaryComparator point3DBinaryComparator = APoint3DPartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ protected IBinaryComparator polygonBinaryComparator = APolygonPartialBinaryComparatorFactory.INSTANCE
+ .createBinaryComparator();
+ protected IBinaryComparator rectangleBinaryComparator = RectangleBinaryComparatorFactory.INSTANCE
.createBinaryComparator();
public AbstractComparisonEvaluator(DataOutput out, ICopyEvaluatorFactory evalLeftFactory,
@@ -119,50 +137,69 @@
case BOOLEAN: {
return compareBooleanWithArg(typeTag2);
}
- case DATETIME: {
- return compareDateTimeWithArg(typeTag2);
- }
- case DATE:
- case TIME: {
- return compareDateOrTimeWithArg(typeTag2);
- }
+
default: {
- throw new AlgebricksException("Comparison is undefined between types " + typeTag1 + " and " + typeTag2
- + " .");
+ return compareStrongTypedWithArg(typeTag1, typeTag2);
}
}
}
- private ComparisonResult compareDateOrTimeWithArg(ATypeTag typeTag2) throws AlgebricksException {
- if (typeTag2 == ATypeTag.NULL) {
- return ComparisonResult.GREATER_THAN;
- } else if (typeTag2 == ATypeTag.DATE || typeTag2 == ATypeTag.TIME) {
- int result = dateOrTimeBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
- outRight.getByteArray(), 1, outRight.getLength() - 1);
- if (result == 0)
- return ComparisonResult.EQUAL;
- else if (result < 0)
- return ComparisonResult.LESS_THAN;
- else
- return ComparisonResult.GREATER_THAN;
+ private ComparisonResult compareStrongTypedWithArg(ATypeTag expectedTypeTag, ATypeTag actualTypeTag)
+ throws AlgebricksException {
+ if (expectedTypeTag != actualTypeTag) {
+ throw new AlgebricksException("Comparison is undefined between " + expectedTypeTag + " and "
+ + actualTypeTag + ".");
}
- throw new AlgebricksException("Comparison is undefined between types Date/Time and " + typeTag2 + " .");
- }
-
- private ComparisonResult compareDateTimeWithArg(ATypeTag typeTag2) throws AlgebricksException {
- if (typeTag2 == ATypeTag.NULL) {
- return ComparisonResult.GREATER_THAN;
- } else if (typeTag2 == ATypeTag.DATETIME) {
- int result = dateTimeBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
- outRight.getByteArray(), 1, outRight.getLength() - 1);
- if (result == 0)
- return ComparisonResult.EQUAL;
- else if (result < 0)
- return ComparisonResult.LESS_THAN;
- else
- return ComparisonResult.GREATER_THAN;
+ int result = 0;
+ switch (actualTypeTag) {
+ case YEARMONTHDURATION:
+ case TIME:
+ case DATE:
+ result = Integer.compare(AInt32SerializerDeserializer.getInt(outLeft.getByteArray(), 1),
+ AInt32SerializerDeserializer.getInt(outRight.getByteArray(), 1));
+ break;
+ case DAYTIMEDURATION:
+ case DATETIME:
+ result = Long.compare(AInt64SerializerDeserializer.getLong(outLeft.getByteArray(), 1),
+ AInt64SerializerDeserializer.getLong(outRight.getByteArray(), 1));
+ break;
+ case CIRCLE:
+ result = circleBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+ outRight.getByteArray(), 1, outRight.getLength() - 1);
+ break;
+ case LINE:
+ result = lineBinaryComparator.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+ outRight.getByteArray(), 1, outRight.getLength() - 1);
+ break;
+ case POINT:
+ result = pointBinaryComparator.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+ outRight.getByteArray(), 1, outRight.getLength() - 1);
+ break;
+ case POINT3D:
+ result = point3DBinaryComparator.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+ outRight.getByteArray(), 1, outRight.getLength() - 1);
+ break;
+ case POLYGON:
+ result = polygonBinaryComparator.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+ outRight.getByteArray(), 1, outRight.getLength() - 1);
+ break;
+ case DURATION:
+ result = durationBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+ outRight.getByteArray(), 1, outRight.getLength() - 1);
+ break;
+ case INTERVAL:
+ result = intervalBinaryComp.compare(outLeft.getByteArray(), 1, outLeft.getLength() - 1,
+ outRight.getByteArray(), 1, outRight.getLength() - 1);
+ break;
+ default:
+ throw new AlgebricksException("Comparison for " + actualTypeTag + " is not supported.");
}
- throw new AlgebricksException("Comparison is undefined between types Datetime and " + typeTag2 + " .");
+ if (result == 0)
+ return ComparisonResult.EQUAL;
+ else if (result < 0)
+ return ComparisonResult.LESS_THAN;
+ else
+ return ComparisonResult.GREATER_THAN;
}
private ComparisonResult compareBooleanWithArg(ATypeTag typeTag2) throws AlgebricksException {