mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-30 14:13:38 +01:00
Fix offset/limit on enums
This commit is contained in:
parent
c80f7adb23
commit
8beba92f8e
@ -311,32 +311,6 @@ public class MapManager {
|
|||||||
rendertype = RENDERTYPE_FULLRENDER;
|
rendertype = RENDERTYPE_FULLRENDER;
|
||||||
}
|
}
|
||||||
this.resume = resume;
|
this.resume = resume;
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
|
|
||||||
if (resume) { // if resume render
|
|
||||||
final MapStorage ms = world.getMapStorage();
|
|
||||||
ms.enumMapBaseTiles(world, map, new MapStorageBaseTileEnumCB() {
|
|
||||||
@Override
|
|
||||||
public void tileFound(MapStorageTile tile, MapType.ImageEncoding enc) {
|
|
||||||
String tileId = String.format("%s_%s_%d_%d", tile.world.getName(), tile.map.getName(), tile.x, tile.y);
|
|
||||||
//sender.sendMessage("Tile found: " + tileId);
|
|
||||||
storedTileIds.add(tileId);
|
|
||||||
}
|
|
||||||
}, new MapStorageTileSearchEndCB() {
|
|
||||||
@Override
|
|
||||||
public void searchEnded() {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
latch.await(10, TimeUnit.SECONDS);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
sender.sendMessage(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Full world, all maps render, with optional render radius */
|
/* Full world, all maps render, with optional render radius */
|
||||||
@ -528,6 +502,27 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// If doing resume, load existing tile IDs here (constructor was stupid, and caused timeouts for non-trivial maps - need to check PRs better....
|
||||||
|
if (resume) { // if resume render
|
||||||
|
sendMessage(String.format("Scanning map to find existing tiles for resume..."));
|
||||||
|
final MapStorage ms = world.getMapStorage();
|
||||||
|
ms.enumMapBaseTiles(world, map, new MapStorageBaseTileEnumCB() {
|
||||||
|
@Override
|
||||||
|
public void tileFound(MapStorageTile tile, MapType.ImageEncoding enc) {
|
||||||
|
String tileId = String.format("%s_%s_%d_%d", tile.world.getName(), tile.map.getName(), tile.x, tile.y);
|
||||||
|
//sender.sendMessage("Tile found: " + tileId);
|
||||||
|
storedTileIds.add(tileId);
|
||||||
|
}
|
||||||
|
}, new MapStorageTileSearchEndCB() {
|
||||||
|
@Override
|
||||||
|
public void searchEnded() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sendMessage(String.format("Scan complete - starting render"));
|
||||||
|
resume = false; // Only due on first run
|
||||||
|
}
|
||||||
|
|
||||||
if(tile0 == null) { /* Not single tile render */
|
if(tile0 == null) { /* Not single tile render */
|
||||||
if (saverestorepending && world.isLoaded() && (savependingperiod > 0) && ((lastPendingSaveTS + (1000 *savependingperiod)) < System.currentTimeMillis())) {
|
if (saverestorepending && world.isLoaded() && (savependingperiod > 0) && ((lastPendingSaveTS + (1000 *savependingperiod)) < System.currentTimeMillis())) {
|
||||||
savePending(this.world, true); // Save the pending data for the given world
|
savePending(this.world, true); // Save the pending data for the given world
|
||||||
|
@ -673,11 +673,13 @@ public class MicrosoftSQLMapStorage extends MapStorage {
|
|||||||
try {
|
try {
|
||||||
c = getConnection();
|
c = getConnection();
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
int offset = 0;
|
||||||
|
int limit = 100;
|
||||||
|
|
||||||
while (!done) {
|
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 + " LIMIT 100;");
|
ResultSet rs = stmt.executeQuery(String.format("SELECT x,y,zoom,Format FROM %s WHERE MapID=%d OFFSET %d LIMIT %d;", tableTiles, mapkey, offset, limit));
|
||||||
int cnt = 0;
|
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);
|
||||||
@ -691,7 +693,8 @@ public class MicrosoftSQLMapStorage extends MapStorage {
|
|||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
if (cnt < 100) done = true;
|
if (cnt < limit) done = true;
|
||||||
|
offset += cnt;
|
||||||
}
|
}
|
||||||
if(cbEnd != null)
|
if(cbEnd != null)
|
||||||
cbEnd.searchEnded();
|
cbEnd.searchEnded();
|
||||||
|
@ -793,10 +793,12 @@ public class MySQLMapStorage extends MapStorage {
|
|||||||
try {
|
try {
|
||||||
c = getConnection();
|
c = getConnection();
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
int limit = 100;
|
||||||
|
int offset = 0;
|
||||||
while (!done) {
|
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 + " LIMIT 100;");
|
ResultSet rs = stmt.executeQuery(String.format("SELECT x,y,zoom,Format FROM %s WHERE MapID=%d OFFSET %d LIMIT %d;", tableTiles, mapkey, offset, limit));
|
||||||
int cnt = 0;
|
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);
|
||||||
@ -810,7 +812,8 @@ public class MySQLMapStorage extends MapStorage {
|
|||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
if (cnt < 100) done = true;
|
if (cnt < limit) done = true;
|
||||||
|
offset += cnt;
|
||||||
}
|
}
|
||||||
if(cbEnd != null)
|
if(cbEnd != null)
|
||||||
cbEnd.searchEnded();
|
cbEnd.searchEnded();
|
||||||
|
@ -699,11 +699,12 @@ public class PostgreSQLMapStorage extends MapStorage {
|
|||||||
try {
|
try {
|
||||||
c = getConnection();
|
c = getConnection();
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
int offset = 0;
|
||||||
|
int limit = 100;
|
||||||
while (!done) {
|
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 + " LIMIT 100;");
|
ResultSet rs = stmt.executeQuery(String.format("SELECT x,y,zoom,Format FROM %s WHERE MapID=%d OFFSET %d LIMIT %d;", tableTiles, mapKey, offset, limit));
|
||||||
int cnt = 0;
|
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);
|
||||||
@ -717,7 +718,8 @@ public class PostgreSQLMapStorage extends MapStorage {
|
|||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
if (cnt < 100) done = true;
|
if (cnt < limit) done = true;
|
||||||
|
offset += cnt;
|
||||||
}
|
}
|
||||||
if(cbEnd != null)
|
if(cbEnd != null)
|
||||||
cbEnd.searchEnded();
|
cbEnd.searchEnded();
|
||||||
|
@ -640,12 +640,14 @@ public class SQLiteMapStorage extends MapStorage {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
c = getConnection();
|
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
int offset = 0;
|
||||||
|
int limit = 100;
|
||||||
while (!done) {
|
while (!done) {
|
||||||
|
c = getConnection(); // Do inside loop - single threaded sqlite will have issues otherwise....
|
||||||
// Query tiles for given mapkey
|
// Query tiles for given mapkey
|
||||||
Statement stmt = c.createStatement();
|
Statement stmt = c.createStatement();
|
||||||
ResultSet rs = doExecuteQuery(stmt, "SELECT x,y,zoom,Format FROM Tiles WHERE MapID=" + mapkey + " LIMIT 100;");
|
ResultSet rs = doExecuteQuery(stmt, String.format("SELECT x,y,zoom,Format FROM Tiles WHERE MapID=%d OFFSET %d LIMIT %d", mapkey, offset, limit));
|
||||||
int cnt = 0;
|
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);
|
||||||
@ -659,7 +661,10 @@ public class SQLiteMapStorage extends MapStorage {
|
|||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
if (cnt < 100) done = true;
|
if (cnt < limit) done = true;
|
||||||
|
offset += cnt;
|
||||||
|
releaseConnection(c, err);
|
||||||
|
c = null;
|
||||||
}
|
}
|
||||||
if(cbEnd != null)
|
if(cbEnd != null)
|
||||||
cbEnd.searchEnded();
|
cbEnd.searchEnded();
|
||||||
@ -1055,4 +1060,11 @@ public class SQLiteMapStorage extends MapStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void logSQLException(String opmsg, SQLException x) {
|
||||||
|
// Ignore interrupted
|
||||||
|
if (x.getMessage().equals("Interrupted")) return;
|
||||||
|
|
||||||
|
super.logSQLException(opmsg, x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user