public class DistributedMultiMap<K,V> extends io.atomix.resource.AbstractResource<DistributedMultiMap<K,V>>
The multi-map resource stores a map of keys that allows multiple values to be associated with each key. Multimap entries are stored in memory on each stateful node and backed by disk, thus the size of a multi-map is limited by the available memory on the smallest node in the cluster.
To create a multimap, use the getMultiMap factory method on an Atomix instance:
DistributedMultiMap<String, String> multiMap = atomix.getMultiMap("foo").get();
The multi-map interface closely simulates that of Map except that values are Collections
rather than V.
map configuration by setting
the value DistributedMultiMap.Order. To set the order of values in a multi-map, create a configuration and provide the
configuration at the creation of the map.
DistributedMultiMap.Config config = DistributedMultiMap.config()
.withValueOrder(DistributedMultiMap.Order.NATURAL);
DistributedMultiMap<String, String> multiMap = atomix.getMultiMap("foo", config).get();
Multi-maps support relaxed consistency levels for some read operations line size(ReadConsistency)
and containsKey(Object, ReadConsistency). By default, read operations on a queue are linearizable
but require some level of communication between nodes.| Modifier and Type | Class and Description |
|---|---|
static class |
DistributedMultiMap.Config
Multimap configuration.
|
static class |
DistributedMultiMap.Order
Represents the order of values in a multimap.
|
| Constructor and Description |
|---|
DistributedMultiMap(CopycatClient client,
Properties options) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
clear()
Removes all entries from the map.
|
io.atomix.resource.Resource.Config |
config() |
CompletableFuture<Boolean> |
containsEntry(K key,
V value)
Checks whether the map contains an entry.
|
CompletableFuture<Boolean> |
containsEntry(K key,
V value,
io.atomix.resource.ReadConsistency consistency)
Checks whether the map contains an entry.
|
CompletableFuture<Boolean> |
containsKey(K key)
Checks whether the map contains a key.
|
CompletableFuture<Boolean> |
containsKey(K key,
io.atomix.resource.ReadConsistency consistency)
Checks whether the map contains a key.
|
CompletableFuture<Boolean> |
containsValue(V value)
Checks whether the map contains a value.
|
CompletableFuture<Boolean> |
containsValue(V value,
io.atomix.resource.ReadConsistency consistency)
Checks whether the map contains a value.
|
CompletableFuture<Collection<V>> |
get(K key)
Gets a value from the map.
|
CompletableFuture<Collection<V>> |
get(K key,
io.atomix.resource.ReadConsistency consistency)
Gets a value from the map.
|
CompletableFuture<Boolean> |
isEmpty()
Checks whether the map is empty.
|
CompletableFuture<Boolean> |
isEmpty(io.atomix.resource.ReadConsistency consistency)
Checks whether the map is empty.
|
CompletableFuture<Boolean> |
put(K key,
V value)
Puts a value in the map.
|
CompletableFuture<Boolean> |
put(K key,
V value,
Duration ttl)
Puts a value in the map.
|
CompletableFuture<Collection<V>> |
remove(Object key)
Removes a value from the map.
|
CompletableFuture<Boolean> |
remove(Object key,
Object value)
Removes a key and value from the map.
|
CompletableFuture<Void> |
removeValue(Object value)
Removes all instances of a value from the map.
|
CompletableFuture<Integer> |
size()
Gets the number of key-value pairs in the map.
|
CompletableFuture<Integer> |
size(K key)
Gets the number of values for the given key.
|
CompletableFuture<Integer> |
size(K key,
io.atomix.resource.ReadConsistency consistency)
Gets the number of values for the given key.
|
CompletableFuture<Integer> |
size(io.atomix.resource.ReadConsistency consistency)
Gets the number of key-value pairs in the map.
|
public DistributedMultiMap(CopycatClient client, Properties options)
public io.atomix.resource.Resource.Config config()
config in interface io.atomix.resource.Resource<DistributedMultiMap<K,V>>config in class io.atomix.resource.AbstractResource<DistributedMultiMap<K,V>>public CompletableFuture<Boolean> isEmpty()
public CompletableFuture<Boolean> isEmpty(io.atomix.resource.ReadConsistency consistency)
public CompletableFuture<Integer> size()
public CompletableFuture<Integer> size(io.atomix.resource.ReadConsistency consistency)
consistency - The read consistency level.public CompletableFuture<Integer> size(K key)
key - The key to check.public CompletableFuture<Integer> size(K key, io.atomix.resource.ReadConsistency consistency)
key - The key to check.consistency - The read consistency level.public CompletableFuture<Boolean> containsKey(K key)
key - The key to check.public CompletableFuture<Boolean> containsKey(K key, io.atomix.resource.ReadConsistency consistency)
key - The key to check.consistency - The read consistency level.public CompletableFuture<Boolean> containsEntry(K key, V value)
key - The key to check.value - The value to check.public CompletableFuture<Boolean> containsEntry(K key, V value, io.atomix.resource.ReadConsistency consistency)
key - The key to check.value - The value to check.consistency - The read consistency level.public CompletableFuture<Boolean> containsValue(V value)
value - The value to check.public CompletableFuture<Boolean> containsValue(V value, io.atomix.resource.ReadConsistency consistency)
value - The value to check.consistency - The read consistency level.public CompletableFuture<Collection<V>> get(K key)
key - The key to get.public CompletableFuture<Collection<V>> get(K key, io.atomix.resource.ReadConsistency consistency)
key - The key to get.consistency - The read consistency level.public CompletableFuture<Boolean> put(K key, V value)
key - The key to set.value - The value to set.public CompletableFuture<Boolean> put(K key, V value, Duration ttl)
key - The key to set.value - The value to set.ttl - The duration after which to expire the key.public CompletableFuture<Collection<V>> remove(Object key)
key - The key to remove.public CompletableFuture<Boolean> remove(Object key, Object value)
key - The key to remove.value - The value to remove.public CompletableFuture<Void> removeValue(Object value)
value - The value to remove.public CompletableFuture<Void> clear()
Copyright © 2013–2017. All rights reserved.