Use limit on enum tiles (for cleaner behavior on purge for large maps)

This commit is contained in:
Mike Primm 2022-07-24 13:52:49 -05:00
parent ab54919956
commit c80f7adb23
4 changed files with 78 additions and 53 deletions

View File

@ -672,22 +672,29 @@ public class MicrosoftSQLMapStorage extends MapStorage {
} }
try { try {
c = getConnection(); c = getConnection();
// Query tiles for given mapkey boolean done = false;
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + ";"); while (!done) {
while (rs.next()) { // Query tiles for given mapkey
StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var); Statement stmt = c.createStatement();
final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format")); ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + " LIMIT 100;");
if(cb != null) int cnt = 0;
cb.tileFound(st, encoding); while (rs.next()) {
if(cbBase != null && st.zoom == 0) StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var);
cbBase.tileFound(st, encoding); final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
st.cleanup(); if(cb != null)
cb.tileFound(st, encoding);
if(cbBase != null && st.zoom == 0)
cbBase.tileFound(st, encoding);
st.cleanup();
cnt++;
}
rs.close();
stmt.close();
if (cnt < 100) done = true;
} }
if(cbEnd != null) if(cbEnd != null)
cbEnd.searchEnded(); cbEnd.searchEnded();
rs.close();
stmt.close();
} catch (SQLException x) { } catch (SQLException x) {
logSQLException("Tile enum error", x); logSQLException("Tile enum error", x);
err = true; err = true;

View File

@ -792,22 +792,28 @@ public class MySQLMapStorage extends MapStorage {
} }
try { try {
c = getConnection(); c = getConnection();
// Query tiles for given mapkey boolean done = false;
Statement stmt = c.createStatement(); while (!done) {
ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + ";"); // Query tiles for given mapkey
while (rs.next()) { Statement stmt = c.createStatement();
StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var); ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + " LIMIT 100;");
final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format")); int cnt = 0;
if(cb != null) while (rs.next()) {
cb.tileFound(st, encoding); StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var);
if(cbBase != null && st.zoom == 0) final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
cbBase.tileFound(st, encoding); if(cb != null)
st.cleanup(); cb.tileFound(st, encoding);
if(cbBase != null && st.zoom == 0)
cbBase.tileFound(st, encoding);
st.cleanup();
cnt++;
}
rs.close();
stmt.close();
if (cnt < 100) done = true;
} }
if(cbEnd != null) if(cbEnd != null)
cbEnd.searchEnded(); cbEnd.searchEnded();
rs.close();
stmt.close();
} catch (SQLException x) { } catch (SQLException x) {
logSQLException("Tile enum error", x); logSQLException("Tile enum error", x);
err = true; err = true;

View File

@ -698,22 +698,29 @@ public class PostgreSQLMapStorage extends MapStorage {
} }
try { try {
c = getConnection(); c = getConnection();
// Query tiles for given mapkey boolean done = false;
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + ";"); while (!done) {
while (rs.next()) { // Query tiles for given mapkey
StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var); Statement stmt = c.createStatement();
final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format")); ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + " LIMIT 100;");
if(cb != null) int cnt = 0;
cb.tileFound(st, encoding); while (rs.next()) {
if(cbBase != null && st.zoom == 0) StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var);
cbBase.tileFound(st, encoding); final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
st.cleanup(); if(cb != null)
cb.tileFound(st, encoding);
if(cbBase != null && st.zoom == 0)
cbBase.tileFound(st, encoding);
st.cleanup();
cnt++;
}
rs.close();
stmt.close();
if (cnt < 100) done = true;
} }
if(cbEnd != null) if(cbEnd != null)
cbEnd.searchEnded(); cbEnd.searchEnded();
rs.close();
stmt.close();
} catch (SQLException x) { } catch (SQLException x) {
logSQLException("Tile enum error", x); logSQLException("Tile enum error", x);
err = true; err = true;

View File

@ -641,23 +641,28 @@ public class SQLiteMapStorage extends MapStorage {
} }
try { try {
c = getConnection(); c = getConnection();
// Query tiles for given mapkey boolean done = false;
Statement stmt = c.createStatement(); while (!done) {
//ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM Tiles WHERE MapID=" + mapkey + ";"); // Query tiles for given mapkey
ResultSet rs = doExecuteQuery(stmt, "SELECT x,y,zoom,Format FROM Tiles WHERE MapID=" + mapkey + ";"); Statement stmt = c.createStatement();
while (rs.next()) { ResultSet rs = doExecuteQuery(stmt, "SELECT x,y,zoom,Format FROM Tiles WHERE MapID=" + mapkey + " LIMIT 100;");
StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var); int cnt = 0;
final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format")); while (rs.next()) {
if(cb != null) StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var);
cb.tileFound(st, encoding); final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
if(cbBase != null && st.zoom == 0) if(cb != null)
cbBase.tileFound(st, encoding); cb.tileFound(st, encoding);
st.cleanup(); if(cbBase != null && st.zoom == 0)
cbBase.tileFound(st, encoding);
st.cleanup();
cnt++;
}
rs.close();
stmt.close();
if (cnt < 100) done = true;
} }
if(cbEnd != null) if(cbEnd != null)
cbEnd.searchEnded(); cbEnd.searchEnded();
rs.close();
stmt.close();
} catch (SQLException x) { } catch (SQLException x) {
logSQLException("Tile enum error", x); logSQLException("Tile enum error", x);
err = true; err = true;