asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Preston Carman (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: ASTERIXDB-1277 - Updated interval desc sort to be based on e...
Date Wed, 27 Jan 2016 01:40:06 GMT
Preston Carman has submitted this change and it was merged.

Change subject: ASTERIXDB-1277 - Updated interval desc sort to be based on end point.
......................................................................


ASTERIXDB-1277 - Updated interval desc sort to be based on end point.

The default interval sort order is now the following:
  asc - start point asc, end point asc
  desc - end point desc, start point desc

Change-Id: I61d00850e0bc8ebc611366b95e2aa4da07d21d55
Reviewed-on: https://asterix-gerrit.ics.uci.edu/598
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Taewoo Kim <wangsaeu@gmail.com>
---
A asterix-app/src/test/resources/runtimets/queries/comparison/ComparisonQueries.xml
A asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.1.ddl.aql
A asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.2.update.aql
A asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.3.query.aql
A asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.4.query.aql
A asterix-app/src/test/resources/runtimets/results/comparison/interval_order/interval_order.3.adm
A asterix-app/src/test/resources/runtimets/results/comparison/interval_order/interval_order.4.adm
M asterix-app/src/test/resources/runtimets/testsuite.xml
R asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalAscPartialBinaryComparatorFactory.java
C asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalDescPartialBinaryComparatorFactory.java
M asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
M asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectDescBinaryComparatorFactory.java
M asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
M asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
M asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
M asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
16 files changed, 393 insertions(+), 219 deletions(-)

Approvals:
  Taewoo Kim: Looks good to me, approved
  Jenkins: Verified



diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/ComparisonQueries.xml b/asterix-app/src/test/resources/runtimets/queries/comparison/ComparisonQueries.xml
new file mode 100644
index 0000000..6c3cc06
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/ComparisonQueries.xml
@@ -0,0 +1,209 @@
+        <test-case FilePath="comparison">
+            <compilation-unit name="year_month_duration_order">
+                <output-dir compare="Text">year_month_duration_order</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="datetime_order">
+                <output-dir compare="Text">datetime_order</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="datetime_range">
+                <output-dir compare="Text">datetime_range</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="datetime_tzeq">
+                <output-dir compare="Text">datetime_tzeq</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="interval_order">
+                <output-dir compare="Text">interval_order</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="time_order">
+                <output-dir compare="Text">time_order</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="date_order">
+                <output-dir compare="Text">date_order</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="double">
+                <output-dir compare="Text">double</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="double_gte_01">
+                <output-dir compare="Text">double_gte_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="double_null">
+                <output-dir compare="Text">double_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="eq_01">
+                <output-dir compare="Text">eq_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="float">
+                <output-dir compare="Text">float</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="float_null">
+                <output-dir compare="Text">float_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="gt_01">
+                <output-dir compare="Text">gt_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="gte_01">
+                <output-dir compare="Text">gte_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int16">
+                <output-dir compare="Text">int16</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int16_null">
+                <output-dir compare="Text">int16_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int32">
+                <output-dir compare="Text">int32</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int32_null">
+                <output-dir compare="Text">int32_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int64">
+                <output-dir compare="Text">int64</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int64_null">
+                <output-dir compare="Text">int64_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int8">
+                <output-dir compare="Text">int8</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="int8_null">
+                <output-dir compare="Text">int8_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="lt_01">
+                <output-dir compare="Text">lt_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="lte_01">
+                <output-dir compare="Text">lte_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="neq_01">
+                <output-dir compare="Text">neq_01</output-dir>
+            </compilation-unit>
+        </test-case>
+        <!--
+        <test-case FilePath="comparison">
+          <compilation-unit name="numeric-comparison_01">
+            <output-dir compare="Text">numeric-comparison_01</output-dir>
+          </compilation-unit>
+        </test-case>
+        -->
+        <test-case FilePath="comparison">
+            <compilation-unit name="string">
+                <output-dir compare="Text">string</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="string_null">
+                <output-dir compare="Text">string_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_equality">
+                <output-dir compare="Text">issue363_equality</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_duration">
+                <output-dir compare="Text">issue363_inequality_duration</output-dir>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the DURATION type are not defined</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_interval">
+                <output-dir compare="Text">issue363_inequality_interval</output-dir>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the INTERVAL type are not defined</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_point">
+                <output-dir compare="Text">issue363_inequality_point</output-dir>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the POINT type are not defined</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_line">
+                <output-dir compare="Text">issue363_inequality_line</output-dir>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the LINE type are not defined</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_polygon">
+                <output-dir compare="Text">issue363_inequality_polygon</output-dir>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the POLYGON type are not defined</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_rectangle">
+                <output-dir compare="Text">issue363_inequality_rectangle</output-dir>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the RECTANGLE type are not defined</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="issue363_inequality_circle">
+                <output-dir compare="Text">issue363_inequality_circle</output-dir>
+                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the CIRCLE type are not defined</expected-error>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="binary">
+                <output-dir compare="Text">binary</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="binary_null">
+                <output-dir compare="Text">binary_null</output-dir>
+            </compilation-unit>
+        </test-case>
+        <test-case FilePath="comparison">
+            <compilation-unit name="uuid_1">
+                <output-dir compare="Text">uuid_1</output-dir>
+            </compilation-unit>
+        </test-case>
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.1.ddl.aql
new file mode 100644
index 0000000..950d2b4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.1.ddl.aql
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 at
+ *
+ *   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.
+ */
+drop dataverse test if exists;
+
+create dataverse test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.2.update.aql
new file mode 100644
index 0000000..042f3ce
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.2.update.aql
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 at
+ *
+ *   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.
+ */
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.3.query.aql
new file mode 100644
index 0000000..8ccca18
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.3.query.aql
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 at
+ *
+ *   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.
+ */
+use dataverse test;
+
+let $id1 := interval-from-date("2002-01-01", "2003-01-01")
+let $id2 := interval-from-date("2006-01-01", "2010-01-01")
+let $id3 := interval-from-date("2001-01-01", "2010-01-01")
+let $id4 := interval-from-date("2003-01-01", "2008-01-01")
+let $id5 := interval-from-date("2002-01-01", "2010-01-01")
+let $id6 := interval-from-date("2004-01-01", "2009-01-01")
+let $id7 := interval-from-date("2003-01-01", "2008-01-01")
+
+for $id in [$id1, $id2, $id3, $id4, $id5, $id6, $id7]
+order by $id
+return $id;
diff --git a/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.4.query.aql b/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.4.query.aql
new file mode 100644
index 0000000..e0d9410
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/comparison/interval_order/interval_order.4.query.aql
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 at
+ *
+ *   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.
+ */
+use dataverse test;
+
+let $id1 := interval-from-date("2002-01-01", "2003-01-01")
+let $id2 := interval-from-date("2006-01-01", "2010-01-01")
+let $id3 := interval-from-date("2001-01-01", "2010-01-01")
+let $id4 := interval-from-date("2003-01-01", "2008-01-01")
+let $id5 := interval-from-date("2002-01-01", "2010-01-01")
+let $id6 := interval-from-date("2004-01-01", "2009-01-01")
+let $id7 := interval-from-date("2003-01-01", "2008-01-01")
+
+for $id in [$id1, $id2, $id3, $id4, $id5, $id6, $id7]
+order by $id desc
+return $id;
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/interval_order/interval_order.3.adm b/asterix-app/src/test/resources/runtimets/results/comparison/interval_order/interval_order.3.adm
new file mode 100644
index 0000000..35b6077
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/interval_order/interval_order.3.adm
@@ -0,0 +1,7 @@
+interval-date("2001-01-01, 2010-01-01")
+interval-date("2002-01-01, 2003-01-01")
+interval-date("2002-01-01, 2010-01-01")
+interval-date("2003-01-01, 2008-01-01")
+interval-date("2003-01-01, 2008-01-01")
+interval-date("2004-01-01, 2009-01-01")
+interval-date("2006-01-01, 2010-01-01")
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/comparison/interval_order/interval_order.4.adm b/asterix-app/src/test/resources/runtimets/results/comparison/interval_order/interval_order.4.adm
new file mode 100644
index 0000000..b8b3d7a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/comparison/interval_order/interval_order.4.adm
@@ -0,0 +1,7 @@
+interval-date("2006-01-01, 2010-01-01")
+interval-date("2002-01-01, 2010-01-01")
+interval-date("2001-01-01, 2010-01-01")
+interval-date("2004-01-01, 2009-01-01")
+interval-date("2003-01-01, 2008-01-01")
+interval-date("2003-01-01, 2008-01-01")
+interval-date("2002-01-01, 2003-01-01")
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 2e0c073..a20dc15 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -18,6 +18,7 @@
  !-->
 <!DOCTYPE test-suite [
 
+<!ENTITY ComparisonQueries SYSTEM "queries/comparison/ComparisonQueries.xml">
 <!ENTITY RecordsQueries SYSTEM "queries/records/RecordsQueries.xml">
 <!ENTITY DeepEqualQueries SYSTEM "queries/comparison/deep_equal/DeepEqualQueries.xml">
 ]>
@@ -971,200 +972,7 @@
         </test-case>
     </test-group>
     <test-group name="comparison">
-        <test-case FilePath="comparison">
-            <compilation-unit name="year_month_duration_order">
-                <output-dir compare="Text">year_month_duration_order</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="datetime_order">
-                <output-dir compare="Text">datetime_order</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="datetime_range">
-                <output-dir compare="Text">datetime_range</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="datetime_tzeq">
-                <output-dir compare="Text">datetime_tzeq</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="double">
-                <output-dir compare="Text">double</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="double_gte_01">
-                <output-dir compare="Text">double_gte_01</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="double_null">
-                <output-dir compare="Text">double_null</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="eq_01">
-                <output-dir compare="Text">eq_01</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="float">
-                <output-dir compare="Text">float</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="float_null">
-                <output-dir compare="Text">float_null</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="gt_01">
-                <output-dir compare="Text">gt_01</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="gte_01">
-                <output-dir compare="Text">gte_01</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="int16">
-                <output-dir compare="Text">int16</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="int16_null">
-                <output-dir compare="Text">int16_null</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="int32">
-                <output-dir compare="Text">int32</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="int32_null">
-                <output-dir compare="Text">int32_null</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="int64">
-                <output-dir compare="Text">int64</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="int64_null">
-                <output-dir compare="Text">int64_null</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="int8">
-                <output-dir compare="Text">int8</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="int8_null">
-                <output-dir compare="Text">int8_null</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="lt_01">
-                <output-dir compare="Text">lt_01</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="lte_01">
-                <output-dir compare="Text">lte_01</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="neq_01">
-                <output-dir compare="Text">neq_01</output-dir>
-            </compilation-unit>
-        </test-case>
-        <!--
-        <test-case FilePath="comparison">
-          <compilation-unit name="numeric-comparison_01">
-            <output-dir compare="Text">numeric-comparison_01</output-dir>
-          </compilation-unit>
-        </test-case>
-        -->
-        <test-case FilePath="comparison">
-            <compilation-unit name="string">
-                <output-dir compare="Text">string</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="string_null">
-                <output-dir compare="Text">string_null</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="issue363_equality">
-                <output-dir compare="Text">issue363_equality</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="issue363_inequality_duration">
-                <output-dir compare="Text">issue363_inequality_duration</output-dir>
-                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the DURATION type are not defined</expected-error>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="issue363_inequality_interval">
-                <output-dir compare="Text">issue363_inequality_interval</output-dir>
-                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the INTERVAL type are not defined</expected-error>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="issue363_inequality_point">
-                <output-dir compare="Text">issue363_inequality_point</output-dir>
-                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the POINT type are not defined</expected-error>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="issue363_inequality_line">
-                <output-dir compare="Text">issue363_inequality_line</output-dir>
-                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the LINE type are not defined</expected-error>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="issue363_inequality_polygon">
-                <output-dir compare="Text">issue363_inequality_polygon</output-dir>
-                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the POLYGON type are not defined</expected-error>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="issue363_inequality_rectangle">
-                <output-dir compare="Text">issue363_inequality_rectangle</output-dir>
-                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the RECTANGLE type are not defined</expected-error>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="issue363_inequality_circle">
-                <output-dir compare="Text">issue363_inequality_circle</output-dir>
-                <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Comparison operations (GT, GE, LT, and LE) for the CIRCLE type are not defined</expected-error>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="binary">
-                <output-dir compare="Text">binary</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="binary_null">
-                <output-dir compare="Text">binary_null</output-dir>
-            </compilation-unit>
-        </test-case>
-        <test-case FilePath="comparison">
-            <compilation-unit name="uuid_1">
-                <output-dir compare="Text">uuid_1</output-dir>
-            </compilation-unit>
-        </test-case>
+        &ComparisonQueries;
     </test-group>
     <test-group name="constructor">
         <test-case FilePath="constructor">
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalAscPartialBinaryComparatorFactory.java
similarity index 74%
rename from asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java
rename to asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalAscPartialBinaryComparatorFactory.java
index f7c4428..6efc7ff 100644
--- a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalAscPartialBinaryComparatorFactory.java
@@ -23,13 +23,13 @@
 import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
 import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
 
-public class AIntervalPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+public class AIntervalAscPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
 
     private static final long serialVersionUID = 1L;
 
-    public static final AIntervalPartialBinaryComparatorFactory INSTANCE = new AIntervalPartialBinaryComparatorFactory();
+    public static final AIntervalAscPartialBinaryComparatorFactory INSTANCE = new AIntervalAscPartialBinaryComparatorFactory();
 
-    private AIntervalPartialBinaryComparatorFactory() {
+    private AIntervalAscPartialBinaryComparatorFactory() {
 
     }
 
@@ -42,19 +42,23 @@
 
             @Override
             public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
-                int c = Double.compare(
+                // The ascending interval comparator sorts intervals first by start point, then by end point.
+                // If the interval have the same point values, the final comparison orders the intervals by type
+                // (datetime, date, time).
+                int c = Long.compare(
                         AInt64SerializerDeserializer.getLong(b1,
                                 s1 + AIntervalSerializerDeserializer.getIntervalStartOffset()),
                         AInt64SerializerDeserializer.getLong(b2,
                                 s2 + AIntervalSerializerDeserializer.getIntervalStartOffset()));
                 if (c == 0) {
-                    c = Double.compare(
+                    c = Long.compare(
                             AInt64SerializerDeserializer.getLong(b1,
                                     s1 + AIntervalSerializerDeserializer.getIntervalEndOffset()),
                             AInt64SerializerDeserializer.getLong(b2,
                                     s2 + AIntervalSerializerDeserializer.getIntervalEndOffset()));
                     if (c == 0) {
-                        c = Byte.compare(b1[s1 + 16], b2[s2 + 16]);
+                        c = Byte.compare(b1[s1 + AIntervalSerializerDeserializer.getIntervalTagOffset()], b2[s2
+                                + AIntervalSerializerDeserializer.getIntervalTagOffset()]);
                     }
                 }
                 return c;
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalDescPartialBinaryComparatorFactory.java
similarity index 67%
copy from asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java
copy to asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalDescPartialBinaryComparatorFactory.java
index f7c4428..9a09623 100644
--- a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalPartialBinaryComparatorFactory.java
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalDescPartialBinaryComparatorFactory.java
@@ -23,13 +23,13 @@
 import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
 import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
 
-public class AIntervalPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
+public class AIntervalDescPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
 
     private static final long serialVersionUID = 1L;
 
-    public static final AIntervalPartialBinaryComparatorFactory INSTANCE = new AIntervalPartialBinaryComparatorFactory();
+    public static final AIntervalDescPartialBinaryComparatorFactory INSTANCE = new AIntervalDescPartialBinaryComparatorFactory();
 
-    private AIntervalPartialBinaryComparatorFactory() {
+    private AIntervalDescPartialBinaryComparatorFactory() {
 
     }
 
@@ -42,22 +42,27 @@
 
             @Override
             public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
-                int c = Double.compare(
+                // The descending interval comparator sorts intervals first by end point, then by start point.
+                // If the interval have the same point values, the final comparison orders the intervals by type
+                // (time, date, datetime).
+                int c = Long.compare(
                         AInt64SerializerDeserializer.getLong(b1,
-                                s1 + AIntervalSerializerDeserializer.getIntervalStartOffset()),
+                                s1 + AIntervalSerializerDeserializer.getIntervalEndOffset()),
                         AInt64SerializerDeserializer.getLong(b2,
-                                s2 + AIntervalSerializerDeserializer.getIntervalStartOffset()));
+                                s2 + AIntervalSerializerDeserializer.getIntervalEndOffset()));
                 if (c == 0) {
-                    c = Double.compare(
+                    c = Long.compare(
                             AInt64SerializerDeserializer.getLong(b1,
-                                    s1 + AIntervalSerializerDeserializer.getIntervalEndOffset()),
+                                    s1 + AIntervalSerializerDeserializer.getIntervalStartOffset()),
                             AInt64SerializerDeserializer.getLong(b2,
-                                    s2 + AIntervalSerializerDeserializer.getIntervalEndOffset()));
+                                    s2 + AIntervalSerializerDeserializer.getIntervalStartOffset()));
                     if (c == 0) {
-                        c = Byte.compare(b1[s1 + 16], b2[s2 + 16]);
+                        c = Byte.compare(b1[s1 + AIntervalSerializerDeserializer.getIntervalTagOffset()],
+                                b2[s2 + AIntervalSerializerDeserializer.getIntervalTagOffset()]);
                     }
                 }
-                return c;
+                // Since the comparisons are based on ascending order, the result is reversed.
+                return -c;
             }
         };
     }
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
index ad3be0e..6a24cf3 100644
--- a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
@@ -89,7 +89,7 @@
             final IBinaryComparator ascDurationComp = ADurationPartialBinaryComparatorFactory.INSTANCE
                     .createBinaryComparator();
             // INTERVAL
