From 6ee2d7d82304e1793724d12398fdae57c32c9df9 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Fri, 8 Aug 2014 00:13:30 -0400 Subject: [PATCH] Do UUID saves in batches. --- .../nossr50/runnables/database/UUIDUpdateAsyncTask.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java index a97f11c25..78a44dd7b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java @@ -18,6 +18,7 @@ import com.gmail.nossr50.util.uuid.UUIDFetcher; public class UUIDUpdateAsyncTask extends BukkitRunnable { private mcMMO plugin; private static final int MAX_LOOKUP = Math.max(HiddenConfig.getInstance().getUUIDConvertAmount(), 100); + private static final int BATCH_SIZE = 5000; private List userNames; private int size; @@ -64,9 +65,13 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { size = userNames.size(); Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis); + if (fetchedUUIDs.size() > BATCH_SIZE) { + mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs); + fetchedUUIDs = new HashMap(); + } } - if (mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) { + if (fetchedUUIDs.size() == 0 || mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) { mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS); plugin.getLogger().info("UUID upgrade completed!"); }