This is an automated email from the ASF dual-hosted git repository. bchapuis pushed a commit to branch mbtiles-perf in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
commit c793110fc96dd36da8aa0bcbe5bd011bda23114b Author: Bertil Chapuis <[email protected]> AuthorDate: Tue Aug 22 17:18:10 2023 +0200 Remove batch operation in TileStore --- .../baremaps/benchmarks/MBTilesBenchmark.java | 23 ---------------------- .../org/apache/baremaps/tilestore/TileStore.java | 17 ---------------- .../baremaps/tilestore/mbtiles/MBTilesStore.java | 1 - .../org/apache/baremaps/utils/SqliteUtils.java | 3 +-- .../baremaps/workflow/tasks/ExportVectorTiles.java | 2 +- 5 files changed, 2 insertions(+), 44 deletions(-) diff --git a/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/MBTilesBenchmark.java b/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/MBTilesBenchmark.java index 8d170729..18435fb3 100644 --- a/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/MBTilesBenchmark.java +++ b/baremaps-benchmark/src/main/java/org/apache/baremaps/benchmarks/MBTilesBenchmark.java @@ -18,7 +18,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.SecureRandom; -import java.util.ArrayList; import java.util.concurrent.TimeUnit; import org.apache.baremaps.tilestore.TileCoord; import org.apache.baremaps.tilestore.TileStoreException; @@ -66,28 +65,6 @@ public class MBTilesBenchmark { } } - @Benchmark - @BenchmarkMode(Mode.SingleShotTime) - public void writeMBTilesBatch(MBTilesBenchmark benchmark) throws TileStoreException { - var coords = new ArrayList<TileCoord>(); - var buffers = new ArrayList<ByteBuffer>(); - for (int i = 0; i < benchmark.iterations; i++) { - var bytes = new byte[1 << 16]; - random.nextBytes(bytes); - coords.add(new TileCoord(0, 0, i)); - buffers.add(ByteBuffer.wrap(bytes)); - if (coords.size() == 100) { - random.nextBytes(bytes); - mbTilesStore.write(coords, buffers); - coords.clear(); - buffers.clear(); - } - } - mbTilesStore.write(coords, buffers); - coords.clear(); - buffers.clear(); - } - public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder().include(MBTilesBenchmark.class.getSimpleName()).forks(1).build(); diff --git a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/TileStore.java b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/TileStore.java index 44681044..c7288383 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/TileStore.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/TileStore.java @@ -15,8 +15,6 @@ package org.apache.baremaps.tilestore; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; /** Represents a store for tiles. */ public interface TileStore { @@ -30,21 +28,6 @@ public interface TileStore { */ ByteBuffer read(TileCoord tileCoord) throws TileStoreException; - /** - * Reads the content of several tiles. - * - * @param tileCoords the tile coordinates - * @return the content of the tiles - * @throws TileStoreException - */ - default List<ByteBuffer> read(List<TileCoord> tileCoords) throws TileStoreException { - var blobs = new ArrayList<ByteBuffer>(tileCoords.size()); - for (var tileCoord : tileCoords) { - blobs.add(read(tileCoord)); - } - return blobs; - } - /** * Writes the content of a tile. * diff --git a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStore.java b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStore.java index 7e211dbf..a5cb03e0 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStore.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTilesStore.java @@ -22,7 +22,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.HashMap; -import java.util.List; import java.util.Map; import javax.sql.DataSource; import org.apache.baremaps.tilestore.TileCoord; diff --git a/baremaps-core/src/main/java/org/apache/baremaps/utils/SqliteUtils.java b/baremaps-core/src/main/java/org/apache/baremaps/utils/SqliteUtils.java index 468cb95a..d2403146 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/utils/SqliteUtils.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/utils/SqliteUtils.java @@ -25,6 +25,7 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; +import javax.sql.DataSource; import org.sqlite.SQLiteConfig; import org.sqlite.SQLiteConfig.JournalMode; import org.sqlite.SQLiteConfig.LockingMode; @@ -32,8 +33,6 @@ import org.sqlite.SQLiteConfig.SynchronousMode; import org.sqlite.SQLiteConfig.TempStore; import org.sqlite.SQLiteDataSource; -import javax.sql.DataSource; - /** A helper class for creating executing sql scripts onto a SQLite database */ public final class SqliteUtils { diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java index ab2c3684..8b5f5a84 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java @@ -75,7 +75,7 @@ public record ExportVectorTiles( .peek(new ProgressLogger<>(count, 5000)); StreamUtils.batch(stream, Runtime.getRuntime().availableProcessors() * 2) - .forEach(new TileChannel(sourceTileStore, targetTileStore)); + .forEach(new TileChannel(sourceTileStore, targetTileStore)); } private TileStore sourceTileStore(Tileset tileset, DataSource datasource) {
