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

org.redisson.RedissonSetMultimapValues Maven / Gradle / Ivy

Go to download

Easy Redis Java client and Real-Time Data Platform. Valkey compatible. Sync/Async/RxJava3/Reactive API. Client side caching. Over 50 Redis based Java objects and services: JCache API, Apache Tomcat, Hibernate, Spring, Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Scheduler, RPC

There is a newer version: 3.40.2
Show newest version
/**
 * Copyright (c) 2013-2024 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;

import org.redisson.api.*;
import org.redisson.api.mapreduce.RCollectionMapReduce;
import org.redisson.client.RedisClient;
import org.redisson.client.codec.Codec;
import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.client.protocol.decoder.*;
import org.redisson.command.CommandAsyncExecutor;
import org.redisson.iterator.RedissonBaseIterator;

import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

/**
 * Set based Multimap Cache values holder
 *
 * @author Nikita Koksharov
 *
 * @param  value
 */
public class RedissonSetMultimapValues extends RedissonExpirable implements RSet {

    private static final RedisCommand> EVAL_SSCAN = new RedisCommand>("EVAL", 
                new ListMultiDecoder2(new ListScanResultReplayDecoder(), new MapValueDecoder(new ObjectListReplayDecoder())));
    
    private final RSet set;
    private final Object key;
    private final String timeoutSetName;
    
    public RedissonSetMultimapValues(Codec codec, CommandAsyncExecutor commandExecutor, String name, String timeoutSetName, Object key) {
        super(codec, commandExecutor, name);
        this.timeoutSetName = timeoutSetName;
        this.key = key;
        this.set = new RedissonSet(codec, commandExecutor, name, null);
    }

    @Override
    public int size() {
        return get(sizeAsync());
    }
    
    @Override
    public  RCollectionMapReduce mapReduce() {
        return null;
    }
    
    @Override
    public boolean tryAdd(V... values) {
        return get(tryAddAsync(values));
    }

    @Override
    public List containsEach(Collection c) {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }

    @Override
    public RFuture tryAddAsync(V... values) {
        return set.tryAddAsync(values);
    }

    @Override
    public RFuture clearExpireAsync() {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }

    @Override
    public RFuture expireAsync(long timeToLive, TimeUnit timeUnit, String param, String... keys) {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }
    
    @Override
    protected RFuture expireAtAsync(long timestamp, String param, String... keys) {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }
    
    @Override
    public RFuture remainTimeToLiveAsync() {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }
    
    @Override
    public RFuture renameAsync(String newName) {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }
    
    @Override
    public RFuture renamenxAsync(String newName) {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }
    
    @Override
    public RFuture deleteAsync() {
        return commandExecutor.evalWriteAsync(getRawName(), codec, RedisCommands.EVAL_BOOLEAN,
                "local expireDate = 92233720368547758; " +
                "local expireDateScore = redis.call('zscore', KEYS[1], ARGV[2]); "
              + "if expireDateScore ~= false then "
                  + "expireDate = tonumber(expireDateScore) "
              + "end; "
              + "if expireDate <= tonumber(ARGV[1]) then "
                  + "return 0;"
              + "end; " +
                "local res = redis.call('zrem', KEYS[1], ARGV[2]); " +
                "if res > 0 then " +
                    "redis.call('del', KEYS[2]); " +
                "end; " +
                "return res; ",
                Arrays.asList(timeoutSetName, getRawName()),
                System.currentTimeMillis(), encodeMapKey(key));
    }

    @Override
    public RFuture sizeInMemoryAsync() {
        List keys = Arrays.asList(getRawName(), timeoutSetName);
        return super.sizeInMemoryAsync(keys);
    }

    @Override
    public RFuture copyAsync(List keys, int database, boolean replace) {
        throw new UnsupportedOperationException();
    }