-            final IBinaryComparator ascIntervalComp = AIntervalPartialBinaryComparatorFactory.INSTANCE
+            final IBinaryComparator ascIntervalComp = AIntervalAscPartialBinaryComparatorFactory.INSTANCE
                     .createBinaryComparator();
             // LINE
             final IBinaryComparator ascLineComp = ALinePartialBinaryComparatorFactory.INSTANCE.createBinaryComparator();
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectDescBinaryComparatorFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectDescBinaryComparatorFactory.java
index 6030908..5db1bcd 100644
--- a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectDescBinaryComparatorFactory.java
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectDescBinaryComparatorFactory.java
@@ -18,6 +18,8 @@
  */
 package org.apache.asterix.dataflow.data.nontagged.comparators;
 
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
 import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -36,8 +38,19 @@
         return new ABinaryComparator() {
             final IBinaryComparator ascComp = AObjectAscBinaryComparatorFactory.INSTANCE.createBinaryComparator();
 
+            // INTERVAL
+            // Interval asc and desc comparator factories are not the inverse of each other.
+            // Thus, we need to specify the interval desc comparator factory for descending comparisons.
+            final IBinaryComparator descIntervalComp = AIntervalDescPartialBinaryComparatorFactory.INSTANCE
+                    .createBinaryComparator();
+
             @Override
             public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
+                ATypeTag tag1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b1[s1]);
+                ATypeTag tag2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b2[s2]);
+                if (tag1 == ATypeTag.INTERVAL && tag2 == ATypeTag.INTERVAL) {
+                    return descIntervalComp.compare(b1, s1 + 1, l1 - 1, b2, s2 + 1, l2 - 1);
+                }
                 return -ascComp.compare(b1, s1, l1, b2, s2, l2);
             }
         };
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
index 767a343..77b8b3a 100644
--- a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
@@ -67,7 +67,7 @@
                     .createBinaryComparator();
             final IBinaryComparator ascDurationComp = ADurationPartialBinaryComparatorFactory.INSTANCE
                     .createBinaryComparator();
