sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ama...@apache.org
Subject [sis] 37/45: fix(Add multiple fixes to handle filtering on SQL feature sets
Date Tue, 12 Nov 2019 16:45:04 GMT
This is an automated email from the ASF dual-hosted git repository.

amanin pushed a commit to branch refactor/sql-store
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 58a998f76b02be6bf16293b06ded4ee419ed07cb
Author: Alexis Manin <amanin@apache.org>
AuthorDate: Thu Oct 17 12:25:51 2019 +0200

    fix(Add multiple fixes to handle filtering on SQL feature sets
---
 .../java/org/apache/sis/internal/sql/feature/Features.java   | 12 +++++-------
 .../org/apache/sis/internal/sql/feature/QueryFeatureSet.java |  2 +-
 .../java/org/apache/sis/internal/sql/feature/StreamSQL.java  |  6 +++---
 .../main/java/org/apache/sis/internal/sql/feature/Table.java |  2 +-
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Features.java
b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Features.java
index 42522b1..dd97df9 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Features.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Features.java
@@ -151,6 +151,8 @@ final class Features implements Spliterator<Feature> {
      */
     private final long estimatedSize;
 
+    private final FeatureAdapter adapter;
+
     /**
      * Creates a new iterator over the feature instances.
      *
@@ -180,6 +182,7 @@ final class Features implements Spliterator<Feature> {
             attributeNames[i++] = column.getAttributeName();
         }
         this.featureType = table.featureType;
+        this.adapter = table.adapter;
         final DatabaseMetaData metadata = connection.getMetaData();
         estimatedSize = following.isEmpty() ? table.countRows(metadata, true) : 0;
         /*
@@ -414,13 +417,8 @@ final class Features implements Spliterator<Feature> {
      */
     private boolean fetch(final Consumer<? super Feature> action, final boolean all)
throws SQLException {
         while (result.next()) {
-            final Feature feature = featureType.newInstance();
-            for (int i=0; i < attributeNames.length; i++) {
-                final Object value = result.getObject(i+1);
-                if (!result.wasNull()) {
-                    feature.setPropertyValue(attributeNames[i], value);
-                }
-            }
+            // TODO: give connection to adapter.
+            final Feature feature = adapter.read(result, null);
             for (int i=0; i < dependencies.length; i++) {
                 final Features dependency = dependencies[i];
                 final int[] columnIndices = foreignerKeyIndices[i];
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/QueryFeatureSet.java
b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/QueryFeatureSet.java
index 706130f..e5d991c 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/QueryFeatureSet.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/QueryFeatureSet.java
@@ -289,7 +289,7 @@ public class QueryFeatureSet extends AbstractFeatureSet {
                     nativeOffset = originOffset + additionalOffset;
                 }
 
-                if (originLimit < 0) {
+                if (originLimit <= 0) {
                     javaLimit = this.additionalLimit;
                 } else if (originLimit > 0 || additionalLimit > 0) {
                     nativeLimit = Math.min(originLimit, additionalLimit);
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/StreamSQL.java
b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/StreamSQL.java
index 30820a9..7291a04 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/StreamSQL.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/StreamSQL.java
@@ -55,9 +55,9 @@ import static org.apache.sis.util.ArgumentChecks.ensurePositive;
  * Manages query lifecycle and optimizations. Operations like {@link #count()}, {@link #distinct()},
{@link #skip(long)}
  * and {@link #limit(long)} are delegated to underlying SQL database. This class consistently
propagate optimisation
  * strategies through streams obtained using {@link #map(Function)}, {@link #mapToDouble(ToDoubleFunction)}
and
- * {@link #peek(Consumer)} operations. However, for result consistency, no optimization is
stacked once either
- * {@link #filter(Predicate)} or {@link #flatMap(Function)} operations are called, as they
modify browing flow (the
- * count of stream elements is not bound 1 to 1 to query result rows).
+ * {@link #peek(Consumer)} operations. However, for result consistency, no optimization is
stacked anymore after either
+ * {@link #filter(Predicate)} or {@link #flatMap(Function)} operations are called, as they
modify volumetry (the count
+ * of stream elements is not bound 1 to 1 to query result rows).
  *
  * @since 1.0
  *
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
index bd35fbb..7205f70 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
@@ -145,7 +145,7 @@ final class Table extends AbstractFeatureSet {
      */
     private final SQLBuilder sqlTemplate;
 
-    private final FeatureAdapter adapter;
+    protected final FeatureAdapter adapter;
 
     /**
      * Creates a description of the table of the given name.


Mime
View raw message