    @Override
    public RFuture sizeAsync() {
        return commandExecutor.evalReadAsync(getRawName(), codec, RedisCommands.EVAL_INTEGER,
                      "local expireDate = 92233720368547758; " +
                      "local expireDateScore = redis.call('zscore', KEYS[1], ARGV[2]); "
                    + "if expireDateScore ~= false then "
                        + "expireDate = tonumber(expireDateScore) "
                    + "end; "
                    + "if expireDate <= tonumber(ARGV[1]) then "
                        + "return 0;"
                    + "end; "
                    + "return redis.call('scard', KEYS[2]);",
               Arrays.asList(timeoutSetName, getRawName()),
               System.currentTimeMillis(), encodeMapKey(key));
    }

    @Override
    public boolean isEmpty() {
        return size() == 0;
    }

    @Override
    public boolean contains(Object o) {
        return get(containsAsync(o));
    }

    @Override
    public RFuture containsAsync(Object o) {
        return commandExecutor.evalReadAsync(getRawName(), codec, RedisCommands.EVAL_BOOLEAN,
                "local expireDate = 92233720368547758; " +
                "local expireDateScore = redis.call('zscore', KEYS[1], ARGV[2]); "
              + "if expireDateScore ~= false then "
                  + "expireDate = tonumber(expireDateScore) "
              + "end; "
              + "if expireDate <= tonumber(ARGV[1]) then "
                  + "return 0;"
              + "end; "
              + "return redis.call('sismember', KEYS[2], ARGV[3]);",
         Arrays.asList(timeoutSetName, getRawName()),
         System.currentTimeMillis(), encodeMapKey(key), encodeMapValue(o));
    }

    private ListScanResult scanIterator(RedisClient client, String startPos, String pattern, int count) {
        List params = new ArrayList();
        params.add(System.currentTimeMillis());
        params.add(startPos);
        params.add(encodeMapKey(key));
        if (pattern != null) {
            params.add(pattern);
        }
        params.add(count);
        
        RFuture> f = commandExecutor.evalReadAsync(client, getRawName(), codec, EVAL_SSCAN,
                "local expireDate = 92233720368547758; " +
                "local expireDateScore = redis.call('zscore', KEYS[1], ARGV[3]); "
              + "if expireDateScore ~= false then "
                  + "expireDate = tonumber(expireDateScore) "
              + "end; "
              + "if expireDate <= tonumber(ARGV[1]) then "
                  + "return {0, {}};"
              + "end;"

              + "local res; "
              + "if (#ARGV == 5) then "
                  + "res = redis.call('sscan', KEYS[2], ARGV[2], 'match', ARGV[4], 'count', ARGV[5]); "
              + "else "
                  + "res = redis.call('sscan', KEYS[2], ARGV[2], 'count', ARGV[4]); "
              + "end;"

              + "return res;", 
              Arrays.asList(timeoutSetName, getRawName()),
              params.toArray());
      return get(f);
    }

    @Override
    public Iterator iterator(int count) {
        return iterator(null, count);
    }
    
    @Override
    public Iterator iterator(String pattern) {
        return iterator(pattern, 10);
    }

    @Override
    public Iterator distributedIterator(final String pattern) {
        String iteratorName = "__redisson_set_cursor_{" + getRawName() + "}";
        return distributedIterator(iteratorName, pattern, 10);
    }

    @Override
    public Iterator distributedIterator(final int count) {
        String iteratorName = "__redisson_set_cursor_{" + getRawName() + "}";
        return distributedIterator(iteratorName, null, count);
    }

    @Override
    public Iterator distributedIterator(final String iteratorName, final String pattern, final int count) {
        return new RedissonBaseIterator() {

            @Override
            protected ScanResult iterator(RedisClient client, String nextIterPos) {
                return distributedScanIterator(iteratorName, pattern, count);
            }

            @Override
            protected void remove(Object value) {
                RedissonSetMultimapValues.this.remove((V) value);
            }
        };
    }

    private ScanResult distributedScanIterator(String iteratorName, String pattern, int count) {
        return get(distributedScanIteratorAsync(iteratorName, pattern, count));
    }

