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


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 3cb1d1ef50 Minor adjustments in API related to `DataStore` in 
preparation for Geopackage. The most significant change is that 
`SQLStore.components()` returns a list of `Resource` instead of `FeatureSet` 
because the store can also contain rasters.
3cb1d1ef50 is described below

commit 3cb1d1ef5008799aa04f9a8e3cd08407a62498b1
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Sat Aug 17 16:56:01 2024 +0200

    Minor adjustments in API related to `DataStore` in preparation for 
Geopackage.
    The most significant change is that `SQLStore.components()` returns a list 
of
    `Resource` instead of `FeatureSet` because the store can also contain 
rasters.
---
 .../apache/sis/storage/landsat/LandsatStore.java   |  7 ++++--
 .../apache/sis/storage/landsat/package-info.java   |  2 +-
 .../apache/sis/storage/geotiff/GeoTiffStore.java   |  4 +++-
 .../sis/storage/geotiff/GeoTiffStoreProvider.java  |  8 ++-----
 .../apache/sis/storage/geotiff/package-info.java   |  3 ++-
 .../org/apache/sis/storage/netcdf/NetcdfStore.java |  7 +++---
 .../apache/sis/storage/netcdf/package-info.java    |  2 +-
 .../main/org/apache/sis/storage/sql/SQLStore.java  | 16 ++++++++------
 .../apache/sis/storage/sql/SQLStoreProvider.java   |  2 +-
 .../apache/sis/storage/sql/feature/Database.java   |  3 ++-
 .../apache/sis/io/stream/InternalOptionKey.java    | 25 ++++++++++++++++++++++
 .../geopackage/featureset/GpkgFeatureSet.java      |  2 +-
 12 files changed, 56 insertions(+), 25 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
 
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
index abbfd80d77..4dec25b23d 100644
--- 
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
+++ 
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
@@ -37,6 +37,7 @@ import org.opengis.metadata.Metadata;
 import org.opengis.parameter.ParameterValueGroup;
 import org.apache.sis.storage.Aggregate;
 import org.apache.sis.storage.DataStore;
+import org.apache.sis.storage.DataStoreProvider;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreClosedException;
 import org.apache.sis.storage.DataStoreReferencingException;
@@ -80,7 +81,7 @@ import org.apache.sis.setup.OptionKey;
  *
  * @author  Thi Phuong Hao Nguyen (VNSC)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.4
