Class EmbeddedMultimapListCache<K,V>

java.lang.Object
org.infinispan.multimap.impl.EmbeddedMultimapListCache<K,V>

public class EmbeddedMultimapListCache<K,V> extends Object
Multimap with Linked List Implementation methods
Since:
15.0
Author:
Katia Aresti
  • Field Details

  • Constructor Details

    • EmbeddedMultimapListCache

      public EmbeddedMultimapListCache(Cache<K,ListBucket<V>> cache)
  • Method Details

    • get

      public CompletionStage<Collection<V>> get(K key)
      Get the value as a collection
      Parameters:
      key - , the name of the list
      Returns:
      the collection with values if such exist, or an empty collection if the key is not present
    • offerFirst

      public CompletionStage<Void> offerFirst(K key, V value)
      Inserts the specified element at the front of the specified list.
      Parameters:
      key - , the name of the list
      value - , the element to be inserted
      Returns:
      CompletionStage containing a Void
    • offerLast

      public CompletionStage<Void> offerLast(K key, V value)
      Inserts the specified element at the end of the specified list.
      Parameters:
      key - , the name of the list
      value - , the element to be inserted
      Returns:
      CompletionStage containing a Void
    • offerFirst

      public CompletionStage<Void> offerFirst(K key, Collection<V> value)
      Inserts the specified collection at the front of the specified list. Elements will be inserted as first one by one: i.e. elements in the list will be in revers order
      Parameters:
      key - , the name of the list
      value - , collection to be inserted
      Returns:
      CompletionStage containing a Void
    • offerLast

      public CompletionStage<Void> offerLast(K key, Collection<V> value)
      Inserts the specified collection at the end of the specified list.
      Parameters:
      key - , the name of the list
      value - , collection to be inserted
      Returns:
      CompletionStage containing a Void
    • containsKey

      public CompletionStage<Boolean> containsKey(K key)
      Returns true if the list associated with the key exists.
      Parameters:
      key - , the name of the list
      Returns:
      CompletionStage containing a Boolean
    • size

      public CompletionStage<Long> size(K key)
      Returns the number of elements in the list. If the entry does not exit, returns size 0.
      Parameters:
      key - , the name of the list
      Returns:
      CompletionStage containing a Long
    • index

      public CompletionStage<V> index(K key, long index)
      Returns the element at the given index. Index is zero-based. 0 means fist element. Negative index counts index from the tail. For example -1 is the last element.
      Parameters:
      key - , the name of the list
      index - , the position of the element.
      Returns:
      The existing value. Returns null if the key does not exist or the index is out of bounds.
    • subList

      public CompletionStage<Collection<V>> subList(K key, long from, long to)
      Retrieves a sub list of elements, starting from 0. Negative indexes point positions counting from the tail of the list. For example 0 is the first element, 1 is the second element, -1 the last element.
      Parameters:
      key - , the name of the list
      from - , the starting offset
      to - , the final offset
      Returns:
      The subList. Returns null if the key does not exist.
    • pollFirst

      public CompletionStage<Collection<V>> pollFirst(K key, long count)
      Removes the given count of elements from the head of the list.
      Parameters:
      key - , the name of the list
      count - , the number of elements. Must be positive.
      Returns:
      CompletionStage containing a Collection<V> of values removed, or null if the key does not exit
    • pollLast

      public CompletionStage<Collection<V>> pollLast(K key, long count)
      Removes the given count of elements from the tail of the list.
      Parameters:
      key - , the name of the list
      count - , the number of elements. Must be positive.
      Returns:
      CompletionStage containing a Collection<V> of values removed, or null if the key does not exit
    • poll

      public CompletableFuture<Collection<V>> poll(K key, long count, boolean first)
      Removes the given count of elements from the tail or the head of the list
      Parameters:
      key - , the name of the list
      count - , the number of elements
      first - , true if it's the head, false for the tail
      Returns:
      CompletionStage containing a Collection<V> of values removed, or null if the key does not exit
    • set

      public CompletionStage<Boolean> set(K key, long index, V value)
      Sets a value in the given index. 0 means fist element. Negative index counts index from the tail. For example -1 is the last element.
      Parameters:
      key - , the name of the list
      index - , the position of the element to be inserted. Can be negative
      value - , the element to be inserted in the index position
      Returns:
      CompletionStage with true if the value was set, false if the key does not exist
      Throws:
      CacheException - when the index is out of range
    • indexOf

      public CompletionStage<Collection<Long>> indexOf(K key, V element, Long count, Long rank, Long maxlen)
      Retrieves indexes of matching elements inside a list. Scans the list looking for the elements that match the provided element.
      Parameters:
      key - , the name of the list, can't be null.
      element - , the element to compare, can't be null.
      count - , number of matches. If null, count is 1 by default. Can't be negative. If count is 0, means all the matches.
      rank - , the "rank" of the first element to return, in case there are multiple matches. A rank of 1 means the first match, 2 the second match, and so forth. Negative rank iterates from the tail. If null, rank is 1 by default. Can't be 0.
      maxlen - , compares the provided element only with a given maximum number of list items. If null, defaults to 0 that means all the elements. Can't be negative.
      Returns:
      Collection<Long> containing the zero-based positions in the list counting from the head of the list. Returns null when the list does not exist or empty list when matches are not found.
    • insert

      public CompletionStage<Long> insert(K key, boolean isBefore, V pivot, V element)
      Inserts an element before or after the pivot element. If the key does not exist, returns 0. If the pivot does not exist, returns -1. If the element was inserted, returns the size of the list. The list is traversed from head to tail, the insertion is done before or after the first element found.
      Parameters:
      key - , the name of the list
      isBefore - , insert before true, after false
      pivot - , the element to compare
      element - , the element to insert
      Returns:
      , the size of the list after insertion, 0 or -1
    • remove

      public CompletionStage<Long> remove(K key, long count, V element)
      Removes from the list the provided element. The number of copies to be removed is provided by the count parameter. When count is 0, all the elements that match the provided element will be removed. If count is negative, the iteration will be done from the tail of the list instead of the head. count = 0, removes all, iterates over the whole list count = 1, removes one match, starts iteration from the head count = -1, removed one match, starts iteration from the tail
      Parameters:
      key - , the name of the list
      count - , number of elements to remove
      element - , the element to remove
      Returns:
      how many elements have actually been removed, 0 if the list does not exist
    • trim

      public CompletionStage<Boolean> trim(K key, long from, long to)
      Trims the list removing the elements with the provided indexes 'from' and 'to'. Negative indexes point positions counting from the tail of the list. For example 0 is the first element, 1 is the second element, -1 the last element. Iteration is done from head to tail.
      Parameters:
      key - , the name of the list
      from - , the starting offset
      to - , the final offset
      Returns:
      CompletionStage<Boolean> true when the list exist and the trim has been done.
    • replace

      public CompletionStage<Long> replace(K key, List<V> list)
      Adds a collection to a key. The collection replaces the current list content if such exist.
      Parameters:
      key - , the name of the list
      list - , content. If the list is null or empty, and the list exists, will be removed
      Returns:
      how many elements have actually been replaced
    • rotate

      public CompletionStage<V> rotate(K key, boolean rotateRight)
      Rotates an element in the list from head to tail or tail to head, depending on the rotateRight parameter.
      Parameters:
      key - , the name of the list
      rotateRight - , true to rotate an element from the left to the right (head -> tail)
      Returns:
      the rotated element value, null if the list does not exist