Package io.pravega.client.tables
Interface KeyValueTableMap<KeyT,ValueT>
-
- Type Parameters:
KeyT
- Table Key Type.ValueT
- Table Value Type.
- All Superinterfaces:
java.util.Map<KeyT,ValueT>
public interface KeyValueTableMap<KeyT,ValueT> extends java.util.Map<KeyT,ValueT>
Map
implementation for aKeyValueTable
's Key Family.All methods inherited from
Map
respect the contracts defined in that interface, except as noted below.Performance considerations:
- The
Map
interface defines synchronous operations, howeverKeyValueTable
defines async operations. All method implementations defined in this interface or inherited fromMap
invokeCompletableFuture.join()
on anyKeyValueTable
methods invoked. This means that two threads are used to fulfill these calls: one from the Executor passed in to theKeyValueTable
factory, and one on which this request is executing. - The following operations result in a single call to the wrapped
KeyValueTable
:-
Map.containsKey(java.lang.Object)
. -
Map.get(java.lang.Object)
,Map.getOrDefault(java.lang.Object, V)
. -
putDirect(KeyT, ValueT)
,Map.putAll(java.util.Map<? extends K, ? extends V>)
,Map.putIfAbsent(K, V)
. -
removeDirect(KeyT)
. -
Map.isEmpty()
(InvokesKeyValueTable.keyIterator(java.lang.String, int, io.pravega.client.tables.IteratorState)
and requests a single item). -
Map.keySet()
:Set.removeAll(java.util.Collection<?>)
,Set.contains(java.lang.Object)
,Set.containsAll(java.util.Collection<?>)
,Set.isEmpty()
. -
Map.entrySet()
:Set.contains(java.lang.Object)
,Set.containsAll(java.util.Collection<?>)
,Set.isEmpty()
,Set.add(E)
,Set.addAll(java.util.Collection<? extends E>)
.
-
- The following operations result up to two calls to the wrapped
KeyValueTable
:-
Map.put(K, V)
(refer to {putDirect(KeyT, ValueT)
if the old value is not needed). -
Map.replace(K, V, V)
. -
Map.remove(java.lang.Object)
(refer toremoveDirect(KeyT)
if the old value is not needed). -
Map.computeIfPresent(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>)
,Map.compute(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>)
},Map.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>)
. -
Map.keySet()
Set.remove(java.lang.Object)
. -
Map.entrySet()
:Set.removeAll(java.util.Collection<?>)
,Set.isEmpty()
.
-
- The following operations may result in iterating through all the Keys using
KeyValueTable.keyIterator(java.lang.String, int, io.pravega.client.tables.IteratorState)
:-
Map.keySet()
Set.iterator()
(Iterates asIterator.hasNext()
orIterator.next()
are invoked. Calls toIterator.remove()
will result in a single call toKeyValueTable
). -
Map.size()
(Iterates through the entire iterator). -
Map.clear()
(Iterates through the entire iterator and makes repeated calls toKeyValueTable.removeAll(java.lang.String, java.lang.Iterable<io.pravega.client.tables.TableKey<KeyT>>)
). -
Map.keySet()
:Set.clear()
,Collection.removeIf(java.util.function.Predicate<? super E>)
,Set.retainAll(java.util.Collection<?>)
.
-
- The following operations may result in iterating through all the Entries using
KeyValueTable.entryIterator(java.lang.String, int, io.pravega.client.tables.IteratorState)
:-
Map.containsValue(java.lang.Object)
. -
Map.replaceAll(java.util.function.BiFunction<? super K, ? super V, ? extends V>)
(which makes multiple calls toKeyValueTable.putAll(java.lang.String, java.lang.Iterable<java.util.Map.Entry<KeyT, ValueT>>)
as well). -
Map.entrySet()
Set.iterator()
(Iterates asIterator.hasNext()
orIterator.next()
are invoked. Calls toIterator.remove()
will result in a single call toKeyValueTable
). -
Map.entrySet()
:Collection.removeIf(java.util.function.Predicate<? super E>)
,Set.retainAll(java.util.Collection<?>)
- All operations on
Map.values()
.
-
- Invocations of
Collection.stream()
},Collection.spliterator()
orCollection.toArray()
onMap.keySet()
,Map.entrySet()
orMap.values()
will invoke those collections' iterators (see above).
If
getKeyFamily()
is null), the following operations are not supported and will throw throwUnsupportedOperationException
).Map.containsValue(java.lang.Object)
.Map.putAll(java.util.Map<? extends K, ? extends V>)
.Map.replaceAll(java.util.function.BiFunction<? super K, ? super V, ? extends V>)
.Map.keySet()
.Map.values()
.Map.entrySet()
.Map.size()
.Map.isEmpty()
.Map.clear()
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
getKeyFamily()
Gets the Key Family over which thisKeyValueTableMap
applies.void
putDirect(KeyT key, ValueT value)
Same asMap.put(K, V)
, but does not attempt to retrieve the existing value.void
removeDirect(KeyT key)
Same asMap.remove(java.lang.Object)
, but does not attempt to retrieve the existing value.
-
-
-
Method Detail
-
getKeyFamily
java.lang.String getKeyFamily()
Gets the Key Family over which thisKeyValueTableMap
applies.- Returns:
- The Key Family, or null if operating over Keys with no Key Family.
-
putDirect
void putDirect(@NonNull KeyT key, @NonNull ValueT value)
Same asMap.put(K, V)
, but does not attempt to retrieve the existing value. Results in a single call to the wrappedKeyValueTable
.- Parameters:
key
- The Key to insert or update.value
- The value to associate with the key.
-
removeDirect
void removeDirect(@NonNull KeyT key)
Same asMap.remove(java.lang.Object)
, but does not attempt to retrieve the existing value. Results in a single call to the wrappedKeyValueTable
.- Parameters:
key
- The key to remove.
-
-