This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a commit to branch calcite
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
The following commit(s) were added to refs/heads/calcite by this push:
new 863feb75 Refactor the collection package
863feb75 is described below
commit 863feb753c3e5c100d89545987b8abf7e63e9ec3
Author: Bertil Chapuis <[email protected]>
AuthorDate: Wed Jun 21 11:40:18 2023 +0200
Refactor the collection package
---
.../java/org/apache/baremaps/calcite/Calcite.java | 61 ++++++------
.../baremaps/collection/DataCollectionAdapter.java | 56 +++++++++++
.../{AbstractTable.java => AbstractDataTable.java} | 2 +-
.../store/{Column.java => DataColumn.java} | 2 +-
.../store/{ColumnImpl.java => DataColumnImpl.java} | 2 +-
.../collection/store/{Row.java => DataRow.java} | 8 +-
.../store/{RowImpl.java => DataRowImpl.java} | 18 +++-
.../store/{Schema.java => DataSchema.java} | 6 +-
.../store/{SchemaImpl.java => DataSchemaImpl.java} | 36 ++++---
.../store/{Store.java => DataStore.java} | 10 +-
.../store/{Table.java => DataTable.java} | 4 +-
.../{TableImpl.java => DataTableAdapter.java} | 48 ++++------
...TableException.java => DataTableException.java} | 13 +--
.../store/DataTableGeometryTransformer.java | 57 +++++++++++
.../store/{TableImpl.java => DataTableImpl.java} | 32 +++----
.../baremaps/collection/store/TableAdapter.java | 60 ------------
.../baremaps/collection/store/TableDecorator.java | 88 -----------------
.../baremaps/collection/type/RowDataType.java | 32 +++----
.../org/apache/baremaps/iploc/IpLocRepository.java | 8 +-
.../postgres/PostgresHeaderRepository.java | 2 +-
...atGeoBufStore.java => FlatGeoBufDataStore.java} | 34 +++----
...atGeoBufTable.java => FlatGeoBufDataTable.java} | 52 +++++-----
.../flatgeobuf/internal/TableConversions.java | 22 ++---
...oPackageStore.java => GeoPackageDataStore.java} | 20 ++--
...oPackageTable.java => GeoPackageDataTable.java} | 38 ++++----
.../{PostgresStore.java => PostgresDataStore.java} | 76 +++++++--------
.../{PostgresTable.java => PostgresDataTable.java} | 78 +++++++--------
...ShapefileStore.java => ShapefileDataStore.java} | 18 ++--
...ShapefileTable.java => ShapefileDataTable.java} | 26 ++---
.../shapefile/internal/DbaseByteReader.java | 8 +-
.../shapefile/internal/ShapefileByteReader.java | 46 ++++-----
.../shapefile/internal/ShapefileInputStream.java | 22 ++---
.../shapefile/internal/ShapefileReader.java | 10 +-
.../vectortile/expression/Expressions.java | 106 ++++++++++-----------
.../baremaps/workflow/tasks/ImportGeoPackage.java | 24 +++--
.../baremaps/workflow/tasks/ImportShapefile.java | 17 ++--
.../baremaps/collection/type/DataTypeProvider.java | 47 +++++----
.../storage/{MockTable.java => MockDataTable.java} | 42 ++++----
...TableTest.java => FlatGeoBufDataTableTest.java} | 12 +--
...StoreTest.java => GeoPackageDataStoreTest.java} | 6 +-
.../geopackage/GeoPackageToPostgresTest.java | 6 +-
...esStoreTest.java => PostgresDataStoreTest.java} | 14 +--
...esTableTest.java => PostgresDataTableTest.java} | 18 ++--
.../{TileStoreTest.java => TileDataStoreTest.java} | 2 +-
...leStoreTest.java => FileTileDataStoreTest.java} | 4 +-
.../baremaps/tilestore/mbtiles/MBTilesTest.java | 4 +-
...oreTest.java => PostgresTileDataStoreTest.java} | 2 +-
.../baremaps/vectortile/ExpressionsTest.java | 16 ++--
.../src/test/resources/queries/schema.sql | 2 +-
.../baremaps/ogcapi/CollectionsResource.java | 14 +--
.../main/resources/initialize_ogcapi_tables.sql | 6 +-
.../main/resources/initialize_studio_tables.sql | 4 +-
baremaps-renderer/assets/report-template.html | 4 +-
.../src/main/resources/assets/viewer.html | 10 +-
.../src/main/resources/geocoder/index.html | 32 +++----
.../src/main/resources/iploc/index.html | 32 +++----
56 files changed, 703 insertions(+), 716 deletions(-)
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/calcite/Calcite.java
b/baremaps-core/src/main/java/org/apache/baremaps/calcite/Calcite.java
index 9d819f74..7c4b5958 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/calcite/Calcite.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/calcite/Calcite.java
@@ -16,9 +16,11 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Collection;
import java.util.List;
import java.util.Properties;
import org.apache.baremaps.collection.AppendOnlyBuffer;
+import org.apache.baremaps.collection.DataCollectionAdapter;
import org.apache.baremaps.collection.IndexedDataList;
import org.apache.baremaps.collection.store.*;
import org.apache.baremaps.collection.type.RowDataType;
@@ -36,38 +38,40 @@ import org.apache.calcite.sql.type.SqlTypeName;
public class Calcite {
- private static final Schema PLAYER_SCHEMA = new SchemaImpl("player", List.of(
- new ColumnImpl("id", Integer.class),
- new ColumnImpl("name", String.class),
- new ColumnImpl("level", Integer.class)));
+ private static final DataSchema PLAYER_DATA_SCHEMA = new
DataSchemaImpl("player", List.of(
+ new DataColumnImpl("id", Integer.class),
+ new DataColumnImpl("name", String.class),
+ new DataColumnImpl("level", Integer.class)));
- private static final Table PLAYER_TABLE = new TableImpl(
- PLAYER_SCHEMA,
- new IndexedDataList<>(new AppendOnlyBuffer<>(new
RowDataType(PLAYER_SCHEMA))));
+ private static final DataTable PLAYER_DATA_TABLE = new DataTableImpl(
+ PLAYER_DATA_SCHEMA,
+ new IndexedDataList<>(new AppendOnlyBuffer<>(new
RowDataType(PLAYER_DATA_SCHEMA))));
static {
- PLAYER_TABLE.add(new RowImpl(PLAYER_TABLE.schema(), List.of(1, "Wizard",
5)));
- PLAYER_TABLE.add(new RowImpl(PLAYER_TABLE.schema(), List.of(2, "Hunter",
7)));
+ PLAYER_DATA_TABLE.add(new DataRowImpl(PLAYER_DATA_TABLE.schema(),
List.of(1, "Wizard", 5)));
+ PLAYER_DATA_TABLE.add(new DataRowImpl(PLAYER_DATA_TABLE.schema(),
List.of(2, "Hunter", 7)));
}
- private static final Schema EQUIPMENT_SCHEMA = new SchemaImpl("equipment",
List.of(
- new ColumnImpl("id", Integer.class),
- new ColumnImpl("name", String.class),
- new ColumnImpl("damage", Integer.class),
- new ColumnImpl("player_id", Integer.class)));
+ private static final DataSchema EQUIPMENT_DATA_SCHEMA = new
DataSchemaImpl("equipment", List.of(
+ new DataColumnImpl("id", Integer.class),
+ new DataColumnImpl("name", String.class),
+ new DataColumnImpl("damage", Integer.class),
+ new DataColumnImpl("player_id", Integer.class)));
- private static final Table EQUIPMENT_TABLE = new TableImpl(
- EQUIPMENT_SCHEMA,
- new IndexedDataList<>(new AppendOnlyBuffer<>(new
RowDataType(EQUIPMENT_SCHEMA))));
+ private static final DataTable EQUIPMENT_DATA_TABLE = new DataTableImpl(
+ EQUIPMENT_DATA_SCHEMA,
+ new IndexedDataList<>(new AppendOnlyBuffer<>(new
RowDataType(EQUIPMENT_DATA_SCHEMA))));
static {
- EQUIPMENT_TABLE.add(new RowImpl(EQUIPMENT_TABLE.schema(), List.of(1,
"fireball", 7, 1)));
- EQUIPMENT_TABLE.add(new RowImpl(EQUIPMENT_TABLE.schema(), List.of(2,
"rifle", 4, 2)));
+ EQUIPMENT_DATA_TABLE
+ .add(new DataRowImpl(EQUIPMENT_DATA_TABLE.schema(), List.of(1,
"fireball", 7, 1)));
+ EQUIPMENT_DATA_TABLE
+ .add(new DataRowImpl(EQUIPMENT_DATA_TABLE.schema(), List.of(2,
"rifle", 4, 2)));
}
public static void main(String[] args) throws SQLException {
Properties info = new Properties();
- info.setProperty("lex", "MYSQL");
+ info.setProperty("lex", "JAVA");
Connection connection = DriverManager.getConnection("jdbc:calcite:", info);
CalciteConnection calciteConnection =
@@ -75,10 +79,10 @@ public class Calcite {
SchemaPlus rootSchema = calciteConnection.getRootSchema();
- ListTable playerTable = new ListTable(PLAYER_TABLE);
+ ListTable playerTable = new ListTable(PLAYER_DATA_TABLE);
rootSchema.add("player", playerTable);
- ListTable equipmentTable = new ListTable(EQUIPMENT_TABLE);
+ ListTable equipmentTable = new ListTable(EQUIPMENT_DATA_TABLE);
rootSchema.add("equipment", equipmentTable);
String sql =
@@ -99,23 +103,24 @@ public class Calcite {
*/
private static class ListTable extends AbstractTable implements
ScannableTable {
- private final Table table;
+ private final DataTable dataTable;
- ListTable(Table table) {
- this.table = table;
+ ListTable(DataTable dataTable) {
+ this.dataTable = dataTable;
}
@Override
public Enumerable<Object[]> scan(final DataContext root) {
- var collection = new TableAdapter<>(table, row ->
row.values().toArray());
+ Collection<Object[]> collection =
+ new DataCollectionAdapter<>(dataTable, row ->
row.values().toArray());
return Linq4j.asEnumerable(collection);
}
@Override
public RelDataType getRowType(final RelDataTypeFactory typeFactory) {
var rowType = new RelDataTypeFactory.Builder(typeFactory);
- for (Column column : table.schema().columns()) {
- rowType.add(column.name(), toSqlType(column.type()));
+ for (DataColumn dataColumn : dataTable.schema().columns()) {
+ rowType.add(dataColumn.name(), toSqlType(dataColumn.type()));
}
return rowType.build();
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/DataCollectionAdapter.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/DataCollectionAdapter.java
new file mode 100644
index 00000000..a58a5a64
--- /dev/null
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/DataCollectionAdapter.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed 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.baremaps.collection;
+
+
+import java.util.Iterator;
+import java.util.function.Function;
+import org.apache.baremaps.collection.AbstractDataCollection;
+import org.apache.baremaps.collection.DataCollection;
+
+/**
+ * A decorator for a table that transforms the geometries of the rows.
+ */
+public class DataCollectionAdapter<S, T> extends AbstractDataCollection<T> {
+
+ private final DataCollection<S> dataCollection;
+
+ private final Function<S, T> transformer;
+
+ /**
+ * Constructs a new table decorator.
+ *
+ * @param dataCollection the table to decorate
+ * @param transformer the row transformer
+ */
+ public DataCollectionAdapter(DataCollection<S> dataCollection, Function<S,
T> transformer) {
+ this.dataCollection = dataCollection;
+ this.transformer = transformer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Iterator iterator() {
+ return dataCollection.stream().map(this.transformer).iterator();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public long sizeAsLong() {
+ return dataCollection.sizeAsLong();
+ }
+}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/AbstractTable.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/AbstractDataTable.java
similarity index 87%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/AbstractTable.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/AbstractDataTable.java
index abf1a8f3..9f3cec73 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/AbstractTable.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/AbstractDataTable.java
@@ -17,6 +17,6 @@ import org.apache.baremaps.collection.AbstractDataCollection;
/**
* A table is a collection of rows respecting a schema.
*/
-public abstract class AbstractTable extends AbstractDataCollection<Row>
implements Table {
+public abstract class AbstractDataTable extends
AbstractDataCollection<DataRow> implements DataTable {
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Column.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataColumn.java
similarity index 96%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/Column.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataColumn.java
index 6163dcb8..bfcaf586 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Column.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataColumn.java
@@ -15,7 +15,7 @@ package org.apache.baremaps.collection.store;
/**
* A column in a table.
*/
-public interface Column {
+public interface DataColumn {
/**
* Returns the name of the column.
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/ColumnImpl.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataColumnImpl.java
similarity index 89%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/ColumnImpl.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataColumnImpl.java
index 7f187c4d..b7001196 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/ColumnImpl.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataColumnImpl.java
@@ -15,6 +15,6 @@ package org.apache.baremaps.collection.store;
/**
* A column in a table.
*/
-public record ColumnImpl(String name, Class type) implements Column {
+public record DataColumnImpl(String name, Class type) implements DataColumn {
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Row.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataRow.java
similarity index 92%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/Row.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataRow.java
index d0f0b82a..9288b075 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Row.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataRow.java
@@ -17,14 +17,14 @@ import java.util.List;
/**
* A row in a table.
*/
-public interface Row {
+public interface DataRow {
/**
* Returns the schema of the row.
*
* @return the schema of the row
*/
- Schema schema();
+ DataSchema schema();
/**
* Returns the values of the columns in the row.
@@ -72,7 +72,7 @@ public interface Row {
* @param value the value
* @return the row
*/
- default Row with(String column, Object value) {
+ default DataRow with(String column, Object value) {
set(column, value);
return this;
}
@@ -84,7 +84,7 @@ public interface Row {
* @param value the value
* @return the row
*/
- default Row with(int index, Object value) {
+ default DataRow with(int index, Object value) {
set(index, value);
return this;
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/RowImpl.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataRowImpl.java
similarity index 75%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/RowImpl.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataRowImpl.java
index d3824ad7..f8a3afaf 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/RowImpl.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataRowImpl.java
@@ -17,15 +17,23 @@ import java.util.List;
/**
* A row in a table.
*/
-public record RowImpl(Schema schema, List values) implements Row {
+public record DataRowImpl(DataSchema dataSchema, List values) implements
DataRow {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DataSchema schema() {
+ return null;
+ }
/**
* {@inheritDoc}
*/
@Override
public Object get(String column) {
- for (int i = 0; i < schema().columns().size(); i++) {
- if (schema().columns().get(i).name().equals(column)) {
+ for (int i = 0; i < dataSchema().columns().size(); i++) {
+ if (dataSchema().columns().get(i).name().equals(column)) {
return values.get(i);
}
}
@@ -45,8 +53,8 @@ public record RowImpl(Schema schema, List values) implements
Row {
*/
@Override
public void set(String column, Object value) {
- for (int i = 0; i < schema().columns().size(); i++) {
- if (schema().columns().get(i).name().equals(column)) {
+ for (int i = 0; i < dataSchema().columns().size(); i++) {
+ if (dataSchema().columns().get(i).name().equals(column)) {
values.set(i, value);
return;
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Schema.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataSchema.java
similarity index 92%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/Schema.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataSchema.java
index 488a4289..42f632a9 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Schema.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataSchema.java
@@ -17,7 +17,7 @@ import java.util.List;
/**
* A schema defines the structure of a table.
*/
-public interface Schema {
+public interface DataSchema {
/**
* Returns the name of the schema.
@@ -31,13 +31,13 @@ public interface Schema {
*
* @return the columns of the schema
*/
- List<Column> columns();
+ List<DataColumn> columns();
/**
* Creates a new row of the schema.
*
* @return a new row of the schema
*/
- Row createRow();
+ DataRow createRow();
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/SchemaImpl.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataSchemaImpl.java
similarity index 58%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/SchemaImpl.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataSchemaImpl.java
index 014d0cc2..e0cb259a 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/SchemaImpl.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataSchemaImpl.java
@@ -20,42 +20,54 @@ import java.util.Map;
/**
* A schema defines the structure of a table.
*/
-public class SchemaImpl implements Schema {
+public class DataSchemaImpl implements DataSchema {
private final String name;
- private final List<Column> columns;
+ private final List<DataColumn> dataColumns;
private final Map<String, Integer> index;
- public SchemaImpl(String name, List<Column> columns) {
+ /**
+ * Constructs a schema.
+ *
+ * @param name the name of the schema
+ * @param dataColumns the columns of the schema
+ */
+ public DataSchemaImpl(String name, List<DataColumn> dataColumns) {
this.name = name;
- this.columns = columns;
+ this.dataColumns = dataColumns;
this.index = new HashMap<>();
- for (int i = 0; i < columns.size(); i++) {
- index.put(columns.get(i).name(), i);
+ for (int i = 0; i < dataColumns.size(); i++) {
+ index.put(dataColumns.get(i).name(), i);
}
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String name() {
return name;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
- public List<Column> columns() {
- return columns;
+ public List<DataColumn> columns() {
+ return dataColumns;
}
/**
* {@inheritDoc}
*/
@Override
- public Row createRow() {
- var values = new ArrayList<>(columns.size());
- for (int i = 0; i < columns.size(); i++) {
+ public DataRow createRow() {
+ var values = new ArrayList<>(dataColumns.size());
+ for (int i = 0; i < dataColumns.size(); i++) {
values.add(null);
}
- return new RowImpl(this, values);
+ return new DataRowImpl(this, values);
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Store.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataStore.java
similarity index 80%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/Store.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataStore.java
index 06d3f9f8..7f650449 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Store.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataStore.java
@@ -17,14 +17,14 @@ import java.util.Collection;
/**
* A store is a collection of tables.
*/
-public interface Store {
+public interface DataStore {
/**
* Lists the names of the tables.
*
* @return the names of the tables
*/
- Collection<String> list() throws TableException;
+ Collection<String> list() throws DataTableException;
/**
* Gets a table by its name.
@@ -32,20 +32,20 @@ public interface Store {
* @param name the name of the table
* @return the table
*/
- Table get(String name) throws TableException;
+ DataTable get(String name) throws DataTableException;
/**
* Adds a table to the store.
*
* @param value the table
*/
- void add(Table value) throws TableException;
+ void add(DataTable value) throws DataTableException;
/**
* Removes a table from the store.
*
* @param name the name of the table
*/
- void remove(String name) throws TableException;
+ void remove(String name) throws DataTableException;
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Table.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTable.java
similarity index 90%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/Table.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTable.java
index b346c851..da4643b8 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/Table.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTable.java
@@ -17,13 +17,13 @@ import org.apache.baremaps.collection.DataCollection;
/**
* A table is a collection of rows respecting a schema.
*/
-public interface Table extends DataCollection<Row> {
+public interface DataTable extends DataCollection<DataRow> {
/**
* Returns the schema of the table.
*
* @return the schema of the table
*/
- Schema schema();
+ DataSchema schema();
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableImpl.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableAdapter.java
similarity index 50%
copy from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableImpl.java
copy to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableAdapter.java
index e4a511f7..3749aa84 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableImpl.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableAdapter.java
@@ -12,53 +12,45 @@
package org.apache.baremaps.collection.store;
-import java.util.Collection;
+
import java.util.Iterator;
+import java.util.function.Function;
import org.apache.baremaps.collection.AbstractDataCollection;
-import org.apache.baremaps.collection.DataCollection;
/**
- * A table is a collection of rows respecting a schema.
+ * A decorator for a table that transforms the geometries of the rows.
*/
-public class TableImpl extends AbstractDataCollection<Row> implements Table {
+public class DataTableAdapter extends AbstractDataCollection<DataRow>
implements DataTable {
- private final Schema schema;
+ private final DataTable dataTable;
- private final Collection<Row> rows;
+ private final Function<DataRow, DataRow> transformer;
/**
- * Constructs a table with the specified schema.
+ * Constructs a new table decorator.
*
- * @param schema the schema of the table
- * @param rows the collection of rows
+ * @param dataTable the table to decorate
+ * @param transformer the row transformer
*/
- public TableImpl(Schema schema, Collection<Row> rows) {
- this.schema = schema;
- this.rows = rows;
+ public DataTableAdapter(DataTable dataTable, Function<DataRow, DataRow>
transformer) {
+ this.dataTable = dataTable;
+ this.transformer = transformer;
}
/**
* {@inheritDoc}
*/
@Override
- public Schema schema() {
- return schema;
+ public DataSchema schema() {
+ return dataTable.schema();
}
/**
* {@inheritDoc}
*/
@Override
- public boolean add(Row e) {
- return rows.add(e);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Iterator<Row> iterator() {
- return rows.iterator();
+ public Iterator iterator() {
+ return dataTable.stream().map(this.transformer).iterator();
}
/**
@@ -66,10 +58,8 @@ public class TableImpl extends AbstractDataCollection<Row>
implements Table {
*/
@Override
public long sizeAsLong() {
- if (rows instanceof DataCollection dataCollection) {
- return dataCollection.sizeAsLong();
- } else {
- return rows.size();
- }
+ return dataTable.sizeAsLong();
}
+
+
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableException.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableException.java
similarity index 76%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableException.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableException.java
index 0edf2c2b..06902950 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableException.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableException.java
@@ -13,16 +13,17 @@
package org.apache.baremaps.collection.store;
/** Signals that an exception occurred in a table. */
-public class TableException extends RuntimeException {
- /** Constructs a {@code TableException} with {@code null} as its error
detail message. */
- public TableException() {}
+public class DataTableException extends RuntimeException {
+
+ /** Constructs a {@link DataTableException} with {@code null} as its error
detail message. */
+ public DataTableException() {}
/**
* Constructs an {@code TableException} with the specified detail message.
*
* @param message the message
*/
- public TableException(String message) {
+ public DataTableException(String message) {
super(message);
}
@@ -31,7 +32,7 @@ public class TableException extends RuntimeException {
*
* @param cause the cause
*/
- public TableException(Throwable cause) {
+ public DataTableException(Throwable cause) {
super(cause);
}
@@ -41,7 +42,7 @@ public class TableException extends RuntimeException {
* @param message the message
* @param cause the cause
*/
- public TableException(String message, Throwable cause) {
+ public DataTableException(String message, Throwable cause) {
super(message, cause);
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableGeometryTransformer.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableGeometryTransformer.java
new file mode 100644
index 00000000..9642628b
--- /dev/null
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableGeometryTransformer.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed 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.baremaps.collection.store;
+
+import java.util.function.Function;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.util.GeometryTransformer;
+
+/**
+ * A transformer that applies a {@code GeometryTransformer} to the geometries
of a {@code DataTable}.
+ */
+public class DataTableGeometryTransformer implements Function<DataRow,
DataRow> {
+
+ private final DataTable dataTable;
+
+ private final GeometryTransformer geometryTransformer;
+
+ /**
+ * Constructs a new table transformer.
+ *
+ * @param dataTable the table to transform
+ * @param geometryTransformer the geometry transformer
+ */
+ public DataTableGeometryTransformer(DataTable dataTable, GeometryTransformer
geometryTransformer) {
+ this.dataTable = dataTable;
+ this.geometryTransformer = geometryTransformer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DataRow apply(DataRow dataRow) {
+ var columns = dataTable.schema()
+ .columns().stream()
+ .filter(column -> column.type().isAssignableFrom(Geometry.class))
+ .toList();
+ for (DataColumn dataColumn : columns) {
+ var name = dataColumn.name();
+ var geometry = (Geometry) dataRow.get(name);
+ if (geometry != null) {
+ dataRow.set(name, geometryTransformer.transform(geometry));
+ }
+ }
+ return dataRow;
+ }
+}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableImpl.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableImpl.java
similarity index 63%
rename from
baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableImpl.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableImpl.java
index e4a511f7..7ef51c24 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableImpl.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/DataTableImpl.java
@@ -20,45 +20,45 @@ import org.apache.baremaps.collection.DataCollection;
/**
* A table is a collection of rows respecting a schema.
*/
-public class TableImpl extends AbstractDataCollection<Row> implements Table {
+public class DataTableImpl extends AbstractDataCollection<DataRow> implements
DataTable {
- private final Schema schema;
+ private final DataSchema dataSchema;
- private final Collection<Row> rows;
+ private final Collection<DataRow> dataRows;
/**
* Constructs a table with the specified schema.
*
- * @param schema the schema of the table
- * @param rows the collection of rows
+ * @param dataSchema the schema of the table
+ * @param dataRows the collection of rows
*/
- public TableImpl(Schema schema, Collection<Row> rows) {
- this.schema = schema;
- this.rows = rows;
+ public DataTableImpl(DataSchema dataSchema, Collection<DataRow> dataRows) {
+ this.dataSchema = dataSchema;
+ this.dataRows = dataRows;
}
/**
* {@inheritDoc}
*/
@Override
- public Schema schema() {
- return schema;
+ public DataSchema schema() {
+ return dataSchema;
}
/**
* {@inheritDoc}
*/
@Override
- public boolean add(Row e) {
- return rows.add(e);
+ public boolean add(DataRow e) {
+ return dataRows.add(e);
}
/**
* {@inheritDoc}
*/
@Override
- public Iterator<Row> iterator() {
- return rows.iterator();
+ public Iterator<DataRow> iterator() {
+ return dataRows.iterator();
}
/**
@@ -66,10 +66,10 @@ public class TableImpl extends AbstractDataCollection<Row>
implements Table {
*/
@Override
public long sizeAsLong() {
- if (rows instanceof DataCollection dataCollection) {
+ if (dataRows instanceof DataCollection dataCollection) {
return dataCollection.sizeAsLong();
} else {
- return rows.size();
+ return dataRows.size();
}
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableAdapter.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableAdapter.java
deleted file mode 100644
index 4976776c..00000000
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableAdapter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed 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.baremaps.collection.store;
-
-import java.util.AbstractCollection;
-import java.util.Iterator;
-import java.util.function.Function;
-
-public class TableAdapter<T> extends AbstractCollection<T> {
-
- private final Function<Row, T> transformer;
-
- private final Table table;
-
- public TableAdapter(Table table, Function<Row, T> transformer) {
- this.transformer = transformer;
- this.table = table;
- }
-
- @Override
- public Iterator iterator() {
- return new TableIterator(table.iterator());
- }
-
- @Override
- public int size() {
- return table.size();
- }
-
- private class TableIterator implements Iterator<T> {
-
- private final Iterator<Row> iterator;
-
- public TableIterator(Iterator<Row> iterator) {
- this.iterator = iterator;
- }
-
- @Override
- public boolean hasNext() {
- return iterator.hasNext();
- }
-
- @Override
- public T next() {
- var row = iterator.next();
- return transformer.apply(row);
- }
- }
-
-}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableDecorator.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableDecorator.java
deleted file mode 100644
index cc1b2a31..00000000
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/store/TableDecorator.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed 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.baremaps.collection.store;
-
-
-import java.util.Iterator;
-import java.util.function.Function;
-import org.apache.baremaps.collection.AbstractDataCollection;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.util.GeometryTransformer;
-
-/**
- * A decorator for a table that transforms the geometries of the rows.
- */
-public class TableDecorator extends AbstractDataCollection<Row> implements
Table {
-
- private final Table table;
-
- private final Function<Row, Row> transformer;
-
- /**
- * Constructs a new table geometry decorator.
- *
- * @param table the table to decorate
- * @param geometryTransformer the geometry transformer
- */
- public TableDecorator(Table table, GeometryTransformer geometryTransformer) {
- this(table, row -> {
- var columns = table.schema()
- .columns().stream()
- .filter(column -> column.type().isAssignableFrom(Geometry.class))
- .toList();
- for (Column column : columns) {
- var name = column.name();
- var geometry = (Geometry) row.get(name);
- if (geometry != null) {
- row.set(name, geometryTransformer.transform(geometry));
- }
- }
- return row;
- });
- }
-
- /**
- * Constructs a new table decorator.
- *
- * @param table the table to decorate
- * @param transformer the row transformer
- */
- public TableDecorator(Table table, Function<Row, Row> transformer) {
- this.table = table;
- this.transformer = transformer;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Schema schema() {
- return table.schema();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Iterator<Row> iterator() {
- return table.stream().map(this.transformer).iterator();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long sizeAsLong() {
- return table.sizeAsLong();
- }
-}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/RowDataType.java
b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/RowDataType.java
index df9cd00a..3fc9c169 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/collection/type/RowDataType.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/collection/type/RowDataType.java
@@ -16,13 +16,13 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import org.apache.baremaps.collection.store.Row;
-import org.apache.baremaps.collection.store.RowImpl;
-import org.apache.baremaps.collection.store.Schema;
+import org.apache.baremaps.collection.store.DataRow;
+import org.apache.baremaps.collection.store.DataRowImpl;
+import org.apache.baremaps.collection.store.DataSchema;
import org.apache.baremaps.collection.type.geometry.*;
import org.locationtech.jts.geom.*;
-public class RowDataType implements DataType<Row> {
+public class RowDataType implements DataType<DataRow> {
private static final Map<Class, DataType> types;
@@ -47,20 +47,20 @@ public class RowDataType implements DataType<Row> {
types.put(Coordinate.class, new CoordinateDataType());
}
- private final Schema schema;
+ private final DataSchema dataSchema;
- public RowDataType(Schema schema) {
- this.schema = schema;
+ public RowDataType(DataSchema dataSchema) {
+ this.dataSchema = dataSchema;
}
@Override
- public int size(Row row) {
+ public int size(DataRow dataRow) {
var size = Integer.BYTES;
- var columns = schema.columns();
+ var columns = dataSchema.columns();
for (int i = 0; i < columns.size(); i++) {
var columnType = columns.get(i).type();
var dataType = types.get(columnType);
- var value = row.get(i);
+ var value = dataRow.get(i);
size += dataType.size(value);
}
return size;
@@ -72,14 +72,14 @@ public class RowDataType implements DataType<Row> {
}
@Override
- public void write(final ByteBuffer buffer, final int position, final Row
row) {
+ public void write(final ByteBuffer buffer, final int position, final DataRow
dataRow) {
var p = position + Integer.BYTES;
- var columns = schema.columns();
+ var columns = dataSchema.columns();
for (int i = 0; i < columns.size(); i++) {
var column = columns.get(i);
var columnType = column.type();
var dataType = types.get(columnType);
- var value = row.get(i);
+ var value = dataRow.get(i);
dataType.write(buffer, p, value);
p += dataType.size(buffer, p);
}
@@ -87,9 +87,9 @@ public class RowDataType implements DataType<Row> {
}
@Override
- public Row read(final ByteBuffer buffer, final int position) {
+ public DataRow read(final ByteBuffer buffer, final int position) {
var p = position + Integer.BYTES;
- var columns = schema.columns();
+ var columns = dataSchema.columns();
var values = new ArrayList();
for (int i = 0; i < columns.size(); i++) {
var column = columns.get(i);
@@ -98,6 +98,6 @@ public class RowDataType implements DataType<Row> {
values.add(dataType.read(buffer, p));
p += dataType.size(buffer, p);
}
- return new RowImpl(schema, values);
+ return new DataRowImpl(dataSchema, values);
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/iploc/IpLocRepository.java
b/baremaps-core/src/main/java/org/apache/baremaps/iploc/IpLocRepository.java
index 9f554c90..e3a433db 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/iploc/IpLocRepository.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/iploc/IpLocRepository.java
@@ -80,26 +80,26 @@ public final class IpLocRepository {
}
/**
- * Drops the table.
+ * Drops the dataTable.
*/
public void dropTable() {
try (var connection = dataSource.getConnection();
var statement = connection.prepareStatement(DROP_TABLE)) {
statement.execute();
} catch (SQLException e) {
- logger.error("Unable to drop inetnum locations table", e);
+ logger.error("Unable to drop inetnum locations dataTable", e);
}
}
/**
- * Creates the table.
+ * Creates the dataTable.
*/
public void createTable() {
try (var connection = dataSource.getConnection();
var statement = connection.prepareStatement(CREATE_TABLE)) {
statement.execute();
} catch (SQLException e) {
- logger.error("Unable to create inetnum locations table", e);
+ logger.error("Unable to create inetnum locations dataTable", e);
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresHeaderRepository.java
b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresHeaderRepository.java
index b7e5a651..2d478c3e 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresHeaderRepository.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresHeaderRepository.java
@@ -32,7 +32,7 @@ import org.apache.baremaps.postgres.copy.CopyWriter;
import org.postgresql.PGConnection;
import org.postgresql.copy.PGCopyOutputStream;
-/** Provides an implementation of the {@code HeaderRepository} baked by a
PostgreSQL table. */
+/** Provides an implementation of the {@code HeaderRepository} baked by a
PostgreSQL dataTable. */
public class PostgresHeaderRepository implements HeaderRepository {
private final DataSource dataSource;
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufStore.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufDataStore.java
similarity index 65%
rename from
baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufStore.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufDataStore.java
index 9cd19e08..15ffaa33 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufStore.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufDataStore.java
@@ -16,18 +16,18 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
-import org.apache.baremaps.collection.store.Store;
-import org.apache.baremaps.collection.store.Table;
-import org.apache.baremaps.collection.store.TableException;
+import org.apache.baremaps.collection.store.DataStore;
+import org.apache.baremaps.collection.store.DataTable;
+import org.apache.baremaps.collection.store.DataTableException;
/**
* A store corresponding to the flatgeobuf files of a directory.
*/
-public class FlatGeoBufStore implements Store {
+public class FlatGeoBufDataStore implements DataStore {
private final Path directory;
- public FlatGeoBufStore(Path directory) {
+ public FlatGeoBufDataStore(Path directory) {
this.directory = directory;
}
@@ -35,14 +35,14 @@ public class FlatGeoBufStore implements Store {
* {@inheritDoc}
*/
@Override
- public Collection<String> list() throws TableException {
+ public Collection<String> list() throws DataTableException {
try (var files = Files.list(directory)) {
return files
.filter(file -> file.toString().toLowerCase().endsWith(".fgb"))
.map(file -> file.getFileName().toString())
.toList();
} catch (IOException e) {
- throw new TableException(e);
+ throw new DataTableException(e);
}
}
@@ -50,26 +50,26 @@ public class FlatGeoBufStore implements Store {
* {@inheritDoc}
*/
@Override
- public Table get(String name) throws TableException {
+ public DataTable get(String name) throws DataTableException {
var path = directory.resolve(name);
- return new FlatGeoBufTable(path);
+ return new FlatGeoBufDataTable(path);
}
/**
* {@inheritDoc}
*/
@Override
- public void add(Table table) throws TableException {
- var filename = table.schema().name();
+ public void add(DataTable dataTable) throws DataTableException {
+ var filename = dataTable.schema().name();
filename = filename.endsWith(".fgb") ? filename : filename + ".fgb";
var path = directory.resolve(filename);
try {
Files.deleteIfExists(path);
Files.createFile(path);
- var flatGeoBufTable = new FlatGeoBufTable(path, table.schema());
- flatGeoBufTable.write(table);
+ var flatGeoBufTable = new FlatGeoBufDataTable(path, dataTable.schema());
+ flatGeoBufTable.write(dataTable);
} catch (IOException e) {
- throw new TableException(e);
+ throw new DataTableException(e);
}
}
@@ -77,16 +77,16 @@ public class FlatGeoBufStore implements Store {
* {@inheritDoc}
*/
@Override
- public void remove(String name) throws TableException {
+ public void remove(String name) throws DataTableException {
var path = directory.resolve(name);
if (name.equals(path.getFileName().toString())) {
try {
Files.delete(path);
} catch (IOException e) {
- throw new TableException(e);
+ throw new DataTableException(e);
}
} else {
- throw new TableException("Table not found");
+ throw new DataTableException("Table not found");
}
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufTable.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufDataTable.java
similarity index 84%
rename from
baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufTable.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufDataTable.java
index b2644e7c..0b900a67 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufTable.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufDataTable.java
@@ -23,9 +23,9 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.apache.baremaps.collection.AbstractDataCollection;
-import org.apache.baremaps.collection.store.AbstractTable;
-import org.apache.baremaps.collection.store.Row;
-import org.apache.baremaps.collection.store.Schema;
+import org.apache.baremaps.collection.store.AbstractDataTable;
+import org.apache.baremaps.collection.store.DataRow;
+import org.apache.baremaps.collection.store.DataSchema;
import org.apache.baremaps.storage.flatgeobuf.internal.TableConversions;
import org.locationtech.jts.geom.*;
import org.wololo.flatgeobuf.Constants;
@@ -38,45 +38,45 @@ import org.wololo.flatgeobuf.generated.GeometryType;
/**
* A table that stores rows in a flatgeobuf file.
*/
-public class FlatGeoBufTable extends AbstractTable {
+public class FlatGeoBufDataTable extends AbstractDataTable {
private final Path file;
- private Schema schema;
+ private DataSchema dataSchema;
/**
* Constructs a table from a flatgeobuf file (used for reading).
*
* @param file the path to the flatgeobuf file
*/
- public FlatGeoBufTable(Path file) {
+ public FlatGeoBufDataTable(Path file) {
this.file = file;
- this.schema = readSchema(file);
+ this.dataSchema = readSchema(file);
}
/**
* Constructs a table from a flatgeobuf file and a schema (used for writing).
*
* @param file the path to the flatgeobuf file
- * @param schema the schema of the table
+ * @param dataSchema the schema of the table
*/
- public FlatGeoBufTable(Path file, Schema schema) {
+ public FlatGeoBufDataTable(Path file, DataSchema dataSchema) {
this.file = file;
- this.schema = schema;
+ this.dataSchema = dataSchema;
}
/**
* {@inheritDoc}
*/
@Override
- public Schema schema() {
- return schema;
+ public DataSchema schema() {
+ return dataSchema;
}
/**
* {@inheritDoc}
*/
- public static Schema readSchema(Path file) {
+ public static DataSchema readSchema(Path file) {
try (var channel = FileChannel.open(file, StandardOpenOption.READ)) {
// try to read the schema from the file
var buffer = ByteBuffer.allocate(1 << 20).order(ByteOrder.LITTLE_ENDIAN);
@@ -91,7 +91,7 @@ public class FlatGeoBufTable extends AbstractTable {
* {@inheritDoc}
*/
@Override
- public Iterator<Row> iterator() {
+ public Iterator<DataRow> iterator() {
try {
var channel = FileChannel.open(file, StandardOpenOption.READ);
@@ -108,7 +108,7 @@ public class FlatGeoBufTable extends AbstractTable {
buffer.clear();
// create the feature stream
- return new RowIterator(channel, headerMeta, schema, buffer);
+ return new RowIterator(channel, headerMeta, dataSchema, buffer);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -149,7 +149,7 @@ public class FlatGeoBufTable extends AbstractTable {
* @param features the collection of rows to write
* @throws IOException if an error occurs while writing the rows
*/
- public void write(Collection<Row> features) throws IOException {
+ public void write(Collection<DataRow> features) throws IOException {
try (
var channel = FileChannel.open(file, StandardOpenOption.CREATE,
StandardOpenOption.WRITE);
var outputStream = Channels.newOutputStream(channel)) {
@@ -162,9 +162,9 @@ public class FlatGeoBufTable extends AbstractTable {
headerMeta.indexNodeSize = 16;
headerMeta.srid = 3857;
headerMeta.featuresCount =
- features instanceof AbstractDataCollection<Row>c ? c.sizeAsLong() :
features.size();
- headerMeta.name = schema.name();
- headerMeta.columns = TableConversions.asColumns(schema.columns());
+ features instanceof AbstractDataCollection<DataRow>c ?
c.sizeAsLong() : features.size();
+ headerMeta.name = dataSchema.name();
+ headerMeta.columns = TableConversions.asColumns(dataSchema.columns());
HeaderMeta.write(headerMeta, outputStream, bufferBuilder);
var indexSize =
@@ -221,11 +221,11 @@ public class FlatGeoBufTable extends AbstractTable {
/**
* An iterator over rows in a flatgeobuf file.
*/
- public static class RowIterator implements Iterator<Row> {
+ public static class RowIterator implements Iterator<DataRow> {
private final HeaderMeta headerMeta;
- private final Schema schema;
+ private final DataSchema dataSchema;
private final SeekableByteChannel channel;
@@ -238,14 +238,14 @@ public class FlatGeoBufTable extends AbstractTable {
*
* @param channel the channel to read from
* @param headerMeta the header meta
- * @param schema the schema of the table
+ * @param dataSchema the schema of the table
* @param buffer the buffer to use
*/
public RowIterator(SeekableByteChannel channel, HeaderMeta headerMeta,
- Schema schema, ByteBuffer buffer) {
+ DataSchema dataSchema, ByteBuffer buffer) {
this.channel = channel;
this.headerMeta = headerMeta;
- this.schema = schema;
+ this.dataSchema = dataSchema;
this.buffer = buffer;
}
@@ -261,14 +261,14 @@ public class FlatGeoBufTable extends AbstractTable {
* {@inheritDoc}
*/
@Override
- public Row next() {
+ public DataRow next() {
try {
channel.read(buffer);
buffer.flip();
var featureSize = buffer.getInt();
var row =
- TableConversions.asRow(headerMeta, schema,
Feature.getRootAsFeature(buffer));
+ TableConversions.asRow(headerMeta, dataSchema,
Feature.getRootAsFeature(buffer));
buffer.position(Integer.BYTES + featureSize);
buffer.compact();
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/internal/TableConversions.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/internal/TableConversions.java
index f494cc21..6508ab1f 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/internal/TableConversions.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/flatgeobuf/internal/TableConversions.java
@@ -34,16 +34,16 @@ import org.wololo.flatgeobuf.generated.Header;
public class TableConversions {
- public static Schema asFeatureType(HeaderMeta headerMeta) {
+ public static DataSchema asFeatureType(HeaderMeta headerMeta) {
var name = headerMeta.name;
var columns = headerMeta.columns.stream()
- .map(column -> new ColumnImpl(column.name, column.getBinding()))
- .map(Column.class::cast)
+ .map(column -> new DataColumnImpl(column.name, column.getBinding()))
+ .map(DataColumn.class::cast)
.toList();
- return new SchemaImpl(name, columns);
+ return new DataSchemaImpl(name, columns);
}
- public static Row asRow(HeaderMeta headerMeta, Schema dataType, Feature
feature) {
+ public static DataRow asRow(HeaderMeta headerMeta, DataSchema dataType,
Feature feature) {
var values = new ArrayList();
var geometryBuffer = feature.geometry();
@@ -60,7 +60,7 @@ public class TableConversions {
}
}
- return new RowImpl(dataType, values);
+ return new DataRowImpl(dataType, values);
}
public static void writeHeaderMeta(HeaderMeta headerMeta,
WritableByteChannel channel,
@@ -189,20 +189,20 @@ public class TableConversions {
Double.class, ColumnType.Double,
String.class, ColumnType.String);
- public static List<ColumnMeta> asColumns(List<Column> columns) {
- return columns.stream()
+ public static List<ColumnMeta> asColumns(List<DataColumn> dataColumns) {
+ return dataColumns.stream()
.map(TableConversions::asColumn)
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
- public static ColumnMeta asColumn(Column column) {
- var type = types.get(column.type());
+ public static ColumnMeta asColumn(DataColumn dataColumn) {
+ var type = types.get(dataColumn.type());
if (type == null) {
return null;
}
var columnMeta = new ColumnMeta();
- columnMeta.name = column.name();
+ columnMeta.name = dataColumn.name();
columnMeta.type = type.byteValue();
return columnMeta;
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageStore.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageDataStore.java
similarity index 70%
rename from
baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageStore.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageDataStore.java
index 5b66a73a..ead21afe 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageStore.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageDataStore.java
@@ -17,14 +17,14 @@ import java.nio.file.Path;
import java.util.Collection;
import mil.nga.geopackage.GeoPackage;
import mil.nga.geopackage.GeoPackageManager;
-import org.apache.baremaps.collection.store.Store;
-import org.apache.baremaps.collection.store.Table;
-import org.apache.baremaps.collection.store.TableException;
+import org.apache.baremaps.collection.store.DataStore;
+import org.apache.baremaps.collection.store.DataTable;
+import org.apache.baremaps.collection.store.DataTableException;
/**
* A store corresponding to a GeoPackage database.
*/
-public class GeoPackageStore implements Store, AutoCloseable {
+public class GeoPackageDataStore implements DataStore, AutoCloseable {
private final GeoPackage geoPackage;
@@ -33,7 +33,7 @@ public class GeoPackageStore implements Store, AutoCloseable {
*
* @param file the path to the GeoPackage database
*/
- public GeoPackageStore(Path file) {
+ public GeoPackageDataStore(Path file) {
this.geoPackage = GeoPackageManager.open(file.toFile());
}
@@ -49,7 +49,7 @@ public class GeoPackageStore implements Store, AutoCloseable {
* {@inheritDoc}
*/
@Override
- public Collection<String> list() throws TableException {
+ public Collection<String> list() throws DataTableException {
return geoPackage.getFeatureTables();
}
@@ -57,15 +57,15 @@ public class GeoPackageStore implements Store,
AutoCloseable {
* {@inheritDoc}
*/
@Override
- public Table get(String name) throws TableException {
- return new GeoPackageTable(geoPackage.getFeatureDao(name));
+ public DataTable get(String name) throws DataTableException {
+ return new GeoPackageDataTable(geoPackage.getFeatureDao(name));
}
/**
* {@inheritDoc}
*/
@Override
- public void add(Table value) throws TableException {
+ public void add(DataTable value) throws DataTableException {
throw new UnsupportedOperationException();
}
@@ -73,7 +73,7 @@ public class GeoPackageStore implements Store, AutoCloseable {
* {@inheritDoc}
*/
@Override
- public void remove(String name) throws TableException {
+ public void remove(String name) throws DataTableException {
throw new UnsupportedOperationException();
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageTable.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageDataTable.java
similarity index 89%
rename from
baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageTable.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageDataTable.java
index aa282823..9078ada1 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageTable.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/geopackage/GeoPackageDataTable.java
@@ -25,11 +25,11 @@ import org.locationtech.jts.geom.*;
/**
* A table that stores rows in a GeoPackage table.
*/
-public class GeoPackageTable extends AbstractDataCollection<Row> implements
Table {
+public class GeoPackageDataTable extends AbstractDataCollection<DataRow>
implements DataTable {
private final FeatureDao featureDao;
- private final Schema schema;
+ private final DataSchema dataSchema;
private final GeometryFactory geometryFactory;
@@ -38,16 +38,16 @@ public class GeoPackageTable extends
AbstractDataCollection<Row> implements Tabl
*
* @param featureDao the feature DAO
*/
- public GeoPackageTable(FeatureDao featureDao) {
+ public GeoPackageDataTable(FeatureDao featureDao) {
this.featureDao = featureDao;
var name = featureDao.getTableName();
- var columns = new ArrayList<Column>();
+ var columns = new ArrayList<DataColumn>();
for (FeatureColumn column : featureDao.getColumns()) {
var propertyName = column.getName();
var propertyType = classType(column);
- columns.add(new ColumnImpl(propertyName, propertyType));
+ columns.add(new DataColumnImpl(propertyName, propertyType));
}
- schema = new SchemaImpl(name, columns);
+ dataSchema = new DataSchemaImpl(name, columns);
geometryFactory = new GeometryFactory(new PrecisionModel(), (int)
featureDao.getSrs().getId());
}
@@ -63,8 +63,8 @@ public class GeoPackageTable extends
AbstractDataCollection<Row> implements Tabl
* {@inheritDoc}
*/
@Override
- public Iterator<Row> iterator() {
- return new GeopackageIterator(featureDao.queryForAll(), schema);
+ public Iterator<DataRow> iterator() {
+ return new GeopackageIterator(featureDao.queryForAll(), dataSchema);
}
/**
@@ -79,8 +79,8 @@ public class GeoPackageTable extends
AbstractDataCollection<Row> implements Tabl
* {@inheritDoc}
*/
@Override
- public Schema schema() {
- return schema;
+ public DataSchema schema() {
+ return dataSchema;
}
/**
@@ -213,11 +213,11 @@ public class GeoPackageTable extends
AbstractDataCollection<Row> implements Tabl
/**
* An iterator over the rows of a GeoPackage table.
*/
- public class GeopackageIterator implements Iterator<Row> {
+ public class GeopackageIterator implements Iterator<DataRow> {
private final FeatureResultSet featureResultSet;
- private final Schema schema;
+ private final DataSchema dataSchema;
private boolean hasNext;
@@ -225,11 +225,11 @@ public class GeoPackageTable extends
AbstractDataCollection<Row> implements Tabl
* Constructs an iterator from a feature result set.
*
* @param featureResultSet the feature result set
- * @param schema the schema of the table
+ * @param dataSchema the schema of the table
*/
- public GeopackageIterator(FeatureResultSet featureResultSet, Schema
schema) {
+ public GeopackageIterator(FeatureResultSet featureResultSet, DataSchema
dataSchema) {
this.featureResultSet = featureResultSet;
- this.schema = schema;
+ this.dataSchema = dataSchema;
this.hasNext = featureResultSet.moveToFirst();
}
@@ -245,19 +245,19 @@ public class GeoPackageTable extends
AbstractDataCollection<Row> implements Tabl
* {@inheritDoc}
*/
@Override
- public Row next() {
+ public DataRow next() {
if (!hasNext) {
throw new NoSuchElementException();
}
- Row row = schema.createRow();
+ DataRow dataRow = dataSchema.createRow();
for (FeatureColumn featureColumn :
featureResultSet.getColumns().getColumns()) {
var value = featureResultSet.getValue(featureColumn);
if (value != null) {
- row.set(featureColumn.getName(), asJavaValue(value));
+ dataRow.set(featureColumn.getName(), asJavaValue(value));
}
}
hasNext = featureResultSet.moveToNext();
- return row;
+ return dataRow;
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresStore.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDataStore.java
similarity index 82%
rename from
baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresStore.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDataStore.java
index 3ec7c7ec..798c362a 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresStore.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDataStore.java
@@ -40,9 +40,9 @@ import org.slf4j.LoggerFactory;
/**
* A store that stores tables in a Postgres database.
*/
-public class PostgresStore implements Store {
+public class PostgresDataStore implements DataStore {
- private static final Logger logger =
LoggerFactory.getLogger(PostgresStore.class);
+ private static final Logger logger =
LoggerFactory.getLogger(PostgresDataStore.class);
private static final String[] TYPES = new String[] {"TABLE", "VIEW"};
@@ -88,7 +88,7 @@ public class PostgresStore implements Store {
*
* @param dataSource the data source
*/
- public PostgresStore(DataSource dataSource) {
+ public PostgresDataStore(DataSource dataSource) {
this.dataSource = dataSource;
}
@@ -96,7 +96,7 @@ public class PostgresStore implements Store {
* {@inheritDoc}
*/
@Override
- public Collection<String> list() throws TableException {
+ public Collection<String> list() throws DataTableException {
DatabaseMetadata metadata = new DatabaseMetadata(dataSource);
return metadata.getTableMetaData(null, "public", null, TYPES).stream()
.map(table -> table.table().tableName())
@@ -107,24 +107,24 @@ public class PostgresStore implements Store {
* {@inheritDoc}
*/
@Override
- public Table get(String name) throws TableException {
+ public DataTable get(String name) throws DataTableException {
var databaseMetadata = new DatabaseMetadata(dataSource);
var tableMetadata = databaseMetadata.getTableMetaData(null, null, name,
TYPES)
.stream().findFirst();
if (tableMetadata.isEmpty()) {
- throw new TableException("Table " + name + " does not exist.");
+ throw new DataTableException("Table " + name + " does not exist.");
}
var schema = createSchema(tableMetadata.get());
- return new PostgresTable(dataSource, schema);
+ return new PostgresDataTable(dataSource, schema);
}
/**
* {@inheritDoc}
*/
@Override
- public void add(Table table) {
+ public void add(DataTable dataTable) {
try (var connection = dataSource.getConnection()) {
- var schema = adaptDataType(table.schema());
+ var schema = adaptDataType(dataTable.schema());
// Drop the table if it exists
var dropQuery = dropTable(schema.name());
@@ -148,12 +148,12 @@ public class PostgresStore implements Store {
writer.writeHeader();
var columns = getColumns(schema);
var handlers = getHandlers(schema);
- for (Row row : table) {
+ for (DataRow dataRow : dataTable) {
writer.startRow(columns.size());
for (int i = 0; i < columns.size(); i++) {
var column = columns.get(i);
var handler = handlers.get(i);
- var value = row.get(column.name());
+ var value = dataRow.get(column.name());
if (value == null) {
writer.writeNull();
} else {
@@ -186,28 +186,28 @@ public class PostgresStore implements Store {
* @param tableMetadata the table metadata
* @return the schema
*/
- protected static Schema createSchema(TableMetadata tableMetadata) {
+ protected static DataSchema createSchema(TableMetadata tableMetadata) {
var name = tableMetadata.table().tableName();
var columns = tableMetadata.columns().stream()
- .map(column -> new ColumnImpl(column.columnName(),
nameToType.get(column.typeName())))
- .map(Column.class::cast)
+ .map(column -> new DataColumnImpl(column.columnName(),
nameToType.get(column.typeName())))
+ .map(DataColumn.class::cast)
.toList();
- return new SchemaImpl(name, columns);
+ return new DataSchemaImpl(name, columns);
}
/**
* Adapt the data type to postgres (e.g. use compatible names).
*
- * @param schema the schema to adapt
+ * @param dataSchema the schema to adapt
* @return the adapted schema
*/
- protected Schema adaptDataType(Schema schema) {
- var name = schema.name().replaceAll("[^a-zA-Z0-9]", "_");
- var properties = schema.columns().stream()
+ protected DataSchema adaptDataType(DataSchema dataSchema) {
+ var name = dataSchema.name().replaceAll("[^a-zA-Z0-9]", "_");
+ var properties = dataSchema.columns().stream()
.filter(column -> typeToName.containsKey(column.type()))
- .map(column -> (Column) new ColumnImpl(column.name(), column.type()))
+ .map(column -> (DataColumn) new DataColumnImpl(column.name(),
column.type()))
.toList();
- return new SchemaImpl(name, properties);
+ return new DataSchemaImpl(name, properties);
}
/**
@@ -223,15 +223,15 @@ public class PostgresStore implements Store {
/**
* Generate a create table query.
*
- * @param schema the schema
+ * @param dataSchema the schema
* @return the query
*/
- protected String createTable(Schema schema) {
+ protected String createTable(DataSchema dataSchema) {
StringBuilder builder = new StringBuilder();
builder.append("CREATE TABLE \"");
- builder.append(schema.name());
+ builder.append(dataSchema.name());
builder.append("\" (");
- builder.append(schema.columns().stream()
+ builder.append(dataSchema.columns().stream()
.map(column -> "\"" + column.name()
+ "\" " + typeToName.get(column.type()))
.collect(Collectors.joining(", ")));
@@ -242,15 +242,15 @@ public class PostgresStore implements Store {
/**
* Generate a copy query.
*
- * @param schema the schema
+ * @param dataSchema the schema
* @return the query
*/
- protected String copy(Schema schema) {
+ protected String copy(DataSchema dataSchema) {
var builder = new StringBuilder();
builder.append("COPY \"");
- builder.append(schema.name());
+ builder.append(dataSchema.name());
builder.append("\" (");
- builder.append(schema.columns().stream()
+ builder.append(dataSchema.columns().stream()
.map(column -> "\"" + column.name() + "\"")
.collect(Collectors.joining(", ")));
builder.append(") FROM STDIN BINARY");
@@ -260,11 +260,11 @@ public class PostgresStore implements Store {
/**
* Get the columns of the schema.
*
- * @param schema the schema
+ * @param dataSchema the schema
* @return the columns
*/
- protected List<Column> getColumns(Schema schema) {
- return schema.columns().stream()
+ protected List<DataColumn> getColumns(DataSchema dataSchema) {
+ return dataSchema.columns().stream()
.filter(this::isSupported)
.collect(Collectors.toList());
}
@@ -272,11 +272,11 @@ public class PostgresStore implements Store {
/**
* Get the handlers for the columns of the schema.
*
- * @param schema the schema
+ * @param dataSchema the schema
* @return the handlers
*/
- protected List<BaseValueHandler> getHandlers(Schema schema) {
- return getColumns(schema).stream()
+ protected List<BaseValueHandler> getHandlers(DataSchema dataSchema) {
+ return getColumns(dataSchema).stream()
.map(column -> getHandler(column.type()))
.collect(Collectors.toList());
}
@@ -337,10 +337,10 @@ public class PostgresStore implements Store {
/**
* Check if the column type is supported by postgres.
*
- * @param column the column
+ * @param dataColumn the column
* @return true if the column type is supported
*/
- protected boolean isSupported(Column column) {
- return typeToName.containsKey(column.type());
+ protected boolean isSupported(DataColumn dataColumn) {
+ return typeToName.containsKey(dataColumn.type());
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresTable.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDataTable.java
similarity index 73%
rename from
baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresTable.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDataTable.java
index 30611160..badd5df5 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresTable.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/postgres/PostgresDataTable.java
@@ -21,31 +21,31 @@ import java.util.*;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import javax.sql.DataSource;
-import org.apache.baremaps.collection.store.AbstractTable;
-import org.apache.baremaps.collection.store.Row;
-import org.apache.baremaps.collection.store.RowImpl;
-import org.apache.baremaps.collection.store.Schema;
+import org.apache.baremaps.collection.store.AbstractDataTable;
+import org.apache.baremaps.collection.store.DataRow;
+import org.apache.baremaps.collection.store.DataRowImpl;
+import org.apache.baremaps.collection.store.DataSchema;
import org.apache.baremaps.utils.GeometryUtils;
import org.locationtech.jts.geom.*;
/**
* A table that stores rows in a Postgres table.
*/
-public class PostgresTable extends AbstractTable {
+public class PostgresDataTable extends AbstractDataTable {
private final DataSource dataSource;
- private final Schema schema;
+ private final DataSchema dataSchema;
/**
* Constructs a table with a given name and a given schema.
*
* @param dataSource the data source
- * @param schema the schema of the table
+ * @param dataSchema the schema of the table
*/
- public PostgresTable(DataSource dataSource, Schema schema) {
+ public PostgresDataTable(DataSource dataSource, DataSchema dataSchema) {
this.dataSource = dataSource;
- this.schema = schema;
+ this.dataSchema = dataSchema;
}
/**
@@ -60,7 +60,7 @@ public class PostgresTable extends AbstractTable {
* {@inheritDoc}
*/
@Override
- public Stream<Row> stream() {
+ public Stream<DataRow> stream() {
var iterator = iterator();
var spliterator = Spliterators.spliteratorUnknownSize(iterator, 0);
var stream = StreamSupport.stream(spliterator, false);
@@ -72,7 +72,7 @@ public class PostgresTable extends AbstractTable {
*/
@Override
public long sizeAsLong() {
- var countQuery = count(schema);
+ var countQuery = count(dataSchema);
try (var connection = dataSource.getConnection();
var statement = connection.prepareStatement(countQuery);
var resultSet = statement.executeQuery()) {
@@ -87,20 +87,20 @@ public class PostgresTable extends AbstractTable {
* {@inheritDoc}
*/
@Override
- public Schema schema() {
- return schema;
+ public DataSchema schema() {
+ return dataSchema;
}
/**
* {@inheritDoc}
*/
@Override
- public boolean add(Row row) {
- var query = insert(schema);
+ public boolean add(DataRow dataRow) {
+ var query = insert(dataSchema);
try (var connection = dataSource.getConnection();
var statement = connection.prepareStatement(query)) {
- for (int i = 1; i <= schema.columns().size(); i++) {
- var value = row.get(schema.columns().get(i - 1).name());
+ for (int i = 1; i <= dataSchema.columns().size(); i++) {
+ var value = dataRow.get(dataSchema.columns().get(i - 1).name());
if (value instanceof Geometry geometry) {
statement.setBytes(i, GeometryUtils.serialize(geometry));
} else {
@@ -117,12 +117,12 @@ public class PostgresTable extends AbstractTable {
* {@inheritDoc}
*/
@Override
- public boolean addAll(Collection<? extends Row> rows) {
+ public boolean addAll(Collection<? extends DataRow> rows) {
try (var connection = dataSource.getConnection();
- var statement = connection.prepareStatement(insert(schema))) {
+ var statement = connection.prepareStatement(insert(dataSchema))) {
for (var row : rows) {
- for (int i = 1; i <= schema.columns().size(); i++) {
- var value = row.get(schema.columns().get(i - 1).name());
+ for (int i = 1; i <= dataSchema.columns().size(); i++) {
+ var value = row.get(dataSchema.columns().get(i - 1).name());
if (value instanceof Geometry geometry) {
statement.setBytes(i, GeometryUtils.serialize(geometry));
} else {
@@ -141,11 +141,11 @@ public class PostgresTable extends AbstractTable {
/**
* Generates a query that selects all the rows of a table.
*
- * @param schema the schema of the table
+ * @param dataSchema the schema of the table
* @return the query
*/
- protected static String select(Schema schema) {
- var columns = schema.columns().stream()
+ protected static String select(DataSchema dataSchema) {
+ var columns = dataSchema.columns().stream()
.map(column -> {
if (column.type().isAssignableFrom(Geometry.class)) {
return String.format("st_asbinary(\"%s\") AS \"%s\"",
column.name(), column.name());
@@ -154,41 +154,41 @@ public class PostgresTable extends AbstractTable {
}
})
.toList();
- return "SELECT " + String.join(", ", columns) + " FROM \"" + schema.name()
+ "\"";
+ return "SELECT " + String.join(", ", columns) + " FROM \"" +
dataSchema.name() + "\"";
}
/**
* Generates a query that counts the number of rows of a table.
*
- * @param schema the schema of the table
+ * @param dataSchema the schema of the table
* @return the query
*/
- protected static String insert(Schema schema) {
- var columns = schema.columns().stream()
+ protected static String insert(DataSchema dataSchema) {
+ var columns = dataSchema.columns().stream()
.map(column -> String.format("\"%s\"", column.name()))
.toList();
- var values = schema.columns().stream()
+ var values = dataSchema.columns().stream()
.map(column -> "?")
.toList();
return "INSERT INTO \""
- + schema.name() + "\" (" + String.join(", ", columns) + ") "
+ + dataSchema.name() + "\" (" + String.join(", ", columns) + ") "
+ "VALUES (" + String.join(", ", values) + ")";
}
/**
* Generates a query that counts the number of rows of a table.
*
- * @param schema the schema of the table
+ * @param dataSchema the schema of the table
* @return the query
*/
- protected String count(Schema schema) {
- return String.format("SELECT COUNT(*) FROM \"%s\"", schema.name());
+ protected String count(DataSchema dataSchema) {
+ return String.format("SELECT COUNT(*) FROM \"%s\"", dataSchema.name());
}
/**
* An iterator that iterates over the rows of a table.
*/
- public class PostgresIterator implements Iterator<Row>, AutoCloseable {
+ public class PostgresIterator implements Iterator<DataRow>, AutoCloseable {
private Connection connection;
private Statement statement;
@@ -202,7 +202,7 @@ public class PostgresTable extends AbstractTable {
try {
connection = dataSource.getConnection();
statement = connection.createStatement();
- resultSet = statement.executeQuery(select(schema));
+ resultSet = statement.executeQuery(select(dataSchema));
hasNext = resultSet.next();
} catch (SQLException e) {
close();
@@ -225,14 +225,14 @@ public class PostgresTable extends AbstractTable {
* {@inheritDoc}
*/
@Override
- public Row next() {
+ public DataRow next() {
if (!hasNext) {
throw new NoSuchElementException();
}
try {
List<Object> values = new ArrayList<>();
- for (int i = 0; i < schema.columns().size(); i++) {
- var column = schema.columns().get(i);
+ for (int i = 0; i < dataSchema.columns().size(); i++) {
+ var column = dataSchema.columns().get(i);
if (column.type().isAssignableFrom(Geometry.class)) {
values.add(GeometryUtils.deserialize(resultSet.getBytes(i + 1)));
} else {
@@ -240,7 +240,7 @@ public class PostgresTable extends AbstractTable {
}
}
hasNext = resultSet.next();
- return new RowImpl(schema, values);
+ return new DataRowImpl(dataSchema, values);
} catch (SQLException e) {
close();
throw new RuntimeException("Error while fetching the next result", e);
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileStore.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileDataStore.java
similarity index 77%
rename from
baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileStore.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileDataStore.java
index c6a56f50..9fe4500b 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileStore.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileDataStore.java
@@ -18,14 +18,14 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
-import org.apache.baremaps.collection.store.Store;
-import org.apache.baremaps.collection.store.Table;
-import org.apache.baremaps.collection.store.TableException;
+import org.apache.baremaps.collection.store.DataStore;
+import org.apache.baremaps.collection.store.DataTable;
+import org.apache.baremaps.collection.store.DataTableException;
/**
* A store corresponding to the shapefiles of a directory.
*/
-public class ShapefileStore implements Store {
+public class ShapefileDataStore implements DataStore {
private final Path directory;
@@ -34,7 +34,7 @@ public class ShapefileStore implements Store {
*
* @param directory the directory
*/
- public ShapefileStore(Path directory) {
+ public ShapefileDataStore(Path directory) {
this.directory = directory;
}
@@ -49,7 +49,7 @@ public class ShapefileStore implements Store {
.map(file -> file.getFileName().toString())
.toList();
} catch (IOException e) {
- throw new TableException(e);
+ throw new DataTableException(e);
}
}
@@ -57,15 +57,15 @@ public class ShapefileStore implements Store {
* {@inheritDoc}
*/
@Override
- public Table get(String name) {
- return new ShapefileTable(directory.resolve(name));
+ public DataTable get(String name) {
+ return new ShapefileDataTable(directory.resolve(name));
}
/**
* {@inheritDoc}
*/
@Override
- public void add(Table value) {
+ public void add(DataTable value) {
throw new UnsupportedOperationException();
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileTable.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileDataTable.java
similarity index 80%
rename from
baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileTable.java
rename to
baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileDataTable.java
index 2c36b55f..8275a5b3 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileTable.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/ShapefileDataTable.java
@@ -17,17 +17,17 @@ import java.io.IOException;
import java.nio.file.Path;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import org.apache.baremaps.collection.store.AbstractTable;
-import org.apache.baremaps.collection.store.Row;
-import org.apache.baremaps.collection.store.Schema;
-import org.apache.baremaps.collection.store.TableException;
+import org.apache.baremaps.collection.store.AbstractDataTable;
+import org.apache.baremaps.collection.store.DataRow;
+import org.apache.baremaps.collection.store.DataSchema;
+import org.apache.baremaps.collection.store.DataTableException;
import org.apache.baremaps.storage.shapefile.internal.ShapefileInputStream;
import org.apache.baremaps.storage.shapefile.internal.ShapefileReader;
/**
* A table that stores rows in a shapefile.
*/
-public class ShapefileTable extends AbstractTable {
+public class ShapefileDataTable extends AbstractDataTable {
private final ShapefileReader shapeFile;
@@ -36,7 +36,7 @@ public class ShapefileTable extends AbstractTable {
*
* @param file the path to the shapefile
*/
- public ShapefileTable(Path file) {
+ public ShapefileDataTable(Path file) {
this.shapeFile = new ShapefileReader(file.toString());
}
@@ -44,11 +44,11 @@ public class ShapefileTable extends AbstractTable {
* {@inheritDoc}
*/
@Override
- public Schema schema() throws TableException {
+ public DataSchema schema() throws DataTableException {
try (var input = shapeFile.read()) {
return input.getSchema();
} catch (IOException e) {
- throw new TableException(e);
+ throw new DataTableException(e);
}
}
@@ -56,7 +56,7 @@ public class ShapefileTable extends AbstractTable {
* {@inheritDoc}
*/
@Override
- public Iterator<Row> iterator() {
+ public Iterator<DataRow> iterator() {
try {
return new ShapefileIterator(shapeFile.read());
} catch (IOException e) {
@@ -76,11 +76,11 @@ public class ShapefileTable extends AbstractTable {
/**
* An iterator over the rows of a shapefile.
*/
- public static class ShapefileIterator implements Iterator<Row> {
+ public static class ShapefileIterator implements Iterator<DataRow> {
private final ShapefileInputStream shapefileInputStream;
- private Row next;
+ private DataRow next;
/**
* Constructs an iterator from a shapefile input stream.
@@ -111,12 +111,12 @@ public class ShapefileTable extends AbstractTable {
* {@inheritDoc}
*/
@Override
- public Row next() {
+ public DataRow next() {
try {
if (next == null) {
next = shapefileInputStream.readRow();
}
- Row current = next;
+ DataRow current = next;
next = null;
return current;
} catch (Exception e) {
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/DbaseByteReader.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/DbaseByteReader.java
index 00d6e9bf..7af3ff30 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/DbaseByteReader.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/DbaseByteReader.java
@@ -22,7 +22,7 @@ import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
import java.text.MessageFormat;
import java.util.*;
-import org.apache.baremaps.collection.store.Row;
+import org.apache.baremaps.collection.store.DataRow;
/**
* Reader of a Database Binary content.
@@ -99,9 +99,9 @@ public class DbaseByteReader extends CommonByteReader
implements AutoCloseable {
/**
* Load a row into a feature.
*
- * @param row Feature to fill.
+ * @param dataRow Feature to fill.
*/
- public void loadRow(Row row) {
+ public void loadRow(DataRow dataRow) {
// TODO: ignore deleted records
getByteBuffer().get(); // denotes whether deleted or current
// read first part of record
@@ -138,7 +138,7 @@ public class DbaseByteReader extends CommonByteReader
implements AutoCloseable {
case DateTime -> value;
};
- row.set(fieldDescriptor.getName(), object);
+ dataRow.set(fieldDescriptor.getName(), object);
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileByteReader.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileByteReader.java
index 0d6cba80..d982f3a3 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileByteReader.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileByteReader.java
@@ -45,7 +45,7 @@ public class ShapefileByteReader extends CommonByteReader {
private List<DBaseFieldDescriptor> databaseFieldsDescriptors;
/** Schema of the rows contained in this shapefile. */
- private Schema schema;
+ private DataSchema dataSchema;
/** Shapefile index. */
private File shapeFileIndex;
@@ -80,7 +80,7 @@ public class ShapefileByteReader extends CommonByteReader {
loadShapefileIndexes();
}
- this.schema = getSchema(shapefile.getName());
+ this.dataSchema = getSchema(shapefile.getName());
}
/**
@@ -106,8 +106,8 @@ public class ShapefileByteReader extends CommonByteReader {
*
* @return the schema
*/
- public Schema getSchema() {
- return this.schema;
+ public DataSchema getSchema() {
+ return this.dataSchema;
}
/**
@@ -116,10 +116,10 @@ public class ShapefileByteReader extends CommonByteReader
{
* @param name Name of the field.
* @return The row type.
*/
- private Schema getSchema(final String name) {
+ private DataSchema getSchema(final String name) {
Objects.requireNonNull(name, "The row name cannot be null.");
- var columns = new ArrayList<Column>();
+ var columns = new ArrayList<DataColumn>();
for (int i = 0; i < databaseFieldsDescriptors.size(); i++) {
var fieldDescriptor = this.databaseFieldsDescriptors.get(i);
var columnName = fieldDescriptor.getName();
@@ -143,13 +143,13 @@ public class ShapefileByteReader extends CommonByteReader
{
case DateTime -> String.class;
};
- columns.add(new ColumnImpl(columnName, columnType));
+ columns.add(new DataColumnImpl(columnName, columnType));
}
// Add geometry column.
- columns.add(new ColumnImpl(GEOMETRY_NAME, Geometry.class));
+ columns.add(new DataColumnImpl(GEOMETRY_NAME, Geometry.class));
- return new SchemaImpl(name, columns);
+ return new DataSchemaImpl(name, columns);
}
/** Load shapefile descriptor. */
@@ -254,9 +254,9 @@ public class ShapefileByteReader extends CommonByteReader {
/**
* Complete a row with shapefile content.
*
- * @param row the row to complete
+ * @param dataRow the row to complete
*/
- public void completeRow(Row row) throws ShapefileException {
+ public void completeRow(DataRow dataRow) throws ShapefileException {
// insert points into some type of list
int RecordNumber = getByteBuffer().getInt();
int ContentLength = getByteBuffer().getInt();
@@ -273,15 +273,15 @@ public class ShapefileByteReader extends CommonByteReader
{
switch (shapefileGeometryType) {
case Point:
- loadPointRow(row);
+ loadPointRow(dataRow);
break;
case Polygon:
- loadPolygonRow(row);
+ loadPolygonRow(dataRow);
break;
case PolyLine:
- loadPolylineRow(row);
+ loadPolylineRow(dataRow);
break;
default:
@@ -294,21 +294,21 @@ public class ShapefileByteReader extends CommonByteReader
{
/**
* Load point row.
*
- * @param row the row to fill.
+ * @param dataRow the row to fill.
*/
- private void loadPointRow(Row row) {
+ private void loadPointRow(DataRow dataRow) {
double x = getByteBuffer().getDouble();
double y = getByteBuffer().getDouble();
Point pnt = geometryFactory.createPoint(new Coordinate(x, y));
- row.set(GEOMETRY_NAME, pnt);
+ dataRow.set(GEOMETRY_NAME, pnt);
}
/**
* Load polygon row.
*
- * @param row the row to fill.
+ * @param dataRow the row to fill.
*/
- private void loadPolygonRow(Row row) {
+ private void loadPolygonRow(DataRow dataRow) {
double xmin = getByteBuffer().getDouble();
double ymin = getByteBuffer().getDouble();
double xmax = getByteBuffer().getDouble();
@@ -319,7 +319,7 @@ public class ShapefileByteReader extends CommonByteReader {
Geometry multiPolygon = readMultiplePolygon(numParts, numPoints);
- row.set(GEOMETRY_NAME, multiPolygon);
+ dataRow.set(GEOMETRY_NAME, multiPolygon);
}
/**
@@ -382,9 +382,9 @@ public class ShapefileByteReader extends CommonByteReader {
/**
* Load polyline row.
*
- * @param row the row to fill.
+ * @param dataRow the row to fill.
*/
- private void loadPolylineRow(Row row) {
+ private void loadPolylineRow(DataRow dataRow) {
/* double xmin = */ getByteBuffer().getDouble();
/* double ymin = */ getByteBuffer().getDouble();
/* double xmax = */ getByteBuffer().getDouble();
@@ -416,7 +416,7 @@ public class ShapefileByteReader extends CommonByteReader {
}
}
- row.set(GEOMETRY_NAME,
+ dataRow.set(GEOMETRY_NAME,
geometryFactory.createLineString(coordinates.toCoordinateArray()));
}
}
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileInputStream.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileInputStream.java
index eee12284..efc8f4d6 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileInputStream.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileInputStream.java
@@ -18,8 +18,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
-import org.apache.baremaps.collection.store.Row;
-import org.apache.baremaps.collection.store.Schema;
+import org.apache.baremaps.collection.store.DataRow;
+import org.apache.baremaps.collection.store.DataSchema;
/**
* Input Stream of features.
@@ -47,7 +47,7 @@ public class ShapefileInputStream extends InputStream {
private boolean hasShapefileIndex;
/** Schema of the features contained in this shapefile. */
- private Schema schema;
+ private DataSchema dataSchema;
/** Shapefile reader. */
private ShapefileByteReader shapefileReader;
@@ -74,7 +74,7 @@ public class ShapefileInputStream extends InputStream {
this.shapefileReader =
new ShapefileByteReader(this.shapefile, this.databaseFile,
this.shapefileIndex);
- this.schema = this.shapefileReader.getSchema();
+ this.dataSchema = this.shapefileReader.getSchema();
}
/**
@@ -113,15 +113,15 @@ public class ShapefileInputStream extends InputStream {
* @throws ShapefileException if the current connection used to query the
shapefile has been
* closed.
*/
- public Row readRow() throws ShapefileException {
+ public DataRow readRow() throws ShapefileException {
if (!this.dbaseReader.nextRowAvailable()) {
return null;
}
- Row row = this.schema.createRow();
- this.dbaseReader.loadRow(row);
+ DataRow dataRow = this.dataSchema.createRow();
+ this.dbaseReader.loadRow(dataRow);
this.shapefileReader.setRowNum(this.dbaseReader.getRowNum());
- this.shapefileReader.completeRow(row);
- return row;
+ this.shapefileReader.completeRow(dataRow);
+ return dataRow;
}
/**
@@ -129,8 +129,8 @@ public class ShapefileInputStream extends InputStream {
*
* @return the schema.
*/
- public Schema getSchema() {
- return schema;
+ public DataSchema getSchema() {
+ return dataSchema;
}
/**
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileReader.java
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileReader.java
index c17140e0..b7872270 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileReader.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileReader.java
@@ -18,7 +18,7 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
-import org.apache.baremaps.collection.store.Schema;
+import org.apache.baremaps.collection.store.DataSchema;
/**
* Provides a ShapeFile Reader.
@@ -44,7 +44,7 @@ public class ShapefileReader {
private File shapeFileIndex;
/** Type of the features contained in this shapefile. */
- private Schema schema;
+ private DataSchema dataSchema;
/** Shapefile descriptor. */
private ShapefileDescriptor shapefileDescriptor;
@@ -117,8 +117,8 @@ public class ShapefileReader {
*
* @return the schema.
*/
- public Schema getSchema() {
- return this.schema;
+ public DataSchema getSchema() {
+ return this.dataSchema;
}
/**
@@ -174,7 +174,7 @@ public class ShapefileReader {
public ShapefileInputStream read() throws IOException {
ShapefileInputStream is =
new ShapefileInputStream(this.shapefile, this.databaseFile,
this.shapeFileIndex);
- this.schema = is.getSchema();
+ this.dataSchema = is.getSchema();
this.shapefileDescriptor = is.getShapefileDescriptor();
this.databaseFieldsDescriptors = is.getDatabaseFieldsDescriptors();
return is;
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/vectortile/expression/Expressions.java
b/baremaps-core/src/main/java/org/apache/baremaps/vectortile/expression/Expressions.java
index 75b012cb..fac7ca0d 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/vectortile/expression/Expressions.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/vectortile/expression/Expressions.java
@@ -32,7 +32,7 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
-import org.apache.baremaps.collection.store.Row;
+import org.apache.baremaps.collection.store.DataRow;
import org.locationtech.jts.geom.*;
public interface Expressions {
@@ -41,7 +41,7 @@ public interface Expressions {
String name();
- T evaluate(Row feature);
+ T evaluate(DataRow feature);
}
@@ -53,7 +53,7 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
+ public Object evaluate(DataRow dataRow) {
return value;
}
}
@@ -66,8 +66,8 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- Object value = expression.evaluate(row);
+ public Object evaluate(DataRow dataRow) {
+ Object value = expression.evaluate(dataRow);
if (value instanceof List list && index >= 0 && index < list.size()) {
return list.get(index);
}
@@ -83,8 +83,8 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- return row.get(property);
+ public Object evaluate(DataRow dataRow) {
+ return dataRow.get(property);
}
}
@@ -96,8 +96,8 @@ public interface Expressions {
}
@Override
- public Boolean evaluate(Row row) {
- return row.get(property) != null;
+ public Boolean evaluate(DataRow dataRow) {
+ return dataRow.get(property) != null;
}
}
@@ -109,8 +109,8 @@ public interface Expressions {
}
@Override
- public Boolean evaluate(Row row) {
- var expressionValue = expression.evaluate(row);
+ public Boolean evaluate(DataRow dataRow) {
+ var expressionValue = expression.evaluate(dataRow);
if (expressionValue instanceof List list) {
return list.contains(value);
} else if (expressionValue instanceof String string) {
@@ -129,8 +129,8 @@ public interface Expressions {
}
@Override
- public Integer evaluate(Row row) {
- var expressionValue = expression.evaluate(row);
+ public Integer evaluate(DataRow dataRow) {
+ var expressionValue = expression.evaluate(dataRow);
if (expressionValue instanceof List list) {
return list.indexOf(value);
} else if (expressionValue instanceof String string) {
@@ -149,8 +149,8 @@ public interface Expressions {
}
@Override
- public Integer evaluate(Row row) {
- Object value = expression.evaluate(row);
+ public Integer evaluate(DataRow dataRow) {
+ Object value = expression.evaluate(dataRow);
if (value instanceof String string) {
return string.length();
} else if (value instanceof List list) {
@@ -173,14 +173,14 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- Object value = expression.evaluate(row);
- var startIndex = (Integer) start.evaluate(row);
+ public Object evaluate(DataRow dataRow) {
+ Object value = expression.evaluate(dataRow);
+ var startIndex = (Integer) start.evaluate(dataRow);
if (value instanceof String string) {
- var endIndex = end == null ? string.length() : (Integer)
end.evaluate(row);
+ var endIndex = end == null ? string.length() : (Integer)
end.evaluate(dataRow);
return string.substring(startIndex, endIndex);
} else if (value instanceof List list) {
- var endIndex = end == null ? list.size() : (Integer) end.evaluate(row);
+ var endIndex = end == null ? list.size() : (Integer)
end.evaluate(dataRow);
return list.subList(startIndex, endIndex);
} else {
return List.of();
@@ -196,8 +196,8 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- return !(boolean) expression.evaluate(row);
+ public Object evaluate(DataRow dataRow) {
+ return !(boolean) expression.evaluate(dataRow);
}
}
@@ -209,8 +209,8 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- return new Not(new Equal(left, right)).evaluate(row);
+ public Object evaluate(DataRow dataRow) {
+ return new Not(new Equal(left, right)).evaluate(dataRow);
}
}
@@ -222,8 +222,8 @@ public interface Expressions {
}
@Override
- public Boolean evaluate(Row row) {
- return (double) left.evaluate(row) < (double) right.evaluate(row);
+ public Boolean evaluate(DataRow dataRow) {
+ return (double) left.evaluate(dataRow) < (double)
right.evaluate(dataRow);
}
}
@@ -235,8 +235,8 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- return (double) left.evaluate(row) <= (double) right.evaluate(row);
+ public Object evaluate(DataRow dataRow) {
+ return (double) left.evaluate(dataRow) <= (double)
right.evaluate(dataRow);
}
}
@@ -248,8 +248,8 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- return left.evaluate(row).equals(right.evaluate(row));
+ public Object evaluate(DataRow dataRow) {
+ return left.evaluate(dataRow).equals(right.evaluate(dataRow));
}
}
@@ -261,8 +261,8 @@ public interface Expressions {
}
@Override
- public Boolean evaluate(Row row) {
- return (double) left.evaluate(row) > (double) right.evaluate(row);
+ public Boolean evaluate(DataRow dataRow) {
+ return (double) left.evaluate(dataRow) > (double)
right.evaluate(dataRow);
}
}
@@ -274,8 +274,8 @@ public interface Expressions {
}
@Override
- public Boolean evaluate(Row row) {
- return (double) left.evaluate(row) >= (double) right.evaluate(row);
+ public Boolean evaluate(DataRow dataRow) {
+ return (double) left.evaluate(dataRow) >= (double)
right.evaluate(dataRow);
}
}
@@ -287,8 +287,8 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- return expressions.stream().allMatch(expression -> (boolean)
expression.evaluate(row));
+ public Object evaluate(DataRow dataRow) {
+ return expressions.stream().allMatch(expression -> (boolean)
expression.evaluate(dataRow));
}
}
@@ -300,8 +300,8 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- return expressions.stream().anyMatch(expression -> (boolean)
expression.evaluate(row));
+ public Object evaluate(DataRow dataRow) {
+ return expressions.stream().anyMatch(expression -> (boolean)
expression.evaluate(dataRow));
}
}
@@ -313,11 +313,11 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
- if ((boolean) condition.evaluate(row)) {
- return then.evaluate(row);
+ public Object evaluate(DataRow dataRow) {
+ if ((boolean) condition.evaluate(dataRow)) {
+ return then.evaluate(dataRow);
} else {
- return otherwise.evaluate(row);
+ return otherwise.evaluate(dataRow);
}
}
}
@@ -330,9 +330,9 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
+ public Object evaluate(DataRow dataRow) {
for (Expression expression : expressions) {
- Object value = expression.evaluate(row);
+ Object value = expression.evaluate(dataRow);
if (value != null) {
return value;
}
@@ -350,20 +350,20 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
+ public Object evaluate(DataRow dataRow) {
if (cases.size() % 2 != 0) {
throw new IllegalArgumentException(
"match expression must have an even number of arguments");
}
- var inputValue = input.evaluate(row);
+ var inputValue = input.evaluate(dataRow);
for (int i = 0; i < cases.size(); i += 2) {
Expression condition = cases.get(i);
Expression then = cases.get(i + 1);
- if (inputValue.equals(condition.evaluate(row))) {
- return then.evaluate(row);
+ if (inputValue.equals(condition.evaluate(dataRow))) {
+ return then.evaluate(dataRow);
}
}
- return fallback.evaluate(row);
+ return fallback.evaluate(dataRow);
}
}
@@ -375,7 +375,7 @@ public interface Expressions {
}
@Override
- public Object evaluate(Row row) {
+ public Object evaluate(DataRow dataRow) {
throw new UnsupportedOperationException("within expression is not
supported");
}
}
@@ -388,8 +388,8 @@ public interface Expressions {
}
@Override
- public String evaluate(Row row) {
- Object property = row.get("geom");
+ public String evaluate(DataRow dataRow) {
+ Object property = dataRow.get("geom");
if (property instanceof Point) {
return "Point";
} else if (property instanceof LineString) {
@@ -518,7 +518,7 @@ public interface Expressions {
return mapper.writeValueAsString(expression);
}
- static Predicate<Row> asPredicate(Expression expression) {
+ static Predicate<DataRow> asPredicate(Expression expression) {
return row -> {
var result = expression.evaluate(row);
if (result instanceof Boolean booleanResult) {
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportGeoPackage.java
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportGeoPackage.java
index 5527b310..34d5c380 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportGeoPackage.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportGeoPackage.java
@@ -13,9 +13,10 @@
package org.apache.baremaps.workflow.tasks;
import java.nio.file.Path;
-import org.apache.baremaps.collection.store.TableDecorator;
-import org.apache.baremaps.storage.geopackage.GeoPackageStore;
-import org.apache.baremaps.storage.postgres.PostgresStore;
+import org.apache.baremaps.collection.store.DataTableGeometryTransformer;
+import org.apache.baremaps.collection.store.DataTableAdapter;
+import org.apache.baremaps.storage.geopackage.GeoPackageDataStore;
+import org.apache.baremaps.storage.postgres.PostgresDataStore;
import org.apache.baremaps.utils.ProjectionTransformer;
import org.apache.baremaps.workflow.Task;
import org.apache.baremaps.workflow.WorkflowContext;
@@ -32,14 +33,17 @@ public record ImportGeoPackage(Path file, String database,
Integer sourceSRID, I
@Override
public void execute(WorkflowContext context) throws Exception {
var path = file.toAbsolutePath();
- try (var geoPackageDatabase = new GeoPackageStore(path)) {
+ try (var geoPackageDataStore = new GeoPackageDataStore(path)) {
var dataSource = context.getDataSource(database);
- var postgresDatabase = new PostgresStore(dataSource);
- for (var name : geoPackageDatabase.list()) {
- var transformer = new ProjectionTransformer(sourceSRID, targetSRID);
- var decoratedTable =
- new TableDecorator(geoPackageDatabase.get(name), transformer);
- postgresDatabase.add(decoratedTable);
+ var postgresDataStore = new PostgresDataStore(dataSource);
+ for (var name : geoPackageDataStore.list()) {
+ var geoPackageTable = geoPackageDataStore.get(name);
+ var projectionTransformer = new ProjectionTransformer(sourceSRID,
targetSRID);
+ var dataRowTransformer =
+ new DataTableGeometryTransformer(geoPackageTable,
projectionTransformer);
+ var transformedDataTable =
+ new DataTableAdapter(geoPackageDataStore.get(name),
dataRowTransformer);
+ postgresDataStore.add(transformedDataTable);
}
} catch (Exception e) {
throw new WorkflowException(e);
diff --git
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportShapefile.java
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportShapefile.java
index 3d6a6ad8..90c05afd 100644
---
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportShapefile.java
+++
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportShapefile.java
@@ -13,9 +13,10 @@
package org.apache.baremaps.workflow.tasks;
import java.nio.file.Path;
-import org.apache.baremaps.collection.store.TableDecorator;
-import org.apache.baremaps.storage.postgres.PostgresStore;
-import org.apache.baremaps.storage.shapefile.ShapefileTable;
+import org.apache.baremaps.collection.store.DataTableGeometryTransformer;
+import org.apache.baremaps.collection.store.DataTableAdapter;
+import org.apache.baremaps.storage.postgres.PostgresDataStore;
+import org.apache.baremaps.storage.shapefile.ShapefileDataTable;
import org.apache.baremaps.utils.ProjectionTransformer;
import org.apache.baremaps.workflow.Task;
import org.apache.baremaps.workflow.WorkflowContext;
@@ -33,11 +34,13 @@ public record ImportShapefile(Path file, String database,
Integer sourceSRID, In
public void execute(WorkflowContext context) throws Exception {
var path = file.toAbsolutePath();
try {
- var featureSet = new ShapefileTable(path);
+ var shapefileDataTable = new ShapefileDataTable(path);
var dataSource = context.getDataSource(database);
- var postgresDatabase = new PostgresStore(dataSource);
- postgresDatabase.add(new TableDecorator(
- featureSet, new ProjectionTransformer(sourceSRID, targetSRID)));
+ var postgresDataStore = new PostgresDataStore(dataSource);
+ var rowTransformer = new DataTableGeometryTransformer(shapefileDataTable,
+ new ProjectionTransformer(sourceSRID, targetSRID));
+ var transformedDataTable = new DataTableAdapter(shapefileDataTable,
rowTransformer);
+ postgresDataStore.add(transformedDataTable);
} catch (Exception e) {
throw new WorkflowException(e);
}
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/collection/type/DataTypeProvider.java
b/baremaps-core/src/test/java/org/apache/baremaps/collection/type/DataTypeProvider.java
index 52c9bdde..cc5e5fc8 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/collection/type/DataTypeProvider.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/collection/type/DataTypeProvider.java
@@ -16,10 +16,9 @@ package org.apache.baremaps.collection.type;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
-import org.apache.baremaps.collection.store.ColumnImpl;
-import org.apache.baremaps.collection.store.Row;
-import org.apache.baremaps.collection.store.Schema;
-import org.apache.baremaps.collection.store.SchemaImpl;
+import org.apache.baremaps.collection.store.*;
+import org.apache.baremaps.collection.store.DataSchema;
+import org.apache.baremaps.collection.store.DataSchemaImpl;
import org.apache.baremaps.collection.type.geometry.*;
import org.junit.jupiter.params.provider.Arguments;
import org.locationtech.jts.geom.*;
@@ -28,26 +27,26 @@ public class DataTypeProvider {
private static final GeometryFactory geometryFactory = new GeometryFactory();
- private static final Schema schema = new SchemaImpl("row", List.of(
- new ColumnImpl("byte", Byte.class),
- new ColumnImpl("boolean", Boolean.class),
- new ColumnImpl("short", Short.class),
- new ColumnImpl("integer", Integer.class),
- new ColumnImpl("long", Long.class),
- new ColumnImpl("float", Float.class),
- new ColumnImpl("double", Double.class),
- new ColumnImpl("string", String.class),
- new ColumnImpl("geometry", Geometry.class),
- new ColumnImpl("point", Point.class),
- new ColumnImpl("linestring", LineString.class),
- new ColumnImpl("polygon", Polygon.class),
- new ColumnImpl("multipoint", MultiPoint.class),
- new ColumnImpl("multilinestring", MultiLineString.class),
- new ColumnImpl("multipolygon", MultiPolygon.class),
- new ColumnImpl("geometrycollection", GeometryCollection.class),
- new ColumnImpl("coordinate", Coordinate.class)));
+ private static final DataSchema DATA_SCHEMA = new DataSchemaImpl("row",
List.of(
+ new DataColumnImpl("byte", Byte.class),
+ new DataColumnImpl("boolean", Boolean.class),
+ new DataColumnImpl("short", Short.class),
+ new DataColumnImpl("integer", Integer.class),
+ new DataColumnImpl("long", Long.class),
+ new DataColumnImpl("float", Float.class),
+ new DataColumnImpl("double", Double.class),
+ new DataColumnImpl("string", String.class),
+ new DataColumnImpl("geometry", Geometry.class),
+ new DataColumnImpl("point", Point.class),
+ new DataColumnImpl("linestring", LineString.class),
+ new DataColumnImpl("polygon", Polygon.class),
+ new DataColumnImpl("multipoint", MultiPoint.class),
+ new DataColumnImpl("multilinestring", MultiLineString.class),
+ new DataColumnImpl("multipolygon", MultiPolygon.class),
+ new DataColumnImpl("geometrycollection", GeometryCollection.class),
+ new DataColumnImpl("coordinate", Coordinate.class)));
- private static final Row row = schema.createRow()
+ private static final DataRow DATA_ROW = DATA_SCHEMA.createRow()
.with("byte", Byte.MAX_VALUE)
.with("boolean", true)
.with("short", Short.MAX_VALUE)
@@ -318,7 +317,7 @@ public class DataTypeProvider {
new Coordinate(4, 1), new
Coordinate(3, 1)})})})),
// Row
- Arguments.of(new RowDataType(schema), row),
+ Arguments.of(new RowDataType(DATA_SCHEMA), DATA_ROW),
// Geometry
Arguments.of(new GeometryDataType(),
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/storage/MockTable.java
b/baremaps-core/src/test/java/org/apache/baremaps/storage/MockDataTable.java
similarity index 63%
rename from
baremaps-core/src/test/java/org/apache/baremaps/storage/MockTable.java
rename to
baremaps-core/src/test/java/org/apache/baremaps/storage/MockDataTable.java
index be6b1f6f..3071f571 100644
--- a/baremaps-core/src/test/java/org/apache/baremaps/storage/MockTable.java
+++ b/baremaps-core/src/test/java/org/apache/baremaps/storage/MockDataTable.java
@@ -20,44 +20,44 @@ import org.apache.baremaps.collection.store.*;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
-public class MockTable extends AbstractTable {
+public class MockDataTable extends AbstractDataTable {
- private final Schema schema;
+ private final DataSchema dataSchema;
- private final List<Row> rows;
+ private final List<DataRow> dataRows;
- public MockTable() {
- this.schema = new SchemaImpl("mock", List.of(
- new ColumnImpl("string", String.class),
- new ColumnImpl("integer", Integer.class),
- new ColumnImpl("double", Double.class),
- new ColumnImpl("float", Float.class),
- new ColumnImpl("geometry", Geometry.class)));
- this.rows = List.of(
- new RowImpl(schema,
+ public MockDataTable() {
+ this.dataSchema = new DataSchemaImpl("mock", List.of(
+ new DataColumnImpl("string", String.class),
+ new DataColumnImpl("integer", Integer.class),
+ new DataColumnImpl("double", Double.class),
+ new DataColumnImpl("float", Float.class),
+ new DataColumnImpl("geometry", Geometry.class)));
+ this.dataRows = List.of(
+ new DataRowImpl(dataSchema,
List.of("string", 1, 1.0, 1.0f, GEOMETRY_FACTORY.createPoint(new
Coordinate(1, 1)))),
- new RowImpl(schema,
+ new DataRowImpl(dataSchema,
List.of("string", 2, 2.0, 2.0f, GEOMETRY_FACTORY.createPoint(new
Coordinate(2, 2)))),
- new RowImpl(schema,
+ new DataRowImpl(dataSchema,
List.of("string", 3, 3.0, 3.0f, GEOMETRY_FACTORY.createPoint(new
Coordinate(3, 3)))),
- new RowImpl(schema,
+ new DataRowImpl(dataSchema,
List.of("string", 4, 4.0, 4.0f, GEOMETRY_FACTORY.createPoint(new
Coordinate(4, 4)))),
- new RowImpl(schema,
+ new DataRowImpl(dataSchema,
List.of("string", 5, 5.0, 5.0f, GEOMETRY_FACTORY.createPoint(new
Coordinate(5, 5)))));
}
@Override
- public Iterator<Row> iterator() {
- return rows.iterator();
+ public Iterator<DataRow> iterator() {
+ return dataRows.iterator();
}
@Override
public long sizeAsLong() {
- return rows.size();
+ return dataRows.size();
}
@Override
- public Schema schema() {
- return schema;
+ public DataSchema schema() {
+ return dataSchema;
}
}
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufTableTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufDataTableTest.java
similarity index 78%
rename from
baremaps-core/src/test/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufTableTest.java
rename to
baremaps-core/src/test/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufDataTableTest.java
index 7f19c72b..0d440297 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufTableTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/storage/flatgeobuf/FlatGeoBufDataTableTest.java
@@ -19,11 +19,11 @@ import java.nio.file.Files;
import org.apache.baremaps.testing.TestFiles;
import org.junit.jupiter.api.Test;
-class FlatGeoBufTableTest {
+class FlatGeoBufDataTableTest {
@Test
void schema() throws IOException {
- var table = new FlatGeoBufTable(TestFiles.resolve("countries.fgb"));
+ var table = new FlatGeoBufDataTable(TestFiles.resolve("countries.fgb"));
var schema = table.schema();
assertEquals(schema.name(), null);
assertEquals(schema.columns().size(), 2);
@@ -31,7 +31,7 @@ class FlatGeoBufTableTest {
@Test
void read() throws IOException {
- var table = new FlatGeoBufTable(TestFiles.resolve("countries.fgb"));
+ var table = new FlatGeoBufDataTable(TestFiles.resolve("countries.fgb"));
assertEquals(179, table.sizeAsLong());
assertEquals(179, table.stream().count());
}
@@ -40,12 +40,12 @@ class FlatGeoBufTableTest {
void write() throws IOException {
var file = Files.createTempFile("countries", ".fgb");
file.toFile().deleteOnExit();
- var table1 = new FlatGeoBufTable(TestFiles.resolve("countries.fgb"));
+ var table1 = new FlatGeoBufDataTable(TestFiles.resolve("countries.fgb"));
var rows = table1.stream().toList();
- var table2 = new FlatGeoBufTable(file, table1.schema());
+ var table2 = new FlatGeoBufDataTable(file, table1.schema());
table2.write(rows);
- var featureSet = new FlatGeoBufTable(file);
+ var featureSet = new FlatGeoBufDataTable(file);
assertEquals(179, featureSet.stream().count());
}
}
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageStoreTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageDataStoreTest.java
similarity index 84%
rename from
baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageStoreTest.java
rename to
baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageDataStoreTest.java
index 706241dd..8add7789 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageStoreTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageDataStoreTest.java
@@ -17,11 +17,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.baremaps.testing.TestFiles;
import org.junit.jupiter.api.Test;
-class GeoPackageStoreTest {
+class GeoPackageDataStoreTest {
@Test
void schema() {
- var geoPackageStore = new
GeoPackageStore(TestFiles.resolve("countries.gpkg"));
+ var geoPackageStore = new
GeoPackageDataStore(TestFiles.resolve("countries.gpkg"));
var table = geoPackageStore.get("countries");
var schema = table.schema();
assertEquals(schema.name(), "countries");
@@ -30,7 +30,7 @@ class GeoPackageStoreTest {
@Test
void read() {
- var geoPackageStore = new
GeoPackageStore(TestFiles.resolve("countries.gpkg"));
+ var geoPackageStore = new
GeoPackageDataStore(TestFiles.resolve("countries.gpkg"));
var table = geoPackageStore.get("countries");
assertEquals(179, table.sizeAsLong());
assertEquals(179, table.stream().count());
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageToPostgresTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageToPostgresTest.java
index 9caa23c5..50ad8535 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageToPostgresTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/storage/geopackage/GeoPackageToPostgresTest.java
@@ -14,7 +14,7 @@ package org.apache.baremaps.storage.geopackage;
import static org.junit.jupiter.api.Assertions.*;
-import org.apache.baremaps.storage.postgres.PostgresStore;
+import org.apache.baremaps.storage.postgres.PostgresDataStore;
import org.apache.baremaps.testing.PostgresContainerTest;
import org.apache.baremaps.testing.TestFiles;
import org.junit.jupiter.api.Tag;
@@ -26,11 +26,11 @@ public class GeoPackageToPostgresTest extends
PostgresContainerTest {
@Tag("integration")
void schema() {
// Open the GeoPackage
- var geoPackageStore = new
GeoPackageStore(TestFiles.resolve("countries.gpkg"));
+ var geoPackageStore = new
GeoPackageDataStore(TestFiles.resolve("countries.gpkg"));
var geoPackageTable = geoPackageStore.get("countries");
// Copy the table to Postgres
- var postgresStore = new PostgresStore(dataSource());
+ var postgresStore = new PostgresDataStore(dataSource());
postgresStore.add(geoPackageTable);
// Check the table in Postgres
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresStoreTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresDataStoreTest.java
similarity index 76%
rename from
baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresStoreTest.java
rename to
baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresDataStoreTest.java
index 95246a3c..2b1104cc 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresStoreTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresDataStoreTest.java
@@ -14,21 +14,21 @@ package org.apache.baremaps.storage.postgres;
import static org.junit.jupiter.api.Assertions.*;
-import org.apache.baremaps.collection.store.TableException;
-import org.apache.baremaps.storage.MockTable;
+import org.apache.baremaps.collection.store.DataTableException;
+import org.apache.baremaps.storage.MockDataTable;
import org.apache.baremaps.testing.PostgresContainerTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
-class PostgresStoreTest extends PostgresContainerTest {
+class PostgresDataStoreTest extends PostgresContainerTest {
- private PostgresStore store;
+ private PostgresDataStore store;
@BeforeEach
void init() {
- store = new PostgresStore(dataSource());
- store.add(new MockTable());
+ store = new PostgresDataStore(dataSource());
+ store.add(new MockDataTable());
}
@Test
@@ -49,6 +49,6 @@ class PostgresStoreTest extends PostgresContainerTest {
@Tag("integration")
void remove() {
store.remove("mock");
- assertThrows(TableException.class, () -> store.get("mock"));
+ assertThrows(DataTableException.class, () -> store.get("mock"));
}
}
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresTableTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresDataTableTest.java
similarity index 84%
rename from
baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresTableTest.java
rename to
baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresDataTableTest.java
index 0b329364..b1c6960e 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresTableTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/storage/postgres/PostgresDataTableTest.java
@@ -16,22 +16,22 @@ import static
org.apache.baremaps.openstreetmap.repository.Constants.GEOMETRY_FA
import static org.junit.jupiter.api.Assertions.*;
import java.util.List;
-import org.apache.baremaps.collection.store.RowImpl;
-import org.apache.baremaps.storage.MockTable;
+import org.apache.baremaps.collection.store.DataRowImpl;
+import org.apache.baremaps.storage.MockDataTable;
import org.apache.baremaps.testing.PostgresContainerTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Coordinate;
-class PostgresTableTest extends PostgresContainerTest {
+class PostgresDataTableTest extends PostgresContainerTest {
- private PostgresStore store;
+ private PostgresDataStore store;
@BeforeEach
void init() {
- store = new PostgresStore(dataSource());
- store.add(new MockTable());
+ store = new PostgresDataStore(dataSource());
+ store.add(new MockDataTable());
}
@Test
@@ -64,7 +64,7 @@ class PostgresTableTest extends PostgresContainerTest {
void add() {
var table = store.get("mock");
var schema = table.schema();
- var added = table.add(new RowImpl(schema,
+ var added = table.add(new DataRowImpl(schema,
List.of("string", 6, 6.0, 6.0f, GEOMETRY_FACTORY.createPoint(new
Coordinate(6, 6)))));
assertTrue(added);
assertEquals(6, table.size());
@@ -76,9 +76,9 @@ class PostgresTableTest extends PostgresContainerTest {
var table = store.get("mock");
var schema = table.schema();
var added = table.addAll(List.of(
- new RowImpl(schema,
+ new DataRowImpl(schema,
List.of("string", 6, 6.0, 6.0f, GEOMETRY_FACTORY.createPoint(new
Coordinate(6, 6)))),
- new RowImpl(schema,
+ new DataRowImpl(schema,
List.of("string", 7, 7.0, 7.0f, GEOMETRY_FACTORY.createPoint(new
Coordinate(7, 7))))));
assertTrue(added);
assertEquals(7, table.size());
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/TileStoreTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/TileDataStoreTest.java
similarity index 97%
rename from
baremaps-core/src/test/java/org/apache/baremaps/tilestore/TileStoreTest.java
rename to
baremaps-core/src/test/java/org/apache/baremaps/tilestore/TileDataStoreTest.java
index b1be4229..aa2c701b 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/TileStoreTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/TileDataStoreTest.java
@@ -19,7 +19,7 @@ import java.nio.ByteBuffer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
-public abstract class TileStoreTest {
+public abstract class TileDataStoreTest {
// TODO: try to move this in the testing module
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/file/FileTileStoreTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/file/FileTileDataStoreTest.java
similarity index 91%
rename from
baremaps-core/src/test/java/org/apache/baremaps/tilestore/file/FileTileStoreTest.java
rename to
baremaps-core/src/test/java/org/apache/baremaps/tilestore/file/FileTileDataStoreTest.java
index b89f8833..053b11ff 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/file/FileTileStoreTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/file/FileTileDataStoreTest.java
@@ -18,13 +18,13 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import org.apache.baremaps.tilestore.TileDataStoreTest;
import org.apache.baremaps.tilestore.TileStore;
-import org.apache.baremaps.tilestore.TileStoreTest;
import org.apache.baremaps.utils.FileUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
-class FileTileStoreTest extends TileStoreTest {
+class FileTileDataStoreTest extends TileDataStoreTest {
Path directory;
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesTest.java
index b677e5d5..40bba3b6 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/mbtiles/MBTilesTest.java
@@ -21,14 +21,14 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-import org.apache.baremaps.tilestore.TileStoreTest;
+import org.apache.baremaps.tilestore.TileDataStoreTest;
import org.apache.baremaps.utils.FileUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.sqlite.SQLiteDataSource;
-class MBTilesTest extends TileStoreTest {
+class MBTilesTest extends TileDataStoreTest {
Path file;
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/postgres/PostgresTileStoreTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/postgres/PostgresTileDataStoreTest.java
similarity index 99%
rename from
baremaps-core/src/test/java/org/apache/baremaps/tilestore/postgres/PostgresTileStoreTest.java
rename to
baremaps-core/src/test/java/org/apache/baremaps/tilestore/postgres/PostgresTileDataStoreTest.java
index ecfe479e..620e5abd 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/tilestore/postgres/PostgresTileStoreTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/tilestore/postgres/PostgresTileDataStoreTest.java
@@ -19,7 +19,7 @@ import java.util.List;
import org.apache.baremaps.tilestore.TileCoord;
import org.junit.jupiter.api.Test;
-class PostgresTileStoreTest {
+class PostgresTileDataStoreTest {
@Test
void sameQueries() {
diff --git
a/baremaps-core/src/test/java/org/apache/baremaps/vectortile/ExpressionsTest.java
b/baremaps-core/src/test/java/org/apache/baremaps/vectortile/ExpressionsTest.java
index d8932169..56bdcf93 100644
---
a/baremaps-core/src/test/java/org/apache/baremaps/vectortile/ExpressionsTest.java
+++
b/baremaps-core/src/test/java/org/apache/baremaps/vectortile/ExpressionsTest.java
@@ -16,8 +16,8 @@ import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.util.List;
-import org.apache.baremaps.collection.store.Row;
-import org.apache.baremaps.collection.store.Schema;
+import org.apache.baremaps.collection.store.DataRow;
+import org.apache.baremaps.collection.store.DataSchema;
import org.apache.baremaps.vectortile.expression.Expressions;
import org.apache.baremaps.vectortile.expression.Expressions.*;
import org.junit.jupiter.api.Test;
@@ -27,10 +27,10 @@ class ExpressionsTest {
record Property(String name, Object value) {
}
- record RowMock(List<Property> properties) implements Row {
+ record DataRowMock(List<Property> properties) implements DataRow {
@Override
- public Schema schema() {
+ public DataSchema schema() {
throw new UnsupportedOperationException();
}
@@ -83,15 +83,15 @@ class ExpressionsTest {
@Test
public void get() throws IOException {
assertEquals("value",
- new Get("key").evaluate(new RowMock(List.of(new Property("key",
"value")))));
- assertEquals(null, new Get("key").evaluate(new RowMock(List.of())));
+ new Get("key").evaluate(new DataRowMock(List.of(new Property("key",
"value")))));
+ assertEquals(null, new Get("key").evaluate(new DataRowMock(List.of())));
}
@Test
public void has() throws IOException {
assertEquals(true,
- new Has("key").evaluate(new RowMock(List.of(new Property("key",
"value")))));
- assertEquals(false, new Has("key").evaluate(new RowMock(List.of())));
+ new Has("key").evaluate(new DataRowMock(List.of(new Property("key",
"value")))));
+ assertEquals(false, new Has("key").evaluate(new DataRowMock(List.of())));
}
@Test
diff --git a/baremaps-core/src/test/resources/queries/schema.sql
b/baremaps-core/src/test/resources/queries/schema.sql
index 18b3fee7..489967db 100644
--- a/baremaps-core/src/test/resources/queries/schema.sql
+++ b/baremaps-core/src/test/resources/queries/schema.sql
@@ -1,4 +1,4 @@
--- mbtiles schema
+-- mbtiles dataSchema
-- Licensed 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
diff --git
a/baremaps-ogcapi/src/main/java/org/apache/baremaps/ogcapi/CollectionsResource.java
b/baremaps-ogcapi/src/main/java/org/apache/baremaps/ogcapi/CollectionsResource.java
index 35b5a85c..0f972578 100644
---
a/baremaps-ogcapi/src/main/java/org/apache/baremaps/ogcapi/CollectionsResource.java
+++
b/baremaps-ogcapi/src/main/java/org/apache/baremaps/ogcapi/CollectionsResource.java
@@ -20,12 +20,12 @@ import javax.sql.DataSource;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.apache.baremaps.collection.store.Table;
+import org.apache.baremaps.collection.store.DataTable;
import org.apache.baremaps.ogcapi.api.CollectionsApi;
import org.apache.baremaps.ogcapi.model.Collection;
import org.apache.baremaps.ogcapi.model.Collections;
import org.apache.baremaps.ogcapi.model.Link;
-import org.apache.baremaps.storage.postgres.PostgresStore;
+import org.apache.baremaps.storage.postgres.PostgresDataStore;
/**
* A resource that provides access to collections.
@@ -36,7 +36,7 @@ public class CollectionsResource implements CollectionsApi {
@Context
UriInfo uriInfo;
- private final PostgresStore store;
+ private final PostgresDataStore store;
/**
* Constructs a {@code CollectionsResource}.
@@ -45,7 +45,7 @@ public class CollectionsResource implements CollectionsApi {
*/
@Inject
public CollectionsResource(DataSource dataSource) {
- this.store = new PostgresStore(dataSource);
+ this.store = new PostgresDataStore(dataSource);
}
/**
@@ -80,11 +80,11 @@ public class CollectionsResource implements CollectionsApi {
/**
* Returns the collection info for the specified table.
*
- * @param table the table
+ * @param dataTable the table
* @return the collection info
*/
- private Collection getCollection(Table table) {
- var name = table.schema().name();
+ private Collection getCollection(DataTable dataTable) {
+ var name = dataTable.schema().name();
var collection = new Collection();
collection.setId(name);
collection.setTitle(name);
diff --git a/baremaps-ogcapi/src/main/resources/initialize_ogcapi_tables.sql
b/baremaps-ogcapi/src/main/resources/initialize_ogcapi_tables.sql
index e89c7dbd..36a3c5ea 100644
--- a/baremaps-ogcapi/src/main/resources/initialize_ogcapi_tables.sql
+++ b/baremaps-ogcapi/src/main/resources/initialize_ogcapi_tables.sql
@@ -1,14 +1,14 @@
-create table if not exists collections (
+create dataTable if not exists collections (
id uuid primary key,
collection jsonb
);
-create table if not exists styles (
+create dataTable if not exists styles (
id uuid primary key,
style jsonb
);
-create table if not exists tilesets (
+create dataTable if not exists tilesets (
id uuid primary key,
tileset jsonb
);
diff --git a/baremaps-ogcapi/src/main/resources/initialize_studio_tables.sql
b/baremaps-ogcapi/src/main/resources/initialize_studio_tables.sql
index df5cc132..f984601c 100644
--- a/baremaps-ogcapi/src/main/resources/initialize_studio_tables.sql
+++ b/baremaps-ogcapi/src/main/resources/initialize_studio_tables.sql
@@ -1,6 +1,6 @@
-create schema studio;
+create dataSchema studio;
-create table if not exists studio.entities (
+create dataTable if not exists studio.entities (
id uuid primary key,
entity jsonb,
kind text
diff --git a/baremaps-renderer/assets/report-template.html
b/baremaps-renderer/assets/report-template.html
index 20209c4a..f05ea3a8 100644
--- a/baremaps-renderer/assets/report-template.html
+++ b/baremaps-renderer/assets/report-template.html
@@ -114,7 +114,7 @@
.results {
display: flex;
- flex-direction: column;
+ flex-direction: dataColumn;
gap: 2rem;
}
@@ -159,7 +159,7 @@
.images {
display: grid;
- grid-template-columns: 1fr 1fr 1fr;
+ grid-template-dataColumns: 1fr 1fr 1fr;
gap: 1rem;
}
diff --git a/baremaps-server/src/main/resources/assets/viewer.html
b/baremaps-server/src/main/resources/assets/viewer.html
index c73ad203..2a1a85fd 100644
--- a/baremaps-server/src/main/resources/assets/viewer.html
+++ b/baremaps-server/src/main/resources/assets/viewer.html
@@ -35,11 +35,11 @@
height: 100%;
}
- .columns {
+ .dataColumns {
display: flex;
}
- .column {
+ .dataColumn {
flex: 1;
height: 100vh;
}
@@ -48,11 +48,11 @@
<title>Baremaps</title>
</head>
<body>
- <div class="columns">
- <div class="column map-wrapper" id="mapWrapper">
+ <div class="dataColumns">
+ <div class="dataColumn map-wrapper" id="mapWrapper">
<div class="map" id="map"></div>
</div>
- <div class="column map-wrapper" id="osmMapWrapper" data-state="hidden"
style="flex: 0">
+ <div class="dataColumn map-wrapper" id="osmMapWrapper" data-state="hidden"
style="flex: 0">
<div class="map" id="osmMap"></div>
</div>
</div>
diff --git a/baremaps-server/src/main/resources/geocoder/index.html
b/baremaps-server/src/main/resources/geocoder/index.html
index d2a0bd33..0ada6fe3 100644
--- a/baremaps-server/src/main/resources/geocoder/index.html
+++ b/baremaps-server/src/main/resources/geocoder/index.html
@@ -25,7 +25,7 @@
border: 1px solid black;
}
- table {
+ dataTable {
border-collapse: collapse;
}
</style>
@@ -37,8 +37,8 @@
<input type="text" id="countryCode" name="countryCode"
placeholder="Country code" value=""/>
<input type="submit" value="Submit"/>
</form>
-<!-- The table of retrieved locations -->
-<table id="results"></table>
+<!-- The dataTable of retrieved locations -->
+<dataTable id="results"></dataTable>
<script>
@@ -46,8 +46,8 @@
const searchForm = document.getElementById('searchForm');
searchForm.addEventListener('submit', search);
- // Get the table of results
- const table = document.getElementById('results');
+ // Get the dataTable of results
+ const dataTable = document.getElementById('results');
function search(event) {
event.preventDefault();
@@ -60,28 +60,28 @@
fetch(`${window.location.origin}/api/geocoder?${queryString}`)
.then(response => response.json())
.then(response => {
- // Extract the headers from the first row
+ // Extract the headers from the first dataRow
const headers = response.results && response.results.length > 0
? Object.keys(response.results[0].data).sort()
: [];
- // Clear the results table
- table.innerHTML = '';
+ // Clear the results dataTable
+ dataTable.innerHTML = '';
- // Insert the headers in the table
- const headerRow = table.insertRow();
+ // Insert the headers in the dataTable
+ const headerRow = dataTable.insertRow();
headerRow.innerHTML =
`<th>#</th><th>score</th>${headers.map(header =>
`<th>${header}</th>`).join('')}`;
- // Insert the results in the table
+ // Insert the results in the dataTable
response.results.forEach((result, index) => {
- const row = table.insertRow();
- row.insertCell().innerText = index;
- row.insertCell().innerText = result.score;
+ const dataRow = dataTable.insertRow();
+ dataRow.insertCell().innerText = index;
+ dataRow.insertCell().innerText = result.score;
headers.forEach(header => {
if (result.data[header] !== undefined) {
- row.insertCell().innerText = result.data[header];
+ dataRow.insertCell().innerText =
result.data[header];
} else {
- row.insertCell().innerText = '';
+ dataRow.insertCell().innerText = '';
}
});
});
diff --git a/baremaps-server/src/main/resources/iploc/index.html
b/baremaps-server/src/main/resources/iploc/index.html
index e4833a2c..c12f1753 100644
--- a/baremaps-server/src/main/resources/iploc/index.html
+++ b/baremaps-server/src/main/resources/iploc/index.html
@@ -25,7 +25,7 @@
border: 1px solid black;
}
- table {
+ dataTable {
border-collapse: collapse;
}
</style>
@@ -37,8 +37,8 @@
<input type="text" id="ip" name="ip" value=""/>
<input type="submit" value="Submit"/>
</form>
- <!-- The table of retrieved locations -->
- <table id="results"></table>
+ <!-- The dataTable of retrieved locations -->
+ <dataTable id="results"></dataTable>
<script>
function searchByIp(event) {
event.preventDefault();
@@ -59,28 +59,28 @@
// Success!
const geoLocations = JSON.parse(request.responseText);
- // Fill the table of geo locations from the resulting
geoLocations
+ // Fill the dataTable of geo locations from the resulting
geoLocations
// Geo locations contain an address, an ipv4Range, a
location, a network and a country
- const table = document.getElementById('results');
- table.innerHTML = '';
- // Insert header row
- table.insertRow().innerHTML =
'<th>#</th><th>Address</th><th>IP
Range</th><th>Longitude</th><th>Latitude</th><th>Network</th><th>Country</th>';
+ const dataTable = document.getElementById('results');
+ dataTable.innerHTML = '';
+ // Insert header dataRow
+ dataTable.insertRow().innerHTML =
'<th>#</th><th>Address</th><th>IP
Range</th><th>Longitude</th><th>Latitude</th><th>Network</th><th>Country</th>';
for (let i = 0; i < geoLocations.length; i++) {
- const row = table.insertRow(i + 1);
+ const dataRow = dataTable.insertRow(i + 1);
let pos = 0;
- let cell = row.insertCell(pos++);
+ let cell = dataRow.insertCell(pos++);
cell.innerHTML = i + 1;
- cell = row.insertCell(pos++);
+ cell = dataRow.insertCell(pos++);
cell.innerHTML = geoLocations[i].address;
- cell = row.insertCell(pos++);
+ cell = dataRow.insertCell(pos++);
cell.innerHTML = `${geoLocations[i].inetStart} -
${geoLocations[i].inetEnd}`;
- cell = row.insertCell(pos++);
+ cell = dataRow.insertCell(pos++);
cell.innerHTML = geoLocations[i].longitude;
- cell = row.insertCell(pos++);
+ cell = dataRow.insertCell(pos++);
cell.innerHTML = geoLocations[i].latitude;
- cell = row.insertCell(pos++);
+ cell = dataRow.insertCell(pos++);
cell.innerHTML = geoLocations[i].network;
- cell = row.insertCell(pos++);
+ cell = dataRow.insertCell(pos++);
cell.innerHTML = geoLocations[i].country;
}
} else {