    private RFuture> distributedScanIteratorAsync(String iteratorName, String pattern, int count) {
        List args = new ArrayList<>(3);
        args.add(System.currentTimeMillis());
        if (pattern != null) {
            args.add(pattern);
        }
        args.add(count);

        return commandExecutor.evalWriteAsync(getRawName(), codec, RedisCommands.EVAL_SCAN,
                "local cursor = redis.call('get', KEYS[3]); "
                + "if cursor ~= false then "
                    + "cursor = tonumber(cursor); "
                + "else"
                    + " cursor = 0;"
                + "end;"
                + "if cursor == -1 then "
                    + "return {0, {}}; "
                + "end;"
                + "local result; "
                + "if (#ARGV == 3) then "
                    + "result = redis.call('sscan', KEYS[2], cursor, 'match', ARGV[2], 'count', ARGV[3]); "
                + "else"
                    + "result = redis.call('sscan', KEYS[2], cursor, 'count', ARGV[2]); "
                + "end;"
                + "local next_cursor = result[1]"
                + "if next_cursor ~= \"0\" then "
                    + "redis.call('setex', KEYS[3], 3600, next_cursor);"
                + "else "
                    + "redis.call('setex', KEYS[3], 3600, -1);"
                + "end; "

                + "local expireDate = 92233720368547758; "
                + "local expirations = redis.call('zmscore', KEYS[1], result[2])"
                + "for i = #expirations, 1, -1 do "
                    + "if expirations[i] ~= false then "
                        + "local expireDate = tonumber(expireDateScore) "
                        + "if expireDate <= tonumber(ARGV[1]) then "
                        +   "table.remove(result[2], i);"
                        + "end; "
                    + "end; "
                + "end; "
                + "return result;",
                Arrays.asList(timeoutSetName, getRawName(), iteratorName), args.toArray());
    }

    @Override
    public Iterator iterator(final String pattern, final int count) {
        return new RedissonBaseIterator() {

            @Override
            protected ListScanResult iterator(RedisClient client, String nextIterPos) {
                return scanIterator(client, nextIterPos, pattern, count);
            }

            @Override
            protected void remove(Object value) {
                RedissonSetMultimapValues.this.remove((V) value);
            }
            
        };
    }
    
    @Override
    public Iterator iterator() {
        return iterator(null);
    }

    @Override
    public RFuture> readAllAsync() {
        return commandExecutor.evalReadAsync(getRawName(), codec, RedisCommands.EVAL_MAP_VALUE_SET,
                "local expireDate = 92233720368547758; " +
                "local expireDateScore = redis.call('zscore', KEYS[1], ARGV[2]); "
              + "if expireDateScore ~= false then "
                  + "expireDate = tonumber(expireDateScore) "
              + "end; "
              + "if expireDate <= tonumber(ARGV[1]) then "
                  + "return {};"
              + "end; "
              + "return redis.call('smembers', KEYS[2]);",
              Arrays.asList(timeoutSetName, getRawName()),
              System.currentTimeMillis(), encodeMapKey(key));
    }

    @Override
    public Set readAll() {
        return get(readAllAsync());
    }

    @Override
    public Object[] toArray() {
        Set res = (Set) get(readAllAsync());
        return res.toArray();
    }

    @Override
    public  T[] toArray(T[] a) {
        Set res = (Set) get(readAllAsync());
        return res.toArray(a);
    }

    @Override
    public boolean add(V e) {
        return set.add(e);
    }

    @Override
    public RFuture addAsync(V e) {
        return set.addAsync(e);
    }

    @Override
    public V removeRandom() {
        return set.removeRandom();
    }

