public interface AsyncConsistentMultimap<K,V> extends DistributedPrimitive, AsyncIterable<Map.Entry<K,V>>
DistributedPrimitive.Status, DistributedPrimitive.Type
DEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS
Modifier and Type | Method and Description |
---|---|
default CompletableFuture<Void> |
addListener(MultimapEventListener<K,V> listener)
Registers the specified listener to be notified whenever the map is updated.
|
CompletableFuture<Void> |
addListener(MultimapEventListener<K,V> listener,
Executor executor)
Registers the specified listener to be notified whenever the map is updated.
|
CompletableFuture<Map<K,Collection<V>>> |
asMap()
Returns a map of keys to collections of values that reflect the set of
key-value pairs contained in the multimap, where the key value pairs
would be the key paired with each of the values in the collection.
|
default ConsistentMultimap<K,V> |
asMultimap()
Returns a
ConsistentMultimap instance that wraps this map. |
default ConsistentMultimap<K,V> |
asMultimap(long timeoutMillis)
Returns a
ConsistentMultimap instance that wraps this map. |
CompletableFuture<Void> |
clear()
Removes all key-value pairs, after which it will be empty.
|
CompletableFuture<Boolean> |
containsEntry(K key,
V value)
Returns true if this map contains at least one key-value pair with key
and value specified.
|
CompletableFuture<Boolean> |
containsKey(K key)
Returns true if there is at lease one key-value pair with a key equal to
key.
|
CompletableFuture<Boolean> |
containsValue(V value)
Returns true if this map contains at lease one key-value pair with a
value equal to value.
|
default CompletableFuture<Void> |
destroy()
Purges state associated with this primitive.
|
CompletableFuture<Collection<Map.Entry<K,V>>> |
entries()
Returns a collection of each key-value pair in this map.
|
CompletableFuture<Versioned<Collection<? extends V>>> |
get(K key)
Returns a collection of values associated with the specified key, if the
key is not in the map it will return an empty collection.
|
CompletableFuture<Boolean> |
isEmpty()
Returns if this multimap contains no key-value pairs.
|
CompletableFuture<com.google.common.collect.Multiset<K>> |
keys()
Returns a multiset of the keys present in this multimap with one or more
associated values each.
|
CompletableFuture<Set<K>> |
keySet()
Returns a set of the keys contained in this multimap with one or more
associated values.
|
default DistributedPrimitive.Type |
primitiveType()
Returns the type of primitive.
|
CompletableFuture<Boolean> |
put(K key,
V value)
If the key-value pair does not already exist adds either the key value
pair or the value to the set of values associated with the key and
returns true, if the key-value pair already exists then behavior is
implementation specific with some implementations allowing duplicates
and others ignoring put requests for existing entries.
|
CompletableFuture<Boolean> |
putAll(K key,
Collection<? extends V> values)
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.
|
CompletableFuture<Versioned<Collection<? extends V>>> |
putAndGet(K key,
V value)
If the key-value pair does not already exist adds either the key value
pair or the value to the set of values associated with the key and
returns the updated value, if the key-value pair already exists then behavior
is implementation specific with some implementations allowing duplicates
and others ignoring put requests for existing entries.
|
CompletableFuture<Boolean> |
remove(K key,
V value)
Removes the key-value pair with the specified values if it exists.
|
CompletableFuture<Versioned<Collection<? extends V>>> |
removeAll(K key)
Removes all values associated with the specified key as well as the key
itself.
|
CompletableFuture<Boolean> |
removeAll(K key,
Collection<? extends V> values)
Removes the key-value pairs with the specified key and values if they
exist.
|
CompletableFuture<Versioned<Collection<? extends V>>> |
removeAndGet(K key,
V value)
Removes the key-value pair with the specified values if it exists.
|
CompletableFuture<Void> |
removeListener(MultimapEventListener<K,V> listener)
Unregisters the specified listener such that it will no longer
receive map change notifications.
|
CompletableFuture<Versioned<Collection<? extends V>>> |
replaceValues(K key,
Collection<V> values)
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.
|
CompletableFuture<Integer> |
size()
Returns the number of key-value pairs in this multimap.
|
CompletableFuture<com.google.common.collect.Multiset<V>> |
values()
Returns a collection of values in the set with duplicates permitted, the
size of this collection will equal the size of the map at the time of
creation.
|
addStatusChangeListener, applicationId, name, removeStatusChangeListener, statusChangeListeners
iterator
default DistributedPrimitive.Type primitiveType()
DistributedPrimitive
primitiveType
in interface DistributedPrimitive
default CompletableFuture<Void> destroy()
DistributedPrimitive
Implementations can override and provide appropriate clean up logic for purging any state state associated with the primitive. Whether modifications made within the destroy method have local or global visibility is left unspecified.
destroy
in interface DistributedPrimitive
CompletableFuture
that is completed when the operation completesCompletableFuture<Integer> size()
CompletableFuture<Boolean> isEmpty()
CompletableFuture<Boolean> containsKey(K key)
key
- the key to queryCompletableFuture<Boolean> containsValue(V value)
value
- the value to queryCompletableFuture<Boolean> containsEntry(K key, V value)
key
- keyvalue
- valueCompletableFuture<Boolean> put(K key, V value)
key
- the key to addvalue
- the value to addCompletableFuture<Versioned<Collection<? extends V>>> putAndGet(K key, V value)
key
- the key to addvalue
- the value to addCompletableFuture<Boolean> remove(K key, V value)
key
- the key of the pair to be removedvalue
- the value of the pair to be removedCompletableFuture<Versioned<Collection<? extends V>>> removeAndGet(K key, V value)
key
- the key of the pair to be removedvalue
- the value of the pair to be removedCompletableFuture<Boolean> removeAll(K key, Collection<? extends V> values)
remove()
for each key value pair but more
efficient.key
- the key of the pair to be removedvalues
- the set of values to be removedCompletableFuture<Versioned<Collection<? extends V>>> removeAll(K key)
key
- the key whose key-value pairs will be removedCompletableFuture<Boolean> putAll(K key, Collection<? extends V> values)
key
- the key to use for all pairs to be addedvalues
- the set of values to be added in pairs with the keyCompletableFuture<Versioned<Collection<? extends V>>> replaceValues(K key, Collection<V> values)
key
- the key for all entries to be addedvalues
- the values to be associated with the keyCompletableFuture<Void> clear()
CompletableFuture<Versioned<Collection<? extends V>>> get(K key)
key
- the key whose associated values will be returnedCompletableFuture<Set<K>> keySet()
CompletableFuture<com.google.common.collect.Multiset<K>> keys()
CompletableFuture<com.google.common.collect.Multiset<V>> values()
CompletableFuture<Collection<Map.Entry<K,V>>> entries()
default CompletableFuture<Void> addListener(MultimapEventListener<K,V> listener)
listener
- listener to notify about map eventsCompletableFuture<Void> addListener(MultimapEventListener<K,V> listener, Executor executor)
listener
- listener to notify about map eventsexecutor
- executor to use for handling incoming map eventsCompletableFuture<Void> removeListener(MultimapEventListener<K,V> listener)
listener
- listener to unregisterCompletableFuture<Map<K,Collection<V>>> asMap()
default ConsistentMultimap<K,V> asMultimap()
ConsistentMultimap
instance that wraps this map. All
calls will have the same behavior as this map but will be blocking
instead of asynchronous. If a call does not complete within the
default timeout an exception will be produced.ConsistentMultimap
which wraps this map, providing
synchronous access to this mapdefault ConsistentMultimap<K,V> asMultimap(long timeoutMillis)
ConsistentMultimap
instance that wraps this map. All
calls will have the same behavior as this map but will be blocking
instead of asynchronous. If a call does not complete within the
specified timeout an exception will be produced.timeoutMillis
- the number of millis to block while waiting for a
call to returnConsistentMultimap
which wraps this map, providing
synchronous access to this map