Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void updateProfiles(HashSet<Profile[]> profiles, String playerfield, String uuidfield, boolean remove) {
- DBCollection collection = mongo.getDB(db).getCollection(this.collection);
- int i = 0;
- long lastSleep = System.currentTimeMillis();
- for (Profile[] profileBulk : profiles) {
- for(Profile profile : profileBulk) {
- BasicDBObject query = new BasicDBObject();
- query.put(playerfield, profile.getName());
- BasicDBObject updateObj = new BasicDBObject();
- updateObj.put("$set", new BasicDBObject(uuidfield, profile.getId()));
- if(remove)
- updateObj.put("$unset", new BasicDBObject(playerfield, ""));
- collection.update(query, updateObj, false, true);
- System.out.println(i);
- i++;
- if(i % 1000 == 0) {
- try {
- TimeUnit.MILLISECONDS.sleep(100 - System.currentTimeMillis() + lastSleep);
- } catch (InterruptedException ex) {
- Logger.getLogger(DatabaseTool.class.getName()).log(Level.SEVERE, null, ex);
- }
- lastSleep = System.currentTimeMillis();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement