Interface KeyValueView<K,V>

Type Parameters:
K - Mapped key type.
V - Mapped value type.
All Superinterfaces:
ContinuousQuerySource<Map.Entry<K,V>>, CriteriaQuerySource<Map.Entry<K,V>>, DataStreamerTarget<Map.Entry<K,V>>

public interface KeyValueView<K,V> extends DataStreamerTarget<Map.Entry<K,V>>, CriteriaQuerySource<Map.Entry<K,V>>, ContinuousQuerySource<Map.Entry<K,V>>
Key-Value view of a table provides methods to access table records.
See Also:
ApiNote:
'Key/value class field' >-< 'table column' mapping laid down in implementation.
  • Method Details

    • get

      @Nullable V get(@Nullable @Nullable Transaction tx, K key)
      Gets a value associated with a given key.

      Note: If the value mapper implies a value can be null, a suitable method getNullable(Transaction, Object) must be used.

      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be returned. The key cannot be null.
      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 is null.
      See Also:
    • getAsync

      CompletableFuture<V> getAsync(@Nullable @Nullable Transaction tx, K key)
      Asynchronously gets a value associated with a given key.

      Note: If the value mapper implies a value can be null, a suitable method getNullableAsync(Transaction, Object) must be used.

      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be returned. The key cannot be null.
      Returns:
      Future that represents the pending completion of the operation.
      Throws:
      MarshallerException - if the key doesn't match the schema.
      See Also:
    • getNullable

      NullableValue<V> getNullable(@Nullable @Nullable Transaction tx, K key)
      Gets a nullable value associated with a given key.

      Examples: getNullable(tx, key) returns null after remove(tx, key). getNullable(tx, key) returns Nullable.of(null) after put(tx, key, null).

      Parameters:
      tx - Transaction or null to auto commit.
      key - Key whose value is to be returned. The key cannot be null.
      Returns:
      Wrapped nullable value or null if it does not exist.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • getNullableAsync

      CompletableFuture<NullableValue<V>> getNullableAsync(@Nullable @Nullable Transaction tx, K key)
      Gets a nullable value associated with a given key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be returned. The key cannot be null.
      Returns:
      Future that represents the pending completion of the operation. The future returns wrapped nullable value or null if the row with the given key does not exist.
      Throws:
      MarshallerException - if the key doesn't match the schema.
      See Also:
    • getOrDefault

      @Nullable V getOrDefault(@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 returns defaultValue.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be returned. The key cannot be null.
      defaultValue - Default value.
      Returns:
      Value or defaultValue if 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 returns defaultValue.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be returned. The key cannot be null.
      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

      Map<K,V> getAll(@Nullable @Nullable Transaction tx, Collection<K> keys)
      Get values associated with given keys.
      Parameters:
      tx - Transaction or null to auto commit.
      keys - Keys whose values are to be returned. The keys cannot be null.
      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

      CompletableFuture<Map<K,V>> getAllAsync(@Nullable @Nullable Transaction tx, Collection<K> keys)
      Get values associated with given keys.
      Parameters:
      tx - Transaction or null to auto commit.
      keys - Keys whose values are to be returned. The keys cannot be null.
      Returns:
      Future that represents the pending completion of the operation.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • contains

      boolean contains(@Nullable @Nullable Transaction tx, K key)
      Determines whether a table contains an entry for the specified key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose presence is to be verified. The key cannot be null.
      Returns:
      True if a value exists for every specified key, false otherwise.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • containsAsync

      CompletableFuture<Boolean> containsAsync(@Nullable @Nullable Transaction tx, K key)
      Determines whether a table contains an entry for the specified key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose presence is to be verified. The key cannot be null.
      Returns:
      Future that represents the pending completion of the operation.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • containsAll

      boolean containsAll(@Nullable @Nullable Transaction tx, Collection<K> keys)
      Determines whether a table contains entries for all given keys.
      Parameters:
      tx - Transaction or null for implicit transaction.
      keys - Keys whose presence is to be verified. The collection and it's values cannot be null.
      Returns:
      True if a value exists for every specified key, false otherwise.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • containsAllAsync

      CompletableFuture<Boolean> containsAllAsync(@Nullable @Nullable Transaction tx, Collection<K> keys)
      Determines whether a table contains entries for all given keys.
      Parameters:
      tx - Transaction or null for implicit transaction.
      keys - Keys whose presence is to be verified. The collection and it's values cannot be null.
      Returns:
      Future that represents the pending completion of the operation. The result of the future will be true if a value exists for every specified key, false otherwise.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • put

      void put(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Puts into a table a value associated with the given key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key with which the specified value is to be associated. The key cannot be null.
      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

      CompletableFuture<Void> putAsync(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Asynchronously puts into a table a value associated with the given key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key with which the specified value is to be associated. The key cannot be null.
      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

      void putAll(@Nullable @Nullable Transaction tx, Map<K,V> pairs)
      Puts associated key-value pairs.
      Parameters:
      tx - Transaction or null for implicit transaction.
      pairs - Key-value pairs. The pairs cannot be null.
      Throws:
      MarshallerException - if one of key, or values doesn't match the schema.
    • putAllAsync

      CompletableFuture<Void> putAllAsync(@Nullable @Nullable Transaction tx, Map<K,V> pairs)
      Asynchronously puts associated key-value pairs.
      Parameters:
      tx - Transaction or null for implicit transaction.
      pairs - Key-value pairs. The pairs cannot be null.
      Returns:
      Future that represents the pending completion of the operation.
      Throws:
      MarshallerException - if one of key, or values doesn't match the schema.
    • getAndPut

      @Nullable V getAndPut(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Puts into a table a new, or replaces an existing, value associated with the given key.

      NB: The method doesn't support null column value, use getNullableAndPut(Transaction, Object, Object) instead.

      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key with which the specified value is to be associated. The key cannot be null.
      val - Value to be associated with the specified key. Can be null when mapped to a single column with a simple type.
      Returns:
      Replaced value or null if 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 is null.
    • getAndPutAsync

      CompletableFuture<V> getAndPutAsync(@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.

      NB: The method doesn't support null column value, use getNullableAndPutAsync(Transaction, Object, Object) instead.

      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key with which the specified value is to be associated. The key cannot be null.
      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.
    • getNullableAndPut

      NullableValue<V> getNullableAndPut(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Puts into a table a new, or replaces an existing, value associated with given key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key with which the specified value is to be associated. The key cannot be null.
      val - Value to be associated with the specified key. Can be null when mapped to a single column with a simple type.
      Returns:
      Wrapped nullable value that was replaced or null if 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 or null for implicit transaction.
      key - Key with which the specified value is to be associated. The key cannot be null.
      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.
    • putIfAbsent

      boolean putIfAbsent(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Puts into a table a value associated with the given key if this value does not exists.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key with which the specified value is to be associated. The key cannot be null.
      val - Value to be associated with the specified key. Can be null when mapped to a single column with a simple type.
      Returns:
      True if successful, false otherwise.
      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 or null for implicit transaction.
      key - Key with which the specified value is to be associated. The key cannot be null.
      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.
    • remove

      boolean remove(@Nullable @Nullable Transaction tx, K key)
      Removes from a table a value associated with the given key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be removed from the table. The key cannot be null.
      Returns:
      True if a value associated with the specified key was successfully removed, false otherwise.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • remove

      boolean remove(@Nullable @Nullable Transaction tx, K key, V val)
      Removes from a table an expected value associated with the given key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be removed from the table. The key cannot be null.
      val - Expected value.
      Returns:
      True if the expected value for the specified key was successfully removed, false otherwise.
      Throws:
      MarshallerException - if the key and/or the value doesn't match the schema.
    • removeAsync

      CompletableFuture<Boolean> removeAsync(@Nullable @Nullable Transaction tx, K key)
      Asynchronously removes from a table a value associated with the given key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - A key whose value is to be removed from the table. The key cannot be null.
      Returns:
      Future that represents the pending completion of the operation.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • removeAsync

      CompletableFuture<Boolean> removeAsync(@Nullable @Nullable Transaction tx, K key, V val)
      Asynchronously removes from a table an expected value associated with the given key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be removed from the table. The key cannot be null.
      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

      Collection<K> removeAll(@Nullable @Nullable Transaction tx, Collection<K> keys)
      Removes from a table values associated with the given keys.
      Parameters:
      tx - Transaction or null for implicit transaction.
      keys - Keys whose values are to be removed from the table. The keys cannot be null.
      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 or null for implicit transaction.
      keys - Keys whose values are to be removed from the table. The keys cannot be null.
      Returns:
      Future that represents the pending completion of the operation.
      Throws:
      MarshallerException - if one of the keys doesn't match the schema.
    • getAndRemove

      @Nullable V getAndRemove(@Nullable @Nullable Transaction tx, K key)
      Gets and removes from a table a value associated with the given key.

      NB: Method doesn't support null column value, use getNullableAndRemove(Transaction, Object) instead.

      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be removed from the table. The key cannot be null.
      Returns:
      Removed value or null if the value did not exist.
      Throws:
      UnexpectedNullValueException - If the key value is null.
      MarshallerException - if the key doesn't match the schema.
    • getAndRemoveAsync

      CompletableFuture<V> getAndRemoveAsync(@Nullable @Nullable Transaction tx, K key)
      Asynchronously gets and removes from a table a value associated with the given key.

      NB: Method doesn't support null column value, use getNullableAndRemoveAsync(Transaction, Object) instead.

      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be removed from the table. The key cannot be null.
      Returns:
      Future that represents the pending completion of the operation.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • getNullableAndRemove

      NullableValue<V> getNullableAndRemove(@Nullable @Nullable Transaction tx, K key)
      Gets and removes from a table a value associated with the given key.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key whose value is to be removed from the table. The key cannot be null.
      Returns:
      Wrapped nullable value that was removed or null if 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 or null for implicit transaction.
      key - Key whose value is to be removed from the table. The key cannot be null.
      Returns:
      Future that represents the pending completion of the operation.
      Throws:
      MarshallerException - if the key doesn't match the schema.
    • replace

      boolean replace(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Replaces a value for a key if it exists. This is equivalent to
      
       if (cache.containsKey(tx, key)) {
         cache.put(tx, key, value);
         return true;
       } else {
         return false;
       }
      except the action is performed atomically.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key the specified value is associated with. The key cannot be null.
      val - Value to be associated with the specified key. Can be null when mapped to a single column with a simple type.
      Returns:
      True if an old value was replaced, false otherwise.
      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
      
       if (cache.get(tx, key) == oldValue) {
         cache.put(tx, key, newValue);
         return true;
       } else {
         return false;
       }
      except the action is performed atomically.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key the specified value is associated with. The key cannot be null.
      oldValue - Expected value associated with the specified key. Can be null when mapped to a single column with a simple type.
      newValue - Value to be associated with the specified key. Can be null when mapped to a single column with a simple type.
      Returns:
      True if an old value was replaced, false otherwise.
      Throws:
      MarshallerException - if the key, the oldValue, or the newValue doesn't match the schema.
    • replaceAsync

      CompletableFuture<Boolean> replaceAsync(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Asynchronously replaces a value for a key if it exists. See replace(Transaction, Object, Object).
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key the specified value is associated with. The key cannot be null.
      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 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. See replace(Transaction, Object, Object, Object)
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key the specified value is associated with. The key cannot be null.
      oldVal - Expected value associated with the specified key. Can be null when mapped to a single column with a simple type.
      newVal - 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, the oldValue, or the newValue doesn't match the schema.
    • getAndReplace

      @Nullable V getAndReplace(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Replaces a value for a given key if it exists. This is equivalent to
      
       if (cache.containsKey(tx, key)) {
         V oldValue = cache.get(tx, key);
         cache.put(tx, key, value);
         return oldValue;
       } else {
         return null;
       }
       
      except the action is performed atomically.

      NB: Method doesn't support null column value, use getNullableAndReplace(Transaction, Object, Object) instead.

      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key the specified value is associated with. The key cannot be null.
      val - Value to be associated with the specified key. Can be null when mapped to a single column with a simple type.
      Returns:
      Replaced value, or null if it did not exist.
      Throws:
      UnexpectedNullValueException - If the value for the key is null.
      MarshallerException - if the key, or the value doesn't match the schema.
    • getAndReplaceAsync

      CompletableFuture<V> getAndReplaceAsync(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Asynchronously replaces a value for a given key if it exists.

      NB: Method doesn't support null column value, use getNullableAndReplaceAsync(Transaction, Object, Object) instead.

      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key the specified value is associated with. The key cannot be null.
      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 or the value doesn't match the schema.
      See Also:
    • getNullableAndReplace

      NullableValue<V> getNullableAndReplace(@Nullable @Nullable Transaction tx, K key, @Nullable V val)
      Replaces a value for a given key if it exists.
      Parameters:
      tx - Transaction or null for implicit transaction.
      key - Key the specified value is associated with. The key cannot be null.
      val - Value to be associated with the specified key. Can be null when mapped to a single column with a simple type.
      Returns:
      Wrapped nullable value that was replaced or null if 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 or null for implicit transaction.
      key - Key the specified value is associated with. The key cannot be null.
      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 or the value doesn't match the schema.
      See Also: