Impelemted it for SQL style storage

This commit is contained in:
BrainStone 2021-07-20 23:18:04 +02:00
parent 476aa0c133
commit ed0e5534fd
No known key found for this signature in database
GPG Key ID: 66CCC234C2CEB306
4 changed files with 12 additions and 12 deletions

View File

@ -145,7 +145,7 @@ public class MariaDBMapStorage extends MapStorage {
}
@Override
public boolean write(long hash, BufferOutputStream encImage) {
public boolean write(long hash, BufferOutputStream encImage, long timestamp) {
if (mapkey == null) return false;
Connection c = null;
boolean err = false;
@ -166,7 +166,7 @@ public class MariaDBMapStorage extends MapStorage {
else if (exists) {
stmt = c.prepareStatement("UPDATE " + tableTiles + " SET HashCode=?, LastUpdate=?, Format=?, Image=? WHERE MapID=? AND x=? and y=? AND zoom=?;");
stmt.setLong(1, hash);
stmt.setLong(2, System.currentTimeMillis());
stmt.setLong(2, timestamp);
stmt.setInt(3, map.getImageFormat().getEncoding().ordinal());
stmt.setBinaryStream(4, new BufferInputStream(encImage.buf, encImage.len), encImage.len);
stmt.setInt(5, mapkey);
@ -181,7 +181,7 @@ public class MariaDBMapStorage extends MapStorage {
stmt.setInt(3, y);
stmt.setInt(4, zoom);
stmt.setLong(5, hash);
stmt.setLong(6, System.currentTimeMillis());
stmt.setLong(6, timestamp);
stmt.setInt(7, map.getImageFormat().getEncoding().ordinal());
stmt.setBinaryStream(8, new BufferInputStream(encImage.buf, encImage.len), encImage.len);
}

View File

@ -146,7 +146,7 @@ public class MySQLMapStorage extends MapStorage {
}
@Override
public boolean write(long hash, BufferOutputStream encImage) {
public boolean write(long hash, BufferOutputStream encImage, long timestamp) {
if (mapkey == null) return false;
Connection c = null;
boolean err = false;
@ -167,7 +167,7 @@ public class MySQLMapStorage extends MapStorage {
else if (exists) {
stmt = c.prepareStatement("UPDATE " + tableTiles + " SET HashCode=?, LastUpdate=?, Format=?, Image=? WHERE MapID=? AND x=? and y=? AND zoom=?;");
stmt.setLong(1, hash);
stmt.setLong(2, System.currentTimeMillis());
stmt.setLong(2, timestamp);
stmt.setInt(3, map.getImageFormat().getEncoding().ordinal());
stmt.setBinaryStream(4, new BufferInputStream(encImage.buf, encImage.len), encImage.len);
stmt.setInt(5, mapkey);
@ -182,7 +182,7 @@ public class MySQLMapStorage extends MapStorage {
stmt.setInt(3, y);
stmt.setInt(4, zoom);
stmt.setLong(5, hash);
stmt.setLong(6, System.currentTimeMillis());
stmt.setLong(6, timestamp);
stmt.setInt(7, map.getImageFormat().getEncoding().ordinal());
stmt.setBinaryStream(8, new BufferInputStream(encImage.buf, encImage.len), encImage.len);
}

View File

@ -149,7 +149,7 @@ public class PostgreSQLMapStorage extends MapStorage {
}
@Override
public boolean write(long hash, BufferOutputStream encImage) {
public boolean write(long hash, BufferOutputStream encImage, long timestamp) {
if (mapkey == null) return false;
Connection c = null;
boolean err = false;
@ -170,7 +170,7 @@ public class PostgreSQLMapStorage extends MapStorage {
else if (exists) {
stmt = c.prepareStatement("UPDATE " + tableTiles + " SET HashCode=?, LastUpdate=?, Format=?, Image=? WHERE MapID=? AND x=? and y=? AND zoom=?;");
stmt.setLong(1, hash);
stmt.setLong(2, System.currentTimeMillis());
stmt.setLong(2, timestamp);
stmt.setInt(3, map.getImageFormat().getEncoding().ordinal());
stmt.setBinaryStream(4, new BufferInputStream(encImage.buf, encImage.len), encImage.len);
stmt.setInt(5, mapkey);
@ -185,7 +185,7 @@ public class PostgreSQLMapStorage extends MapStorage {
stmt.setInt(3, y);
stmt.setInt(4, zoom);
stmt.setLong(5, hash);
stmt.setLong(6, System.currentTimeMillis());
stmt.setLong(6, timestamp);
stmt.setInt(7, map.getImageFormat().getEncoding().ordinal());
stmt.setBinaryStream(8, new BufferInputStream(encImage.buf, encImage.len), encImage.len);
}

View File

@ -139,7 +139,7 @@ public class SQLiteMapStorage extends MapStorage {
}
@Override
public boolean write(long hash, BufferOutputStream encImage) {
public boolean write(long hash, BufferOutputStream encImage, long timestamp) {
if (mapkey == null) return false;
Connection c = null;
boolean err = false;
@ -160,7 +160,7 @@ public class SQLiteMapStorage extends MapStorage {
else if (exists) {
stmt = c.prepareStatement("UPDATE Tiles SET HashCode=?, LastUpdate=?, Format=?, Image=?, ImageLen=? WHERE MapID=? AND x=? and y=? AND zoom=?;");
stmt.setLong(1, hash);
stmt.setLong(2, System.currentTimeMillis());
stmt.setLong(2, timestamp);
stmt.setInt(3, map.getImageFormat().getEncoding().ordinal());
stmt.setBytes(4, encImage.buf);
stmt.setInt(5, encImage.len);
@ -176,7 +176,7 @@ public class SQLiteMapStorage extends MapStorage {
stmt.setInt(3, y);
stmt.setInt(4, zoom);
stmt.setLong(5, hash);
stmt.setLong(6, System.currentTimeMillis());
stmt.setLong(6, timestamp);
stmt.setInt(7, map.getImageFormat().getEncoding().ordinal());
stmt.setBytes(8, encImage.buf);
stmt.setInt(9, encImage.len);