Interface KeyValueView<K,V>
- Type Parameters:
K- Mapped key type.V- Mapped value type.
- All Superinterfaces:
AutoCloseable,ContinuousQuerySource<Map.Entry<K,,V>> CriteriaQuerySource<Map.Entry<K,,V>> DataStreamerTarget<Map.Entry<K,V>>
- See Also:
- ApiNote:
- 'Key/value class field' >-< 'table column' mapping laid down in implementation.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(@Nullable Transaction tx, K key) Determines whether a table contains an entry for the specified key.booleancontainsAll(@Nullable Transaction tx, Collection<K> keys) Determines whether a table contains entries for all given keys.containsAllAsync(@Nullable Transaction tx, Collection<K> keys) Determines whether a table contains entries for all given keys.containsAsync(@Nullable Transaction tx, K key) Determines whether a table contains an entry for the specified key.get(@Nullable Transaction tx, K key) Gets a value associated with a given key.getAll(@Nullable Transaction tx, Collection<K> keys) Get values associated with given keys.getAllAsync(@Nullable Transaction tx, Collection<K> keys) Get values associated with given keys.getAndPut(@Nullable Transaction tx, K key, V val) Puts into a table a new, or replaces an existing, value associated with the given key.getAndPutAsync(@Nullable Transaction tx, K key, V val) Asynchronously puts into a table a new, or replaces an existing, value associated with given key.getAndRemove(@Nullable Transaction tx, K key) Gets and removes from a table a value associated with the given key.getAndRemoveAsync(@Nullable Transaction tx, K key) Asynchronously gets and removes from a table a value associated with the given key.getAndReplace(@Nullable Transaction tx, K key, V val) Replaces a value for a given key if it exists.getAndReplaceAsync(@Nullable Transaction tx, K key, V val) Asynchronously replaces a value for a given key if it exists.getAsync(@Nullable Transaction tx, K key) Asynchronously gets a value associated with a given key.getNullable(@Nullable Transaction tx, K key) Gets a nullable value associated with a given key.getNullableAndPut(@Nullable Transaction tx, K key, V val) Puts into a table a new, or replaces an existing, value associated with given key.getNullableAndPutAsync(@Nullable Transaction tx, K key, V val) Asynchronously puts into a table a new, or replaces an existing, value associated with given key.getNullableAndRemove(@Nullable Transaction tx, K key) Gets and removes from a table a value associated with the given key.getNullableAndRemoveAsync(@Nullable Transaction tx, K key) Asynchronously gets and removes from a table a value associated with the given key.getNullableAndReplace(@Nullable Transaction tx, K key, V val) Replaces a value for a given key if it exists.getNullableAndReplaceAsync(@Nullable Transaction tx, K key, V val) Asynchronously replaces a value for a given key if it exists.getNullableAsync(@Nullable Transaction tx, K key) Gets a nullable value associated with a given key.getOrDefault(@Nullable Transaction tx, K key, V defaultValue) Gets a value associated with a given key, if it exists and is not null, otherwise returnsdefaultValue.getOrDefaultAsync(@Nullable Transaction tx, K key, V defaultValue) Gets a value associated with a given key, if it exists and is not null, otherwise returnsdefaultValue.voidput(@Nullable Transaction tx, K key, V val) Puts into a table a value associated with the given key.voidputAll(@Nullable Transaction tx, Map<K, V> pairs) Puts associated key-value pairs.putAllAsync(@Nullable Transaction tx, Map<K, V> pairs) Asynchronously puts associated key-value pairs.putAsync(@Nullable Transaction tx, K key, V val) Asynchronously puts into a table a value associated with the given key.booleanputIfAbsent(@Nullable Transaction tx, K key, V val) Puts into a table a value associated with the given key if this value does not exists.putIfAbsentAsync(@Nullable Transaction tx, K key, V val) Asynchronously puts into a table a value associated with the given key if this value does not exist.booleanremove(@Nullable Transaction tx, K key) Removes from a table a value associated with the given key.booleanremove(@Nullable Transaction tx, K key, V val) Removes from a table an expected value associated with the given key.voidremoveAll(@Nullable Transaction tx) Removes all entries from a table.removeAll(@Nullable Transaction tx, Collection<K> keys) Removes from a table values associated with the given keys.removeAllAsync(@Nullable Transaction tx) Asynchronously remove all entries from a table.removeAllAsync(@Nullable Transaction tx, Collection<K> keys) Asynchronously remove from a table values associated with the given keys.removeAsync(@Nullable Transaction tx, K key) Asynchronously removes from a table a value associated with the given key.removeAsync(@Nullable Transaction tx, K key, V val) Asynchronously removes from a table an expected value associated with the given key.booleanreplace(@Nullable Transaction tx, K key, V val) Replaces a value for a key if it exists.booleanreplace(@Nullable Transaction tx, K key, V oldValue, V newValue) Replaces an expected value for a key.replaceAsync(@Nullable Transaction tx, K key, V val) Asynchronously replaces a value for a key if it exists.replaceAsync(@Nullable Transaction tx, K key, V oldVal, V newVal) Asynchronously replaces an expected value for a key.Methods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface org.apache.ignite.table.ContinuousQuerySource
queryContinuously, queryContinuouslyMethods inherited from interface org.apache.ignite.table.criteria.CriteriaQuerySource
query, query, query, queryAsync, queryAsync, queryAsyncMethods inherited from interface org.apache.ignite.table.DataStreamerTarget
streamData, streamData, streamData
-
Method Details
-
get
Gets a value associated with a given key.Note: If the value mapper implies a value can be
null, a suitable methodgetNullable(Transaction, Object)must be used.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be returned. The key cannot benull.- Returns:
- Value or
null, if it does not exist. - Throws:
MarshallerException- if the key doesn't match the schema.UnexpectedNullValueException- If value for the key exists, and it isnull.- See Also:
-
getAsync
Asynchronously gets a value associated with a given key.Note: If the value mapper implies a value can be
null, a suitable methodgetNullableAsync(Transaction, Object)must be used.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be returned. The key cannot benull.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key doesn't match the schema.- See Also:
-
getNullable
Gets a nullable value associated with a given key.Examples:
getNullable(tx, key)returnsnullafterremove(tx, key).getNullable(tx, key)returnsNullable.of(null)afterput(tx, key, null).- Parameters:
tx- Transaction ornullto auto commit.key- Key whose value is to be returned. The key cannot benull.- Returns:
- Wrapped nullable value or
nullif it does not exist. - Throws:
MarshallerException- if the key doesn't match the schema.
-
getNullableAsync
Gets a nullable value associated with a given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be returned. The key cannot benull.- Returns:
- Future that represents the pending completion of the operation.
The future returns wrapped nullable value or
nullif the row with the given key does not exist. - Throws:
MarshallerException- if the key doesn't match the schema.- See Also:
-
getOrDefault
Gets a value associated with a given key, if it exists and is not null, otherwise returnsdefaultValue.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be returned. The key cannot benull.defaultValue- Default value.- Returns:
- Value or
defaultValueif does not exist. - Throws:
MarshallerException- if the key doesn't match the schema.
-
getOrDefaultAsync
CompletableFuture<V> getOrDefaultAsync(@Nullable @Nullable Transaction tx, K key, @Nullable V defaultValue) Gets a value associated with a given key, if it exists and is not null, otherwise returnsdefaultValue.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be returned. The key cannot benull.defaultValue- Default value.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key doesn't match the schema.- See Also:
-
getAll
Get values associated with given keys.- Parameters:
tx- Transaction ornullto auto commit.keys- Keys whose values are to be returned. The keys cannot benull.- Returns:
- Values associated with given keys. If a requested key does not exist, it will have no corresponding entry in the returned map.
- Throws:
MarshallerException- if the keys don't match the schema.
-
getAllAsync
Get values associated with given keys.- Parameters:
tx- Transaction ornullto auto commit.keys- Keys whose values are to be returned. The keys cannot benull.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key doesn't match the schema.
-
contains
Determines whether a table contains an entry for the specified key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose presence is to be verified. The key cannot benull.- Returns:
Trueif a value exists for every specified key,falseotherwise.- Throws:
MarshallerException- if the key doesn't match the schema.
-
containsAsync
Determines whether a table contains an entry for the specified key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose presence is to be verified. The key cannot benull.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key doesn't match the schema.
-
containsAll
Determines whether a table contains entries for all given keys.- Parameters:
tx- Transaction ornullfor implicit transaction.keys- Keys whose presence is to be verified. The collection and it's values cannot benull.- Returns:
Trueif a value exists for every specified key,falseotherwise.- Throws:
MarshallerException- if the key doesn't match the schema.
-
containsAllAsync
Determines whether a table contains entries for all given keys.- Parameters:
tx- Transaction ornullfor implicit transaction.keys- Keys whose presence is to be verified. The collection and it's values cannot benull.- Returns:
- Future that represents the pending completion of the operation. The result of the future will be
trueif a value exists for every specified key,falseotherwise. - Throws:
MarshallerException- if the key doesn't match the schema.
-
put
Puts into a table a value associated with the given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key with which the specified value is to be associated. The key cannot benull.val- Value to be associated with the specified key. Can be null when mapped to a single column with a simple type.- Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
putAsync
Asynchronously puts into a table a value associated with the given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key with which the specified value is to be associated. The key cannot benull.val- Value to be associated with the specified key. Can be null when mapped to a single column with a simple type.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
putAll
Puts associated key-value pairs.- Parameters:
tx- Transaction ornullfor implicit transaction.pairs- Key-value pairs. The pairs cannot benull.- Throws:
MarshallerException- if one of key, or values doesn't match the schema.
-
putAllAsync
Asynchronously puts associated key-value pairs.- Parameters:
tx- Transaction ornullfor implicit transaction.pairs- Key-value pairs. The pairs cannot benull.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if one of key, or values doesn't match the schema.
-
getAndPut
Puts into a table a new, or replaces an existing, value associated with the given key.NB: The method doesn't support
nullcolumn value, usegetNullableAndPut(Transaction, Object, Object)instead.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key with which the specified value is to be associated. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Replaced value or
nullif it did not exist. - Throws:
MarshallerException- if one of the keys or values doesn't match the schema.UnexpectedNullValueException- If value for the key exists, and it isnull.
-
getAndPutAsync
Asynchronously puts into a table a new, or replaces an existing, value associated with given key.NB: The method doesn't support
nullcolumn value, usegetNullableAndPutAsync(Transaction, Object, Object)instead.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key with which the specified value is to be associated. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
getNullableAndPut
Puts into a table a new, or replaces an existing, value associated with given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key with which the specified value is to be associated. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Wrapped nullable value that was replaced or
nullif it did no exist. - Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
getNullableAndPutAsync
CompletableFuture<NullableValue<V>> getNullableAndPutAsync(@Nullable @Nullable Transaction tx, K key, @Nullable V val) Asynchronously puts into a table a new, or replaces an existing, value associated with given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key with which the specified value is to be associated. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
putIfAbsent
Puts into a table a value associated with the given key if this value does not exists.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key with which the specified value is to be associated. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
Trueif successful,falseotherwise.- Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
putIfAbsentAsync
CompletableFuture<Boolean> putIfAbsentAsync(@Nullable @Nullable Transaction tx, K key, @Nullable V val) Asynchronously puts into a table a value associated with the given key if this value does not exist.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key with which the specified value is to be associated. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
remove
Removes from a table a value associated with the given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be removed from the table. The key cannot benull.- Returns:
Trueif a value associated with the specified key was successfully removed,falseotherwise.- Throws:
MarshallerException- if the key doesn't match the schema.
-
remove
Removes from a table an expected value associated with the given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be removed from the table. The key cannot benull.val- Expected value.- Returns:
Trueif the expected value for the specified key was successfully removed,falseotherwise.- Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
removeAsync
Asynchronously removes from a table a value associated with the given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- A key whose value is to be removed from the table. The key cannot benull.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key doesn't match the schema.
-
removeAsync
Asynchronously removes from a table an expected value associated with the given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be removed from the table. The key cannot benull.val- Expected value.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
removeAll
Removes all entries from a table.- Parameters:
tx- Transaction ornullfor implicit transaction.
-
removeAll
Removes from a table values associated with the given keys.- Parameters:
tx- Transaction ornullfor implicit transaction.keys- Keys whose values are to be removed from the table. The keys cannot benull.- Returns:
- Keys that did not exist.
- Throws:
MarshallerException- if one of keys doesn't match the schema.
-
removeAllAsync
CompletableFuture<Collection<K>> removeAllAsync(@Nullable @Nullable Transaction tx, Collection<K> keys) Asynchronously remove from a table values associated with the given keys.- Parameters:
tx- Transaction ornullfor implicit transaction.keys- Keys whose values are to be removed from the table. The keys cannot benull.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if one of the keys doesn't match the schema.
-
removeAllAsync
Asynchronously remove all entries from a table.- Parameters:
tx- Transaction ornullfor implicit transaction.
-
getAndRemove
Gets and removes from a table a value associated with the given key.NB: Method doesn't support
nullcolumn value, usegetNullableAndRemove(Transaction, Object)instead.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be removed from the table. The key cannot benull.- Returns:
- Removed value or
nullif the value did not exist. - Throws:
UnexpectedNullValueException- If the key value isnull.MarshallerException- if the key doesn't match the schema.
-
getAndRemoveAsync
Asynchronously gets and removes from a table a value associated with the given key.NB: Method doesn't support
nullcolumn value, usegetNullableAndRemoveAsync(Transaction, Object)instead.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be removed from the table. The key cannot benull.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key doesn't match the schema.
-
getNullableAndRemove
Gets and removes from a table a value associated with the given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be removed from the table. The key cannot benull.- Returns:
- Wrapped nullable value that was removed or
nullif it did not exist. - Throws:
MarshallerException- if the key doesn't match the schema.
-
getNullableAndRemoveAsync
CompletableFuture<NullableValue<V>> getNullableAndRemoveAsync(@Nullable @Nullable Transaction tx, K key) Asynchronously gets and removes from a table a value associated with the given key.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key whose value is to be removed from the table. The key cannot benull.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key doesn't match the schema.
-
replace
Replaces a value for a key if it exists. This is equivalent to
except the action is performed atomically.if (cache.containsKey(tx, key)) { cache.put(tx, key, value); return true; } else { return false; }- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key the specified value is associated with. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
Trueif an old value was replaced,falseotherwise.- Throws:
MarshallerException- if the key and/or the value doesn't match the schema.
-
replace
boolean replace(@Nullable @Nullable Transaction tx, K key, @Nullable V oldValue, @Nullable V newValue) Replaces an expected value for a key. This is equivalent to
except the action is performed atomically.if (cache.get(tx, key) == oldValue) { cache.put(tx, key, newValue); return true; } else { return false; }- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key the specified value is associated with. The key cannot benull.oldValue- Expected value associated with the specified key. Can benullwhen mapped to a single column with a simple type.newValue- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
Trueif an old value was replaced,falseotherwise.- Throws:
MarshallerException- if the key, the oldValue, or the newValue doesn't match the schema.
-
replaceAsync
Asynchronously replaces a value for a key if it exists. Seereplace(Transaction, Object, Object).- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key the specified value is associated with. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key or the oldValue doesn't match the schema.
-
replaceAsync
CompletableFuture<Boolean> replaceAsync(@Nullable @Nullable Transaction tx, K key, @Nullable V oldVal, @Nullable V newVal) Asynchronously replaces an expected value for a key. Seereplace(Transaction, Object, Object, Object)- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key the specified value is associated with. The key cannot benull.oldVal- Expected value associated with the specified key. Can benullwhen mapped to a single column with a simple type.newVal- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key, the oldValue, or the newValue doesn't match the schema.
-
getAndReplace
Replaces a value for a given key if it exists. This is equivalent to
except the action is performed atomically.if (cache.containsKey(tx, key)) { V oldValue = cache.get(tx, key); cache.put(tx, key, value); return oldValue; } else { return null; }NB: Method doesn't support
nullcolumn value, usegetNullableAndReplace(Transaction, Object, Object)instead.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key the specified value is associated with. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Replaced value, or
nullif it did not exist. - Throws:
UnexpectedNullValueException- If the value for the key isnull.MarshallerException- if the key, or the value doesn't match the schema.
-
getAndReplaceAsync
Asynchronously replaces a value for a given key if it exists.NB: Method doesn't support
nullcolumn value, usegetNullableAndReplaceAsync(Transaction, Object, Object)instead.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key the specified value is associated with. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key or the value doesn't match the schema.- See Also:
-
getNullableAndReplace
Replaces a value for a given key if it exists.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key the specified value is associated with. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Wrapped nullable value that was replaced or
nullif it did not exist. - Throws:
MarshallerException- if the key or the value doesn't match the schema.- See Also:
-
getNullableAndReplaceAsync
CompletableFuture<NullableValue<V>> getNullableAndReplaceAsync(@Nullable @Nullable Transaction tx, K key, @Nullable V val) Asynchronously replaces a value for a given key if it exists.- Parameters:
tx- Transaction ornullfor implicit transaction.key- Key the specified value is associated with. The key cannot benull.val- Value to be associated with the specified key. Can benullwhen mapped to a single column with a simple type.- Returns:
- Future that represents the pending completion of the operation.
- Throws:
MarshallerException- if the key or the value doesn't match the schema.- See Also:
-