[AETHER-72] Add bulk update to ConsistentMultimap
Change-Id: I61e9f0c2ed5ab368777c64b6fb4aa2c8dd31d081
diff --git a/core/api/src/test/java/org/onosproject/store/service/TestConsistentMultimap.java b/core/api/src/test/java/org/onosproject/store/service/TestConsistentMultimap.java
index 08be2e4..f70d186 100644
--- a/core/api/src/test/java/org/onosproject/store/service/TestConsistentMultimap.java
+++ b/core/api/src/test/java/org/onosproject/store/service/TestConsistentMultimap.java
@@ -24,6 +24,7 @@
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
/**
* Implementation to test ConsistentMultimap. Very limited.
@@ -103,11 +104,42 @@
}
@Override
+ public boolean removeAll(Map<K, Collection<? extends V>> mapping) {
+ // Semantic is that any change in the map should return true
+ boolean result = false;
+ for (Map.Entry<K, Collection<? extends V>> entry : mapping.entrySet()) {
+ Collection<? extends Versioned<V>> versionedValues = entry.getValue().stream()
+ .map(this::version)
+ .collect(Collectors.toList());
+ for (Versioned<V> value : versionedValues) {
+ if (innermap.remove(entry.getKey(), value)) {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
public boolean putAll(K key, Collection<? extends V> values) {
return false;
}
@Override
+ public boolean putAll(Map<K, Collection<? extends V>> mapping) {
+ // Semantic is that any change in the map should return true
+ boolean result = false;
+ for (Map.Entry<K, Collection<? extends V>> entry : mapping.entrySet()) {
+ Collection<? extends Versioned<V>> versionedValues = entry.getValue().stream()
+ .map(this::version).collect(Collectors.toList());
+ if (innermap.putAll(entry.getKey(), versionedValues)) {
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ @Override
public Versioned<Collection<? extends V>> replaceValues(K key, Collection<V> values) {
return null;
}