This is an automated email from the ASF dual-hosted git repository. bchapuis pushed a commit to branch modularization in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
commit ce00613ccb7411ffc8f784e4bac7b9afeec23e77 Author: Bertil Chapuis <[email protected]> AuthorDate: Fri May 3 23:12:17 2024 +0200 Decouple the parser from the map --- .../apache/baremaps/openstreetmap/DiffService.java | 14 +-- .../function/CoordinateMapBuilder.java | 6 +- .../function/EntityGeometryBuilder.java | 6 +- .../openstreetmap/function/GeometryMapBuilder.java | 6 +- .../function/ReferenceMapBuilder.java | 6 +- .../function/RelationMultiPolygonBuilder.java | 10 +- .../openstreetmap/function/WayGeometryBuilder.java | 6 +- .../baremaps/openstreetmap/pbf/PbfBlockReader.java | 14 +-- .../openstreetmap/pbf/PbfEntityReader.java | 10 +- .../baremaps/openstreetmap/pbf/PbfReader.java | 10 +- .../postgres/PostgresCoordinateMap.java | 2 +- .../openstreetmap/postgres/PostgresMap.java | 136 +++++++++++++++++++++ .../postgres/PostgresReferenceMap.java | 2 +- .../baremaps/workflow/tasks/ImportOsmPbf.java | 5 +- .../baremaps/workflow/tasks/UpdateOsmDatabase.java | 7 +- .../workflow/tasks/ImportUpdateSampleTest.java | 6 +- 16 files changed, 190 insertions(+), 56 deletions(-) diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/DiffService.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/DiffService.java index 6857a82a..adaade37 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/DiffService.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/DiffService.java @@ -23,15 +23,11 @@ import java.io.BufferedInputStream; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; -import java.util.List; -import java.util.Optional; -import java.util.Spliterator; -import java.util.Spliterators; +import java.util.*; import java.util.concurrent.Callable; import java.util.stream.Stream; import java.util.stream.StreamSupport; import java.util.zip.GZIPInputStream; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.function.EntityGeometryBuilder; import org.apache.baremaps.openstreetmap.function.EntityToGeometryMapper; import org.apache.baremaps.openstreetmap.model.*; @@ -50,8 +46,8 @@ public class DiffService implements Callable<List<TileCoord>> { private static final Logger logger = LoggerFactory.getLogger(DiffService.class); - private final DataMap<Long, Coordinate> coordinateMap; - private final DataMap<Long, List<Long>> referenceMap; + private final Map<Long, Coordinate> coordinateMap; + private final Map<Long, List<Long>> referenceMap; private final HeaderRepository headerRepository; private final Repository<Long, Node> nodeRepository; private final Repository<Long, Way> wayRepository; @@ -59,8 +55,8 @@ public class DiffService implements Callable<List<TileCoord>> { private final int srid; private final int zoom; - public DiffService(DataMap<Long, Coordinate> coordinateMap, - DataMap<Long, List<Long>> referenceMap, + public DiffService(Map<Long, Coordinate> coordinateMap, + Map<Long, List<Long>> referenceMap, HeaderRepository headerRepository, Repository<Long, Node> nodeRepository, Repository<Long, Way> wayRepository, Repository<Long, Relation> relationRepository, int srid, int zoom) { diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/CoordinateMapBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/CoordinateMapBuilder.java index 34a4731b..3686b3ff 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/CoordinateMapBuilder.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/CoordinateMapBuilder.java @@ -19,8 +19,8 @@ package org.apache.baremaps.openstreetmap.function; +import java.util.Map; import java.util.function.Consumer; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.model.Entity; import org.apache.baremaps.openstreetmap.model.Node; import org.locationtech.jts.geom.Coordinate; @@ -28,14 +28,14 @@ import org.locationtech.jts.geom.Coordinate; /** A consumer that stores openstreetmap coordinates in a map. */ public class CoordinateMapBuilder implements Consumer<Entity> { - private final DataMap<Long, Coordinate> coordinateMap; + private final Map<Long, Coordinate> coordinateMap; /** * Constructs a {@code CacheBlockConsumer} with the provided map. * * @param coordinateMap the map of coordinates */ - public CoordinateMapBuilder(DataMap<Long, Coordinate> coordinateMap) { + public CoordinateMapBuilder(Map<Long, Coordinate> coordinateMap) { this.coordinateMap = coordinateMap; } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/EntityGeometryBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/EntityGeometryBuilder.java index 093d6efb..aa790782 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/EntityGeometryBuilder.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/EntityGeometryBuilder.java @@ -20,8 +20,8 @@ package org.apache.baremaps.openstreetmap.function; import java.util.List; +import java.util.Map; import java.util.function.Consumer; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.model.*; import org.locationtech.jts.geom.*; @@ -39,8 +39,8 @@ public class EntityGeometryBuilder implements Consumer<Entity> { * @param referenceMap the reference cache */ public EntityGeometryBuilder( - DataMap<Long, Coordinate> coordinateMap, - DataMap<Long, List<Long>> referenceMap) { + Map<Long, Coordinate> coordinateMap, + Map<Long, List<Long>> referenceMap) { this.nodeGeometryBuilder = new NodeGeometryBuilder(); this.wayGeometryBuilder = new WayGeometryBuilder(coordinateMap); this.relationMultiPolygonBuilder = new RelationMultiPolygonBuilder(coordinateMap, referenceMap); diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/GeometryMapBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/GeometryMapBuilder.java index 3bac8678..52e189e0 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/GeometryMapBuilder.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/GeometryMapBuilder.java @@ -19,9 +19,9 @@ package org.apache.baremaps.openstreetmap.function; +import java.util.Map; import java.util.function.Consumer; import java.util.function.Predicate; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.model.Element; import org.apache.baremaps.openstreetmap.model.Entity; import org.locationtech.jts.geom.Geometry; @@ -31,7 +31,7 @@ import org.locationtech.jts.geom.Geometry; */ public class GeometryMapBuilder implements Consumer<Entity> { - private final DataMap<Long, Geometry> geometryMap; + private final Map<Long, Geometry> geometryMap; private final Predicate<Entity> filter; @@ -41,7 +41,7 @@ public class GeometryMapBuilder implements Consumer<Entity> { * @param geometryMap the geometry map * @param filter the entity filter */ - public GeometryMapBuilder(DataMap<Long, Geometry> geometryMap, Predicate<Entity> filter) { + public GeometryMapBuilder(Map<Long, Geometry> geometryMap, Predicate<Entity> filter) { this.geometryMap = geometryMap; this.filter = filter; } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/ReferenceMapBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/ReferenceMapBuilder.java index 90368cc8..b0d042a3 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/ReferenceMapBuilder.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/ReferenceMapBuilder.java @@ -20,22 +20,22 @@ package org.apache.baremaps.openstreetmap.function; import java.util.List; +import java.util.Map; import java.util.function.Consumer; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.model.Entity; import org.apache.baremaps.openstreetmap.model.Way; /** A consumer that stores openstreetmap references in a map. */ public class ReferenceMapBuilder implements Consumer<Entity> { - private final DataMap<Long, List<Long>> referenceMap; + private final Map<Long, List<Long>> referenceMap; /** * Constructs a {@code CacheBlockConsumer} with the provided map. * * @param referenceMap the map of references */ - public ReferenceMapBuilder(DataMap<Long, List<Long>> referenceMap) { + public ReferenceMapBuilder(Map<Long, List<Long>> referenceMap) { this.referenceMap = referenceMap; } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/RelationMultiPolygonBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/RelationMultiPolygonBuilder.java index a530a671..111cfe81 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/RelationMultiPolygonBuilder.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/RelationMultiPolygonBuilder.java @@ -21,8 +21,8 @@ import static org.apache.baremaps.utils.GeometryUtils.GEOMETRY_FACTORY_WGS84; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.function.Consumer; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.model.Entity; import org.apache.baremaps.openstreetmap.model.Member; import org.apache.baremaps.openstreetmap.model.Member.MemberType; @@ -42,8 +42,8 @@ public class RelationMultiPolygonBuilder implements Consumer<Entity> { private static final Logger logger = LoggerFactory.getLogger(RelationMultiPolygonBuilder.class); - private final DataMap<Long, Coordinate> coordinateMap; - private final DataMap<Long, List<Long>> referenceMap; + private final Map<Long, Coordinate> coordinateMap; + private final Map<Long, List<Long>> referenceMap; /** * Constructs a relation geometry builder. @@ -52,8 +52,8 @@ public class RelationMultiPolygonBuilder implements Consumer<Entity> { * @param referenceMap the references map */ public RelationMultiPolygonBuilder( - DataMap<Long, Coordinate> coordinateMap, - DataMap<Long, List<Long>> referenceMap) { + Map<Long, Coordinate> coordinateMap, + Map<Long, List<Long>> referenceMap) { this.coordinateMap = coordinateMap; this.referenceMap = referenceMap; } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/WayGeometryBuilder.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/WayGeometryBuilder.java index b6b74ccc..a44d7d4f 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/WayGeometryBuilder.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/function/WayGeometryBuilder.java @@ -21,8 +21,8 @@ import static org.apache.baremaps.utils.GeometryUtils.GEOMETRY_FACTORY_WGS84; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.function.Consumer; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.model.Entity; import org.apache.baremaps.openstreetmap.model.Way; import org.locationtech.jts.geom.Coordinate; @@ -39,14 +39,14 @@ public class WayGeometryBuilder implements Consumer<Entity> { private static final Logger logger = LoggerFactory.getLogger(WayGeometryBuilder.class); - private final DataMap<Long, Coordinate> coordinateMap; + private final Map<Long, Coordinate> coordinateMap; /** * Constructs a way geometry builder. * * @param coordinateMap the coordinates map */ - public WayGeometryBuilder(DataMap<Long, Coordinate> coordinateMap) { + public WayGeometryBuilder(Map<Long, Coordinate> coordinateMap) { this.coordinateMap = coordinateMap; } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfBlockReader.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfBlockReader.java index 1879a532..cfdcf863 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfBlockReader.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfBlockReader.java @@ -21,8 +21,8 @@ import static org.apache.baremaps.stream.ConsumerUtils.consumeThenReturn; import java.io.InputStream; import java.util.List; +import java.util.Map; import java.util.stream.Stream; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.function.*; import org.apache.baremaps.openstreetmap.model.Block; import org.apache.baremaps.stream.StreamUtils; @@ -37,9 +37,9 @@ public class PbfBlockReader implements PbfReader<Block> { private int srid = 4326; - private DataMap<Long, Coordinate> coordinateMap; + private Map<Long, Coordinate> coordinateMap; - private DataMap<Long, List<Long>> referenceMap; + private Map<Long, List<Long>> referenceMap; @Override public int buffer() { @@ -79,23 +79,23 @@ public class PbfBlockReader implements PbfReader<Block> { } @Override - public DataMap<Long, Coordinate> coordinateMap() { + public Map<Long, Coordinate> coordinateMap() { return coordinateMap; } @Override - public PbfBlockReader coordinateMap(DataMap<Long, Coordinate> coordinateMap) { + public PbfBlockReader coordinateMap(Map<Long, Coordinate> coordinateMap) { this.coordinateMap = coordinateMap; return this; } @Override - public DataMap<Long, List<Long>> referenceMap() { + public Map<Long, List<Long>> referenceMap() { return referenceMap; } @Override - public PbfBlockReader referenceMap(DataMap<Long, List<Long>> referenceMap) { + public PbfBlockReader referenceMap(Map<Long, List<Long>> referenceMap) { this.referenceMap = referenceMap; return this; } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfEntityReader.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfEntityReader.java index a49dbd9c..cf8c1dba 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfEntityReader.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfEntityReader.java @@ -21,8 +21,8 @@ package org.apache.baremaps.openstreetmap.pbf; import java.io.InputStream; import java.util.List; +import java.util.Map; import java.util.stream.Stream; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.model.DataBlock; import org.apache.baremaps.openstreetmap.model.Entity; import org.apache.baremaps.openstreetmap.model.HeaderBlock; @@ -75,23 +75,23 @@ public class PbfEntityReader implements PbfReader<Entity> { } @Override - public DataMap<Long, Coordinate> coordinateMap() { + public Map<Long, Coordinate> coordinateMap() { return reader.coordinateMap(); } @Override - public PbfEntityReader coordinateMap(DataMap<Long, Coordinate> coordinateMap) { + public PbfEntityReader coordinateMap(Map<Long, Coordinate> coordinateMap) { reader.coordinateMap(coordinateMap); return this; } @Override - public DataMap<Long, List<Long>> referenceMap() { + public Map<Long, List<Long>> referenceMap() { return reader.referenceMap(); } @Override - public PbfEntityReader referenceMap(DataMap<Long, List<Long>> referenceMap) { + public PbfEntityReader referenceMap(Map<Long, List<Long>> referenceMap) { reader.referenceMap(referenceMap); return this; } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfReader.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfReader.java index 43605fe5..bb560357 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfReader.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/pbf/PbfReader.java @@ -21,8 +21,8 @@ package org.apache.baremaps.openstreetmap.pbf; import java.io.InputStream; import java.util.List; +import java.util.Map; import java.util.stream.Stream; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.OsmReader; import org.locationtech.jts.geom.Coordinate; @@ -78,7 +78,7 @@ public interface PbfReader<T> extends OsmReader<T> { * * @return the map of coordinates */ - DataMap<Long, Coordinate> coordinateMap(); + Map<Long, Coordinate> coordinateMap(); /** * Sets the map used to store coordinates for generating geometries. @@ -86,14 +86,14 @@ public interface PbfReader<T> extends OsmReader<T> { * @param coordinateMap the map of coordinates * @return the reader */ - PbfReader<T> coordinateMap(DataMap<Long, Coordinate> coordinateMap); + PbfReader<T> coordinateMap(Map<Long, Coordinate> coordinateMap); /** * Gets the map used to store references for generating geometries. * * @return the map of references */ - DataMap<Long, List<Long>> referenceMap(); + Map<Long, List<Long>> referenceMap(); /** * Sets the map used to store references for generating geometries. @@ -101,7 +101,7 @@ public interface PbfReader<T> extends OsmReader<T> { * @param referenceMap the map of references * @return the reader */ - PbfReader<T> referenceMap(DataMap<Long, List<Long>> referenceMap); + PbfReader<T> referenceMap(Map<Long, List<Long>> referenceMap); /** * Creates an ordered stream of osm objects. diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresCoordinateMap.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresCoordinateMap.java index 7f27b313..4d17fb46 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresCoordinateMap.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresCoordinateMap.java @@ -29,7 +29,7 @@ import org.locationtech.jts.geom.Coordinate; /** * A read-only {@link DataMap} for coordinates baked by OpenStreetMap nodes stored in PostgreSQL. */ -public class PostgresCoordinateMap extends DataMap<Long, Coordinate> { +public class PostgresCoordinateMap extends PostgresMap<Long, Coordinate> { private final DataSource dataSource; diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresMap.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresMap.java new file mode 100644 index 00000000..3c1f9f71 --- /dev/null +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresMap.java @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.baremaps.openstreetmap.postgres; + +import com.google.common.collect.Streams; +import java.util.*; + +/** + * An abstract map of data elements backed by a Postgres database. + */ +public abstract class PostgresMap<K, V> implements Map<K, V> { + + /** {@inheritDoc} */ + @Override + public void putAll(Map<? extends K, ? extends V> m) { + m.forEach(this::put); + } + + /** + * Returns the value associated with the specified key or null if the key is not present. + * + * @param keys the keys + * @return the values + */ + public List<V> getAll(List<K> keys) { + return Streams.stream(keys).map(this::get).toList(); + } + + /** {@inheritDoc} */ + @Override + public boolean isEmpty() { + return size() == 0; + } + + /** + * Returns the size of the map as a long. + * + * @return the size of the map + */ + public abstract long sizeAsLong(); + + /** {@inheritDoc} */ + public int size() { + return (int) Math.min(sizeAsLong(), Integer.MAX_VALUE); + } + + /** + * Returns an iterator over the keys of the map. + * + * @return an iterator + */ + protected abstract Iterator<K> keyIterator(); + + /** {@inheritDoc} */ + @Override + public Set<K> keySet() { + return new PostgresMap.KeySet(); + } + + private class KeySet extends AbstractSet<K> { + @Override + public Iterator<K> iterator() { + return keyIterator(); + } + + @Override + public int size() { + return PostgresMap.this.size(); + } + } + + /** + * Returns an iterator over the values of the map. + * + * @return an iterator + */ + protected abstract Iterator<V> valueIterator(); + + /** {@inheritDoc} */ + @Override + public Collection<V> values() { + return new PostgresMap.ValueCollection(); + } + + private class ValueCollection extends AbstractCollection<V> { + @Override + public Iterator<V> iterator() { + return valueIterator(); + } + + @Override + public int size() { + return PostgresMap.this.size(); + } + } + + /** + * Returns an iterator over the entries of the map. + * + * @return an iterator + */ + protected abstract Iterator<Entry<K, V>> entryIterator(); + + /** {@inheritDoc} */ + @Override + public Set<Entry<K, V>> entrySet() { + return new PostgresMap.EntrySet(); + } + + private class EntrySet extends AbstractSet<Entry<K, V>> { + @Override + public Iterator<Entry<K, V>> iterator() { + return entryIterator(); + } + + @Override + public int size() { + return PostgresMap.this.size(); + } + } +} diff --git a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresReferenceMap.java b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresReferenceMap.java index 08b86c6b..2dd4ab68 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresReferenceMap.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresReferenceMap.java @@ -32,7 +32,7 @@ import org.apache.baremaps.database.collection.DataMap; /** * A read-only {@code LongDataMap} for references baked by OpenStreetMap ways stored in Postgres. */ -public class PostgresReferenceMap extends DataMap<Long, List<Long>> { +public class PostgresReferenceMap extends PostgresMap<Long, List<Long>> { private final DataSource dataSource; diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmPbf.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmPbf.java index 22637b42..5800b26b 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmPbf.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmPbf.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; +import java.util.Map; import java.util.StringJoiner; import org.apache.baremaps.database.collection.*; import org.apache.baremaps.openstreetmap.model.Node; @@ -132,8 +133,8 @@ public class ImportOsmPbf implements Task { */ public static void execute( Path path, - DataMap<Long, Coordinate> coordinateMap, - DataMap<Long, List<Long>> referenceMap, + Map<Long, Coordinate> coordinateMap, + Map<Long, List<Long>> referenceMap, HeaderRepository headerRepository, Repository<Long, Node> nodeRepository, Repository<Long, Way> wayRepository, diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOsmDatabase.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOsmDatabase.java index 817efa6d..8ccc2a30 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOsmDatabase.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/UpdateOsmDatabase.java @@ -19,9 +19,9 @@ package org.apache.baremaps.workflow.tasks; import java.io.BufferedInputStream; import java.util.List; +import java.util.Map; import java.util.StringJoiner; import java.util.zip.GZIPInputStream; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.openstreetmap.function.*; import org.apache.baremaps.openstreetmap.model.Header; import org.apache.baremaps.openstreetmap.model.Node; @@ -107,8 +107,9 @@ public class UpdateOsmDatabase implements Task { * @param databaseSrid the SRID * @throws Exception if something went wrong */ - public static void execute(DataMap<Long, Coordinate> coordinateMap, - DataMap<Long, List<Long>> referenceMap, + public static void execute( + Map<Long, Coordinate> coordinateMap, + Map<Long, List<Long>> referenceMap, HeaderRepository headerRepository, Repository<Long, Node> nodeRepository, Repository<Long, Way> wayRepository, Repository<Long, Relation> relationRepository, Integer databaseSrid, diff --git a/baremaps-core/src/test/java/org/apache/baremaps/workflow/tasks/ImportUpdateSampleTest.java b/baremaps-core/src/test/java/org/apache/baremaps/workflow/tasks/ImportUpdateSampleTest.java index 055f7e1a..38df3c91 100644 --- a/baremaps-core/src/test/java/org/apache/baremaps/workflow/tasks/ImportUpdateSampleTest.java +++ b/baremaps-core/src/test/java/org/apache/baremaps/workflow/tasks/ImportUpdateSampleTest.java @@ -24,8 +24,8 @@ import static org.junit.jupiter.api.Assertions.assertNull; import java.nio.file.Files; import java.util.List; +import java.util.Map; import org.apache.baremaps.database.collection.AppendOnlyBuffer; -import org.apache.baremaps.database.collection.DataMap; import org.apache.baremaps.database.collection.IndexedDataMap; import org.apache.baremaps.database.memory.OnHeapMemory; import org.apache.baremaps.database.type.LongListDataType; @@ -58,9 +58,9 @@ class ImportUpdateSampleTest extends PostgresRepositoryTest { PostgresRelationRepository relationRepository = new PostgresRelationRepository(dataSource()); // Initialize the data maps - DataMap<Long, Coordinate> coordinateMap = + Map<Long, Coordinate> coordinateMap = new IndexedDataMap<>(new AppendOnlyBuffer<>(new CoordinateDataType(), new OnHeapMemory())); - DataMap<Long, List<Long>> referenceMap = + Map<Long, List<Long>> referenceMap = new IndexedDataMap<>(new AppendOnlyBuffer<>(new LongListDataType(), new OnHeapMemory())); // Import the sample data
