mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-20 11:42:50 +02:00
Improved performance of UserInfoTable#getSavedUUIDs(UUID)
This commit is contained in:
parent
4a2f18d9ee
commit
04f426aca1
|
@ -361,8 +361,34 @@ public class UserInfoTable extends UserIDTable {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO improve performance of this method.
|
||||
public Set<UUID> getSavedUUIDs(UUID serverUUID) throws SQLException {
|
||||
return getSavedUUIDs().get(serverUUID);
|
||||
String usersIDColumn = usersTable + "." + UsersTable.Col.ID;
|
||||
String usersUUIDColumn = usersTable + "." + UsersTable.Col.UUID + " as uuid";
|
||||
String serverIDColumn = serverTable + "." + ServerTable.Col.SERVER_ID;
|
||||
String serverUUIDColumn = serverTable + "." + ServerTable.Col.SERVER_UUID + " as s_uuid";
|
||||
String sql = "SELECT " +
|
||||
usersUUIDColumn + ", " +
|
||||
serverUUIDColumn +
|
||||
" FROM " + tableName +
|
||||
" INNER JOIN " + usersTable + " on " + usersIDColumn + "=" + Col.USER_ID +
|
||||
" INNER JOIN " + serverTable + " on " + serverIDColumn + "=" + Col.SERVER_ID +
|
||||
" WHERE s_uuid=?";
|
||||
|
||||
return query(new QueryStatement<Set<UUID>>(sql, 50000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> processResults(ResultSet set) throws SQLException {
|
||||
Set<UUID> uuids = new HashSet<>();
|
||||
while (set.next()) {
|
||||
UUID uuid = UUID.fromString(set.getString("uuid"));
|
||||
uuids.add(uuid);
|
||||
}
|
||||
return uuids;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user