    @Override
    public RFuture removeRandomAsync() {
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SPOP_SINGLE, getRawName());
    }

    @Override
    public Set removeRandom(int amount) {
        return get(removeRandomAsync(amount));
    }

    @Override
    public RFuture> removeRandomAsync(int amount) {
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SPOP, getRawName(), amount);
    }
    
    @Override
    public V random() {
        return get(randomAsync());
    }

    @Override
    public RFuture randomAsync() {
        return commandExecutor.readAsync(getRawName(), codec, RedisCommands.SRANDMEMBER_SINGLE, getRawName());
    }

    @Override
    public Set random(int count) {
        return get(randomAsync(count));
    }

    @Override
    public RFuture> randomAsync(int count) {
        return commandExecutor.readAsync(getRawName(), codec, RedisCommands.SRANDMEMBER, getRawName(), count);
    }
    
    @Override
    public RFuture removeAsync(Object o) {
        return commandExecutor.evalWriteAsync(getRawName(), codec, RedisCommands.EVAL_BOOLEAN,
                "local expireDate = 92233720368547758; " +
                "local expireDateScore = redis.call('zscore', KEYS[1], ARGV[2]); "
              + "if expireDateScore ~= false then "
                  + "expireDate = tonumber(expireDateScore) "
              + "end; "
              + "if expireDate <= tonumber(ARGV[1]) then "
                  + "return 0;"
              + "end; "
              + "return redis.call('srem', KEYS[2], ARGV[3]) > 0 and 1 or 0;",
         Arrays.asList(timeoutSetName, getRawName()),
         System.currentTimeMillis(), encodeMapKey(key), encodeMapValue(o));
    }

    @Override
    public boolean remove(Object value) {
        return get(removeAsync((V) value));
    }

    @Override
    public RFuture moveAsync(String destination, V member) {
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SMOVE, getRawName(), destination, encode(member));
    }

    @Override
    public boolean move(String destination, V member) {
        return get(moveAsync(destination, member));
    }

    @Override
    public boolean containsAll(Collection c) {
        return get(containsAllAsync(c));
    }

    @Override
    public RFuture containsAllAsync(Collection c) {
        List args = new ArrayList(c.size() + 2);
        args.add(System.currentTimeMillis());
        args.add(encodeMapKey(key));
        encodeMapValues(args, c);
        
        return commandExecutor.evalReadAsync(getRawName(), codec, RedisCommands.EVAL_BOOLEAN,
                "local expireDate = 92233720368547758; " +
                "local expireDateScore = redis.call('zscore', KEYS[1], ARGV[2]); "
              + "if expireDateScore ~= false then "
                  + "expireDate = tonumber(expireDateScore) "
              + "end; "
              + "if expireDate <= tonumber(ARGV[1]) then "
                  + "return 0;"
              + "end; " +
                "local s = redis.call('smembers', KEYS[2]);" +
                        "for i = 1, #s, 1 do " +
                            "for j = #ARGV, 3, -1 do "
                            + "if ARGV[j] == s[i] "
                            + "then table.remove(ARGV, j) end "
                        + "end; "
                       + "end;"
                       + "return #ARGV == 2 and 1 or 0; ",
                   Arrays.asList(timeoutSetName, getRawName()), args.toArray());
    }

    @Override
    public boolean addAll(Collection c) {
        if (c.isEmpty()) {
            return false;
        }

        return get(addAllAsync(c));
    }

    @Override
    public RFuture addAllAsync(Collection c) {
        List args = new ArrayList(c.size() + 1);
        args.add(getRawName());
        encodeMapValues(args, c);
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SADD_BOOL, args.toArray());
    }

    @Override
    public RFuture addAllCountedAsync(Collection c) {
        List args = new ArrayList<>(c.size() + 1);
        args.add(getRawName());
        encodeMapValues(args, c);
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SADD, args.toArray());
    }

    @Override
    public int addAllCounted(Collection c) {
        return get(addAllCountedAsync(c));
    }

    @Override
    public int removeAllCounted(Collection c) {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }

    @Override
    public RFuture removeAllCountedAsync(Collection c) {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }

    @Override
    public RFuture> containsEachAsync(Collection c) {
        throw new UnsupportedOperationException("This operation is not supported for SetMultimap values");
    }

    @Override
    public boolean retainAll(Collection c) {
        return get(retainAllAsync(c));
    }

    @Override
    public RFuture retainAllAsync(Collection c) {
        List args = new ArrayList(c.size() + 2);
        args.add(System.currentTimeMillis());
        args.add(encodeMapKey(key));
        encodeMapValues(args, c);

        return commandExecutor.evalWriteAsync(getRawName(), codec, RedisCommands.EVAL_BOOLEAN,
                    "local expireDate = 92233720368547758; " +
                    "local expireDateScore = redis.call('zscore', KEYS[1], ARGV[2]); "
                  + "if expireDateScore ~= false then "
                      + "expireDate = tonumber(expireDateScore) "
                  + "end; "
                  + "if expireDate <= tonumber(ARGV[1]) then "
                      + "return 0;"
                  + "end; " +

                    "local changed = 0 " +
                    "local s = redis.call('smembers', KEYS[2]) "
                       + "local i = 1 "
                       + "while i <= #s do "
                            + "local element = s[i] "
                            + "local isInAgrs = false "
                            + "for j = 3, #ARGV, 1 do "
                                + "if ARGV[j] == element then "
                                    + "isInAgrs = true "
                                    + "break "
                                + "end "
                            + "end "
                            + "if isInAgrs == false then "
                                + "redis.call('SREM', KEYS[2], element) "
                                + "changed = 1 "
                            + "end "
                            + "i = i + 1 "
                       + "end "
                       + "return changed ",
                       Arrays.asList(timeoutSetName, getRawName()), args.toArray());
    }

    @Override
    public RFuture removeAllAsync(Collection c) {
        List args = new ArrayList(c.size() + 2);
        args.add(System.currentTimeMillis());
        args.add(encodeMapKey(key));
        encodeMapValues(args, c);
        
        return commandExecutor.evalWriteAsync(getRawName(), codec, RedisCommands.EVAL_BOOLEAN,
                        "local expireDate = 92233720368547758; " +
                        "local expireDateScore = redis.call('zscore', KEYS[1], ARGV[2]); "
                      + "if expireDateScore ~= false then "
                          + "expireDate = tonumber(expireDateScore) "
                      + "end; "
                      + "if expireDate <= tonumber(ARGV[1]) then "
                          + "return 0;"
                      + "end; " +
                
                        "local v = 0 " +
                        "for i = 3, #ARGV, 1 do "
                            + "if redis.call('srem', KEYS[2], ARGV[i]) == 1 "
                            + "then v = 1 end "
                        +"end "
                       + "return v ",
               Arrays.asList(timeoutSetName, getRawName()), args.toArray());
    }

    @Override
    public RCountDownLatch getCountDownLatch(V value) {
        return set.getCountDownLatch(value);
    }

    @Override
    public RPermitExpirableSemaphore getPermitExpirableSemaphore(V value) {
        return set.getPermitExpirableSemaphore(value);
    }

    @Override
    public RSemaphore getSemaphore(V value) {
        return set.getSemaphore(value);
    }

    @Override
    public RLock getFairLock(V value) {
        return set.getFairLock(value);
    }

    @Override
    public RReadWriteLock getReadWriteLock(V value) {
        return set.getReadWriteLock(value);
    }

    @Override
    public RLock getLock(V value) {
        return set.getLock(value);
    }
    
    @Override
    public boolean removeAll(Collection c) {
        return get(removeAllAsync(c));
    }

    @Override
    public int union(String... names) {
        return get(unionAsync(names));
    }

    @Override
    public RFuture unionAsync(String... names) {
        List args = new ArrayList<>(names.length + 1);
        args.add(getRawName());
        args.addAll(map(names));
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SUNIONSTORE_INT, args.toArray());
    }

    @Override
    public Set readUnion(String... names) {
        return get(readUnionAsync(names));
    }

    @Override
    public RFuture> readUnionAsync(String... names) {
        List args = new ArrayList<>(names.length + 1);
        args.add(getRawName());
        args.addAll(map(names));
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SUNION, args.toArray());
    }

    @Override
    public void clear() {
        delete();
    }

    @Override
    public int diff(String... names) {
        return get(diffAsync(names));
    }

    @Override
    public RFuture diffAsync(String... names) {
        List args = new ArrayList<>(names.length + 1);
        args.add(getRawName());
        args.addAll(map(names));
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SDIFFSTORE_INT, args.toArray());
    }

    @Override
    public Set readDiff(String... names) {
        return get(readDiffAsync(names));
    }

    @Override
    public RFuture> readDiffAsync(String... names) {
        List args = new ArrayList<>(names.length + 1);
        args.add(getRawName());
        args.addAll(map(names));
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SDIFF, args.toArray());
    }

    @Override
    public int intersection(String... names) {
        return get(intersectionAsync(names));
    }

    @Override
    public RFuture intersectionAsync(String... names) {
        List args = new ArrayList<>(names.length + 1);
        args.add(getRawName());
        args.addAll(map(names));
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SINTERSTORE_INT, args.toArray());
    }

    @Override
    public Set readIntersection(String... names) {
        return get(readIntersectionAsync(names));
    }

    @Override
    public RFuture> readIntersectionAsync(String... names) {
        List args = new ArrayList<>(names.length + 1);
        args.add(getRawName());
        args.addAll(map(names));
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SINTER, args.toArray());
    }

    @Override
    public Integer countIntersection(String... names) {
        return get(countIntersectionAsync(names));
    }

    @Override
    public RFuture countIntersectionAsync(String... names) {
        return countIntersectionAsync(0, names);
    }

    @Override
    public Integer countIntersection(int limit, String... names) {
        return get(countIntersectionAsync(limit, names));
    }

    @Override
    public RFuture countIntersectionAsync(int limit, String... names) {
        List args = new ArrayList<>(names.length + 1);
        args.add(names.length + 1);
        args.add(getRawName());
        args.addAll(map(names));
        if (limit > 0) {
            args.add("LIMIT");
            args.add(limit);
        }
        return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.SINTERCARD_INT, args.toArray());
    }

    @Override
    public RFuture> readSortAsync(SortOrder order) {
        return set.readSortAsync(order);
    }

    @Override
    public Set readSort(SortOrder order) {
        return set.readSort(order);
    }

    @Override
    public RFuture> readSortAsync(SortOrder order, int offset, int count) {
        return set.readSortAsync(order, offset, count);
    }

    @Override
    public Set readSort(SortOrder order, int offset, int count) {
        return set.readSort(order, offset, count);
    }

    @Override
    public Set readSort(String byPattern, SortOrder order) {
        return set.readSort(byPattern, order);
    }

    @Override
    public RFuture> readSortAsync(String byPattern, SortOrder order) {
        return set.readSortAsync(byPattern, order);
    }

    @Override
    public Set readSort(String byPattern, SortOrder order, int offset, int count) {
        return set.readSort(byPattern, order, offset, count);
    }

    @Override
    public RFuture> readSortAsync(String byPattern, SortOrder order, int offset, int count) {
        return set.readSortAsync(byPattern, order, offset, count);
    }

    @Override
    public  Collection readSort(String byPattern, List getPatterns, SortOrder order) {
        return set.readSort(byPattern, getPatterns, order);
    }

    @Override
    public  RFuture> readSortAsync(String byPattern, List getPatterns, SortOrder order) {
        return set.readSortAsync(byPattern, getPatterns, order);
    }

    @Override
    public  Collection readSort(String byPattern, List getPatterns, SortOrder order, int offset,
            int count) {
        return set.readSort(byPattern, getPatterns, order, offset, count);
    }

    @Override
    public  RFuture> readSortAsync(String byPattern, List getPatterns, SortOrder order,
            int offset, int count) {
        return set.readSortAsync(byPattern, getPatterns, order, offset, count);
    }

    @Override
    public Set readSortAlpha(SortOrder order) {
        return set.readSortAlpha(order);
    }

    @Override
    public Set readSortAlpha(SortOrder order, int offset, int count) {
        return set.readSortAlpha(order, offset, count);
    }

    @Override
    public Set readSortAlpha(String byPattern, SortOrder order) {
        return set.readSortAlpha(byPattern, order);
    }

    @Override
    public Set readSortAlpha(String byPattern, SortOrder order, int offset, int count) {
        return set.readSortAlpha(byPattern, order, offset, count);
    }

    @Override
    public  Collection readSortAlpha(String byPattern, List getPatterns, SortOrder order) {
        return set.readSortAlpha(byPattern, getPatterns, order);
    }

    @Override
    public  Collection readSortAlpha(String byPattern, List getPatterns, SortOrder order, int offset, int count) {
        return set.readSortAlpha(byPattern, getPatterns, order, offset, count);
    }

    @Override
    public RFuture> readSortAlphaAsync(SortOrder order) {
        return set.readSortAlphaAsync(order);
    }

    @Override
    public RFuture> readSortAlphaAsync(SortOrder order, int offset, int count) {
        return set.readSortAlphaAsync(order, offset, count);
    }

    @Override
    public RFuture> readSortAlphaAsync(String byPattern, SortOrder order) {
        return set.readSortAlphaAsync(byPattern, order);
    }

    @Override
    public RFuture> readSortAlphaAsync(String byPattern, SortOrder order, int offset, int count) {
        return set.readSortAlphaAsync(byPattern, order, offset, count);
    }

    @Override
    public  RFuture> readSortAlphaAsync(String byPattern, List getPatterns, SortOrder order) {
        return set.readSortAlphaAsync(byPattern, getPatterns, order);
    }

    @Override
    public  RFuture> readSortAlphaAsync(String byPattern, List getPatterns, SortOrder order, int offset, int count) {
        return set.readSortAlphaAsync(byPattern, getPatterns, order, offset, count);
    }

    @Override
    public int sortTo(String destName, SortOrder order) {
        return set.sortTo(destName, order);
    }

    @Override
    public RFuture sortToAsync(String destName, SortOrder order) {
        return set.sortToAsync(destName, order);
    }

    @Override
    public int sortTo(String destName, SortOrder order, int offset, int count) {
        return set.sortTo(destName, order, offset, count);
    }

    @Override
    public RFuture sortToAsync(String destName, SortOrder order, int offset, int count) {
        return set.sortToAsync(destName, order, offset, count);
    }

    @Override
    public int sortTo(String destName, String byPattern, SortOrder order) {
        return set.sortTo(destName, byPattern, order);
    }

    @Override
    public RFuture sortToAsync(String destName, String byPattern, SortOrder order) {
        return set.sortToAsync(destName, byPattern, order);
    }

    @Override
    public int sortTo(String destName, String byPattern, SortOrder order, int offset, int count) {
        return set.sortTo(destName, byPattern, order, offset, count);
    }

    @Override
    public RFuture sortToAsync(String destName, String byPattern, SortOrder order, int offset, int count) {
        return set.sortToAsync(destName, byPattern, order, offset, count);
    }

    @Override
    public int sortTo(String destName, String byPattern, List getPatterns, SortOrder order) {
        return set.sortTo(destName, byPattern, getPatterns, order);
    }

    @Override
    public RFuture sortToAsync(String destName, String byPattern, List getPatterns, SortOrder order) {
        return set.sortToAsync(destName, byPattern, getPatterns, order);
    }

    @Override
    public int sortTo(String destName, String byPattern, List getPatterns, SortOrder order, int offset,
            int count) {
        return set.sortTo(destName, byPattern, getPatterns, order, offset, count);
    }

    @Override
    public RFuture sortToAsync(String destName, String byPattern, List getPatterns, SortOrder order,
            int offset, int count) {
        return set.sortToAsync(destName, byPattern, getPatterns, order, offset, count);
    }

    @Override
    public Stream stream(int count) {
        return toStream(iterator(count));
    }

    @Override
    public Stream stream(String pattern, int count) {
        return toStream(iterator(pattern, count));
    }

    @Override
    public Stream stream(String pattern) {
        return toStream(iterator(pattern));
    }
    
}