Skip to content

Commit

Permalink
Minor clean-ups: replace new HashSet + add with copy constructor and …
Browse files Browse the repository at this point in the history
…inline it variable.
  • Loading branch information
ijuma committed Apr 5, 2009
1 parent 8c08e26 commit b8acff0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/java/voldemort/store/routed/ReadRepairer.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;


Expand Down Expand Up @@ -104,8 +103,7 @@ public List<NodeValue<K, V>> getRepairs(List<NodeValue<K, V>> nodeValues) {
for(Integer id: obsolete) { for(Integer id: obsolete) {
// repair all obsolete nodes // repair all obsolete nodes
for(Version v: concurrents.keySet()) { for(Version v: concurrents.keySet()) {
Iterator<NodeValue<K, V>> it = concurrents.get(v).iterator(); NodeValue<K, V> concurrent = concurrents.get(v).iterator().next();
NodeValue<K, V> concurrent = it.next();
NodeValue<K, V> repair = new NodeValue<K, V>(id, NodeValue<K, V> repair = new NodeValue<K, V>(id,
concurrent.getKey(), concurrent.getKey(),
concurrent.getVersioned()); concurrent.getVersioned());
Expand All @@ -117,9 +115,7 @@ public List<NodeValue<K, V>> getRepairs(List<NodeValue<K, V>> nodeValues) {
// if there are more then one concurrent versions on different // if there are more then one concurrent versions on different
// nodes, // nodes,
// we should repair so all have the same set of values // we should repair so all have the same set of values
HashSet<NodeValue<K, V>> existing = new HashSet<NodeValue<K, V>>(); Set<NodeValue<K, V>> existing = new HashSet<NodeValue<K, V>>(repairs);
for(NodeValue<K, V> value: repairs)
existing.add(value);
for(NodeValue<K, V> entry1: concurrents.values()) { for(NodeValue<K, V> entry1: concurrents.values()) {
for(NodeValue<K, V> entry2: concurrents.values()) { for(NodeValue<K, V> entry2: concurrents.values()) {
if(!entry1.getVersion().equals(entry2.getVersion())) { if(!entry1.getVersion().equals(entry2.getVersion())) {
Expand Down

0 comments on commit b8acff0

Please sign in to comment.