[AETHER-72] Add bulk update to ConsistentMultimap
Change-Id: I61e9f0c2ed5ab368777c64b6fb4aa2c8dd31d081
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMultimap.java b/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMultimap.java
index c14b187..51f0934 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMultimap.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMultimap.java
@@ -111,11 +111,21 @@
}
@Override
+ public boolean removeAll(Map<K, Collection<? extends V>> mapping) {
+ return complete(asyncMultimap.removeAll(mapping));
+ }
+
+ @Override
public boolean putAll(K key, Collection<? extends V> values) {
return complete(asyncMultimap.putAll(key, values));
}
@Override
+ public boolean putAll(Map<K, Collection<? extends V>> mapping) {
+ return complete(asyncMultimap.putAll(mapping));
+ }
+
+ @Override
public Versioned<Collection<? extends V>> replaceValues(
K key, Collection<V> values) {
return complete(asyncMultimap.replaceValues(key, values));
diff --git a/core/api/src/main/java/org/onosproject/store/service/AsyncConsistentMultimap.java b/core/api/src/main/java/org/onosproject/store/service/AsyncConsistentMultimap.java
index 94943b8..b86845e 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AsyncConsistentMultimap.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AsyncConsistentMultimap.java
@@ -166,6 +166,19 @@
CompletableFuture<Versioned<Collection<? extends V>>> removeAll(K key);
/**
+ * Removes the set of key-value pairs with the specified key and values if they
+ * exist. In implementations that allow duplicates each instance of a key
+ * will remove one matching entry, which one is not defined. Equivalent to
+ * repeated calls to {@code remove()} for each key value pair but more
+ * efficient.
+ *
+ * @param mapping the keys-values to be removed
+ * @return a future whose value will be true if the map changes because of
+ * this call, false otherwise.
+ */
+ CompletableFuture<Boolean> removeAll(Map<K, Collection<? extends V>> mapping);
+
+ /**
* Adds the set of key-value pairs of the specified key with each of the
* values in the iterable if each key-value pair does not already exist,
* if the pair does exist the behavior is implementation specific.
@@ -180,6 +193,18 @@
Collection<? extends V> values);
/**
+ * Adds the set of key-value pairs of the specified mapping with each of
+ * the values in the iterable if each key-value pair does not already exist,
+ * if the pair does exist the behavior is implementation specific.
+ * (Same as repeated puts but with efficiency gains.)
+ *
+ * @param mapping the keys-values to be added
+ * @return a future whose value will be true if any change in the map
+ * results from this call, false otherwise
+ */
+ CompletableFuture<Boolean> putAll(Map<K, Collection<? extends V>> mapping);
+
+ /**
* Stores all the values in values associated with the key specified,
* removes all preexisting values and returns a collection of the removed
* values which may be empty if the entry did not exist.
diff --git a/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimap.java b/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimap.java
index 99045a8..8aabca7 100644
--- a/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimap.java
+++ b/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimap.java
@@ -149,6 +149,18 @@
Versioned<Collection<? extends V>> removeAll(K key);
/**
+ * Removes the set of key-value pairs with the specified key and values if they
+ * exist. In implementations that allow duplicates each instance of a key
+ * will remove one matching entry, which one is not defined. Equivalent to
+ * repeated calls to {@code remove()} for each key value pair but more
+ * efficient.
+ *
+ * @param mapping the keys-values to be removed
+ * @return true if the map changes because of this call, false otherwise.
+ */
+ boolean removeAll(Map<K, Collection<? extends V>> mapping);
+
+ /**
* Adds the set of key-value pairs of the specified key with each of the
* values in the iterable if each key-value pair does not already exist,
* if the pair does exist the behavior is implementation specific.
@@ -162,6 +174,18 @@
boolean putAll(K key, Collection<? extends V> values);
/**
+ * Adds the set of key-value pairs of the specified mapping with each of
+ * the values in the iterable if each key-value pair does not already exist,
+ * if the pair does exist the behavior is implementation specific.
+ * (Same as repeated puts but with efficiency gains.)
+ *
+ * @param mapping the keys-values to be added
+ * @return true if any change in the map results from this call,
+ * false otherwise
+ */
+ boolean putAll(Map<K, Collection<? extends V>> mapping);
+
+ /**
* Stores all the values in values associated with the key specified,
* removes all preexisting values and returns a collection of the removed
* values which may be empty if the entry did not exist.