-            final IBinaryComparator ascIntervalComp = AIntervalPartialBinaryComparatorFactory.INSTANCE
+            final IBinaryComparator ascIntervalComp = AIntervalAscPartialBinaryComparatorFactory.INSTANCE
                     .createBinaryComparator();
             final IBinaryComparator ascLineComp = ALinePartialBinaryComparatorFactory.INSTANCE.createBinaryComparator();
             final IBinaryComparator ascPointComp = APointPartialBinaryComparatorFactory.INSTANCE
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
index 5d08d52..94a8917 100644
--- a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
@@ -30,6 +30,10 @@
 
     private static final long serialVersionUID = 1L;
 
+    private static final int INTERVAL_START_POINT_OFFSET = 0;
+    private static final int INTERVAL_END_POINT_OFFSET = INTERVAL_START_POINT_OFFSET + Long.BYTES;
+    private static final int INTERVAL_TAG_OFFSET = INTERVAL_END_POINT_OFFSET + Long.BYTES;
+
     public static final AIntervalSerializerDeserializer INSTANCE = new AIntervalSerializerDeserializer();
 
     private AIntervalSerializerDeserializer() {
@@ -65,11 +69,15 @@
     }
 
     public static int getIntervalStartOffset() {
-        return 0;
+        return INTERVAL_START_POINT_OFFSET;
     }
 
     public static int getIntervalEndOffset() {
-        return 8;
+        return INTERVAL_END_POINT_OFFSET;
+    }
+
+    public static int getIntervalTagOffset() {
+        return INTERVAL_TAG_OFFSET;
     }
 
     public static byte getIntervalTimeType(byte[] data, int offset) {
diff --git a/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java b/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
index 8f43a17..44851e3 100644
--- a/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
+++ b/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
@@ -23,7 +23,8 @@
 import org.apache.asterix.dataflow.data.nontagged.comparators.ABinaryComparator;
 import org.apache.asterix.dataflow.data.nontagged.comparators.ACirclePartialBinaryComparatorFactory;
 import org.apache.asterix.dataflow.data.nontagged.comparators.ADurationPartialBinaryComparatorFactory;
-import org.apache.asterix.dataflow.data.nontagged.comparators.AIntervalPartialBinaryComparatorFactory;
+import org.apache.asterix.dataflow.data.nontagged.comparators.AIntervalAscPartialBinaryComparatorFactory;
+import org.apache.asterix.dataflow.data.nontagged.comparators.AIntervalDescPartialBinaryComparatorFactory;
 import org.apache.asterix.dataflow.data.nontagged.comparators.ALinePartialBinaryComparatorFactory;
 import org.apache.asterix.dataflow.data.nontagged.comparators.AObjectAscBinaryComparatorFactory;
 import org.apache.asterix.dataflow.data.nontagged.comparators.AObjectDescBinaryComparatorFactory;
@@ -172,7 +173,7 @@
                 return addOffset(ADurationPartialBinaryComparatorFactory.INSTANCE, ascending);
             }
             case INTERVAL: {
-                return addOffset(AIntervalPartialBinaryComparatorFactory.INSTANCE, ascending);
+                return addOffset(intervalBinaryComparatorFactory(ascending), ascending);
             }
             case UUID: {
                 return addOffset(AUUIDPartialBinaryComparatorFactory.INSTANCE, ascending);
@@ -224,4 +225,14 @@
         }
     }
 
