Package org.infinispan.multimap.impl
Class EmbeddedMultimapListCache<K,V>
java.lang.Object
org.infinispan.multimap.impl.EmbeddedMultimapListCache<K,V>
Multimap with Linked List Implementation methods
- Since:
- 15.0
- Author:
- Katia Aresti
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AdvancedCache
<K, ListBucket<V>> protected final InternalEntryFactory
static final String
static final String
static final String
static final String
protected final FunctionalMap.ReadWriteMap
<K, ListBucket<V>> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncontainsKey
(K key) Returns true if the list associated with the key exists.Get the value as a collectionReturns the element at the given index.Retrieves indexes of matching elements inside a list.Inserts an element before or after the pivot element.offerFirst
(K key, Collection<V> value) Inserts the specified collection at the front of the specified list.offerFirst
(K key, V value) Inserts the specified element at the front of the specified list.offerLast
(K key, Collection<V> value) Inserts the specified collection at the end of the specified list.Inserts the specified element at the end of the specified list.Removes the given count of elements from the tail or the head of the listRemoves the given count of elements from the head of the list.Removes the given count of elements from the tail of the list.Removes from the list the provided element.Adds a collection to a key.Rotates an element in the list from head to tail or tail to head, depending on the rotateRight parameter.Sets a value in the given index.Returns the number of elements in the list.Retrieves a sub list of elements, starting from 0.Trims the list removing the elements with the provided indexes 'from' and 'to'.
-
Field Details
-
ERR_KEY_CAN_T_BE_NULL
- See Also:
-
ERR_ELEMENT_CAN_T_BE_NULL
- See Also:
-
ERR_VALUE_CAN_T_BE_NULL
- See Also:
-
ERR_PIVOT_CAN_T_BE_NULL
- See Also:
-
readWriteMap
-
cache
-
entryFactory
-
-
Constructor Details
-
EmbeddedMultimapListCache
-
-
Method Details
-
get
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
Inserts the specified element at the front of the specified list.- Parameters:
key
- , the name of the listvalue
- , the element to be inserted- Returns:
CompletionStage
containing aVoid
-
offerLast
Inserts the specified element at the end of the specified list.- Parameters:
key
- , the name of the listvalue
- , the element to be inserted- Returns:
CompletionStage
containing aVoid
-
offerFirst
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 listvalue
- , collection to be inserted- Returns:
CompletionStage
containing aVoid
-
offerLast
Inserts the specified collection at the end of the specified list.- Parameters:
key
- , the name of the listvalue
- , collection to be inserted- Returns:
CompletionStage
containing aVoid
-
containsKey
Returns true if the list associated with the key exists.- Parameters:
key
- , the name of the list- Returns:
CompletionStage
containing aBoolean
-
size
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 aLong
-
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 listindex
- , 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
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 listfrom
- , the starting offsetto
- , the final offset- Returns:
- The subList. Returns null if the key does not exist.
-
pollFirst
Removes the given count of elements from the head of the list.- Parameters:
key
- , the name of the listcount
- , the number of elements. Must be positive.- Returns:
CompletionStage
containing aCollection<V>
of values removed, or null if the key does not exit
-
pollLast
Removes the given count of elements from the tail of the list.- Parameters:
key
- , the name of the listcount
- , the number of elements. Must be positive.- Returns:
CompletionStage
containing aCollection<V>
of values removed, or null if the key does not exit
-
poll
Removes the given count of elements from the tail or the head of the list- Parameters:
key
- , the name of the listcount
- , the number of elementsfirst
- , true if it's the head, false for the tail- Returns:
CompletionStage
containing aCollection<V>
of values removed, or null if the key does not exit
-
set
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 listindex
- , the position of the element to be inserted. Can be negativevalue
- , 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
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 listisBefore
- , insert before true, after falsepivot
- , the element to compareelement
- , the element to insert- Returns:
- , the size of the list after insertion, 0 or -1
-
remove
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 listcount
- , number of elements to removeelement
- , the element to remove- Returns:
- how many elements have actually been removed, 0 if the list does not exist
-
trim
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 listfrom
- , the starting offsetto
- , the final offset- Returns:
CompletionStage<Boolean>
true when the list exist and the trim has been done.
-
replace
Adds a collection to a key. The collection replaces the current list content if such exist.- Parameters:
key
- , the name of the listlist
- , content. If the list is null or empty, and the list exists, will be removed- Returns:
- how many elements have actually been replaced
-
rotate
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 listrotateRight
- , 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
-