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,9 +672,13 @@ public class MicrosoftSQLMapStorage extends MapStorage {
} }
try { try {
c = getConnection(); c = getConnection();
boolean done = false;
while (!done) {
// Query tiles for given mapkey // Query tiles for given mapkey
Statement stmt = c.createStatement(); Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + ";"); ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + " LIMIT 100;");
int cnt = 0;
while (rs.next()) { while (rs.next()) {
StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var); StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var);
final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format")); final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
@ -683,11 +687,14 @@ public class MicrosoftSQLMapStorage extends MapStorage {
if(cbBase != null && st.zoom == 0) if(cbBase != null && st.zoom == 0)
cbBase.tileFound(st, encoding); cbBase.tileFound(st, encoding);
st.cleanup(); 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,9 +792,12 @@ public class MySQLMapStorage extends MapStorage {
} }
try { try {
c = getConnection(); c = getConnection();
boolean done = false;
while (!done) {
// Query tiles for given mapkey // Query tiles for given mapkey
Statement stmt = c.createStatement(); Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + ";"); ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + " LIMIT 100;");
int cnt = 0;
while (rs.next()) { while (rs.next()) {
StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var); StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var);
final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format")); final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
@ -803,11 +806,14 @@ public class MySQLMapStorage extends MapStorage {
if(cbBase != null && st.zoom == 0) if(cbBase != null && st.zoom == 0)
cbBase.tileFound(st, encoding); cbBase.tileFound(st, encoding);
st.cleanup(); 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,9 +698,13 @@ public class PostgreSQLMapStorage extends MapStorage {
} }
try { try {
c = getConnection(); c = getConnection();
boolean done = false;
while (!done) {
// Query tiles for given mapkey // Query tiles for given mapkey
Statement stmt = c.createStatement(); Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + ";"); ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM " + tableTiles + " WHERE MapID=" + mapkey + " LIMIT 100;");
int cnt = 0;
while (rs.next()) { while (rs.next()) {
StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var); StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var);
final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format")); final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
@ -709,11 +713,14 @@ public class PostgreSQLMapStorage extends MapStorage {
if(cbBase != null && st.zoom == 0) if(cbBase != null && st.zoom == 0)
cbBase.tileFound(st, encoding); cbBase.tileFound(st, encoding);
st.cleanup(); 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,10 +641,12 @@ public class SQLiteMapStorage extends MapStorage {
} }
try { try {
c = getConnection(); c = getConnection();
boolean done = false;
while (!done) {
// Query tiles for given mapkey // Query tiles for given mapkey
Statement stmt = c.createStatement(); Statement stmt = c.createStatement();
//ResultSet rs = stmt.executeQuery("SELECT x,y,zoom,Format FROM Tiles WHERE MapID=" + mapkey + ";"); ResultSet rs = doExecuteQuery(stmt, "SELECT x,y,zoom,Format FROM Tiles WHERE MapID=" + mapkey + " LIMIT 100;");
ResultSet rs = doExecuteQuery(stmt, "SELECT x,y,zoom,Format FROM Tiles WHERE MapID=" + mapkey + ";"); int cnt = 0;
while (rs.next()) { while (rs.next()) {
StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var); StorageTile st = new StorageTile(world, map, rs.getInt("x"), rs.getInt("y"), rs.getInt("zoom"), var);
final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format")); final MapType.ImageEncoding encoding = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
@ -653,11 +655,14 @@ public class SQLiteMapStorage extends MapStorage {
if(cbBase != null && st.zoom == 0) if(cbBase != null && st.zoom == 0)
cbBase.tileFound(st, encoding); cbBase.tileFound(st, encoding);
st.cleanup(); 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;