*/
public void addKV(KeyValue newKV) {
+ KeyValue rmKV = null;
+
// Make sure there are no duplicates
for (KeyValue kv : keyValueUpdateSet) {
if (kv.getKey().equals(newKV.getKey())) {
// Remove key if we are adding a newer version of the same key
- keyValueUpdateSet.remove(kv);
+ rmKV = kv;
break;
}
}
+ // Remove key if we are adding a newer version of the same key
+ if (rmKV != null) {
+ keyValueUpdateSet.remove(rmKV);
+ }
+
// Add the key to the hash set
keyValueUpdateSet.add(newKV);
}