All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.redisson.api.RScoredSortedSet Maven / Gradle / Ivy

There is a newer version: 3.34.1
Show newest version
/**
 * Copyright (c) 2013-2022 Nikita Koksharov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.redisson.api;

import org.redisson.api.mapreduce.RCollectionMapReduce;
import org.redisson.client.protocol.RankedEntry;
import org.redisson.client.protocol.ScoredEntry;

import java.time.Duration;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Stream;

/**
 * Set containing elements sorted by score.
 * 
 * @author Nikita Koksharov
 *
 * @param  object type
 */
public interface RScoredSortedSet extends RScoredSortedSetAsync, Iterable, RExpirable, RSortable> {

    enum Aggregate {
        
        SUM, MAX, MIN
        
    }
    
    /**
     * Returns RMapReduce object associated with this object
     * 
     * @param  output key
     * @param  output value
     * @return MapReduce instance
     */
     RCollectionMapReduce mapReduce();
    
    /**
     * Removes and returns first available tail element of any sorted set,
     * waiting up to the specified wait time if necessary for an element to become available
     * in any of defined sorted sets including this one.
     * 

* Requires Redis 5.0.0 and higher. * * @param queueNames name of queues * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return the tail element, or {@code null} if all sorted sets are empty */ V pollLastFromAny(long timeout, TimeUnit unit, String... queueNames); /** * Removes and returns first available tail elements of any sorted set, * waiting up to the specified wait time if necessary for elements to become available * in any of defined sorted sets including this one. *

* Requires Redis 7.0.0 and higher. * * @param duration how long to wait before giving up * @param count elements amount * @param queueNames name of queues * @return the tail elements */ List pollLastFromAny(Duration duration, int count, String... queueNames); /** * Removes and returns first available tail elements * of any sorted set including this one. *

* Requires Redis 7.0.0 and higher. * * @param count elements amount * @param queueNames name of queues * @return the tail elements */ List pollLastFromAny(int count, String... queueNames); /** * Removes and returns first available tail entries * of any sorted set including this one. *

* Requires Redis 7.0.0 and higher. * * @param count entries amount * @param queueNames name of queues * @return the head entries */ Map> pollLastEntriesFromAny(int count, String... queueNames); /** * Removes and returns first available tail entries of any sorted set, * waiting up to the specified wait time if necessary for elements to become available * in any of defined sorted sets including this one. *

* Requires Redis 7.0.0 and higher. * * @param duration how long to wait before giving up * @param count entries amount * @param queueNames name of queues * @return the tail entries */ Map> pollLastEntriesFromAny(Duration duration, int count, String... queueNames); /** * Removes and returns first available head element of any sorted set, * waiting up to the specified wait time if necessary for an element to become available * in any of defined sorted sets including this one. *

* Requires Redis 5.0.0 and higher. * * @param queueNames name of queues * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return the head element, or {@code null} if all sorted sets are empty */ V pollFirstFromAny(long timeout, TimeUnit unit, String... queueNames); /** * Removes and returns first available head elements of any sorted set, * waiting up to the specified wait time if necessary for elements to become available * in any of defined sorted sets including this one. *

* Requires Redis 7.0.0 and higher. * * @param duration how long to wait before giving up * @param count elements amount * @param queueNames name of queues * @return the head elements */ List pollFirstFromAny(Duration duration, int count, String... queueNames); /** * Removes and returns first available head elements * of any sorted set including this one. *

* Requires Redis 7.0.0 and higher. * * @param count elements amount * @param queueNames name of queues * @return the head elements */ List pollFirstFromAny(int count, String... queueNames); /** * Removes and returns first available head entries * of any sorted set including this one. *

* Requires Redis 7.0.0 and higher. * * @param count entries amount * @param queueNames name of queues * @return the head elements */ Map> pollFirstEntriesFromAny(int count, String... queueNames); /** * Removes and returns first available head entries of any sorted set, * waiting up to the specified wait time if necessary for elements to become available * in any of defined sorted sets including this one. *

* Requires Redis 7.0.0 and higher. * * @param duration how long to wait before giving up * @param count entries amount * @param queueNames name of queues * @return the head entries */ Map> pollFirstEntriesFromAny(Duration duration, int count, String... queueNames); /** * Removes and returns the head element waiting if necessary for an element to become available. * * @return the head element */ V takeFirst(); /** * Removes and returns the tail element waiting if necessary for an element to become available. * * @return the tail element */ V takeLast(); /** * Subscribes on first elements appeared in this set. * Continuously invokes {@link #takeFirstAsync()} method to get a new element. * * @param consumer - queue elements listener * @return listenerId - id of listener */ int subscribeOnFirstElements(Consumer consumer); /** * Subscribes on last elements appeared in this set. * Continuously invokes {@link #takeLastAsync()} method to get a new element. * * @param consumer - queue elements listener * @return listenerId - id of listener */ int subscribeOnLastElements(Consumer consumer); /** * Un-subscribes defined listener. * * @param listenerId - id of listener */ void unsubscribe(int listenerId); /** * Removes and returns the head element or {@code null} if this sorted set is empty. *

* Requires Redis 5.0.0 and higher. * * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return the head element, * or {@code null} if this sorted set is empty */ V pollFirst(long timeout, TimeUnit unit); /** * Removes and returns the head elements. *

* Requires Redis 7.0.0 and higher. * * @param duration how long to wait before giving up * @param count entries amount * @return the head elements */ List pollFirst(Duration duration, int count); /** * Removes and returns the tail element or {@code null} if this sorted set is empty. *

* Requires Redis 5.0.0 and higher. * * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return the tail element or {@code null} if this sorted set is empty */ V pollLast(long timeout, TimeUnit unit); /** * Removes and returns the tail elements. *

* Requires Redis 7.0.0 and higher. * * @param duration how long to wait before giving up * @return the tail elements */ List pollLast(Duration duration, int count); /** * Removes and returns the head elements of this sorted set. * * @param count - elements amount * @return the head elements of this sorted set */ Collection pollFirst(int count); /** * Removes and returns the tail elements of this sorted set. * * @param count - elements amount * @return the tail elements of this sorted set */ Collection pollLast(int count); /** * Removes and returns the head element or {@code null} if this sorted set is empty. * * @return the head element, * or {@code null} if this sorted set is empty */ V pollFirst(); /** * Removes and returns the head entry (value and its score) or {@code null} if this sorted set is empty. * * @return the head entry, * or {@code null} if this sorted set is empty */ ScoredEntry pollFirstEntry(); /** * Removes and returns the head entries (value and its score) of this sorted set. * * @param count entries amount * @return the head entries of this sorted set */ List> pollFirstEntries(int count); /** * Removes and returns the head entries (value and its score). *

* Requires Redis 7.0.0 and higher. * * @param duration how long to wait before giving up * @param count entries amount * @return the head entries */ List> pollFirstEntries(Duration duration, int count); /** * Removes and returns the tail element or {@code null} if this sorted set is empty. * * @return the tail element or {@code null} if this sorted set is empty */ V pollLast(); /** * Removes and returns the tail entry (value and its score) or {@code null} if this sorted set is empty. * * @return the tail entry or {@code null} if this sorted set is empty */ ScoredEntry pollLastEntry(); /** * Removes and returns the tail entries (value and its score) of this sorted set. * * @param count entries amount * @return the tail entries of this sorted set */ List> pollLastEntries(int count); /** * Removes and returns the head entries (value and its score). *

* Requires Redis 7.0.0 and higher. * * @param duration how long to wait before giving up * @param count entries amount * @return the tail entries */ List> pollLastEntries(Duration duration, int count); /** * Returns the head element or {@code null} if this sorted set is empty. * * @return the head element or {@code null} if this sorted set is empty */ V first(); /** * Returns the head entry (value and its score) or {@code null} if this sorted set is empty. * * @return the head entry or {@code null} if this sorted set is empty */ ScoredEntry firstEntry(); /** * Returns the tail element or {@code null} if this sorted set is empty. * * @return the tail element or {@code null} if this sorted set is empty */ V last(); /** * Returns the tail entry (value and its score) or {@code null} if this sorted set is empty. * * @return the tail entry or {@code null} if this sorted set is empty */ ScoredEntry lastEntry(); /** * Returns score of the tail element or returns {@code null} if this sorted set is empty. * * @return the tail element or {@code null} if this sorted set is empty */ Double firstScore(); /** * Returns score of the head element or returns {@code null} if this sorted set is empty. * * @return the tail element or {@code null} if this sorted set is empty */ Double lastScore(); /** * Returns random element from this sorted set *

* Requires Redis 6.2.0 and higher. * * @return random element */ V random(); /** * Returns random elements from this sorted set limited by count *

* Requires Redis 6.2.0 and higher. * * @param count - values amount to return * @return random elements */ Collection random(int count); /** * Returns random entries from this sorted set limited by count. * Each map entry uses element as key and score as value. *

* Requires Redis 6.2.0 and higher. * * @param count - entries amount to return * @return random entries */ Map randomEntries(int count); /** * Adds all elements contained in the specified map to this sorted set. * Map contains of score mapped by object. * * @param objects - map of elements to add * @return amount of added elements, not including already existing in this sorted set */ int addAll(Map objects); /** * Adds elements to this set only if they haven't been added before. *

* Requires Redis 3.0.2 and higher. * * @param objects map of elements to add * @return amount of added elements */ int addAllIfAbsent(Map objects); /** * Adds elements to this set only if they already exist. *

* Requires Redis 3.0.2 and higher. * * @param objects map of elements to add * @return amount of added elements */ int addAllIfExist(Map objects); /** * Adds elements to this set only if new scores greater than current score of existed elements. *

* Requires Redis 6.2.0 and higher. * * @param objects map of elements to add * @return amount of added elements */ int addAllIfGreater(Map objects); /** * Adds elements to this set only if new scores less than current score of existed elements. *

* Requires Redis 6.2.0 and higher. * * @param objects map of elements to add * @return amount of added elements */ int addAllIfLess(Map objects); /** * Removes values by score range. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @return number of elements removed */ int removeRangeByScore(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); /** * Removes values by rank range. Indexes are zero based. * -1 means the highest score, -2 means the second highest score. * * @param startIndex - start index * @param endIndex - end index * @return number of elements removed */ int removeRangeByRank(int startIndex, int endIndex); /** * Returns rank of value, with the ranks ordered from low to high. * * @param o - object * @return rank or null if value does not exist */ Integer rank(V o); /** * Returns rank and score of specified value, * with the ranks ordered from low to high. * * @param value object * @return ranked entry or null if value does not exist */ RankedEntry rankEntry(V value); /** * Returns rank of value, with the ranks ordered from high to low. * * @param o - object * @return rank or null if value does not exist */ Integer revRank(V o); /** * Returns rank and score of specified value, * with the ranks ordered from high to low. * * @param value object * @return ranked entry or null if value does not exist */ RankedEntry revRankEntry(V value); /** * Returns ranks of elements, with the scores ordered from high to low. * * @param elements - elements * @return ranks or null if value does not exist */ List revRank(Collection elements); /** * Returns score of element or null if it doesn't exist. * * @param o - element * @return score */ Double getScore(V o); /** * Returns scores of elements. * * @param elements - elements * @return element scores */ List getScore(List elements); /** * Adds element to this set, overrides previous score if it has been already added. * * @param score - object score * @param object - object itself * @return true if element has added and false if not. */ boolean add(double score, V object); /** * Adds element to this set, overrides previous score if it has been already added. * Finally return the rank of the item * @param score - object score * @param object - object itself * @return rank */ Integer addAndGetRank(double score, V object); /** * Adds element to this set, overrides previous score if it has been already added. * Finally return the reverse rank of the item * @param score - object score * @param object - object itself * @return reverse rank */ Integer addAndGetRevRank(double score, V object); /** * Adds elements to this set, overrides previous score if it has been already added. * Finally returns reverse rank list of the items * @param map - map of object and scores, make sure to use an ordered map * @return collection of reverse ranks */ List addAndGetRevRank(Map map); /** * Use {@link #addIfAbsent(double, Object)} instead * * @param score - object score * @param object - object itself * @return true if element added and false if not. */ @Deprecated boolean tryAdd(double score, V object); /** * Adds element to this set only if has not been added before. *

* Requires Redis 3.0.2 and higher. * * @param score - object score * @param object - object itself * @return true if element added and false if not. */ boolean addIfAbsent(double score, V object); /** * Adds element to this set only if it's already exists. *

* Requires Redis 3.0.2 and higher. * * @param score - object score * @param object - object itself * @return true if element added and false if not. */ boolean addIfExists(double score, V object); /** * Adds element to this set only if new score less than current score of existed element. *

* Requires Redis 6.2.0 and higher. * * @param score - object score * @param object - object itself * @return true if element added and false if not. */ boolean addIfLess(double score, V object); /** * Adds element to this set only if new score greater than current score of existed element. *

* Requires Redis 6.2.0 and higher. * * @param score - object score * @param object - object itself * @return true if element added and false if not. */ boolean addIfGreater(double score, V object); /** * Replaces a previous oldObject with a newObject. * Returns false if previous object doesn't exist. * * @param oldObject old object * @param newObject new object * @return true if object has been replaced otherwise false. */ boolean replace(V oldObject, V newObject); /** * Returns size of this set. * * @return size */ int size(); /** * Returns true if this set is empty * * @return true if empty */ boolean isEmpty(); /** * Returns stream of elements in this set. * Elements are loaded in batch. Batch size is 10. * * @return stream of elements */ Stream stream(); /** * Returns stream of elements in this set. * If pattern is not null then only elements match this pattern are loaded. * * @param pattern - search pattern * @return stream of elements */ Stream stream(String pattern); /** * Returns stream of elements in this set. * Elements are loaded in batch. Batch size is defined by count param. * * @param count - size of elements batch * @return stream of elements */ Stream stream(int count); /** * Returns stream of elements in this set. * Elements are loaded in batch. Batch size is defined by count param. * If pattern is not null then only elements match this pattern are loaded. * * @param pattern - search pattern * @param count - size of elements batch * @return stream of elements */ Stream stream(String pattern, int count); /** * Returns an iterator over elements in this set. * If pattern is not null then only elements match this pattern are loaded. * * @param pattern - search pattern * @return iterator */ Iterator iterator(String pattern); /** * Returns an iterator over elements in this set. * Elements are loaded in batch. Batch size is defined by count param. * * @param count - size of elements batch * @return iterator */ Iterator iterator(int count); /** * Returns an iterator over elements in this set. * Elements are loaded in batch. Batch size is defined by count param. * If pattern is not null then only elements match this pattern are loaded. * * @param pattern - search pattern * @param count - size of elements batch * @return iterator */ Iterator iterator(String pattern, int count); /** * Returns an iterator over entries (value and its score) in this set. * * @return iterator */ Iterator> entryIterator(); /** * Returns an iterator over entries (value and its score) in this set. * If pattern is not null then only entries match this pattern are loaded. * * @param pattern search pattern * @return iterator */ Iterator> entryIterator(String pattern); /** * Returns an iterator over entries (value and its score) in this set. * Entries are loaded in batch. Batch size is defined by count param. * * @param count size of elements batch * @return iterator */ Iterator> entryIterator(int count); /** * Returns an iterator over entries (value and its score) in this set. * Entries are loaded in batch. Batch size is defined by count param. * If pattern is not null then only entries match this pattern are loaded. * * @param pattern search pattern * @param count size of entries batch * @return iterator */ Iterator> entryIterator(String pattern, int count); /** * Returns element iterator that can be shared across multiple applications. * Creating multiple iterators on the same object with this method will result in a single shared iterator. * See {@linkplain RSet#distributedIterator(String, String, int)} for creating different iterators. * @param count batch size * @return shared elements iterator */ Iterator distributedIterator(int count); /** * Returns iterator over elements that match specified pattern. Iterator can be shared across multiple applications. * Creating multiple iterators on the same object with this method will result in a single shared iterator. * See {@linkplain RSet#distributedIterator(String, String, int)} for creating different iterators. * @param pattern element pattern * @return shared elements iterator */ Iterator distributedIterator(String pattern); /** * Returns iterator over elements that match specified pattern. Iterator can be shared across multiple applications. * Creating multiple iterators on the same object with this method will result in a single shared iterator. * Iterator name must be resolved to the same hash slot as set name. * @param pattern element pattern * @param count batch size * @param iteratorName redis object name to which cursor will be saved * @return shared elements iterator */ Iterator distributedIterator(String iteratorName, String pattern, int count); /** * Returns true if this sorted set contains encoded state of the specified element. * * @param o element whose presence in this collection is to be tested * @return true if this sorted set contains the specified * element and false otherwise */ boolean contains(Object o); /** * Returns this sorted set in array of Object type. * * @return array of values */ Object[] toArray(); /** * Returns this sorted set in array of defined type. * * @param type of element * @param a - instance of array * @return array of values */ T[] toArray(T[] a); /** * Removes a single instance of the specified element from this * sorted set, if it is present. * * @param o element to be removed from this sorted set, if present * @return true if an element was removed as a result of this call */ boolean remove(Object o); /** * Returns true if this sorted set contains all of the elements * in encoded state in the specified collection. * * @param c collection to be checked for containment in this sorted set * @return true if this sorted set contains all of the elements * in the specified collection */ boolean containsAll(Collection c); /** * Removes all of this sorted set's elements that are also contained in the * specified collection. * * @param c collection containing elements to be removed from this collection * @return true if this sorted set changed as a result of the * call */ boolean removeAll(Collection c); /** * Retains only the elements in this sorted set that are contained in the * specified collection. * * @param c collection containing elements to be retained in this collection * @return true if this sorted set changed as a result of the call */ boolean retainAll(Collection c); /** * Removes all elements of this sorted set. */ void clear(); /** * Increases score of specified element by value. * * @param element - element whose score needs to be increased * @param value - value * @return updated score of element */ Double addScore(V element, Number value); /** * Adds score to element and returns its rank * * @param object - object itself * @param value - object score * @return rank */ Integer addScoreAndGetRank(V object, Number value); /** * Adds score to element and returns its reverse rank * * @param object - object itself * @param value - object score * @return reverse rank */ Integer addScoreAndGetRevRank(V object, Number value); /** * Stores to defined ScoredSortedSet values by rank range. Indexes are zero based. * -1 means the highest score, -2 means the second highest score. *

* Requires Redis 6.2.0 and higher. * * @param startIndex - start index * @param endIndex - end index * @return elements */ int rangeTo(String destName, int startIndex, int endIndex); /** * Stores to defined ScoredSortedSet values between startScore and endScore. *

* Requires Redis 6.2.0 and higher. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @return values */ int rangeTo(String destName, double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); /** * Stores to defined ScoredSortedSet values between startScore and endScore. *

* Requires Redis 6.2.0 and higher. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @param offset - offset of sorted data * @param count - amount of sorted data * @return values */ int rangeTo(String destName, double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); /** * Stores to defined ScoredSortedSet values in reversed order by rank range. Indexes are zero based. * -1 means the highest score, -2 means the second highest score. *

* Requires Redis 6.2.0 and higher. * * @param startIndex - start index * @param endIndex - end index * @return elements */ int revRangeTo(String destName, int startIndex, int endIndex); /** * Stores to defined ScoredSortedSet values in reversed order between startScore and endScore. *

* Requires Redis 6.2.0 and higher. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @return values */ int revRangeTo(String destName, double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); /** * Stores to defined ScoredSortedSet values in reversed order between startScore and endScore. *

* Requires Redis 6.2.0 and higher. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @param offset - offset of sorted data * @param count - amount of sorted data * @return values */ int revRangeTo(String destName, double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); /** * Returns values by rank range. Indexes are zero based. * -1 means the highest score, -2 means the second highest score. * * @param startIndex - start index * @param endIndex - end index * @return elements */ Collection valueRange(int startIndex, int endIndex); /** * Returns values by rank range in reverse order. Indexes are zero based. * -1 means the highest score, -2 means the second highest score. * * @param startIndex - start index * @param endIndex - end index * @return elements */ Collection valueRangeReversed(int startIndex, int endIndex); /** * Returns entries (value and its score) by rank range. Indexes are zero based. * -1 means the highest score, -2 means the second highest score. * * @param startIndex - start index * @param endIndex - end index * @return entries */ Collection> entryRange(int startIndex, int endIndex); /** * Returns entries (value and its score) by rank range in reverse order. Indexes are zero based. * -1 means the highest score, -2 means the second highest score. * * @param startIndex - start index * @param endIndex - end index * @return entries */ Collection> entryRangeReversed(int startIndex, int endIndex); /** * Returns all values between startScore and endScore. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @return values */ Collection valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); /** * Returns all values between startScore and endScore in reversed order. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @return values */ Collection valueRangeReversed(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); /** * Returns all entries (value and its score) between startScore and endScore. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @return entries */ Collection> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); /** * Returns all values between startScore and endScore. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @param offset - offset of sorted data * @param count - amount of sorted data * @return values */ Collection valueRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); /** * Returns all values between startScore and endScore in reversed order. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @param offset - offset of sorted data * @param count - amount of sorted data * @return values */ Collection valueRangeReversed(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); /** * Returns all entries (value and its score) between startScore and endScore. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @param offset - offset of sorted data * @param count - amount of sorted data * @return entries */ Collection> entryRange(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); /** * Returns all entries (value and its score) between startScore and endScore in reversed order. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @return entries */ Collection> entryRangeReversed(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); /** * Returns all entries (value and its score) between startScore and endScore in reversed order. * * @param startScore - start score. * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * @param startScoreInclusive - start score inclusive * @param endScore - end score * Use Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY * to define infinity numbers * * @param endScoreInclusive - end score inclusive * @param offset - offset of sorted data * @param count - amount of sorted data * @return entries */ Collection> entryRangeReversed(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive, int offset, int count); /** * Returns the number of elements with a score between startScore and endScore. * * @param startScore - start score * @param startScoreInclusive - start score inclusive * @param endScore - end score * @param endScoreInclusive - end score inclusive * @return count of elements */ int count(double startScore, boolean startScoreInclusive, double endScore, boolean endScoreInclusive); /** * Read all values at once. * * @return values */ Collection readAll(); /** * Intersect provided ScoredSortedSets * and store result to current ScoredSortedSet * * @param names - names of ScoredSortedSet * @return length of intersection */ int intersection(String... names); /** * Intersect provided ScoredSortedSets with defined aggregation method * and store result to current ScoredSortedSet * * @param aggregate - score aggregation mode * @param names - names of ScoredSortedSet * @return length of intersection */ int intersection(Aggregate aggregate, String... names); /** * Intersect provided ScoredSortedSets mapped to weight multiplier * and store result to current ScoredSortedSet * * @param nameWithWeight - name of ScoredSortedSet mapped to weight multiplier * @return length of intersection */ int intersection(Map nameWithWeight); /** * Intersect provided ScoredSortedSets mapped to weight multiplier * with defined aggregation method * and store result to current ScoredSortedSet * * @param aggregate - score aggregation mode * @param nameWithWeight - name of ScoredSortedSet mapped to weight multiplier * @return length of intersection */ int intersection(Aggregate aggregate, Map nameWithWeight); /** * Intersect provided ScoredSortedSets * with current ScoredSortedSet without state change *

* Requires Redis 6.2.0 and higher. * * @param names - names of ScoredSortedSet * @return result of intersection */ Collection readIntersection(String... names); /** * Intersect provided ScoredSortedSets with current ScoredSortedSet using defined aggregation method * without state change *

* Requires Redis 6.2.0 and higher. * * @param aggregate - score aggregation mode * @param names - names of ScoredSortedSet * @return result of intersection */ Collection readIntersection(Aggregate aggregate, String... names); /** * Intersect provided ScoredSortedSets mapped to weight multiplier * with current ScoredSortedSet without state change *

* Requires Redis 6.2.0 and higher. * * @param nameWithWeight - name of ScoredSortedSet mapped to weight multiplier * @return result of intersection */ Collection readIntersection(Map nameWithWeight); /** * Counts elements of set as a result of sets intersection with current set. *

* Requires Redis 7.0.0 and higher. * * @param names - name of sets * @return amount of elements */ Integer countIntersection(String... names); /** * Counts elements of set as a result of sets intersection with current set. *

* Requires Redis 7.0.0 and higher. * * @param names - name of sets * @param limit - sets intersection limit * @return amount of elements */ Integer countIntersection(int limit, String... names); /** * Intersect provided ScoredSortedSets mapped to weight multiplier * with current ScoredSortedSet using defined aggregation method * without state change *

* Requires Redis 6.2.0 and higher. * * @param aggregate - score aggregation mode * @param nameWithWeight - name of ScoredSortedSet mapped to weight multiplier * @return result of intersection */ Collection readIntersection(Aggregate aggregate, Map nameWithWeight); /** * Union provided ScoredSortedSets * and store result to current ScoredSortedSet * * @param names - names of ScoredSortedSet * @return length of union */ int union(String... names); /** * Union provided ScoredSortedSets with defined aggregation method * and store result to current ScoredSortedSet * * @param aggregate - score aggregation mode * @param names - names of ScoredSortedSet * @return length of union */ int union(Aggregate aggregate, String... names); /** * Union provided ScoredSortedSets mapped to weight multiplier * and store result to current ScoredSortedSet * * @param nameWithWeight - name of ScoredSortedSet mapped to weight multiplier * @return length of union */ int union(Map nameWithWeight); /** * Union provided ScoredSortedSets mapped to weight multiplier * with defined aggregation method * and store result to current ScoredSortedSet * * @param aggregate - score aggregation mode * @param nameWithWeight - name of ScoredSortedSet mapped to weight multiplier * @return length of union */ int union(Aggregate aggregate, Map nameWithWeight); /** * Union ScoredSortedSets specified by name with current ScoredSortedSet * without state change. *

* Requires Redis 6.2.0 and higher. * * @param names - names of ScoredSortedSet * @return result of union */ Collection readUnion(String... names); /** * Union ScoredSortedSets specified by name with defined aggregation method * and current ScoredSortedSet without state change. *

* Requires Redis 6.2.0 and higher. * * @param aggregate - score aggregation mode * @param names - names of ScoredSortedSet * @return result of union */ Collection readUnion(Aggregate aggregate, String... names); /** * Union provided ScoredSortedSets mapped to weight multiplier * and current ScoredSortedSet without state change. *

* Requires Redis 6.2.0 and higher. * * @param nameWithWeight - name of ScoredSortedSet mapped to weight multiplier * @return result of union */ Collection readUnion(Map nameWithWeight); /** * Union provided ScoredSortedSets mapped to weight multiplier * with defined aggregation method * and current ScoredSortedSet without state change *

* Requires Redis 6.2.0 and higher. * * @param aggregate - score aggregation mode * @param nameWithWeight - name of ScoredSortedSet mapped to weight multiplier * @return result of union */ Collection readUnion(Aggregate aggregate, Map nameWithWeight); /** * Diff ScoredSortedSets specified by name * with current ScoredSortedSet without state change. *

* Requires Redis 6.2.0 and higher. * * @param names - name of sets * @return result of diff */ Collection readDiff(String... names); /** * Diff provided ScoredSortedSets * and store result to current ScoredSortedSet *

* Requires Redis 6.2.0 and higher. * * @param names - name of sets * @return length of diff */ int diff(String... names); /** * Adds object event listener * * @see org.redisson.api.listener.ScoredSortedSetAddListener * @see org.redisson.api.listener.ScoredSortedSetRemoveListener * @see org.redisson.api.ExpiredObjectListener * @see org.redisson.api.DeletedObjectListener * * @param listener - object event listener * @return listener id */ int addListener(ObjectListener listener); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy