You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2021/09/09 14:11:25 UTC

[sis] branch geoapi-4.0 updated (bc2b551 -> fa65ecf)

This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git.


    from bc2b551  Update for change in GeoAPI: parameterize `SortBy` and `SortProperty`. Use `SortBy` instead of `SortProperty[]` where appropriate.
     new 982b713  Generalize `SortByComparator`.
     new 3b0f5c0  Filter implementations override Predicate.and/or/not methods.
     new fa65ecf  Move Query sub-types to public package.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/sis/filter/BinaryGeometryFilter.java    |   3 +-
 .../org/apache/sis/filter/ComparisonFilter.java    |   3 +-
 .../apache/sis/filter/DefaultFilterFactory.java    |  32 ++++
 .../java/org/apache/sis/filter/FilterNode.java     |  90 +++++++++
 .../org/apache/sis/filter/IdentifierFilter.java    |   3 +-
 .../java/org/apache/sis/filter/LikeFilter.java     |   3 +-
 .../java/org/apache/sis/filter/LogicalFilter.java  |  25 ++-
 .../java/org/apache/sis/filter/Optimization.java   |  50 +++++
 .../sis/internal/filter/SortByComparator.java      | 206 +++++++++++++++++++++
 .../org/apache/sis/filter/LogicalFilterTest.java   |  10 +
 .../org/apache/sis/internal/map/SEPortrayer.java   |   2 +-
 .../apache/sis/internal/map/SEPortrayerTest.java   |   2 +-
 .../sis/internal/sql/feature/FeatureStream.java    |  11 +-
 .../org/apache/sis/storage/sql/SQLStoreTest.java   |   2 +-
 .../sis/internal/storage/JoinFeatureSet.java       |   2 +-
 .../internal/storage/query/SortByComparator.java   | 100 ----------
 .../sis/internal/storage/query/package-info.java   |  32 ----
 .../storage/query => storage}/CoverageQuery.java   |  28 ++-
 .../storage/query => storage}/CoverageSubset.java  |   6 +-
 .../storage/query => storage}/FeatureQuery.java    | 145 ++++++++++-----
 .../java/org/apache/sis/storage/FeatureSet.java    |   1 -
 .../storage/query => storage}/FeatureSubset.java   |  21 +--
 .../apache/sis/storage/GridCoverageResource.java   |   1 -
 .../main/java/org/apache/sis/storage/Query.java    |   5 +-
 .../query => storage}/CoverageQueryTest.java       |   4 +-
 .../FeatureQueryTest.java}                         |   8 +-
 .../query => storage}/GridResourceMock.java        |   2 +-
 .../apache/sis/test/suite/StorageTestSuite.java    |   4 +-
 28 files changed, 558 insertions(+), 243 deletions(-)
 create mode 100644 core/sis-feature/src/main/java/org/apache/sis/filter/FilterNode.java
 create mode 100644 core/sis-feature/src/main/java/org/apache/sis/internal/filter/SortByComparator.java
 delete mode 100644 storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SortByComparator.java
 delete mode 100644 storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/package-info.java
 rename storage/sis-storage/src/main/java/org/apache/sis/{internal/storage/query => storage}/CoverageQuery.java (90%)
 rename storage/sis-storage/src/main/java/org/apache/sis/{internal/storage/query => storage}/CoverageSubset.java (97%)
 rename storage/sis-storage/src/main/java/org/apache/sis/{internal/storage/query => storage}/FeatureQuery.java (80%)
 rename storage/sis-storage/src/main/java/org/apache/sis/{internal/storage/query => storage}/FeatureSubset.java (89%)
 rename storage/sis-storage/src/test/java/org/apache/sis/{internal/storage/query => storage}/CoverageQueryTest.java (97%)
 rename storage/sis-storage/src/test/java/org/apache/sis/{internal/storage/query/SimpleQueryTest.java => storage/FeatureQueryTest.java} (97%)
 rename storage/sis-storage/src/test/java/org/apache/sis/{internal/storage/query => storage}/GridResourceMock.java (98%)

[sis] 01/03: Generalize `SortByComparator`.

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 982b7136345f6bf7cfa0b271eb9299e42b16b07a
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu Sep 9 10:38:42 2021 +0200

    Generalize `SortByComparator`.
---
 .../sis/internal/sql/feature/FeatureStream.java    |   9 +-
 .../sis/internal/storage/query/FeatureQuery.java   |   4 +-
 .../internal/storage/query/SortByComparator.java   | 148 ++++++++++++++++++---
 3 files changed, 132 insertions(+), 29 deletions(-)

diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureStream.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureStream.java
index f7f734d..af89400 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureStream.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureStream.java
@@ -243,12 +243,9 @@ final class FeatureStream extends DeferredStream<Feature> {
         if (isPagined() || hasComparator) {
             return delegate().sorted(comparator);
         }
-        if (sort == null && comparator instanceof SortBy<?>) {
-            sort = (SortBy<? super Feature>) comparator;
-            return this;
-        }
-        if (sort instanceof SortByComparator && comparator instanceof SortByComparator) {
-            sort = new SortByComparator((SortByComparator) sort, (SortByComparator) comparator);
+        final SortBy<? super Feature> c = SortByComparator.concatenate(sort, comparator);
+        if (c != null) {
+            sort = c;
             return this;
         }
         hasComparator = true;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureQuery.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureQuery.java
index 32926a5..67baf3b 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureQuery.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureQuery.java
@@ -254,8 +254,8 @@ public class FeatureQuery extends Query implements Cloneable {
     @SafeVarargs
     public final void setSortBy(final SortProperty<Feature>... properties) {
         SortBy<Feature> sortBy = null;
-        if (properties != null && properties.length != 0) {
-            sortBy = new SortByComparator(properties);
+        if (properties != null) {
+            sortBy = SortByComparator.create(properties);
         }
         setSortBy(sortBy);
     }
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SortByComparator.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SortByComparator.java
index 6d4a010..37aeaee 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SortByComparator.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SortByComparator.java
@@ -16,31 +16,34 @@
  */
 package org.apache.sis.internal.storage.query;
 
+import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
+import java.util.LinkedHashMap;
+import java.util.Comparator;
 import java.io.Serializable;
-import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 
 // Branch-dependent imports
-import org.opengis.feature.Feature;
 import org.opengis.filter.SortBy;
 import org.opengis.filter.SortProperty;
+import org.opengis.filter.ValueReference;
 
 
 /**
  * Comparator sorting features using an array of {@link SortProperty} elements applied in order.
- * This is restricted to comparator of {@link Feature} instances for now because this is the only
- * comparator that we currently need, and it makes {@linkplain #SortByComparator(SortByComparator,
- * SortByComparator) concatenations} type-safe. We may generalize in the future if needed.
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
- * @since   1.0
+ *
+ * @param  <R>  the type of resources (typically {@code Feature}) to sort.
+ *
+ * @since 1.0
  * @module
  */
-public final class SortByComparator implements SortBy<Feature>, Serializable {
+public final class SortByComparator<R> implements SortBy<R>, Serializable {
     /**
      * For cross-version compatibility.
      */
@@ -51,28 +54,109 @@ public final class SortByComparator implements SortBy<Feature>, Serializable {
      *
      * @see #getSortProperties()
      */
-    private final SortProperty<Feature>[] properties;
+    private final SortProperty<R>[] properties;
+
+    /**
+     * Creates a new comparator for the given sort expression.
+     * This is shortcut for the common case where there is a single expression.
+     *
+     * @param  p  the property to wrap in a {@link SortBy} comparator.
+     */
+    @SuppressWarnings({"unchecked","rawtypes"})             // Generic array creation.
+    private SortByComparator(final SortProperty<R> p) {
+        ArgumentChecks.ensureNonNullElement("properties", 0, p);
+        properties = new SortProperty[] {p};
+    }
+
+    /**
+     * Creates a new comparator with the values of given map.
+     * The map is used for removing duplicated expressions.
+     */
+    @SuppressWarnings({"unchecked","rawtypes"})             // Generic array creation.
+    private SortByComparator(final Map<?, SortProperty<R>> merged) {
+        properties = merged.values().toArray(new SortProperty[merged.size()]);
+    }
 
     /**
      * Creates a new comparator for the given sort expressions.
-     * It is caller responsibility to ensure that the given array is non-empty.
+     *
+     * @param  <R>         the type of resources (typically {@code Feature}) to sort.
+     * @param  properties  the sort order.
+     * @return the comparator, or {@code null} if the given array is empty.
+     */
+    public static <R> SortByComparator<R> create(final SortProperty<R>[] properties) {
+        switch (properties.length) {
+            case 0: return null;
+            case 1: return new SortByComparator<>(properties[0]);
+        }
+        final Map<ValueReference<? super R, ?>, SortProperty<R>> merged = new LinkedHashMap<>();
+        addAll(Arrays.asList(properties), merged);
+        return new SortByComparator<>(merged);
+    }
+
+    /**
+     * Creates a new comparator as the concatenation of the two given comparators.
+     * The first comparator is used first, and if two resources are equal then the
+     * second comparator is used.
+     *
+     * @param  <R>         the type of resources (typically {@code Feature}) to sort.
+     * @param  sort        the first "sort by" to use, or {@code null} if none.
+     * @param  comparator  the second "sort by" to use.
+     * @return concatenation of the two comparators.
      */
-    SortByComparator(SortProperty<Feature>[] properties) {
-        properties = properties.clone();
-        this.properties = properties;
-        for (int i=0; i < properties.length; i++) {
-            ArgumentChecks.ensureNonNullElement("properties", i, properties[i]);
+    @SuppressWarnings("unchecked")
+    public static <R> SortBy<? super R> concatenate(final SortBy<? super R> sort, final Comparator<? super R> comparator) {
+        final SortBy<? super R> other;
+        if (comparator instanceof SortBy<?>) {
+            other = (SortBy<? super R>) comparator;
+        } else if (comparator instanceof SortProperty<?>) {
+            other = new SortByComparator<>((SortProperty<? super R>) comparator);
+        } else {
+            return null;
+        }
+        if (sort == null) {
+            return other;
         }
+        /*
+         * The (SortBy<R>) casts are unsafe — they should be (SortBy<? super R>) — but are okay in this context
+         * because we create a `SortByComparator` which will only "push" instances of R to the comparators.
+         * There is no code that "pull" instances of R from the comparators, consequently no code that may
+         * be surprised to get an instance of a super type of R instead of R.
+         */
+        return concatenate((SortBy<R>) sort, (SortBy<R>) other);
     }
 
     /**
      * Creates a new comparator as the concatenation of the two given comparators.
+     * The first comparator is used first, and if two resources are equal then the
+     * second comparator is used.
      *
-     * @param  s1  the first "sort by" to concatenate.
-     * @param  s2  the second "sort by" to concatenate.
+     * @param  <R>  the type of resources (typically {@code Feature}) to sort.
+     * @param  s1   the first "sort by" to use.
+     * @param  s2   the second "sort by" to use.
+     * @return concatenation of the two comparators.
+     */
+    public static <R> SortBy<R> concatenate(final SortBy<R> s1, final SortBy<R> s2) {
+        final Map<ValueReference<? super R, ?>, SortProperty<R>> merged = new LinkedHashMap<>();
+        addAll(s1.getSortProperties(), merged);
+        addAll(s2.getSortProperties(), merged);
+        return new SortByComparator<>(merged);
+    }
+
+    /**
+     * Adds all elements of the {@code properties} list into the {@code merged} map.
+     * If two {@code SortProperty} instances use the same {@link ValueReference},
+     * then only the first occurrence is retained.
      */
-    public SortByComparator(final SortByComparator s1, final SortByComparator s2) {
-        properties = ArraysExt.concatenate(s1.properties, s2.properties);
+    private static <R> void addAll(final List<SortProperty<R>> properties,
+            final Map<ValueReference<? super R, ?>, SortProperty<R>> merged)
+    {
+        final int size = properties.size();
+        for (int i=0; i<size; i++) {
+            final SortProperty<R> p = properties.get(i);
+            ArgumentChecks.ensureNonNullElement("properties", i, p);
+            merged.putIfAbsent(p.getValueReference(), p);
+        }
     }
 
     /**
@@ -80,7 +164,7 @@ public final class SortByComparator implements SortBy<Feature>, Serializable {
      * The list shall have a minimum of one element.
      */
     @Override
-    public List<SortProperty<Feature>> getSortProperties() {
+    public List<SortProperty<R>> getSortProperties() {
         return UnmodifiableArrayList.wrap(properties);
     }
 
@@ -90,11 +174,33 @@ public final class SortByComparator implements SortBy<Feature>, Serializable {
      * The ordering of null resources or null property values is unspecified.
      */
     @Override
-    public int compare(final Feature r1, final Feature r2) {
-        for (final SortProperty<Feature> p : properties) {
+    public int compare(final R r1, final R r2) {
+        for (final SortProperty<R> p : properties) {
             final int c = p.compare(r1, r2);
             if (c != 0) return c;
         }
         return 0;
     }
+
+    /**
+     * Returns a comparator as the concatenation of this comparator with the given one.
+     * This comparator is used first, and if two resources are equal then the other comparator is used.
+     *
+     * @param  other  the other comparator to be used when this comparator considers two resources as equal.
+     * @return concatenation of this comparator with the given one.
+     */
+    @Override
+    @SuppressWarnings("unchecked")
+    public Comparator<R> thenComparing​(final Comparator<? super R> other) {
+        if (other instanceof SortBy<?>) {
+            /*
+             * The (SortBy<R>) cast is unsafe — it should be (SortBy<? super R>) — but it is okay in this context
+             * because we create a `SortByComparator` which will only "push" instances of R to the `other` comparator.
+             * There is no code that "pull" instances of R from the `other` comparator, consequently no code that may
+             * be surprised to get an instance of a super type of R instead of R.
+             */
+            return concatenate(this, (SortBy<R>) other);
+        }
+        return SortBy.super.thenComparing​(other);
+    }
 }

[sis] 02/03: Filter implementations override Predicate.and/or/not methods.

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 3b0f5c0e9303cd2d08f623e192c1a91f3a3a8751
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu Sep 9 12:38:36 2021 +0200

    Filter implementations override Predicate.and/or/not methods.
---
 .../apache/sis/filter/BinaryGeometryFilter.java    |  3 +-
 .../org/apache/sis/filter/ComparisonFilter.java    |  3 +-
 .../apache/sis/filter/DefaultFilterFactory.java    | 32 ++++++++
 .../java/org/apache/sis/filter/FilterNode.java     | 90 ++++++++++++++++++++++
 .../org/apache/sis/filter/IdentifierFilter.java    |  3 +-
 .../java/org/apache/sis/filter/LikeFilter.java     |  3 +-
 .../java/org/apache/sis/filter/LogicalFilter.java  | 25 +++++-
 .../java/org/apache/sis/filter/Optimization.java   | 50 ++++++++++++
 .../org/apache/sis/filter/LogicalFilterTest.java   | 10 +++
 9 files changed, 208 insertions(+), 11 deletions(-)

diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/BinaryGeometryFilter.java b/core/sis-feature/src/main/java/org/apache/sis/filter/BinaryGeometryFilter.java
index e1afc00..cd60f3f 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/filter/BinaryGeometryFilter.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/BinaryGeometryFilter.java
@@ -27,7 +27,6 @@ import org.apache.sis.internal.feature.Geometries;
 import org.apache.sis.internal.feature.GeometryWrapper;
 import org.apache.sis.internal.feature.SpatialOperationContext;
 import org.apache.sis.internal.feature.AttributeConvention;
-import org.apache.sis.internal.filter.Node;
 import org.apache.sis.util.ArgumentChecks;
 
 // Branch-dependent imports
@@ -58,7 +57,7 @@ import org.opengis.feature.PropertyNotFoundException;
  * @since 1.1
  * @module
  */
-abstract class BinaryGeometryFilter<R,G> extends Node implements SpatialOperator<R>, Optimization.OnFilter<R> {
+abstract class BinaryGeometryFilter<R,G> extends FilterNode<R> implements SpatialOperator<R>, Optimization.OnFilter<R> {
     /**
      * For cross-version compatibility.
      */
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/ComparisonFilter.java b/core/sis-feature/src/main/java/org/apache/sis/filter/ComparisonFilter.java
index 76d4a0b..b6a8f0a 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/filter/ComparisonFilter.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/ComparisonFilter.java
@@ -35,7 +35,6 @@ import java.time.chrono.ChronoLocalDateTime;
 import java.time.chrono.ChronoZonedDateTime;
 import java.time.temporal.ChronoField;
 import java.time.temporal.Temporal;
-import org.apache.sis.internal.filter.Node;
 import org.apache.sis.math.Fraction;
 import org.apache.sis.util.ArgumentChecks;
 
@@ -786,7 +785,7 @@ abstract class ComparisonFilter<R> extends BinaryFunction<R,Object,Object>
      *
      * @see org.apache.sis.filter.LogicalFilter.And
      */
-    static final class Between<R> extends Node implements BetweenComparisonOperator<R> {
+    static final class Between<R> extends FilterNode<R> implements BetweenComparisonOperator<R> {
         /** For cross-version compatibility during (de)serialization. */
         private static final long serialVersionUID = -2434954008425799595L;
 
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
index 029eb4e..f028cb8 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
@@ -430,6 +430,22 @@ public abstract class DefaultFilterFactory<R,G,T> extends AbstractFactory implem
     }
 
     /**
+     * Creates a {@code AND} filter between two filters.
+     *
+     * @param  operand1  the first operand of the AND operation.
+     * @param  operand2  the second operand of the AND operation.
+     * @return a filter evaluating {@code operand1 AND operand2}.
+     *
+     * @see LogicalOperatorName#AND
+     */
+    @Override
+    public LogicalOperator<R> and(final Filter<? super R> operand1, final Filter<? super R> operand2) {
+        ArgumentChecks.ensureNonNull("operand1", operand1);
+        ArgumentChecks.ensureNonNull("operand2", operand2);
+        return new LogicalFilter.And<>(operand1, operand2);
+    }
+
+    /**
      * Creates a {@code AND} filter between two or more filters.
      *
      * @param  operands  a collection of at least 2 operands.
@@ -444,6 +460,22 @@ public abstract class DefaultFilterFactory<R,G,T> extends AbstractFactory implem
     }
 
     /**
+     * Creates a {@code OR} filter between two filters.
+     *
+     * @param  operand1  the first operand of the OR operation.
+     * @param  operand2  the second operand of the OR operation.
+     * @return a filter evaluating {@code operand1 OR operand2}.
+     *
+     * @see LogicalOperatorName#OR
+     */
+    @Override
+    public LogicalOperator<R> or(final Filter<? super R> operand1, final Filter<? super R> operand2) {
+        ArgumentChecks.ensureNonNull("operand1", operand1);
+        ArgumentChecks.ensureNonNull("operand2", operand2);
+        return new LogicalFilter.Or<>(operand1, operand2);
+    }
+
+    /**
      * Creates a {@code OR} filter between two or more filters.
      *
      * @param  operands  a collection of at least 2 operands.
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/FilterNode.java b/core/sis-feature/src/main/java/org/apache/sis/filter/FilterNode.java
new file mode 100644
index 0000000..8a1186a
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/FilterNode.java
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+package org.apache.sis.filter;
+
+import java.util.function.Predicate;
+import org.apache.sis.internal.filter.Node;
+
+// Branch-dependent imports
+import org.opengis.filter.Filter;
+
+
+/**
+ * Base class of some (not all) nodes that are filters. This base class overrides {@link Predicate}
+ * methods for building other {@link Filter} objects instead than default Java implementations that
+ * Apache SIS can not recognize.
+ *
+ * <p><b>Note:</b> this class duplicates the method definition in {@link Optimization.OnFilter}.
+ * This duplication exists because not all filter implementations extends this class, and not all
+ * implementations implement the {@link Optimization.OnFilter} interface.</p>
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.1
+ *
+ * @param  <R>  the type of resources (e.g. {@link org.opengis.feature.Feature}) used as inputs.
+ *
+ * @since 1.1
+ * @module
+ */
+abstract class FilterNode<R> extends Node implements Filter<R> {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -1272149643938168189L;
+
+    /**
+     * Creates a new node.
+     */
+    FilterNode() {
+    }
+
+    /**
+     * Returns the {@code AND} logical operation between this filter and the given predicate.
+     * This method duplicates the {@link Optimization.OnFilter#and(Predicate)} method, but is
+     * defined because not all subclasses implement the {@code Optimization} inner interface.
+     */
+    @Override
+    public final Predicate<R> and(final Predicate<? super R> other) {
+        if (other instanceof Filter<?>) {
+            return new LogicalFilter.And<>(this, (Filter<? super R>) other);
+        } else {
+            return Filter.super.and(other);
+        }
+    }
+
+    /**
+     * Returns the {@code OR} logical operation between this filter and the given predicate.
+     * This method duplicates the {@link Optimization.OnFilter#or(Predicate)} method, but is
+     * defined because not all subclasses implement the {@code Optimization} inner interface.
+     */
+    @Override
+    public final Predicate<R> or(final Predicate<? super R> other) {
+        if (other instanceof Filter<?>) {
+            return new LogicalFilter.Or<>(this, (Filter<? super R>) other);
+        } else {
+            return Filter.super.and(other);
+        }
+    }
+
+    /**
+     * Returns the logical negation of this filter.
+     */
+    @Override
+    public final Predicate<R> negate() {
+        return new LogicalFilter.Not<>(this);
+    }
+}
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/IdentifierFilter.java b/core/sis-feature/src/main/java/org/apache/sis/filter/IdentifierFilter.java
index 96b87dd..74b4c65 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/filter/IdentifierFilter.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/IdentifierFilter.java
@@ -20,7 +20,6 @@ import java.util.List;
 import java.util.Collection;
 import java.util.Collections;
 import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.internal.filter.Node;
 import org.apache.sis.internal.feature.AttributeConvention;
 
 // Branch-dependent imports
@@ -42,7 +41,7 @@ import org.opengis.filter.ResourceId;
  * @since 1.1
  * @module
  */
-final class IdentifierFilter<R extends Feature> extends Node implements ResourceId<R> {
+final class IdentifierFilter<R extends Feature> extends FilterNode<R> implements ResourceId<R> {
     /**
      * For cross-version compatibility.
      */
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/LikeFilter.java b/core/sis-feature/src/main/java/org/apache/sis/filter/LikeFilter.java
index 019b264..96c335c 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/filter/LikeFilter.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/LikeFilter.java
@@ -20,7 +20,6 @@ import java.util.List;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.regex.Pattern;
-import org.apache.sis.internal.filter.Node;
 import org.apache.sis.util.ArgumentChecks;
 
 // Branch-dependent imports
@@ -41,7 +40,7 @@ import org.opengis.filter.LikeOperator;
  * @since 1.1
  * @module
  */
-final class LikeFilter<R> extends Node implements LikeOperator<R>, Optimization.OnFilter<R> {
+final class LikeFilter<R> extends FilterNode<R> implements LikeOperator<R>, Optimization.OnFilter<R> {
     /**
      * For cross-version compatibility.
      */
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/LogicalFilter.java b/core/sis-feature/src/main/java/org/apache/sis/filter/LogicalFilter.java
index ef2b878..fe849e4 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/filter/LogicalFilter.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/LogicalFilter.java
@@ -21,7 +21,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedHashSet;
 import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.internal.filter.Node;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.util.resources.Errors;
@@ -45,7 +44,7 @@ import org.opengis.filter.LogicalOperatorName;
  * @since 1.1
  * @module
  */
-abstract class LogicalFilter<R> extends Node implements LogicalOperator<R>, Optimization.OnFilter<R> {
+abstract class LogicalFilter<R> extends FilterNode<R> implements LogicalOperator<R>, Optimization.OnFilter<R> {
     /**
      * For cross-version compatibility.
      */
@@ -74,6 +73,16 @@ abstract class LogicalFilter<R> extends Node implements LogicalOperator<R>, Opti
     }
 
     /**
+     * Creates a new logical operator with the two given operands.
+     * This method does not verify if the operands are non-null;
+     * this check should be already done by the caller.
+     */
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    LogicalFilter(final Filter<? super R> operand1, final Filter<? super R> operand2) {
+        operands = new Filter[] {operand1, operand2};
+    }
+
+    /**
      * Creates a new logical operator of the same kind than this operator.
      *
      * @param  op  operands of the new operator.
@@ -111,6 +120,11 @@ abstract class LogicalFilter<R> extends Node implements LogicalOperator<R>, Opti
             super(op);
         }
 
+        /** Creates a new operator for the two given operands. */
+        And(final Filter<? super R> operand1, final Filter<? super R> operand2) {
+            super(operand1, operand2);
+        }
+
         /** Creates a new logical operator of the same kind than this operator. */
         @Override protected LogicalFilter<R> createSameType(Collection<? extends Filter<? super R>> op) {
             return new And<>(op);
@@ -155,6 +169,11 @@ abstract class LogicalFilter<R> extends Node implements LogicalOperator<R>, Opti
             super(op);
         }
 
+        /** Creates a new operator for the two given operands. */
+        Or(final Filter<? super R> operand1, final Filter<? super R> operand2) {
+            super(operand1, operand2);
+        }
+
         /** Creates a new logical operator of the same kind than this operator. */
         @Override protected LogicalFilter<R> createSameType(Collection<? extends Filter<? super R>> op) {
             return new Or<>(op);
@@ -190,7 +209,7 @@ abstract class LogicalFilter<R> extends Node implements LogicalOperator<R>, Opti
     /**
      * The negation filter (¬).
      */
-    static final class Not<R> extends Node implements LogicalOperator<R>, Optimization.OnFilter<R> {
+    static final class Not<R> extends FilterNode<R> implements LogicalOperator<R>, Optimization.OnFilter<R> {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = -1296823195138427781L;
 
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/Optimization.java b/core/sis-feature/src/main/java/org/apache/sis/filter/Optimization.java
index 2ea41df..ccd3fd7 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/filter/Optimization.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/Optimization.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.IdentityHashMap;
 import java.util.ConcurrentModificationException;
+import java.util.function.Predicate;
 import org.opengis.util.CodeList;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.CollectionsExt;
@@ -230,6 +231,55 @@ public class Optimization {
         default Filter<R> recreate(Expression<? super R, ?>[] effective) {
             return this;
         }
+
+        /**
+         * Returns the {@code AND} logical operation between this filter and the given predicate.
+         * If the given predicate is an instance of {@link Filter}, then the returned predicate
+         * is an instance of {@code Optimization.OnFilter}.
+         *
+         * @param  other  the other predicate.
+         * @return the {@code AND} logical operation between this filter and the given predicate.
+         *
+         * @see DefaultFilterFactory#and(Filter, Filter)
+         */
+        @Override
+        default Predicate<R> and(final Predicate<? super R> other) {
+            if (other instanceof Filter<?>) {
+                return new LogicalFilter.And<>(this, (Filter<? super R>) other);
+            } else {
+                return Filter.super.and(other);
+            }
+        }
+
+        /**
+         * Returns the {@code OR} logical operation between this filter and the given predicate.
+         * If the given predicate is an instance of {@link Filter}, then the returned predicate
+         * is an instance of {@code Optimization.OnFilter}.
+         *
+         * @param  other  the other predicate.
+         * @return the {@code OR} logical operation between this filter and the given predicate.
+         *
+         * @see DefaultFilterFactory#or(Filter, Filter)
+         */
+        @Override
+        default Predicate<R> or(final Predicate<? super R> other) {
+            if (other instanceof Filter<?>) {
+                return new LogicalFilter.Or<>(this, (Filter<? super R>) other);
+            } else {
+                return Filter.super.and(other);
+            }
+        }
+
+        /**
+         * Returns the logical negation of this filter.
+         * The returned predicate is an instance of {@code Optimization.OnFilter}.
+         *
+         * @return the logical negation of this filter.
+         */
+        @Override
+        default Predicate<R> negate() {
+            return new LogicalFilter.Not<>(this);
+        }
     }
 
     /**
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/LogicalFilterTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/LogicalFilterTest.java
index 242a31d..073c715 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/filter/LogicalFilterTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/LogicalFilterTest.java
@@ -92,6 +92,16 @@ public final strictfp class LogicalFilterTest extends TestCase {
     }
 
     /**
+     * Verifies that {@link Filter#negate()} is overridden.
+     */
+    @Test
+    public void testNegate() {
+        final Literal<Feature,String>  literal = factory.literal("text");
+        final Filter<Feature>          operand = factory.isNull(literal);
+        assertInstanceOf("Predicate.negate()", LogicalFilter.Not.class, operand.negate());
+    }
+
+    /**
      * Implementation of {@link #testAnd()} and {@link #testOr()}.
      *
      * @param  binary    the function creating a logical operator from two operands.

[sis] 03/03: Move Query sub-types to public package.

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit fa65ecf05431a6d88d0f7a017822ad99019694ce
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu Sep 9 15:05:29 2021 +0200

    Move Query sub-types to public package.
---
 .../sis/internal/filter}/SortByComparator.java     |   2 +-
 .../org/apache/sis/internal/map/SEPortrayer.java   |   2 +-
 .../apache/sis/internal/map/SEPortrayerTest.java   |   2 +-
 .../sis/internal/sql/feature/FeatureStream.java    |   2 +-
 .../org/apache/sis/storage/sql/SQLStoreTest.java   |   2 +-
 .../sis/internal/storage/JoinFeatureSet.java       |   2 +-
 .../sis/internal/storage/query/package-info.java   |  32 -----
 .../storage/query => storage}/CoverageQuery.java   |  28 ++--
 .../storage/query => storage}/CoverageSubset.java  |   6 +-
 .../storage/query => storage}/FeatureQuery.java    | 141 ++++++++++++++-------
 .../java/org/apache/sis/storage/FeatureSet.java    |   1 -
 .../storage/query => storage}/FeatureSubset.java   |  21 ++-
 .../apache/sis/storage/GridCoverageResource.java   |   1 -
 .../main/java/org/apache/sis/storage/Query.java    |   5 +-
 .../query => storage}/CoverageQueryTest.java       |   4 +-
 .../FeatureQueryTest.java}                         |   8 +-
 .../query => storage}/GridResourceMock.java        |   2 +-
 .../apache/sis/test/suite/StorageTestSuite.java    |   4 +-
 18 files changed, 140 insertions(+), 125 deletions(-)

diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SortByComparator.java b/core/sis-feature/src/main/java/org/apache/sis/internal/filter/SortByComparator.java
similarity index 99%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SortByComparator.java
rename to core/sis-feature/src/main/java/org/apache/sis/internal/filter/SortByComparator.java
index 37aeaee..3727386 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SortByComparator.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/internal/filter/SortByComparator.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.storage.query;
+package org.apache.sis.internal.filter;
 
 import java.util.Arrays;
 import java.util.List;
diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPortrayer.java b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPortrayer.java
index 19765d1..9b267af 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPortrayer.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/SEPortrayer.java
@@ -43,7 +43,7 @@ import org.apache.sis.filter.DefaultFilterFactory;
 import org.apache.sis.geometry.Envelopes;
 import org.apache.sis.geometry.GeneralEnvelope;
 import org.apache.sis.internal.feature.AttributeConvention;
-import org.apache.sis.internal.storage.query.FeatureQuery;
+import org.apache.sis.storage.FeatureQuery;
 import org.apache.sis.portrayal.MapItem;
 import org.apache.sis.portrayal.MapLayer;
 import org.apache.sis.portrayal.MapLayers;
diff --git a/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/SEPortrayerTest.java b/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/SEPortrayerTest.java
index 8f8b16b..d35ca20 100644
--- a/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/SEPortrayerTest.java
+++ b/core/sis-portrayal/src/test/java/org/apache/sis/internal/map/SEPortrayerTest.java
@@ -35,7 +35,7 @@ import org.apache.sis.filter.DefaultFilterFactory;
 import org.apache.sis.geometry.GeneralEnvelope;
 import org.apache.sis.internal.feature.AttributeConvention;
 import org.apache.sis.internal.storage.MemoryFeatureSet;
-import org.apache.sis.internal.storage.query.FeatureQuery;
+import org.apache.sis.storage.FeatureQuery;
 import org.apache.sis.portrayal.MapItem;
 import org.apache.sis.portrayal.MapLayer;
 import org.apache.sis.portrayal.MapLayers;
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureStream.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureStream.java
index af89400..e6f8790 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureStream.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/FeatureStream.java
@@ -31,7 +31,7 @@ import org.apache.sis.filter.Optimization;
 import org.apache.sis.internal.metadata.sql.SQLBuilder;
 import org.apache.sis.internal.stream.DeferredStream;
 import org.apache.sis.internal.stream.PaginedStream;
-import org.apache.sis.internal.storage.query.SortByComparator;
+import org.apache.sis.internal.filter.SortByComparator;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.util.collection.BackingStoreException;
 import org.apache.sis.util.ArgumentChecks;
diff --git a/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java b/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java
index d7a810d..2f4c2a9 100644
--- a/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java
+++ b/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java
@@ -26,7 +26,7 @@ import org.apache.sis.storage.FeatureSet;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.filter.DefaultFilterFactory;
-import org.apache.sis.internal.storage.query.FeatureQuery;
+import org.apache.sis.storage.FeatureQuery;
 import org.apache.sis.test.sql.TestDatabase;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.TestCase;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/JoinFeatureSet.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/JoinFeatureSet.java
index 0977396..c74e056 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/JoinFeatureSet.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/JoinFeatureSet.java
@@ -29,7 +29,7 @@ import org.apache.sis.feature.FeatureOperations;
 import org.apache.sis.feature.DefaultFeatureType;
 import org.apache.sis.feature.DefaultAssociationRole;
 import org.apache.sis.internal.feature.AttributeConvention;
-import org.apache.sis.internal.storage.query.FeatureQuery;
+import org.apache.sis.storage.FeatureQuery;
 import org.apache.sis.storage.FeatureSet;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.event.StoreListeners;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/package-info.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/package-info.java
deleted file mode 100644
index a75a1c9..0000000
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/package-info.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Default implementation of query operations.
- *
- * <STRONG>Do not use!</STRONG>
- *
- * This package is for internal use by SIS only. Classes in this package
- * may change in incompatible ways in any future version without notice.
- *
- * @author  Johann Sorel (Geomatys)
- * @author  Martin Desruisseaux (Geomatys)
- * @version 1.1
- * @since   1.0
- * @module
- */
-package org.apache.sis.internal.storage.query;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/CoverageQuery.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageQuery.java
similarity index 90%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/CoverageQuery.java
rename to storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageQuery.java
index 9e9dd1c..c668af6 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/CoverageQuery.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageQuery.java
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.storage.query;
+package org.apache.sis.storage;
 
 import java.util.Arrays;
 import java.util.Objects;
+import java.io.Serializable;
 import java.math.RoundingMode;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.apache.sis.measure.Angle;
@@ -25,15 +26,16 @@ import org.apache.sis.measure.Latitude;
 import org.apache.sis.measure.Longitude;
 import org.apache.sis.measure.AngleFormat;
 import org.apache.sis.coverage.grid.GridGeometry;
-import org.apache.sis.storage.GridCoverageResource;
-import org.apache.sis.storage.Query;
-import org.apache.sis.storage.UnsupportedQueryException;
 import org.apache.sis.util.ArgumentChecks;
 
 
 /**
- * A simple query configuration for coverage resources for requesting a subset of the domain and the range.
- * Experimental for now, may move to public API in a future version.
+ * Definition of filtering to apply for fetching a subset of {@link GridCoverageResource}.
+ * This query allows requesting a subset of the coverage domain and the range.
+ *
+ * <h2>Optional values</h2>
+ * All aspects of this query are optional and initialized to "none".
+ * Unless otherwise specified, all methods accept a null argument or can return a null value, which means "none".
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -41,7 +43,12 @@ import org.apache.sis.util.ArgumentChecks;
  * @since   1.1
  * @module
  */
-public final class CoverageQuery extends Query implements Cloneable {
+public class CoverageQuery extends Query implements Cloneable, Serializable {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -4296814883807414158L;
+
     /**
      * Desired grid extent and resolution, or {@code null} for reading the whole domain.
      */
@@ -115,7 +122,7 @@ public final class CoverageQuery extends Query implements Cloneable {
     }
 
     /**
-     * Set a number of additional cells to read on each border of the source grid coverage.
+     * Sets a number of additional cells to read on each border of the source grid coverage.
      * If non-zero, this property expands the {@linkplain #getDomain() domain} to be read
      * by the specified margin.
      *
@@ -158,7 +165,7 @@ public final class CoverageQuery extends Query implements Cloneable {
      * @return a view over the given coverage resource containing only the given domain and range.
      * @throws UnsupportedQueryException if this query contains filtering options not yet supported.
      */
-    public GridCoverageResource execute(final GridCoverageResource source) throws UnsupportedQueryException {
+    final GridCoverageResource execute(final GridCoverageResource source) throws UnsupportedQueryException {
         ArgumentChecks.ensureNonNull("source", source);
         return new CoverageSubset(source, clone());
     }
@@ -214,7 +221,8 @@ public final class CoverageQuery extends Query implements Cloneable {
     }
 
     /**
-     * Returns a textual representation looking like an SQL Select query.
+     * Returns a textual representation of this query for debugging purposes.
+     * The default implementation returns a string that looks like an SQL Select query.
      *
      * @return textual representation of this query.
      */
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/CoverageSubset.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageSubset.java
similarity index 97%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/CoverageSubset.java
rename to storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageSubset.java
index eb0a1a4..4ff419f 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/CoverageSubset.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageSubset.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.storage.query;
+package org.apache.sis.storage;
 
 import java.util.Arrays;
 import java.util.List;
@@ -25,11 +25,7 @@ import org.apache.sis.coverage.grid.GridDerivation;
 import org.apache.sis.coverage.grid.GridRoundingMode;
 import org.apache.sis.coverage.grid.GridClippingMode;
 import org.apache.sis.coverage.grid.DisjointExtentException;
-import org.apache.sis.storage.GridCoverageResource;
 import org.apache.sis.storage.event.StoreListeners;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.DataStoreReferencingException;
-import org.apache.sis.storage.NoSuchDataException;
 import org.apache.sis.internal.storage.Resources;
 import org.apache.sis.internal.storage.AbstractGridResource;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureQuery.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
similarity index 80%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureQuery.java
rename to storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
index 67baf3b..d34fa2e 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureQuery.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
@@ -14,23 +14,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.storage.query;
+package org.apache.sis.storage;
 
 import java.util.Arrays;
 import java.util.Map;
-import java.util.List;
 import java.util.LinkedHashMap;
 import java.util.Objects;
+import java.util.OptionalLong;
+import java.io.Serializable;
 import javax.measure.Quantity;
 import javax.measure.quantity.Length;
 import org.opengis.util.GenericName;
 import org.apache.sis.feature.builder.FeatureTypeBuilder;
 import org.apache.sis.feature.builder.PropertyTypeBuilder;
 import org.apache.sis.internal.feature.FeatureExpression;
-import org.apache.sis.internal.util.UnmodifiableArrayList;
+import org.apache.sis.internal.filter.SortByComparator;
 import org.apache.sis.internal.storage.Resources;
-import org.apache.sis.storage.FeatureSet;
-import org.apache.sis.storage.Query;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.collection.Containers;
@@ -49,21 +48,40 @@ import org.opengis.filter.InvalidFilterValueException;
 
 
 /**
- * Mimics {@code SQL SELECT} statements using OGC Filter and Expressions.
+ * Definition of filtering to apply for fetching a subset of {@link FeatureSet}.
+ * This query mimics {@code SQL SELECT} statements using OGC Filter and Expressions.
  * Information stored in this query can be used directly with {@link java.util.stream.Stream} API.
  *
+ * <h2>Terminology</h2>
+ * This class uses relational database terminology:
+ * <ul>
+ *   <li>A <cite>selection</cite> is a filter choosing the features instances to include in the subset.
+ *       In relational databases, a feature instances are mapped to table rows.</li>
+ *   <li>A <cite>projection</cite> (not to be confused with map projection) is the set of feature property to keep.
+ *       In relational databases, feature properties are mapped to table columns.</li>
+ * </ul>
+ *
+ * <h2>Optional values</h2>
+ * All aspects of this query are optional and initialized to "none".
+ * Unless otherwise specified, all methods accept a null argument or can return a null value, which means "none".
+ *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
- * @since   1.0
+ * @since   1.1
  * @module
  */
-public class FeatureQuery extends Query implements Cloneable {
+public class FeatureQuery extends Query implements Cloneable, Serializable {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -5841189659773611160L;
+
     /**
      * Sentinel limit value for queries of unlimited length.
-     * This value can be given to {@link #setLimit(long)} or retrieved from {@link #getLimit()}.
+     * This value applies to the {@link #limit} field.
      */
-    public static final long UNLIMITED = -1;
+    private static final long UNLIMITED = -1;
 
     /**
      * The properties to retrieve, or {@code null} if all properties shall be included in the query.
@@ -87,6 +105,7 @@ public class FeatureQuery extends Query implements Cloneable {
 
     /**
      * The number of feature instances to skip from the beginning.
+     * This is zero if there is no instance to skip.
      *
      * @see #getOffset()
      * @see #setOffset(long)
@@ -96,6 +115,7 @@ public class FeatureQuery extends Query implements Cloneable {
 
     /**
      * The maximum number of feature instances contained in the {@code FeatureSet}.
+     * This is {@link #UNLIMITED} if there is no limit.
      *
      * @see #getLimit()
      * @see #setLimit(long)
@@ -113,7 +133,7 @@ public class FeatureQuery extends Query implements Cloneable {
 
     /**
      * Hint used by resources to optimize returned features.
-     * Different stores makes use of vector tiles of different scales.
+     * Different stores make use of vector tiles of different scales.
      * A {@code null} value means to query data at their full resolution.
      *
      * @see #getLinearResolution()
@@ -122,33 +142,54 @@ public class FeatureQuery extends Query implements Cloneable {
     private Quantity<Length> linearResolution;
 
     /**
-     * Creates a new query retrieving no property and applying no filter.
+     * Creates a new query applying no filter.
      */
     public FeatureQuery() {
-        selection = Filter.include();
         limit = UNLIMITED;
     }
 
     /**
      * Sets the properties to retrieve, or {@code null} if all properties shall be included in the query.
+     * This convenience method wraps the given expression in {@link NamedExpression}s without alias and
+     * delegates to {@link #setProjection(NamedExpression...)}.
+     *
+     * @param  properties  properties to retrieve, or {@code null} to retrieve all properties.
+     * @throws IllegalArgumentException if a property is duplicated.
+     */
+    @SafeVarargs
+    public final void setProjection(final Expression<? super Feature, ?>... properties) {
+        NamedExpression[] wrappers = null;
+        if (properties != null) {
+            wrappers = new NamedExpression[properties.length];
+            for (int i=0; i<wrappers.length; i++) {
+                final Expression<? super Feature, ?> e = properties[i];
+                ArgumentChecks.ensureNonNullElement("properties", i, e);
+                wrappers[i] = new NamedExpression(e);
+            }
+        }
+        setProjection(wrappers);
+    }
+
+    /**
+     * Sets the properties to retrieve, or {@code null} if all properties shall be included in the query.
      * A query column may use a simple or complex expression and an alias to create a new type of property
      * in the returned features.
      *
      * <p>This is equivalent to the column names in the {@code SELECT} clause of a SQL statement.
      * Subset of columns is called <cite>projection</cite> in relational database terminology.</p>
      *
-     * @param  projection  properties to retrieve, or {@code null} to retrieve all properties.
+     * @param  properties  properties to retrieve, or {@code null} to retrieve all properties.
      * @throws IllegalArgumentException if a property or an alias is duplicated.
      */
     @SuppressWarnings("AssignmentToCollectionOrArrayFieldFromParameter")
-    public void setProjection(NamedExpression... projection) {
-        if (projection != null) {
-            ArgumentChecks.ensureNonEmpty("projection", projection);
-            projection = projection.clone();
-            final Map<Object,Integer> uniques = new LinkedHashMap<>(Containers.hashMapCapacity(projection.length));
-            for (int i=0; i<projection.length; i++) {
-                final NamedExpression c = projection[i];
-                ArgumentChecks.ensureNonNullElement("projection", i, c);
+    public void setProjection(NamedExpression... properties) {
+        if (properties != null) {
+            ArgumentChecks.ensureNonEmpty("properties", properties);
+            properties = properties.clone();
+            final Map<Object,Integer> uniques = new LinkedHashMap<>(Containers.hashMapCapacity(properties.length));
+            for (int i=0; i<properties.length; i++) {
+                final NamedExpression c = properties[i];
+                ArgumentChecks.ensureNonNullElement("properties", i, c);
                 final Object key = c.alias != null ? c.alias : c.expression;
                 final Integer p = uniques.putIfAbsent(key, i);
                 if (p != null) {
@@ -156,17 +197,18 @@ public class FeatureQuery extends Query implements Cloneable {
                 }
             }
         }
-        this.projection = projection;
+        this.projection = properties;
     }
 
     /**
      * Returns the properties to retrieve, or {@code null} if all properties shall be included in the query.
-     * This is the list of expressions specified in the last call to {@link #setProjection(NamedExpression[])}.
+     * This is the expressions specified in the last call to {@link #setProjection(NamedExpression[])}.
+     * The default value is null.
      *
      * @return properties to retrieve, or {@code null} to retrieve all feature properties.
      */
-    public List<NamedExpression> getProjection() {
-        return UnmodifiableArrayList.wrap(projection);
+    public NamedExpression[] getProjection() {
+        return (projection != null) ? projection.clone() : null;
     }
 
     /**
@@ -174,18 +216,18 @@ public class FeatureQuery extends Query implements Cloneable {
      * Features that do not pass the filter are discarded.
      * Discarded features are not counted for the {@linkplain #setLimit(long) query limit}.
      *
-     * @param  selection  the filter, or {@link Filter#include()} if none.
+     * @param  selection  the filter, or {@code null} if none.
      */
     public void setSelection(final Filter<? super Feature> selection) {
-        ArgumentChecks.ensureNonNull("selection", selection);
         this.selection = selection;
     }
 
     /**
      * Returns the filter for trimming feature instances.
      * This is the value specified in the last call to {@link #setSelection(Filter)}.
+     * The default value is {@code null}, which means that no filtering is applied.
      *
-     * @return the filter, or {@link Filter#include()} if none.
+     * @return the filter, or {@code null} if none.
      */
     public Filter<? super Feature> getSelection() {
         return selection;
@@ -209,6 +251,7 @@ public class FeatureQuery extends Query implements Cloneable {
     /**
      * Returns the number of feature instances to skip from the beginning.
      * This is the value specified in the last call to {@link #setOffset(long)}.
+     * The default value is zero, which means that no features are skipped.
      *
      * @return the number of feature instances to skip from the beginning.
      */
@@ -217,18 +260,23 @@ public class FeatureQuery extends Query implements Cloneable {
     }
 
     /**
+     * Removes any limit defined by {@link #setLimit(long)}.
+     */
+    public void setUnlimited() {
+        limit = UNLIMITED;
+    }
+
+    /**
      * Set the maximum number of feature instances contained in the {@code FeatureSet}.
      * Offset and limit are often combined to obtain paging.
      *
      * <p>Note that setting this property can be costly on parallelized streams.
      * See {@link java.util.stream.Stream#limit(long)} for more information.</p>
      *
-     * @param  limit  maximum number of feature instances contained in the {@code FeatureSet}, or {@link #UNLIMITED}.
+     * @param  limit  maximum number of feature instances contained in the {@code FeatureSet}.
      */
     public void setLimit(final long limit) {
-        if (limit != UNLIMITED) {
-            ArgumentChecks.ensurePositive("limit", limit);
-        }
+        ArgumentChecks.ensurePositive("limit", limit);
         this.limit = limit;
     }
 
@@ -236,16 +284,15 @@ public class FeatureQuery extends Query implements Cloneable {
      * Returns the maximum number of feature instances contained in the {@code FeatureSet}.
      * This is the value specified in the last call to {@link #setLimit(long)}.
      *
-     * @return maximum number of feature instances contained in the {@code FeatureSet}, or {@link #UNLIMITED}.
+     * @return maximum number of feature instances contained in the {@code FeatureSet}, or empty if none.
      */
-    public long getLimit() {
-        return limit;
+    public OptionalLong getLimit() {
+        return (limit >= 0) ? OptionalLong.of(limit) : OptionalLong.empty();
     }
 
     /**
      * Sets the expressions to use for sorting the feature instances.
-     * {@code SortBy} objects are used to order the {@link org.opengis.feature.Feature} instances
-     * returned by the {@link org.apache.sis.storage.FeatureSet}.
+     * {@code SortBy} objects are used to order the {@link Feature} instances returned by the {@link FeatureSet}.
      * {@code SortBy} clauses are applied in declaration order, like SQL.
      *
      * @param  properties  expressions to use for sorting the feature instances,
@@ -262,8 +309,7 @@ public class FeatureQuery extends Query implements Cloneable {
 
     /**
      * Sets the expressions to use for sorting the feature instances.
-     * {@code SortBy} objects are used to order the {@link org.opengis.feature.Feature} instances
-     * returned by the {@link org.apache.sis.storage.FeatureSet}.
+     * {@code SortBy} objects are used to order the {@link Feature} instances returned by the {@link FeatureSet}.
      *
      * @param  sortBy  expressions to use for sorting the feature instances, or {@code null} if none.
      */
@@ -273,7 +319,7 @@ public class FeatureQuery extends Query implements Cloneable {
 
     /**
      * Returns the expressions to use for sorting the feature instances.
-     * They are the values specified in the last call to {@link #setSortBy(SortBy)}.
+     * This is the value specified in the last call to {@link #setSortBy(SortBy)}.
      *
      * @return expressions to use for sorting the feature instances, or {@code null} if none.
      */
@@ -306,9 +352,15 @@ public class FeatureQuery extends Query implements Cloneable {
      * In relational database terminology, subset of columns is called <cite>projection</cite>.
      * Columns can be given to the {@link FeatureQuery#setProjection(NamedExpression[])} method.
      */
-    public static class NamedExpression {
+    public static class NamedExpression implements Serializable {
+        /**
+         * For cross-version compatibility.
+         */
+        private static final long serialVersionUID = -6919525113513842514L;
+
         /**
          * The literal, value reference or more complex expression to be retrieved by a {@code Query}.
+         * Never {@code null}.
          */
         public final Expression<? super Feature, ?> expression;
 
@@ -447,7 +499,7 @@ public class FeatureQuery extends Query implements Cloneable {
      * @param  source  the set of features to filter, sort or process.
      * @return a view over the given feature set containing only the filtered feature instances.
      */
-    public FeatureSet execute(final FeatureSet source) {
+    final FeatureSet execute(final FeatureSet source) {
         ArgumentChecks.ensureNonNull("source", source);
         return new FeatureSubset(source, clone());
     }
@@ -527,7 +579,8 @@ public class FeatureQuery extends Query implements Cloneable {
     }
 
     /**
-     * Returns a textual representation looking like an SQL Select query.
+     * Returns a textual representation of this query for debugging purposes.
+     * The default implementation returns a string that looks like an SQL Select query.
      *
      * @return textual representation of this query.
      */
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
index d7534b7..fc97a9c 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
@@ -18,7 +18,6 @@ package org.apache.sis.storage;
 
 import java.util.stream.Stream;
 import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.internal.storage.query.FeatureQuery;
 
 // Branch-dependent imports
 import org.opengis.feature.Feature;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureSubset.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
similarity index 89%
rename from storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureSubset.java
rename to storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
index 2452752..47c98e0 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureSubset.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
@@ -14,16 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.storage.query;
+package org.apache.sis.storage;
 
-import java.util.List;
+import java.util.OptionalLong;
 import java.util.stream.Stream;
 import org.apache.sis.internal.feature.FeatureUtilities;
 import org.apache.sis.internal.storage.AbstractFeatureSet;
 import org.apache.sis.internal.storage.Resources;
-import org.apache.sis.storage.DataStoreContentException;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.FeatureSet;
 import org.apache.sis.storage.event.StoreListeners;
 
 // Branch-dependent imports
@@ -99,7 +96,7 @@ final class FeatureSubset extends AbstractFeatureSet {
          * Apply filter.
          */
         final Filter<? super Feature> selection = query.getSelection();
-        if (!Filter.include().equals(selection)) {
+        if (selection != null && !selection.equals(Filter.include())) {
             stream = stream.filter(selection);
         }
         /*
@@ -119,20 +116,20 @@ final class FeatureSubset extends AbstractFeatureSet {
         /*
          * Apply limit.
          */
-        final long limit = query.getLimit();
-        if (limit >= 0) {
-            stream = stream.limit(limit);
+        final OptionalLong limit = query.getLimit();
+        if (limit.isPresent()) {
+            stream = stream.limit(limit.getAsLong());
         }
         /*
          * Transform feature instances.
          * Note: "projection" here is in relational database sense, not map projection.
          */
-        final List<FeatureQuery.NamedExpression> projection = query.getProjection();
+        final FeatureQuery.NamedExpression[] projection = query.getProjection();
         if (projection != null) {
             @SuppressWarnings({"unchecked", "rawtypes"})
-            final Expression<? super Feature, ?>[] expressions = new Expression[projection.size()];
+            final Expression<? super Feature, ?>[] expressions = new Expression[projection.length];
             for (int i=0; i<expressions.length; i++) {
-                expressions[i] = projection.get(i).expression;
+                expressions[i] = projection[i].expression;
             }
             final FeatureType type = getType();
             final String[] names = FeatureUtilities.getNames(type.getProperties(false));
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
index a0dfe3b..e30cf6b 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/GridCoverageResource.java
@@ -20,7 +20,6 @@ import java.util.List;
 import org.apache.sis.coverage.SampleDimension;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridCoverage;
-import org.apache.sis.internal.storage.query.CoverageQuery;
 import org.apache.sis.util.ArgumentChecks;
 
 
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/Query.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/Query.java
index 548f6bb..2aa4b8f 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/Query.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/Query.java
@@ -17,6 +17,7 @@
 package org.apache.sis.storage;
 
 import org.opengis.feature.Feature;
+import org.opengis.filter.QueryExpression;
 
 
 /**
@@ -54,10 +55,8 @@ import org.opengis.feature.Feature;
  *
  * @since 0.8
  * @module
- *
- * @todo Retrofit {@link org.opengis.filter.QueryExpression}.
  */
-public abstract class Query {
+public abstract class Query implements QueryExpression {
     /*
      * Current version does not yet contain any field. But some fields may be added in the future.
      * For example some methods from org.apache.sis.internal.storage.query.FeatureQuery may move here.
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/CoverageQueryTest.java b/storage/sis-storage/src/test/java/org/apache/sis/storage/CoverageQueryTest.java
similarity index 97%
rename from storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/CoverageQueryTest.java
rename to storage/sis-storage/src/test/java/org/apache/sis/storage/CoverageQueryTest.java
index b515937..eef4d96 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/CoverageQueryTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/storage/CoverageQueryTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.storage.query;
+package org.apache.sis.storage;
 
 import org.opengis.metadata.spatial.DimensionNameType;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
@@ -24,8 +24,6 @@ import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
 import org.apache.sis.referencing.crs.HardCodedCRS;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.GridCoverageResource;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/SimpleQueryTest.java b/storage/sis-storage/src/test/java/org/apache/sis/storage/FeatureQueryTest.java
similarity index 97%
rename from storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/SimpleQueryTest.java
rename to storage/sis-storage/src/test/java/org/apache/sis/storage/FeatureQueryTest.java
index a66c759..cbe7414 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/SimpleQueryTest.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/storage/FeatureQueryTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.storage.query;
+package org.apache.sis.storage;
 
 import java.util.List;
 import java.util.Arrays;
@@ -22,8 +22,6 @@ import java.util.stream.Collectors;
 import org.apache.sis.feature.builder.FeatureTypeBuilder;
 import org.apache.sis.internal.storage.MemoryFeatureSet;
 import org.apache.sis.filter.DefaultFilterFactory;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.FeatureSet;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -49,7 +47,7 @@ import org.opengis.filter.SortOrder;
  * @since   1.0
  * @module
  */
-public final strictfp class SimpleQueryTest extends TestCase {
+public final strictfp class FeatureQueryTest extends TestCase {
     /**
      * An arbitrary amount of features, all of the same type.
      */
@@ -68,7 +66,7 @@ public final strictfp class SimpleQueryTest extends TestCase {
     /**
      * Creates a new test.
      */
-    public SimpleQueryTest() {
+    public FeatureQueryTest() {
         final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
         ftb.setName("Test");
         ftb.addAttribute(Integer.class).setName("value1");
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/GridResourceMock.java b/storage/sis-storage/src/test/java/org/apache/sis/storage/GridResourceMock.java
similarity index 98%
rename from storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/GridResourceMock.java
rename to storage/sis-storage/src/test/java/org/apache/sis/storage/GridResourceMock.java
index b984874..0971c06 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/GridResourceMock.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/storage/GridResourceMock.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.storage.query;
+package org.apache.sis.storage;
 
 import java.util.List;
 import java.util.Collections;
diff --git a/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java b/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
index a89fc63..1231745 100644
--- a/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
+++ b/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
@@ -46,8 +46,8 @@ import org.junit.BeforeClass;
     org.apache.sis.storage.ProbeResultTest.class,
     org.apache.sis.storage.StorageConnectorTest.class,
     org.apache.sis.storage.event.StoreListenersTest.class,
-    org.apache.sis.internal.storage.query.CoverageQueryTest.class,
-    org.apache.sis.internal.storage.query.SimpleQueryTest.class,
+    org.apache.sis.storage.CoverageQueryTest.class,
+    org.apache.sis.storage.FeatureQueryTest.class,
     org.apache.sis.internal.storage.xml.MimeTypeDetectorTest.class,
     org.apache.sis.internal.storage.xml.StoreProviderTest.class,
     org.apache.sis.internal.storage.xml.StoreTest.class,