From 06fe411035438391c3b760e63d2a554a4bb33463 Mon Sep 17 00:00:00 2001 From: Bertil Chapuis Date: Wed, 14 Jun 2023 00:01:16 +0200 Subject: [PATCH] Format code --- .../baremaps/benchmarks/MBTilesBenchmark.java | 85 +++++++++---------- .../baremaps/tilestore/mbtiles/MBTiles.java | 2 +- .../workflow/tasks/ExportVectorTiles.java | 1 + 3 files changed, 44 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 9dd817a9b..b529eb663 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.util.ArrayList; import java.util.Random; import java.util.concurrent.TimeUnit; - import org.apache.baremaps.tilestore.TileCoord; import org.apache.baremaps.tilestore.TileStoreException; import org.apache.baremaps.tilestore.mbtiles.MBTiles; @@ -34,59 +33,59 @@ @Fork(value = 1, warmups = 1) public class MBTilesBenchmark { - public Random random = new Random(0); + public Random random = new Random(0); - @Param({"10", "100", "1000"}) - public int iterations; + @Param({"10", "100", "1000"}) + public int iterations; - private MBTiles mbTiles; + private MBTiles mbTiles; - @Setup - public void setup() throws IOException, TileStoreException { - var sqliteFile = File.createTempFile("baremaps", ".sqlite"); - sqliteFile.deleteOnExit(); - var sqliteDataSource = ExportVectorTiles.createDataSource(sqliteFile.toPath()); - mbTiles = new MBTiles(sqliteDataSource); - mbTiles.initializeDatabase(); - } + @Setup + public void setup() throws IOException, TileStoreException { + var sqliteFile = File.createTempFile("baremaps", ".sqlite"); + sqliteFile.deleteOnExit(); + var sqliteDataSource = ExportVectorTiles.createDataSource(sqliteFile.toPath()); + mbTiles = new MBTiles(sqliteDataSource); + mbTiles.initializeDatabase(); + } - @Benchmark - @BenchmarkMode(Mode.SingleShotTime) - public void writeMBTiles(MBTilesBenchmark benchmark) throws TileStoreException { - for (int i = 0; i < benchmark.iterations; i++) { - var bytes = new byte[1 << 16]; - random.nextBytes(bytes); - mbTiles.put(new TileCoord(0, 0, i), ByteBuffer.wrap(bytes)); - } + @Benchmark + @BenchmarkMode(Mode.SingleShotTime) + public void writeMBTiles(MBTilesBenchmark benchmark) throws TileStoreException { + for (int i = 0; i < benchmark.iterations; i++) { + var bytes = new byte[1 << 16]; + random.nextBytes(bytes); + mbTiles.put(new TileCoord(0, 0, i), ByteBuffer.wrap(bytes)); } + } - @Benchmark - @BenchmarkMode(Mode.SingleShotTime) - public void writeMBTilesBatch(MBTilesBenchmark benchmark) throws TileStoreException { - var coords = new ArrayList(); - var buffers = new ArrayList(); - 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); - mbTiles.put(coords, buffers); - coords.clear(); - buffers.clear(); - } - } + @Benchmark + @BenchmarkMode(Mode.SingleShotTime) + public void writeMBTilesBatch(MBTilesBenchmark benchmark) throws TileStoreException { + var coords = new ArrayList(); + var buffers = new ArrayList(); + 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); mbTiles.put(coords, buffers); coords.clear(); buffers.clear(); + } } + mbTiles.put(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(); - new Runner(opt).run(); - } + public static void main(String[] args) throws RunnerException { + Options opt = + new OptionsBuilder().include(MBTilesBenchmark.class.getSimpleName()).forks(1).build(); + new Runner(opt).run(); + } } diff --git a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTiles.java b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTiles.java index fa1fb9d7c..0344aed55 100644 --- a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTiles.java +++ b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/mbtiles/MBTiles.java @@ -110,7 +110,7 @@ public void put(TileCoord tileCoord, ByteBuffer blob) throws TileStoreException @Override public void put(List tileCoords, List blobs) throws TileStoreException { try (Connection connection = dataSource.getConnection(); - PreparedStatement statement = connection.prepareStatement(INSERT_TILE)) { + PreparedStatement statement = connection.prepareStatement(INSERT_TILE)) { for (int i = 0; i < tileCoords.size(); i++) { TileCoord tileCoord = tileCoords.get(i); ByteBuffer blob = blobs.get(i); 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 435556eae..5cca2bec5 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 @@ -142,6 +142,7 @@ private Map metadata(Tileset tileset) throws JsonProcessingExcep /** * Create a SQLite data source. + * * @param path the path to the SQLite database * @return the SQLite data source */