+    private IBinaryComparatorFactory intervalBinaryComparatorFactory(boolean ascending) {
+        // Intervals have separate binary comparator factories, since asc is primarily based on start point
+        // and desc is similarly based on end point.
+        if (ascending) {
+            return AIntervalAscPartialBinaryComparatorFactory.INSTANCE;
+        } else {
+            return AIntervalDescPartialBinaryComparatorFactory.INSTANCE;
+        }
+    }
+
 }
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
index 356a77b..b2a91ea 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
@@ -23,7 +23,7 @@
 import org.apache.asterix.dataflow.data.nontagged.comparators.ABinaryComparator;
 import org.apache.asterix.dataflow.data.nontagged.comparators.ACirclePartialBinaryComparatorFactory;
 import org.apache.asterix.dataflow.data.nontagged.comparators.ADurationPartialBinaryComparatorFactory;
-import org.apache.asterix.dataflow.data.nontagged.comparators.AIntervalPartialBinaryComparatorFactory;
+import org.apache.asterix.dataflow.data.nontagged.comparators.AIntervalAscPartialBinaryComparatorFactory;
 import org.apache.asterix.dataflow.data.nontagged.comparators.ALinePartialBinaryComparatorFactory;
 import org.apache.asterix.dataflow.data.nontagged.comparators.APoint3DPartialBinaryComparatorFactory;
 import org.apache.asterix.dataflow.data.nontagged.comparators.APointPartialBinaryComparatorFactory;
@@ -85,7 +85,7 @@
             .createBinaryComparator();
     protected IBinaryComparator durationBinaryComp = ADurationPartialBinaryComparatorFactory.INSTANCE
             .createBinaryComparator();
-    protected IBinaryComparator intervalBinaryComp = AIntervalPartialBinaryComparatorFactory.INSTANCE
+    protected IBinaryComparator intervalBinaryComp = AIntervalAscPartialBinaryComparatorFactory.INSTANCE
             .createBinaryComparator();
     protected IBinaryComparator lineBinaryComparator = ALinePartialBinaryComparatorFactory.INSTANCE
             .createBinaryComparator();

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/598
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I61d00850e0bc8ebc611366b95e2aa4da07d21d55
Gerrit-PatchSet: 7
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Preston Carman <prestonc@apache.org>
Gerrit-Reviewer: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Murtadha Hubail <hubailmor@gmail.com>
Gerrit-Reviewer: Preston Carman <prestonc@apache.org>
Gerrit-Reviewer: Steven Jacobs <sjaco002@ucr.edu>
Gerrit-Reviewer: Taewoo Kim <wangsaeu@gmail.com>
Gerrit-Reviewer: Till Westmann <tillw@apache.org>


Mime
View raw message