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/10 10:36:16 UTC
[sis] 01/02: Apply filter optimization before to create a feature
subset.
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 987a3262e4a03f757cad94739a843640949543c7
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Fri Sep 10 10:35:30 2021 +0200
Apply filter optimization before to create a feature subset.
---
.../src/main/java/org/apache/sis/storage/FeatureQuery.java | 12 ++++++++++--
.../src/main/java/org/apache/sis/storage/FeatureSubset.java | 1 +
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
index d34fa2e..927ec64 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
@@ -30,6 +30,7 @@ import org.apache.sis.feature.builder.PropertyTypeBuilder;
import org.apache.sis.internal.feature.FeatureExpression;
import org.apache.sis.internal.filter.SortByComparator;
import org.apache.sis.internal.storage.Resources;
+import org.apache.sis.filter.Optimization;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.Classes;
import org.apache.sis.util.collection.Containers;
@@ -498,10 +499,17 @@ public class FeatureQuery extends Query implements Cloneable, Serializable {
*
* @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.
+ * @throws DataStoreException if an error occurred during creation of the subset.
*/
- final FeatureSet execute(final FeatureSet source) {
+ final FeatureSet execute(final FeatureSet source) throws DataStoreException {
ArgumentChecks.ensureNonNull("source", source);
- return new FeatureSubset(source, clone());
+ final FeatureQuery query = clone();
+ if (query.selection != null) {
+ final Optimization optimization = new Optimization();
+ optimization.setFeatureType(source.getType());
+ query.selection = optimization.apply(query.selection);
+ }
+ return new FeatureSubset(source, query);
}
/**
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
index 47c98e0..5ee4507 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
@@ -62,6 +62,7 @@ final class FeatureSubset extends AbstractFeatureSet {
/**
* Creates a new set of features by filtering the given set using the given query.
+ * This given query is stored as-is (it is not cloned neither optimized).
*/
FeatureSubset(final FeatureSet source, final FeatureQuery query) {
super(source instanceof StoreListeners ? (StoreListeners) source : null);