+ * @version 1.5
  * @since   1.1
  */
 public class LandsatStore extends DataStore implements Aggregate {
@@ -124,9 +125,11 @@ public class LandsatStore extends DataStore implements 
Aggregate {
      * @param  provider   the factory that created this {@code DataStore} 
instance, or {@code null} if unspecified.
      * @param  connector  information about the storage (URL, stream, reader 
instance, <i>etc</i>).
      * @throws DataStoreException if an error occurred while opening the 
Landsat file.
+     *
+     * @since 1.5
      */
     @SuppressWarnings("this-escape")    // The invoked method does not store 
`this` and is not overrideable.
-    public LandsatStore(final LandsatStoreProvider provider, final 
StorageConnector connector) throws DataStoreException {
+    public LandsatStore(final DataStoreProvider provider, final 
StorageConnector connector) throws DataStoreException {
         super(provider, connector);
         Path path = connector.getStorageAs(Path.class);
         location  = connector.getStorageAs(URI.class);
diff --git 
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/package-info.java
 
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/package-info.java
index 93e964fb18..934243d37f 100644
--- 
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/package-info.java
+++ 
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/package-info.java
@@ -27,7 +27,7 @@
  * @author  Thi Phuong Hao Nguyen (VNSC)
  * @author  Minh Chinh Vu (VNSC)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.4
+ * @version 1.5
  * @since   1.1
  */
 package org.apache.sis.storage.landsat;
diff --git 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
index dbcc25ae03..67a087e7ab 100644
--- 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
+++ 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStore.java
@@ -208,8 +208,10 @@ public class GeoTiffStore extends DataStore implements 
Aggregate {
      * @param  provider   the factory that created this {@code DataStore} 
instance, or {@code null} if unspecified.
      * @param  connector  information about the storage (URL, stream, 
<i>etc</i>).
      * @throws DataStoreException if an error occurred while opening the 
GeoTIFF file.
+     *
+     * @since 1.5
      */
-    public GeoTiffStore(final GeoTiffStoreProvider provider, final 
StorageConnector connector) throws DataStoreException {
+    public GeoTiffStore(final DataStoreProvider provider, final 
StorageConnector connector) throws DataStoreException {
         this(null, provider, connector, false);
     }
 
diff --git 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
index b07486d160..5d707ba4bc 100644
--- 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
+++ 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
@@ -40,10 +40,6 @@ import org.apache.sis.parameter.ParameterBuilder;
  * The provider of {@link GeoTiffStore} instances. Given a {@link 
StorageConnector} input,
  * this class tries to instantiate a {@code GeoTiffStore}.
  *
- * <h2>Thread safety</h2>
- * The same {@code GeoTiffStoreProvider} instance can be safely used by many 
threads without synchronization on
- * the part of the caller. However, the {@link GeoTiffStore} instances created 
by this factory are not thread-safe.
- *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.5
  *
@@ -154,7 +150,7 @@ public class GeoTiffStoreProvider extends DataStoreProvider 
{
     }
 
     /**
-     * Returns a {@link GeoTiffStore} implementation associated with this 
provider.
+     * Creates a {@link GeoTiffStore} implementation associated with this 
provider.
      *
      * @param  connector  information about the storage (URL, stream, 
<i>etc</i>).
      * @return a data store implementation associated with this provider for 
the given storage.
@@ -169,7 +165,7 @@ public class GeoTiffStoreProvider extends DataStoreProvider 
{
     }
 
     /**
-     * {@return the logger used by GeoTIFF stores}.
+     * Returns the logger used by GeoTIFF stores.
      */
     @Override
     public Logger getLogger() {
diff --git 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/package-info.java
 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/package-info.java
index d468109668..d5d2f35134 100644
--- 
a/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/package-info.java
+++ 
b/endorsed/src/org.apache.sis.storage.geotiff/main/org/apache/sis/storage/geotiff/package-info.java
@@ -16,7 +16,8 @@
  */
 
 /**
- * Maps GeoTIFF tags to ISO metadata and read raster data as coverages.
+ * A data store that can read and write GeoTIFF files as grid coverages.
+ * This module also maps GeoTIFF tags to <abbr>ISO</abbr> 19115 metadata.
  *
  * <p>References:</p>
  * <ul>
diff --git 
a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/NetcdfStore.java
 
b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/NetcdfStore.java
index 71e2efe3ba..21fb0746c5 100644
--- 
a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/NetcdfStore.java
+++ 
b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/NetcdfStore.java
@@ -31,6 +31,7 @@ import org.opengis.util.GenericName;
 import org.opengis.metadata.Metadata;
 import org.opengis.parameter.ParameterValueGroup;
 import org.apache.sis.storage.DataStore;
+import org.apache.sis.storage.DataStoreProvider;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.UnsupportedStorageException;
 import org.apache.sis.storage.StorageConnector;
@@ -58,7 +59,7 @@ import org.apache.sis.util.collection.TreeTable;
  * Instances of this data store are created by {@link 
NetcdfStoreProvider#open(StorageConnector)}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.3
+ * @version 1.5
  *
  * @see NetcdfStoreProvider
  *
@@ -103,10 +104,10 @@ public class NetcdfStore extends DataStore implements 
Aggregate {
      * @param  connector  information about the storage (URL, stream, {@link 
ucar.nc2.NetcdfFile} instance, <i>etc</i>).
      * @throws DataStoreException if an error occurred while opening the 
netCDF file.
      *
-     * @since 0.8
+     * @since 1.5
      */
     @SuppressWarnings("this-escape")        // The invoked method does not 
store `this` and is not overrideable.
-    public NetcdfStore(final NetcdfStoreProvider provider, final 
StorageConnector connector) throws DataStoreException {
+    public NetcdfStore(final DataStoreProvider provider, final 
StorageConnector connector) throws DataStoreException {
         super(provider, connector);
         location = connector.getStorageAs(URI.class);
         final Path path = connector.getStorageAs(Path.class);
diff --git 
a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/package-info.java
 
b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/package-info.java
index e3a5ebe421..428d78a5a9 100644
--- 
a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/package-info.java
+++ 
b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/package-info.java
@@ -40,7 +40,7 @@
  * Care must be taken for avoiding confusion when using SIS and UCAR libraries 
together.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 1.4
+ * @version 1.5
  * @since   0.3
  */
 package org.apache.sis.storage.netcdf;
diff --git 
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStore.java
 
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStore.java
index 44b7d958c6..fef44eb0d4 100644
--- 
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStore.java
+++ 
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStore.java
@@ -22,7 +22,6 @@ import java.util.Optional;
 import java.util.Collection;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.sql.DataSource;
 import java.sql.Connection;
 import java.lang.reflect.Method;
@@ -31,9 +30,11 @@ import org.opengis.metadata.Metadata;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.metadata.spatial.SpatialRepresentationType;
+import org.apache.sis.storage.Resource;
 import org.apache.sis.storage.Aggregate;
 import org.apache.sis.storage.FeatureSet;
 import org.apache.sis.storage.DataStore;
+import org.apache.sis.storage.DataStoreProvider;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.storage.NoSuchDataException;
@@ -47,6 +48,7 @@ import org.apache.sis.storage.sql.feature.Resources;
 import org.apache.sis.storage.sql.feature.InfoStatements;
 import org.apache.sis.storage.sql.feature.SchemaModifier;
 import org.apache.sis.storage.base.MetadataBuilder;
+import org.apache.sis.io.stream.InternalOptionKey;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.Exceptions;
@@ -160,9 +162,9 @@ public class SQLStore extends DataStore implements 
Aggregate {
      * @param  resources  tables, views or queries to include in this store.
      * @throws DataStoreException if an error occurred while creating the data 
store for the given storage.
      *
-     * @since 1.1
+     * @since 1.5
      */
-    public SQLStore(final SQLStoreProvider provider, final StorageConnector 
connector, final ResourceDefinition... resources)
+    public SQLStore(final DataStoreProvider provider, final StorageConnector 
connector, final ResourceDefinition... resources)
             throws DataStoreException
     {
         super(provider, connector);
@@ -193,9 +195,9 @@ public class SQLStore extends DataStore implements 
Aggregate {
                 queries[queryCount++] = resource;
             }
         }
-        this.tableNames = ArraysExt.resize(tableNames, tableCount);
-        this.queries    = ArraysExt.resize(queries,    queryCount);
-        transactionLocks = new ReentrantReadWriteLock();    // TODO: make 
optional.
+        this.tableNames  = ArraysExt.resize(tableNames, tableCount);
+        this.queries     = ArraysExt.resize(queries,    queryCount);
+        transactionLocks = connector.getOption(InternalOptionKey.LOCKS);
     }
 
     /**
@@ -336,7 +338,7 @@ public class SQLStore extends DataStore implements 
Aggregate {
      * @throws DataStoreException if an error occurred while fetching the 
components.
      */
     @Override
-    public Collection<FeatureSet> components() throws DataStoreException {
+    public Collection<Resource> components() throws DataStoreException {
         return model().tables();
     }
 
diff --git 
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStoreProvider.java
 
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStoreProvider.java
index e6fc576e6b..762618ee2c 100644
--- 
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStoreProvider.java
+++ 
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/SQLStoreProvider.java
@@ -50,7 +50,7 @@ import static 
org.apache.sis.storage.sql.feature.Database.WILDCARD;
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.4
+ * @version 1.5
  * @since   1.0
  */
 @StoreMetadata(formatName    = SQLStoreProvider.NAME,
diff --git 
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
 
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
index 23cf211df8..6e62677f7f 100644
--- 
a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
+++ 
b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
@@ -47,6 +47,7 @@ import org.apache.sis.metadata.sql.privy.Dialect;
 import org.apache.sis.metadata.sql.privy.Reflection;
 import org.apache.sis.metadata.sql.privy.SQLBuilder;
 import org.apache.sis.metadata.sql.privy.SQLUtilities;
+import org.apache.sis.storage.Resource;
 import org.apache.sis.storage.FeatureSet;
 import org.apache.sis.storage.FeatureNaming;
 import org.apache.sis.storage.DataStoreException;
@@ -534,7 +535,7 @@ public class Database<G> extends Syntax  {
      *
      * @return all tables in an unmodifiable list.
      */
-    public final List<FeatureSet> tables() {
+    public final List<Resource> tables() {
         return UnmodifiableArrayList.wrap(tables);
     }
 
diff --git 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/InternalOptionKey.java
 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/InternalOptionKey.java
index 42547e5cda..b34ff79a7d 100644
--- 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/InternalOptionKey.java
+++ 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/InternalOptionKey.java
@@ -16,8 +16,10 @@
  */
 package org.apache.sis.io.stream;
 
+import java.util.Map;
 import java.util.function.Predicate;
 import java.util.function.UnaryOperator;
+import java.util.concurrent.locks.ReadWriteLock;
 import org.apache.sis.setup.OptionKey;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStoreProvider;
@@ -53,6 +55,29 @@ public final class InternalOptionKey<T> extends OptionKey<T> 
{
     public static final InternalOptionKey<UnaryOperator<ChannelFactory>> 
CHANNEL_FACTORY_WRAPPER =
             (InternalOptionKey) new 
InternalOptionKey<>("READ_CHANNEL_WRAPPER", UnaryOperator.class);
 
+    /**
+     * The lock to use in a data store when those locks are optional. For 
example, data stores on
+     * <abbr>SQL</abbr> databases should not need locks because 
<abbr>ACID</abbr>-compliant databases
+     * should support thread-safe transactions. However, some database 
products do not provide the
+     * expected thread-safety, in which case Apache <abbr>SIS</abbr> may need 
to do locking itself.
+     */
+    public static final InternalOptionKey<ReadWriteLock> LOCKS =
+            new InternalOptionKey<>("LOCKS", ReadWriteLock.class);
+
+    /**
+     * Additional information for the data store. This option is used for 
directives that are not defined
+     * by Apache SIS, but are rather defined by some underlying 
implementations to which Apache SIS will
+     * pass the PRAGMA statements verbatim.
+     * Examples:
+     *
+     * <ul>
+     *   <li><a href="https://www.sqlite.org/pragma.html";>SQLite PRAGMA 
statements</a>.</li>
+     * </ul>
+     */
+    @SuppressWarnings("unchecked")
+    public static final InternalOptionKey<Map<String,String>> PRAGMAS =
+            (InternalOptionKey) new InternalOptionKey<>("PRAGMAS", Map.class);
+
     /**
      * Creates a new key of the given name.
      *
diff --git 
a/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/featureset/GpkgFeatureSet.java
 
b/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/featureset/GpkgFeatureSet.java
index 943bb9fa2a..0fb1a94a49 100644
--- 
a/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/featureset/GpkgFeatureSet.java
+++ 
b/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/featureset/GpkgFeatureSet.java
@@ -89,7 +89,7 @@ final class GpkgFeatureSet extends AbstractResource 
implements FeatureSet, GpkgC
         final ResourceDefinition table = ResourceDefinition.table(null, null, 
row.tableName);
 
         final SQLStore sqlStore = new SQLStore(new SQLStoreProvider(), 
connector, table);
-        sqlSet = sqlStore.components().iterator().next();
+        sqlSet = (FeatureSet) sqlStore.components().iterator().next();
         return sqlSet;
     }
 

Reply via email to