package com.rackspacecloud.blueflood.dw.ingest;

import com.rackspacecloud.blueflood.service.ScheduleContext;

import java.util.HashMap;
import java.util.Map;

public class ShardUpdates {
    private Map<Integer, Long> updates = new HashMap<Integer, Long>();
    
    public void update(long when, int shard) {
        Long current = updates.get(shard);
        if (current == null) {
            updates.put(shard, when);
        } else {
            if (when > current) {
                updates.put(shard, when);
            }
        }
    }
    
    public void flush(ScheduleContext context) {
        for (Map.Entry<Integer, Long> entry : updates.entrySet()) {
            context.update(entry.getValue(), entry.getKey());
        }
    }
}

@@ -157,387 +157,371 @@
 p;%0A%0A
-public class ShardUpdates %7B%0A    private Map%3CInteger, Long%3E updates = new HashMap%3CInteger, Long%3E();%0A    %0A    public void update(long when, int shard) %7B%0A        Long current = updates.get(shard);%0A        if (current == null) %7B%0A            updates.put(shard, when);%0A        %7D else %7B%0A            if (when %3E current) %7B%0A                updates.put(shard, when);%0A            %7D%0A        %7D
+/**%0A * Reduce contention on the locks in a ScheduleContext object by keeping all of its updates until they can all be%0A * flushed at once.%0A * %0A * This class is NOT threadsafe.%0A */%0Apublic class ShardUpdates %7B%0A    private Map%3CInteger, Long%3E updates = new HashMap%3CInteger, Long%3E();%0A    %0A    public void update(long when, int shard) %7B%0A        updates.put(shard, when);
 %0A   

Remove the latest-time-wins strategy employed by `ShardUpdates`. Also document its concurrency properties.