Skip to content

Commit

Permalink
Fix issues identified when executing the workflow (#894)
Browse files Browse the repository at this point in the history
- DataConversions should always call the wrapped methods
- Only one log provider should be included in the project
- Use MonotonicPairedDataMap for coordinates and references
  • Loading branch information
bchapuis committed Sep 16, 2024
1 parent 7502fb1 commit cc1ee9c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,22 @@ public DataSource getDataSource(Object database) {
}

public Map<Long, Coordinate> getCoordinateMap() throws IOException {
return DataConversions.asMap(getMemoryAlignedDataMap("coordinates", new LonLatDataType()));
return DataConversions.asMap(getMonotonicPairedDataMap("coordinates", new LonLatDataType()));
}

public Map<Long, List<Long>> getReferenceMap() throws IOException {
return DataConversions.asMap(getMonotonicDataMap("references", new LongListDataType()));
}

public <T> DataMap<Long, T> getMemoryAlignedDataMap(String name, FixedSizeDataType<T> dataType)
private <T> DataMap<Long, T> getMemoryAlignedDataMap(String name, FixedSizeDataType<T> dataType)
throws IOException {
var coordinateDir = Files.createDirectories(cacheDir.resolve(name));
return new MemoryAlignedDataMap<>(
dataType,
new MemoryMappedDirectory(coordinateDir));
}

public <T> DataMap<Long, T> getMonotonicDataMap(String name, DataType<T> dataType)
private <T> DataMap<Long, T> getMonotonicDataMap(String name, DataType<T> dataType)
throws IOException {
var mapDir = Files.createDirectories(cacheDir.resolve(name));
var keysDir = Files.createDirectories(mapDir.resolve("keys"));
Expand All @@ -93,6 +93,16 @@ public <T> DataMap<Long, T> getMonotonicDataMap(String name, DataType<T> dataTyp
new MemoryMappedDirectory(valuesDir)));
}

private DataMap<Long, Coordinate> getMonotonicPairedDataMap(String name,
DataType<Coordinate> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public Iterator<Entry<Long, E>> entryIterator() {
.iterator();
}


/** {@inheritDoc} */
@Override
public long size() {
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ limitations under the License.
<groupId>mil.nga.geopackage</groupId>
<artifactId>geopackage</artifactId>
<version>${version.lib.geopackage}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.ripe.ipresource</groupId>
Expand Down

0 comments on commit cc1ee9c

Please sign in to comment.