Class EmbeddedMultimapPairCache<K,HK,HV>

java.lang.Object
org.infinispan.multimap.impl.EmbeddedMultimapPairCache<K,HK,HV>
Type Parameters:
K - : The type of key to identify the structure.
HK - : The structure type for keys.
HV - : The structure type for values.

public class EmbeddedMultimapPairCache<K,HK,HV> extends Object
Multimap which holds a collection of key-values pairs.

This multimap can create arbitrary objects by holding a collection of key-value pairs under a single cache entry. It is possible to add or remove attributes dynamically, varying the structure format between keys.

Note that the structure is not distributed, it is under a single key, and the distribution happens per key.
Since:
15.0
Author:
José Bolina
  • Field Details

  • Constructor Details

  • Method Details

    • set

      @SafeVarargs public final CompletionStage<Integer> set(K key, Map.Entry<HK,HV>... entries)
      Set the given key-value pair in the multimap under the given key.

      If the key is not present, a new multimap is created.
      Parameters:
      key - : Cache key to store the values.
      entries - : Key-value pairs to store.
      Returns:
      CompletionStage with the number of created entries.
    • setIfAbsent

      public final CompletionStage<Boolean> setIfAbsent(K key, HK propertyKey, HV propertyValue)
      Set the given key-value in the multimap under the given key.

      If the key is not present, a new multimap is created. If the property already exists, the operation has no effect.

      Parameters:
      key - : Cache key to store key-value pair.
      propertyKey - : The property key.
      propertyValue - : The property value.
      Returns:
      true if the value is set, false, otherwise.
    • get

      public CompletionStage<Map<HK,HV>> get(K key)
      Get the key-value pairs under the given key.
      Parameters:
      key - : Cache key to retrieve the values.
      Returns:
      CompletionStage containing a Map with the key-value pairs or an empty map if the key is not found.
    • get

      public CompletionStage<HV> get(K key, HK property)
    • get

      @SafeVarargs public final CompletionStage<Map<HK,HV>> get(K key, HK... properties)
      Return the values of the given stored under the given .
      Parameters:
      key - : Cache key to retrieve the hash map.
      properties - : Properties to retrieve.
      Returns:
      CompletionStage containing a Map with the key-value pairs or an empty map if the key is not found.
    • size

      public CompletionStage<Integer> size(K key)
      Get the size of the hash map stored under key.
      Parameters:
      key - : Cache key to retrieve the hash map.
      Returns:
      CompletionStage containing the size of the hash map or 0 if the key is not found.
    • keySet

      public CompletionStage<Set<HK>> keySet(K key)
      Get the key set from the hash map stored under the given key.
      Parameters:
      key - : Cache key to retrieve the hash map.
      Returns:
      CompletionStage containing a Set with the keys or an empty set if the key is not found.
    • values

      public CompletionStage<Collection<HV>> values(K key)
      Get the values from the hash map stored under the given key.
      Parameters:
      key - : Cache key to retrieve the hash map.
      Returns:
      CompletionStage containing a Collection with the values or an empty collection if the key is not found.
    • contains

      public CompletionStage<Boolean> contains(K key, HK property)
      Verify if the property is present in the hash map stored under the given key.
      Parameters:
      key - : Cache key to retrieve the hash map.
      property - : Property to verify in the hash map.
      Returns:
      CompletionStage with true if the property is present or false otherwise.
    • remove

      @SafeVarargs public final CompletionStage<Integer> remove(K key, HK property, HK... properties)
      Remove the properties in the hash map under the given key.
      Parameters:
      key - : Cache key to remove the properties.
      property - : Property to remove.
      properties - : Additional properties to remove.
      Returns:
      CompletionStage with the number of removed properties.
    • remove

      public final CompletionStage<Integer> remove(K key, Collection<HK> properties)
      Remove the given properties in the hash map stored under the given key.
      Parameters:
      key - : Cache key to remove the properties.
      properties - : Properties to remove.
      Returns:
      CompletionStage with the number of removed properties.
    • compute

      public CompletionStage<HV> compute(K key, HK property, BiFunction<HK,HV,HV> biConsumer)
      Execute the given on the value mapped to the stored under .

      If the key is not present, a new entry is created. The is executed until the value is replaced with the new value. This is implementation behaves like Map.compute(Object, BiFunction).

      Parameters:
      key - : The key to retrieve the HashMapBucket.
      property - : The property to be updated.
      biConsumer - : Receives the key and previous value and returns the new value.
      Returns:
      A CompletionStage with the new value returned from .
      See Also:
    • subSelect

      public CompletionStage<Map<HK,HV>> subSelect(K key, int count)
      Select key-value pairs from the hash map stored under the given key.

      The returned values are randomly selected from the underlying map. An bigger than the size of the stored map does not raise an exception.

      Parameters:
      key - : Cache key to retrieve the stored hash map.
      count - : Number of key-value pairs to select.
      Returns:
      CompletionStage containing a Map with the key-value pairs or null if not found.