Skip to content

Commit

Permalink
Fix minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bchapuis committed Oct 24, 2023
1 parent 97063ff commit b7e9741
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@
package org.apache.baremaps.tilestore.postgres;


import org.apache.baremaps.tilestore.TileCoord;
import org.apache.baremaps.tilestore.TileStore;
import org.apache.baremaps.tilestore.TileStoreException;
import org.apache.baremaps.vectortile.tileset.Tileset;
import org.apache.baremaps.vectortile.tileset.TilesetQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.sql.DataSource;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
Expand All @@ -35,6 +26,14 @@
import java.sql.Statement;
import java.util.Map;
import java.util.zip.GZIPOutputStream;
import javax.sql.DataSource;
import org.apache.baremaps.tilestore.TileCoord;
import org.apache.baremaps.tilestore.TileStore;
import org.apache.baremaps.tilestore.TileStoreException;
import org.apache.baremaps.vectortile.tileset.Tileset;
import org.apache.baremaps.vectortile.tileset.TilesetQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A read-only {@code TileStore} implementation that uses the PostgreSQL to generate vector tiles.
Expand Down Expand Up @@ -90,7 +89,7 @@ public String withQuery(TileCoord tileCoord) {

for (int j = 0; j < layerQueries.size(); j++) {
if (j != 0) {
sqlBuilder.append("\n UNION \n");
sqlBuilder.append("UNION\n");
}
var layerQuery = layerQueries.get(j).getSql().replace(";", "");
sqlBuilder.append(String.format("""
Expand Down Expand Up @@ -121,12 +120,12 @@ public ByteBuffer read(TileCoord tileCoord) throws TileStoreException {
long start = System.currentTimeMillis();

try (Connection connection = datasource.getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query)) {
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query)) {

int length = 0;
try (ByteArrayOutputStream data = new ByteArrayOutputStream();
OutputStream gzip = new GZIPOutputStream(data)) {
OutputStream gzip = new GZIPOutputStream(data)) {

while (resultSet.next()) {
byte[] bytes = resultSet.getBytes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@


import com.google.common.io.Resources;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
Expand All @@ -29,9 +31,6 @@
import java.sql.SQLException;
import java.sql.Statement;
import javax.sql.DataSource;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.sqlite.SQLiteConfig;
import org.sqlite.SQLiteConfig.JournalMode;
import org.sqlite.SQLiteConfig.LockingMode;
Expand Down Expand Up @@ -64,11 +63,11 @@ public static DataSource createDataSource(Path path, boolean readOnly) {
sqliteDataSource.setConfig(sqliteConfig);
sqliteDataSource.setUrl("jdbc:sqlite:" + path.toAbsolutePath());

var hikariConfig = new HikariConfig();
hikariConfig.setDataSource(sqliteDataSource);
hikariConfig.setMaximumPoolSize(readOnly ? Runtime.getRuntime().availableProcessors() : 1);
var hikariConfig = new HikariConfig();
hikariConfig.setDataSource(sqliteDataSource);
hikariConfig.setMaximumPoolSize(readOnly ? Runtime.getRuntime().availableProcessors() : 1);

return new HikariDataSource(hikariConfig);
return new HikariDataSource(hikariConfig);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public void execute(WorkflowContext context) throws Exception {
var count = TileCoord.count(envelope, tileset.getMinzoom(), tileset.getMaxzoom());
var start = System.currentTimeMillis();


var tileCoordIterator =
TileCoord.iterator(envelope, tileset.getMinzoom(), tileset.getMaxzoom());
var tileCoordStream =
Expand Down

0 comments on commit b7e9741

Please sign in to comment.