From cc1ee9c0810c5b6481c379ffaf6787c24a89026f Mon Sep 17 00:00:00 2001 From: Bertil Chapuis Date: Mon, 16 Sep 2024 16:49:40 +0200 Subject: [PATCH] Fix issues identified when executing the workflow (#894) - DataConversions should always call the wrapped methods - Only one log provider should be included in the project - Use MonotonicPairedDataMap for coordinates and references --- .../baremaps/workflow/WorkflowContext.java | 16 +++++++++++++--- .../data/collection/DataConversions.java | 8 +------- .../data/collection/MonotonicDataMap.java | 1 - pom.xml | 6 ++++++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java index 349f30121..f793c7d04 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/WorkflowContext.java @@ -64,14 +64,14 @@ public DataSource getDataSource(Object database) { } public Map getCoordinateMap() throws IOException { - return DataConversions.asMap(getMemoryAlignedDataMap("coordinates", new LonLatDataType())); + return DataConversions.asMap(getMonotonicPairedDataMap("coordinates", new LonLatDataType())); } public Map> getReferenceMap() throws IOException { return DataConversions.asMap(getMonotonicDataMap("references", new LongListDataType())); } - public DataMap getMemoryAlignedDataMap(String name, FixedSizeDataType dataType) + private DataMap getMemoryAlignedDataMap(String name, FixedSizeDataType dataType) throws IOException { var coordinateDir = Files.createDirectories(cacheDir.resolve(name)); return new MemoryAlignedDataMap<>( @@ -79,7 +79,7 @@ public DataMap getMemoryAlignedDataMap(String name, FixedSizeDataTy new MemoryMappedDirectory(coordinateDir)); } - public DataMap getMonotonicDataMap(String name, DataType dataType) + private DataMap getMonotonicDataMap(String name, DataType dataType) throws IOException { var mapDir = Files.createDirectories(cacheDir.resolve(name)); var keysDir = Files.createDirectories(mapDir.resolve("keys")); @@ -93,6 +93,16 @@ public DataMap getMonotonicDataMap(String name, DataType dataTyp new MemoryMappedDirectory(valuesDir))); } + private DataMap getMonotonicPairedDataMap(String name, + DataType dataType) + throws IOException { + var mapDir = Files.createDirectories(cacheDir.resolve(name)); + return new MonotonicPairedDataMap<>( + new MemoryAlignedDataList<>( + new PairDataType<>(new LongDataType(), new LonLatDataType()), + new MemoryMappedDirectory(Files.createDirectories(mapDir)))); + } + public void cleanCache() throws IOException { FileUtils.deleteRecursively(cacheDir); } diff --git a/baremaps-data/src/main/java/org/apache/baremaps/data/collection/DataConversions.java b/baremaps-data/src/main/java/org/apache/baremaps/data/collection/DataConversions.java index 1211985d5..593f6acd4 100644 --- a/baremaps-data/src/main/java/org/apache/baremaps/data/collection/DataConversions.java +++ b/baremaps-data/src/main/java/org/apache/baremaps/data/collection/DataConversions.java @@ -270,13 +270,7 @@ public V put(K key, V value) { @Override public V get(Object key) { - if (map instanceof MemoryAlignedDataMap) { - return map.get(key); - } else if (map instanceof IndexedDataMap) { - return map.get(key); - } else { - return super.get(key); - } + return map.get(key); } @Override diff --git a/baremaps-data/src/main/java/org/apache/baremaps/data/collection/MonotonicDataMap.java b/baremaps-data/src/main/java/org/apache/baremaps/data/collection/MonotonicDataMap.java index 6a5b44674..25094823b 100644 --- a/baremaps-data/src/main/java/org/apache/baremaps/data/collection/MonotonicDataMap.java +++ b/baremaps-data/src/main/java/org/apache/baremaps/data/collection/MonotonicDataMap.java @@ -149,7 +149,6 @@ public Iterator> entryIterator() { .iterator(); } - /** {@inheritDoc} */ @Override public long size() { diff --git a/pom.xml b/pom.xml index d60471ea2..75f89b46b 100644 --- a/pom.xml +++ b/pom.xml @@ -237,6 +237,12 @@ limitations under the License. mil.nga.geopackage geopackage ${version.lib.geopackage} + + + org.slf4j + slf4j-nop + + net.ripe.ipresource