>From <[email protected]>: [email protected] has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19637 )
Change subject: [ASTERIXDB-3596][STO] Fix double comparison in range filters - user model changes: no - storage format changes: no - interface changes: no ...................................................................... [ASTERIXDB-3596][STO] Fix double comparison in range filters - user model changes: no - storage format changes: no - interface changes: no Details: When doubles are compared in range filters, denormalize it and compare as the normalization of doubles don't follow the natural order. Ext-ref: MB-66208 Change-Id: I64ebbfe3852e3521d6238314d1fe59dfd3695708 --- M asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/filter/ColumnRangeFilterBuilder.java A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.003.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.003.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double/double.003.adm A asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double-precision/double-precision.003.adm A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.002.update.sqlpp M asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GTColumnFilterEvaluatorFactory.java M asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml M asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LTColumnFilterEvaluatorFactory.java M asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LEColumnFilterEvaluatorFactory.java A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.001.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.001.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.002.update.sqlpp M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_single_partition_sqlpp.xml M asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GEColumnFilterEvaluatorFactory.java 15 files changed, 330 insertions(+), 0 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/37/19637/1 diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.001.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.001.ddl.sqlpp new file mode 100644 index 0000000..de03881 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.001.ddl.sqlpp @@ -0,0 +1,30 @@ +/* + * 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; + +USE test; + +CREATE DATASET dsUntyped PRIMARY KEY (id:string) +WITH { + "storage-format": { + "format": "column" + } +}; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.002.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.002.update.sqlpp new file mode 100644 index 0000000..6e750a4 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.002.update.sqlpp @@ -0,0 +1,39 @@ +/* + * 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 test; + +-- Closest possible values to zero that can be represented in double-precision + +INSERT INTO dsUntyped ( { 'id': "dsUntyped:0", 'c_double':double(0.0)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:1", 'c_double':double(-0.0)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:2", 'c_double':double(-4.9e-324)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:3", 'c_double':double(-9.9e-324)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:4", 'c_double':double(-1.5e-323)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:5", 'c_double':double(-2.0e-323)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:6", 'c_double':double(-2.5e-323)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:7", 'c_double':double(-3.0e-323)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:8", 'c_double':double(-4.0e-323)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:9", 'c_double':double(4.9e-324)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:10", 'c_double':double(9.9e-324)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:11", 'c_double':double(1.5e-323)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:12", 'c_double':double(2.0e-323)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:13", 'c_double':double(2.5e-323)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:14", 'c_double':double(3.0e-323)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:15", 'c_double':double(4.0e-323)} ); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.003.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.003.query.sqlpp new file mode 100644 index 0000000..9842965 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.003.query.sqlpp @@ -0,0 +1,25 @@ +/* + * 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 test; + +SELECT VALUE c_double +FROM dsUntyped +WHERE (c_double) <= double(1.5e-323) ORDER BY c_double; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.001.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.001.ddl.sqlpp new file mode 100644 index 0000000..de03881 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.001.ddl.sqlpp @@ -0,0 +1,30 @@ +/* + * 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; + +USE test; + +CREATE DATASET dsUntyped PRIMARY KEY (id:string) +WITH { + "storage-format": { + "format": "column" + } +}; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.002.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.002.update.sqlpp new file mode 100644 index 0000000..0277980 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.002.update.sqlpp @@ -0,0 +1,86 @@ +/* + * 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 test; + +INSERT INTO dsUntyped ( { 'id': "dsUntyped:0", 'c_double':double(-3.5)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:1", 'c_double':double(-3.375)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:2", 'c_double':double(-3.25)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:3", 'c_double':double(-3.125)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:4", 'c_double':double(-3.0)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:5", 'c_double':double(-2.875)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:6", 'c_double':double(-2.75)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:7", 'c_double':double(-2.625)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:8", 'c_double':null} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:9", 'c_double':double(-2.5)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:10", 'c_double':double(-2.375)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:11", 'c_double':double(-2.25)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:12", 'c_double':double(-2.125)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:13", 'c_double':double(-2.0)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:14", 'c_double':double(-1.875)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:15", 'c_double':double(-1.75)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:16", 'c_double':double('INF')} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:17", 'c_double':double(-1.625)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:18", 'c_double':double(-1.5)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:19", 'c_double':double(-1.375)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:20", 'c_double':double(-1.25)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:21", 'c_double':double(-1.125)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:22", 'c_double':double(-1.0)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:23", 'c_double':double(-0.875)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:24", 'c_double':double('-INF')} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:25", 'c_double':double(-0.75)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:26", 'c_double':double(-0.625)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:27", 'c_double':double(-0.5)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:28", 'c_double':double(-0.375)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:29", 'c_double':double(-0.25)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:30", 'c_double':double(-0.125)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:31", 'c_double':double(0.0)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:32", 'c_double':null} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:33", 'c_double':double(0.125)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:34", 'c_double':double(0.25)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:35", 'c_double':double(0.375)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:36", 'c_double':double(0.5)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:37", 'c_double':double(0.625)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:38", 'c_double':double(0.75)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:39", 'c_double':double(0.875)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:40", 'c_double':double('INF')} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:41", 'c_double':double(1.0)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:42", 'c_double':double(1.125)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:43", 'c_double':double(1.25)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:44", 'c_double':double(1.375)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:45", 'c_double':double(1.5)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:46", 'c_double':double(1.625)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:47", 'c_double':double(1.75)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:48", 'c_double':double('-INF')} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:49", 'c_double':double(1.875)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:50", 'c_double':double(2.0)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:51", 'c_double':double(2.125)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:52", 'c_double':double(2.25)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:53", 'c_double':double(2.375)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:54", 'c_double':double(2.5)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:55", 'c_double':double(2.625)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:56", 'c_double':null} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:57", 'c_double':double(2.75)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:58", 'c_double':double(2.875)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:59", 'c_double':double(3.0)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:60", 'c_double':double(3.125)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:61", 'c_double':double(3.25)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:62", 'c_double':double(3.375)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:63", 'c_double':double(3.5)} ); +INSERT INTO dsUntyped ( { 'id': "dsUntyped:64", 'c_double':double('INF')} ); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.003.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.003.query.sqlpp new file mode 100644 index 0000000..da3519d --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.003.query.sqlpp @@ -0,0 +1,25 @@ +/* + * 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 test; + +SELECT VALUE c_double +FROM dsUntyped +WHERE (c_double) <= double(-3.5) ORDER BY c_double; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double-precision/double-precision.003.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double-precision/double-precision.003.adm new file mode 100644 index 0000000..6d7c209 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double-precision/double-precision.003.adm @@ -0,0 +1,12 @@ +-4.0E-323 +-3.0E-323 +-2.5E-323 +-2.0E-323 +-1.5E-323 +-9.9E-324 +-4.9E-324 +-0.0 +0.0 +4.9E-324 +9.9E-324 +1.5E-323 diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double/double.003.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double/double.003.adm new file mode 100644 index 0000000..b32e800 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double/double.003.adm @@ -0,0 +1,3 @@ +-INF +-INF +-3.5 \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml index ac237d5..10e8302 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml @@ -16557,6 +16557,16 @@ </compilation-unit> </test-case> <test-case FilePath="column"> + <compilation-unit name="filter/double"> + <output-dir compare="Text">filter/double</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="column"> + <compilation-unit name="filter/double-precision"> + <output-dir compare="Text">filter/double-precision</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="column"> <compilation-unit name="delete/001"> <output-dir compare="Text">delete/001</output-dir> </compilation-unit> diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_single_partition_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_single_partition_sqlpp.xml index dc35948..d2fb6c1 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_single_partition_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_single_partition_sqlpp.xml @@ -95,6 +95,16 @@ </compilation-unit> </test-case> <test-case FilePath="column"> + <compilation-unit name="filter/double"> + <output-dir compare="Text">filter/double</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="column"> + <compilation-unit name="filter/double-precision"> + <output-dir compare="Text">filter/double-precision</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="column"> <compilation-unit name="delete/001"> <output-dir compare="Text">delete/001</output-dir> </compilation-unit> diff --git a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GEColumnFilterEvaluatorFactory.java b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GEColumnFilterEvaluatorFactory.java index 0edee65..3eee8ba 100644 --- a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GEColumnFilterEvaluatorFactory.java +++ b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GEColumnFilterEvaluatorFactory.java @@ -21,6 +21,7 @@ import org.apache.asterix.column.filter.IColumnFilterEvaluator; import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessor; import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessorFactory; +import org.apache.asterix.om.types.ATypeTag; public class GEColumnFilterEvaluatorFactory extends AbstractColumnFilterComparatorFactory { private static final long serialVersionUID = 6879193736347174789L; @@ -36,6 +37,14 @@ return new AbstractComparator(left, right) { @Override public boolean evaluate() { + if (left.getTypeTag() != right.getTypeTag()) { + throw new IllegalStateException("Cannot compare different types %s and %s" + .formatted(left.getTypeTag(), right.getTypeTag())); + } + if (left.getTypeTag() == ATypeTag.DOUBLE) { + return Double.longBitsToDouble(left.getNormalizedValue()) >= Double + .longBitsToDouble(right.getNormalizedValue()); + } return left.getNormalizedValue() >= right.getNormalizedValue(); } }; diff --git a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GTColumnFilterEvaluatorFactory.java b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GTColumnFilterEvaluatorFactory.java index 7a21bd1..c951b0d 100644 --- a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GTColumnFilterEvaluatorFactory.java +++ b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GTColumnFilterEvaluatorFactory.java @@ -21,6 +21,7 @@ import org.apache.asterix.column.filter.IColumnFilterEvaluator; import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessor; import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessorFactory; +import org.apache.asterix.om.types.ATypeTag; public class GTColumnFilterEvaluatorFactory extends AbstractColumnFilterComparatorFactory { private static final long serialVersionUID = -3104103170926445020L; @@ -36,6 +37,14 @@ return new AbstractComparator(left, right) { @Override public boolean evaluate() { + if (left.getTypeTag() != right.getTypeTag()) { + throw new IllegalStateException("Cannot compare different types %s and %s" + .formatted(left.getTypeTag(), right.getTypeTag())); + } + if (left.getTypeTag() == ATypeTag.DOUBLE) { + return Double.longBitsToDouble(left.getNormalizedValue()) > Double + .longBitsToDouble(right.getNormalizedValue()); + } return left.getNormalizedValue() > right.getNormalizedValue(); } }; diff --git a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LEColumnFilterEvaluatorFactory.java b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LEColumnFilterEvaluatorFactory.java index 7cef6ab..5336aff 100644 --- a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LEColumnFilterEvaluatorFactory.java +++ b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LEColumnFilterEvaluatorFactory.java @@ -21,6 +21,7 @@ import org.apache.asterix.column.filter.IColumnFilterEvaluator; import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessor; import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessorFactory; +import org.apache.asterix.om.types.ATypeTag; public class LEColumnFilterEvaluatorFactory extends AbstractColumnFilterComparatorFactory { private static final long serialVersionUID = 1068661809768620550L; @@ -36,6 +37,14 @@ return new AbstractComparator(left, right) { @Override public boolean evaluate() { + if (left.getTypeTag() != right.getTypeTag()) { + throw new IllegalStateException("Cannot compare different types %s and %s" + .formatted(left.getTypeTag(), right.getTypeTag())); + } + if (left.getTypeTag() == ATypeTag.DOUBLE) { + return Double.longBitsToDouble(left.getNormalizedValue()) <= Double + .longBitsToDouble(right.getNormalizedValue()); + } return left.getNormalizedValue() <= right.getNormalizedValue(); } }; diff --git a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LTColumnFilterEvaluatorFactory.java b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LTColumnFilterEvaluatorFactory.java index 2848d57..d40a685 100644 --- a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LTColumnFilterEvaluatorFactory.java +++ b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LTColumnFilterEvaluatorFactory.java @@ -21,6 +21,7 @@ import org.apache.asterix.column.filter.IColumnFilterEvaluator; import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessor; import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessorFactory; +import org.apache.asterix.om.types.ATypeTag; public class LTColumnFilterEvaluatorFactory extends AbstractColumnFilterComparatorFactory { private static final long serialVersionUID = -4066709771630858677L; @@ -36,6 +37,14 @@ return new AbstractComparator(left, right) { @Override public boolean evaluate() { + if (left.getTypeTag() != right.getTypeTag()) { + throw new IllegalStateException("Cannot compare different types %s and %s" + .formatted(left.getTypeTag(), right.getTypeTag())); + } + if (left.getTypeTag() == ATypeTag.DOUBLE) { + return Double.longBitsToDouble(left.getNormalizedValue()) < Double + .longBitsToDouble(right.getNormalizedValue()); + } return left.getNormalizedValue() < right.getNormalizedValue(); } }; diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/filter/ColumnRangeFilterBuilder.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/filter/ColumnRangeFilterBuilder.java index 894394e..c77ca57 100644 --- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/filter/ColumnRangeFilterBuilder.java +++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/filter/ColumnRangeFilterBuilder.java @@ -194,6 +194,14 @@ private static IColumnRangeFilterEvaluatorFactory createEvaluator(ComparisonKind comparisonKind, IColumnRangeFilterValueAccessorFactory min, IColumnRangeFilterValueAccessorFactory constVal, IColumnRangeFilterValueAccessorFactory max) { + + /* + * For a filter condition of the form col < const, the page will be read only if const >= min(col). + * Similarly, for col <= const, the page will be read only if const > min(col). + * for col > const, the page will be read only if const < max(col). + * for col >= const, the page will be read only if const <= max(col). + * */ + if (comparisonKind == ComparisonKind.LT) { return new GTColumnFilterEvaluatorFactory(constVal, min); } else if (comparisonKind == ComparisonKind.LE) { -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19637 To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: ionic Gerrit-Change-Id: I64ebbfe3852e3521d6238314d1fe59dfd3695708 Gerrit-Change-Number: 19637 Gerrit-PatchSet: 1 Gerrit-Owner: [email protected] Gerrit-MessageType: newchange
