From a48f117a12881fdf1d3fe16349c860e9491c1c0b Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Sat, 7 Nov 2020 21:54:36 +0100 Subject: [PATCH] Polishing #1450 Revert zinterstore/zunionstore accepting ZAggregateArgs to retain binary compatibility. Remove numkey parameter as this parameter can be calculated from the number of specified keys to simplify API usage. Reinstate builder and override methods in ZStoreArgs to retain binary compatibility. Tweak Javadoc, add author tags and license headers. Fix Coroutines zmscore signature. Original pull request: #1469. --- .../core/AbstractRedisAsyncCommands.java | 53 +++--- .../core/AbstractRedisReactiveCommands.java | 53 +++--- .../io/lettuce/core/RedisCommandBuilder.java | 47 ++--- .../java/io/lettuce/core/ZAggregateArgs.java | 40 +---- src/main/java/io/lettuce/core/ZStoreArgs.java | 160 +++++++++++++++++- .../async/RedisSortedSetAsyncCommands.java | 40 ++--- .../RedisSortedSetReactiveCommands.java | 40 ++--- .../core/api/sync/RedisSortedSetCommands.java | 40 ++--- .../NodeSelectionSortedSetAsyncCommands.java | 40 ++--- .../sync/NodeSelectionSortedSetCommands.java | 40 ++--- .../RedisSortedSetCoroutinesCommands.kt | 50 +++--- .../RedisSortedSetCoroutinesCommandsImpl.kt | 41 +++-- .../core/api/RedisSortedSetCommands.java | 41 ++--- .../SortedSetCommandIntegrationTests.java | 27 ++- 14 files changed, 410 insertions(+), 302 deletions(-) diff --git a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java index 3be735c0d8..b739d3471e 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java @@ -32,8 +32,17 @@ import io.lettuce.core.internal.LettuceAssert; import io.lettuce.core.models.stream.PendingMessage; import io.lettuce.core.models.stream.PendingMessages; -import io.lettuce.core.output.*; -import io.lettuce.core.protocol.*; +import io.lettuce.core.output.CommandOutput; +import io.lettuce.core.output.KeyStreamingChannel; +import io.lettuce.core.output.KeyValueStreamingChannel; +import io.lettuce.core.output.ScoredValueStreamingChannel; +import io.lettuce.core.output.ValueStreamingChannel; +import io.lettuce.core.protocol.AsyncCommand; +import io.lettuce.core.protocol.Command; +import io.lettuce.core.protocol.CommandArgs; +import io.lettuce.core.protocol.CommandType; +import io.lettuce.core.protocol.ProtocolKeyword; +import io.lettuce.core.protocol.RedisCommand; /** * An asynchronous and thread-safe API for a Redis connection. @@ -1794,23 +1803,23 @@ public RedisFuture zincrby(K key, double amount, V member) { } @Override - public RedisFuture> zinter(long numkey, K... keys) { - return dispatch(commandBuilder.zinter(numkey, keys)); + public RedisFuture> zinter(K... keys) { + return dispatch(commandBuilder.zinter(keys)); } @Override - public RedisFuture> zinter(long numkey, ZAggregateArgs aggregateArgs, K... keys) { - return dispatch(commandBuilder.zinter(numkey, aggregateArgs, keys)); + public RedisFuture> zinter(ZAggregateArgs aggregateArgs, K... keys) { + return dispatch(commandBuilder.zinter(aggregateArgs, keys)); } @Override - public RedisFuture>> zinterWithScores(long numkey, K... keys) { - return dispatch(commandBuilder.zinterWithScores(numkey, keys)); + public RedisFuture>> zinterWithScores(K... keys) { + return dispatch(commandBuilder.zinterWithScores(keys)); } @Override - public RedisFuture>> zinterWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys) { - return dispatch(commandBuilder.zinterWithScores(numkey, aggregateArgs, keys)); + public RedisFuture>> zinterWithScores(ZAggregateArgs aggregateArgs, K... keys) { + return dispatch(commandBuilder.zinterWithScores(aggregateArgs, keys)); } @Override @@ -1819,8 +1828,8 @@ public RedisFuture zinterstore(K destination, K... keys) { } @Override - public RedisFuture zinterstore(K destination, ZAggregateArgs aggregateArgs, K... keys) { - return dispatch(commandBuilder.zinterstore(destination, aggregateArgs, keys)); + public RedisFuture zinterstore(K destination, ZStoreArgs zStoreArgs, K... keys) { + return dispatch(commandBuilder.zinterstore(destination, zStoreArgs, keys)); } @Override @@ -2276,23 +2285,23 @@ public RedisFuture zscore(K key, V member) { } @Override - public RedisFuture> zunion(long numkey, K... keys) { - return dispatch(commandBuilder.zunion(numkey, keys)); + public RedisFuture> zunion(K... keys) { + return dispatch(commandBuilder.zunion(keys)); } @Override - public RedisFuture> zunion(long numkey, ZAggregateArgs aggregateArgs, K... keys) { - return dispatch(commandBuilder.zunion(numkey, aggregateArgs, keys)); + public RedisFuture> zunion(ZAggregateArgs aggregateArgs, K... keys) { + return dispatch(commandBuilder.zunion(aggregateArgs, keys)); } @Override - public RedisFuture>> zunionWithScores(long numkey, K... keys) { - return dispatch(commandBuilder.zunionWithScores(numkey, keys)); + public RedisFuture>> zunionWithScores(K... keys) { + return dispatch(commandBuilder.zunionWithScores(keys)); } @Override - public RedisFuture>> zunionWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys) { - return dispatch(commandBuilder.zunionWithScores(numkey, aggregateArgs, keys)); + public RedisFuture>> zunionWithScores(ZAggregateArgs aggregateArgs, K... keys) { + return dispatch(commandBuilder.zunionWithScores(aggregateArgs, keys)); } @Override @@ -2301,8 +2310,8 @@ public RedisFuture zunionstore(K destination, K... keys) { } @Override - public RedisFuture zunionstore(K destination, ZAggregateArgs aggregateArgs, K... keys) { - return dispatch(commandBuilder.zunionstore(destination, aggregateArgs, keys)); + public RedisFuture zunionstore(K destination, ZStoreArgs zStoreArgs, K... keys) { + return dispatch(commandBuilder.zunionstore(destination, zStoreArgs, keys)); } private byte[] encodeScript(String script) { diff --git a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java index 044f9fd192..1c4880f7e8 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java @@ -34,8 +34,17 @@ import io.lettuce.core.internal.LettuceAssert; import io.lettuce.core.models.stream.PendingMessage; import io.lettuce.core.models.stream.PendingMessages; -import io.lettuce.core.output.*; -import io.lettuce.core.protocol.*; +import io.lettuce.core.output.CommandOutput; +import io.lettuce.core.output.KeyStreamingChannel; +import io.lettuce.core.output.KeyValueStreamingChannel; +import io.lettuce.core.output.ScoredValueStreamingChannel; +import io.lettuce.core.output.ValueStreamingChannel; +import io.lettuce.core.protocol.Command; +import io.lettuce.core.protocol.CommandArgs; +import io.lettuce.core.protocol.CommandType; +import io.lettuce.core.protocol.ProtocolKeyword; +import io.lettuce.core.protocol.RedisCommand; +import io.lettuce.core.protocol.TracedCommand; import io.lettuce.core.resource.ClientResources; import io.lettuce.core.tracing.TraceContext; import io.lettuce.core.tracing.TraceContextProvider; @@ -1867,23 +1876,23 @@ public Mono zincrby(K key, double amount, V member) { } @Override - public Flux zinter(long numkey, K... keys) { - return createDissolvingFlux(() -> commandBuilder.zinter(numkey, keys)); + public Flux zinter(K... keys) { + return createDissolvingFlux(() -> commandBuilder.zinter(keys)); } @Override - public Flux zinter(long numkey, ZAggregateArgs aggregateArgs, K... keys) { - return createDissolvingFlux(() -> commandBuilder.zinter(numkey, aggregateArgs, keys)); + public Flux zinter(ZAggregateArgs aggregateArgs, K... keys) { + return createDissolvingFlux(() -> commandBuilder.zinter(aggregateArgs, keys)); } @Override - public Flux> zinterWithScores(long numkey, K... keys) { - return createDissolvingFlux(() -> commandBuilder.zinterWithScores(numkey, keys)); + public Flux> zinterWithScores(K... keys) { + return createDissolvingFlux(() -> commandBuilder.zinterWithScores(keys)); } @Override - public Flux> zinterWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys) { - return createDissolvingFlux(() -> commandBuilder.zinterWithScores(numkey, aggregateArgs, keys)); + public Flux> zinterWithScores(ZAggregateArgs aggregateArgs, K... keys) { + return createDissolvingFlux(() -> commandBuilder.zinterWithScores(aggregateArgs, keys)); } @Override @@ -1892,8 +1901,8 @@ public Mono zinterstore(K destination, K... keys) { } @Override - public Mono zinterstore(K destination, ZAggregateArgs aggregateArgs, K... keys) { - return createMono(() -> commandBuilder.zinterstore(destination, aggregateArgs, keys)); + public Mono zinterstore(K destination, ZStoreArgs zStoreArgs, K... keys) { + return createMono(() -> commandBuilder.zinterstore(destination, zStoreArgs, keys)); } @Override @@ -2341,23 +2350,23 @@ public Mono zscore(K key, V member) { } @Override - public Flux zunion(long numkey, K... keys) { - return createDissolvingFlux(() -> commandBuilder.zunion(numkey, keys)); + public Flux zunion(K... keys) { + return createDissolvingFlux(() -> commandBuilder.zunion(keys)); } @Override - public Flux zunion(long numkey, ZAggregateArgs aggregateArgs, K... keys) { - return createDissolvingFlux(() -> commandBuilder.zunion(numkey, aggregateArgs, keys)); + public Flux zunion(ZAggregateArgs aggregateArgs, K... keys) { + return createDissolvingFlux(() -> commandBuilder.zunion(aggregateArgs, keys)); } @Override - public Flux> zunionWithScores(long numkey, K... keys) { - return createDissolvingFlux(() -> commandBuilder.zunionWithScores(numkey, keys)); + public Flux> zunionWithScores(K... keys) { + return createDissolvingFlux(() -> commandBuilder.zunionWithScores(keys)); } @Override - public Flux> zunionWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys) { - return createDissolvingFlux(() -> commandBuilder.zunionWithScores(numkey, aggregateArgs, keys)); + public Flux> zunionWithScores(ZAggregateArgs aggregateArgs, K... keys) { + return createDissolvingFlux(() -> commandBuilder.zunionWithScores(aggregateArgs, keys)); } @Override @@ -2366,8 +2375,8 @@ public Mono zunionstore(K destination, K... keys) { } @Override - public Mono zunionstore(K destination, ZAggregateArgs aggregateArgs, K... keys) { - return createMono(() -> commandBuilder.zunionstore(destination, aggregateArgs, keys)); + public Mono zunionstore(K destination, ZStoreArgs zStoreArgs, K... keys) { + return createMono(() -> commandBuilder.zunionstore(destination, zStoreArgs, keys)); } private byte[] encodeScript(String script) { diff --git a/src/main/java/io/lettuce/core/RedisCommandBuilder.java b/src/main/java/io/lettuce/core/RedisCommandBuilder.java index ec9b0f5e70..c9ae540cf8 100644 --- a/src/main/java/io/lettuce/core/RedisCommandBuilder.java +++ b/src/main/java/io/lettuce/core/RedisCommandBuilder.java @@ -15,12 +15,16 @@ */ package io.lettuce.core; -import static io.lettuce.core.internal.LettuceStrings.string; +import static io.lettuce.core.internal.LettuceStrings.*; import static io.lettuce.core.protocol.CommandKeyword.*; import static io.lettuce.core.protocol.CommandType.*; import java.nio.ByteBuffer; -import java.util.*; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; import io.lettuce.core.Range.Boundary; import io.lettuce.core.XReadArgs.StreamOffset; @@ -30,7 +34,11 @@ import io.lettuce.core.models.stream.PendingMessage; import io.lettuce.core.models.stream.PendingMessages; import io.lettuce.core.output.*; -import io.lettuce.core.protocol.*; +import io.lettuce.core.protocol.BaseRedisCommandBuilder; +import io.lettuce.core.protocol.Command; +import io.lettuce.core.protocol.CommandArgs; +import io.lettuce.core.protocol.CommandType; +import io.lettuce.core.protocol.RedisCommand; /** * @param @@ -39,6 +47,7 @@ * @author Zhang Jessey * @author Tugdual Grall * @author dengliming + * @author Mikhael Sokolov */ @SuppressWarnings({ "unchecked", "varargs" }) class RedisCommandBuilder extends BaseRedisCommandBuilder { @@ -2609,32 +2618,32 @@ Command zincrby(K key, double amount, V member) { return createCommand(ZINCRBY, new DoubleOutput<>(codec), args); } - Command> zinter(long numkey, K... keys) { + Command> zinter(K... keys) { notEmpty(keys); - return zinter(numkey, new ZAggregateArgs(), keys); + return zinter(new ZAggregateArgs(), keys); } - Command> zinter(long numkey, ZAggregateArgs aggregateArgs, K... keys) { + Command> zinter(ZAggregateArgs aggregateArgs, K... keys) { notEmpty(keys); CommandArgs args = new CommandArgs<>(codec); - args.add(numkey).addKeys(keys); + args.add(keys.length).addKeys(keys); aggregateArgs.build(args); return createCommand(ZINTER, new ValueListOutput<>(codec), args); } - Command>> zinterWithScores(long numkey, K... keys) { + Command>> zinterWithScores(K... keys) { notEmpty(keys); - return zinterWithScores(numkey, new ZAggregateArgs(), keys); + return zinterWithScores(new ZAggregateArgs(), keys); } - Command>> zinterWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys) { + Command>> zinterWithScores(ZAggregateArgs aggregateArgs, K... keys) { notEmpty(keys); CommandArgs args = new CommandArgs<>(codec); - args.add(numkey).addKeys(keys).add(WITHSCORES); + args.add(keys.length).addKeys(keys).add(WITHSCORES); aggregateArgs.build(args); return createCommand(ZINTER, new ScoredValueListOutput<>(codec), args); } @@ -3260,32 +3269,32 @@ Command zscore(K key, V member) { return createCommand(ZSCORE, new DoubleOutput<>(codec), key, member); } - Command> zunion(long numkey, K... keys) { + Command> zunion(K... keys) { notEmpty(keys); - return zunion(numkey, new ZAggregateArgs(), keys); + return zunion(new ZAggregateArgs(), keys); } - Command> zunion(long numkey, ZAggregateArgs aggregateArgs, K... keys) { + Command> zunion(ZAggregateArgs aggregateArgs, K... keys) { notEmpty(keys); CommandArgs args = new CommandArgs<>(codec); - args.add(numkey).addKeys(keys); + args.add(keys.length).addKeys(keys); aggregateArgs.build(args); return createCommand(ZUNION, new ValueListOutput<>(codec), args); } - Command>> zunionWithScores(long numkey, K... keys) { + Command>> zunionWithScores(K... keys) { notEmpty(keys); - return zunionWithScores(numkey, new ZAggregateArgs(), keys); + return zunionWithScores(new ZAggregateArgs(), keys); } - Command>> zunionWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys) { + Command>> zunionWithScores(ZAggregateArgs aggregateArgs, K... keys) { notEmpty(keys); CommandArgs args = new CommandArgs<>(codec); - args.add(numkey).addKeys(keys).add(WITHSCORES); + args.add(keys.length).addKeys(keys).add(WITHSCORES); aggregateArgs.build(args); return createCommand(ZUNION, new ScoredValueListOutput<>(codec), args); } diff --git a/src/main/java/io/lettuce/core/ZAggregateArgs.java b/src/main/java/io/lettuce/core/ZAggregateArgs.java index 6e815b1dd6..f3232398e7 100644 --- a/src/main/java/io/lettuce/core/ZAggregateArgs.java +++ b/src/main/java/io/lettuce/core/ZAggregateArgs.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2020 the original author or authors. + * Copyright 2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ * @author Xy Ma * @author Mark Paluch * @author Mikhael Sokolov + * @since 6.1 */ public class ZAggregateArgs implements CompositeArgument { @@ -55,18 +56,6 @@ public static class Builder { Builder() { } - /** - * Creates new {@link ZAggregateArgs} setting {@literal WEIGHTS} using long. - * - * @return new {@link ZAddArgs} with {@literal WEIGHTS} set. - * @see ZAggregateArgs#weights(long[]) - * @deprecated use {@link #weights(double...)}. - */ - @Deprecated - public static ZAggregateArgs weights(long[] weights) { - return new ZAggregateArgs().weights(toDoubleArray(weights)); - } - /** * Creates new {@link ZAggregateArgs} setting {@literal WEIGHTS}. * @@ -109,21 +98,6 @@ public static ZAggregateArgs max() { } - /** - * Specify a multiplication factor for each input sorted set. - * - * @param weights must not be {@code null}. - * @return {@code this} {@link ZAggregateArgs}. - * @deprecated use {@link #weights(double...)} - */ - @Deprecated - public static ZAggregateArgs weights(long[] weights) { - - LettuceAssert.notNull(weights, "Weights must not be null"); - - return new ZAggregateArgs().weights(toDoubleArray(weights)); - } - /** * Specify a multiplication factor for each input sorted set. * @@ -175,15 +149,7 @@ public ZAggregateArgs max() { return this; } - private static double[] toDoubleArray(long[] weights) { - - double result[] = new double[weights.length]; - for (int i = 0; i < weights.length; i++) { - result[i] = weights[i]; - } - return result; - } - + @Override public void build(CommandArgs args) { if (weights != null && !weights.isEmpty()) { diff --git a/src/main/java/io/lettuce/core/ZStoreArgs.java b/src/main/java/io/lettuce/core/ZStoreArgs.java index 9a718315bd..08945437ea 100644 --- a/src/main/java/io/lettuce/core/ZStoreArgs.java +++ b/src/main/java/io/lettuce/core/ZStoreArgs.java @@ -1,9 +1,29 @@ +/* + * Copyright 2011-2020 the original author or authors. + * + * 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 + * + * https://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 io.lettuce.core; +import io.lettuce.core.internal.LettuceAssert; + /** - * Argument list builder for the Redis ZUNIONSTORE - * and ZINTERSTORE commands. - * Static import the methods from {@link Builder} an chain the method calls: {@code weights(1, 2).max()}. + * Argument list builder for the Redis ZUNIONSTORE and + * ZINTERSTORE commands. Static import the methods from {@link Builder} and + * chain the method calls: {@code weights(1, 2).max()}. + * + *

+ * {@link ZAddArgs} is a mutable object and instances should be used only once to avoid shared mutable state. * * @author Will Glozer * @author Xy Ma @@ -12,12 +32,142 @@ */ public class ZStoreArgs extends ZAggregateArgs { - public static class Builder extends ZAggregateArgs.Builder { + /** + * Builder entry points for {@link ScanArgs}. + */ + public static class Builder { /** * Utility constructor. */ - Builder() { + private Builder() { + } + + /** + * Creates new {@link ZStoreArgs} setting {@literal WEIGHTS} using long. + * + * @return new {@link ZAddArgs} with {@literal WEIGHTS} set. + * @see ZStoreArgs#weights(long[]) + * @deprecated use {@link #weights(double...)}. + */ + @Deprecated + public static ZStoreArgs weights(long[] weights) { + return new ZStoreArgs().weights(toDoubleArray(weights)); + } + + /** + * Creates new {@link ZStoreArgs} setting {@literal WEIGHTS}. + * + * @return new {@link ZAddArgs} with {@literal WEIGHTS} set. + * @see ZStoreArgs#weights(double...) + */ + public static ZStoreArgs weights(double... weights) { + return new ZStoreArgs().weights(weights); + } + + /** + * Creates new {@link ZStoreArgs} setting {@literal AGGREGATE SUM}. + * + * @return new {@link ZAddArgs} with {@literal AGGREGATE SUM} set. + * @see ZStoreArgs#sum() + */ + public static ZStoreArgs sum() { + return new ZStoreArgs().sum(); + } + + /** + * Creates new {@link ZStoreArgs} setting {@literal AGGREGATE MIN}. + * + * @return new {@link ZAddArgs} with {@literal AGGREGATE MIN} set. + * @see ZStoreArgs#sum() + */ + public static ZStoreArgs min() { + return new ZStoreArgs().min(); + } + + /** + * Creates new {@link ZStoreArgs} setting {@literal AGGREGATE MAX}. + * + * @return new {@link ZAddArgs} with {@literal AGGREGATE MAX} set. + * @see ZStoreArgs#sum() + */ + public static ZStoreArgs max() { + return new ZStoreArgs().max(); + } + + } + + /** + * Specify a multiplication factor for each input sorted set. + * + * @param weights must not be {@code null}. + * @return {@code this} {@link ZStoreArgs}. + * @deprecated use {@link #weights(double...)} + */ + @Deprecated + public static ZStoreArgs weights(long[] weights) { + + LettuceAssert.notNull(weights, "Weights must not be null"); + + return new ZStoreArgs().weights(toDoubleArray(weights)); + } + + /** + * Specify a multiplication factor for each input sorted set. + * + * @param weights must not be {@code null}. + * @return {@code this} {@link ZStoreArgs}. + */ + @Override + public ZStoreArgs weights(double... weights) { + + super.weights(weights); + return this; + } + + /** + * Aggregate scores of elements existing across multiple sets by summing up. + * + * @return {@code this} {@link ZStoreArgs}. + */ + @Override + public ZStoreArgs sum() { + + super.sum(); + return this; + } + + /** + * Aggregate scores of elements existing across multiple sets by using the lowest score. + * + * @return {@code this} {@link ZStoreArgs}. + */ + @Override + public ZStoreArgs min() { + + super.min(); + return this; + } + + /** + * Aggregate scores of elements existing across multiple sets by using the highest score. + * + * @return {@code this} {@link ZStoreArgs}. + */ + @Override + public ZStoreArgs max() { + + super.max(); + return this; + } + + private static double[] toDoubleArray(long[] weights) { + + double[] result = new double[weights.length]; + for (int i = 0; i < weights.length; i++) { + result[i] = weights[i]; } + return result; } + } diff --git a/src/main/java/io/lettuce/core/api/async/RedisSortedSetAsyncCommands.java b/src/main/java/io/lettuce/core/api/async/RedisSortedSetAsyncCommands.java index 2db50757f4..34a0737fb7 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisSortedSetAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisSortedSetAsyncCommands.java @@ -212,44 +212,40 @@ public interface RedisSortedSetAsyncCommands { /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - RedisFuture> zinter(long numkey, K... keys); + RedisFuture> zinter(K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - RedisFuture> zinter(long numkey, ZAggregateArgs aggregateArgs, K... keys); + RedisFuture> zinter(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - RedisFuture>> zinterWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + RedisFuture>> zinterWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - RedisFuture>> zinterWithScores(long numkey, K... keys); + RedisFuture>> zinterWithScores(K... keys); /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. @@ -264,11 +260,11 @@ public interface RedisSortedSetAsyncCommands { * Intersect multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - RedisFuture zinterstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + RedisFuture zinterstore(K destination, ZStoreArgs storeArgs, K... keys); /** * Count the number of members in a sorted set between a given lexicographical range. @@ -1285,44 +1281,40 @@ public interface RedisSortedSetAsyncCommands { /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - RedisFuture> zunion(long numkey, K... keys); + RedisFuture> zunion(K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - RedisFuture> zunion(long numkey, ZAggregateArgs aggregateArgs, K... keys); + RedisFuture> zunion(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - RedisFuture>> zunionWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + RedisFuture>> zunionWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - RedisFuture>> zunionWithScores(long numkey, K... keys); + RedisFuture>> zunionWithScores(K... keys); /** * Add multiple sorted sets and store the resulting sorted set in a new key. @@ -1337,9 +1329,9 @@ public interface RedisSortedSetAsyncCommands { * Add multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - RedisFuture zunionstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + RedisFuture zunionstore(K destination, ZStoreArgs storeArgs, K... keys); } diff --git a/src/main/java/io/lettuce/core/api/reactive/RedisSortedSetReactiveCommands.java b/src/main/java/io/lettuce/core/api/reactive/RedisSortedSetReactiveCommands.java index b4a5f0b9ca..c0b4d7f397 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisSortedSetReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisSortedSetReactiveCommands.java @@ -214,44 +214,40 @@ public interface RedisSortedSetReactiveCommands { /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return V array-reply list of elements. * @since 6.1 */ - Flux zinter(long numkey, K... keys); + Flux zinter(K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return V array-reply list of elements. * @since 6.1 */ - Flux zinter(long numkey, ZAggregateArgs aggregateArgs, K... keys); + Flux zinter(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return V array-reply list of scored values. * @since 6.1 */ - Flux> zinterWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + Flux> zinterWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return V array-reply list of scored values. * @since 6.1 */ - Flux> zinterWithScores(long numkey, K... keys); + Flux> zinterWithScores(K... keys); /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. @@ -266,11 +262,11 @@ public interface RedisSortedSetReactiveCommands { * Intersect multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - Mono zinterstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + Mono zinterstore(K destination, ZStoreArgs storeArgs, K... keys); /** * Count the number of members in a sorted set between a given lexicographical range. @@ -1335,44 +1331,40 @@ public interface RedisSortedSetReactiveCommands { /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return V array-reply list of elements. * @since 6.1 */ - Flux zunion(long numkey, K... keys); + Flux zunion(K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return V array-reply list of elements. * @since 6.1 */ - Flux zunion(long numkey, ZAggregateArgs aggregateArgs, K... keys); + Flux zunion(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return V array-reply list of scored values. * @since 6.1 */ - Flux> zunionWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + Flux> zunionWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return V array-reply list of scored values. * @since 6.1 */ - Flux> zunionWithScores(long numkey, K... keys); + Flux> zunionWithScores(K... keys); /** * Add multiple sorted sets and store the resulting sorted set in a new key. @@ -1387,9 +1379,9 @@ public interface RedisSortedSetReactiveCommands { * Add multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - Mono zunionstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + Mono zunionstore(K destination, ZStoreArgs storeArgs, K... keys); } diff --git a/src/main/java/io/lettuce/core/api/sync/RedisSortedSetCommands.java b/src/main/java/io/lettuce/core/api/sync/RedisSortedSetCommands.java index 69cba318e8..a72bba3755 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisSortedSetCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisSortedSetCommands.java @@ -212,44 +212,40 @@ public interface RedisSortedSetCommands { /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - List zinter(long numkey, K... keys); + List zinter(K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - List zinter(long numkey, ZAggregateArgs aggregateArgs, K... keys); + List zinter(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - List> zinterWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + List> zinterWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - List> zinterWithScores(long numkey, K... keys); + List> zinterWithScores(K... keys); /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. @@ -264,11 +260,11 @@ public interface RedisSortedSetCommands { * Intersect multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - Long zinterstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + Long zinterstore(K destination, ZStoreArgs storeArgs, K... keys); /** * Count the number of members in a sorted set between a given lexicographical range. @@ -1285,44 +1281,40 @@ public interface RedisSortedSetCommands { /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - List zunion(long numkey, K... keys); + List zunion(K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - List zunion(long numkey, ZAggregateArgs aggregateArgs, K... keys); + List zunion(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - List> zunionWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + List> zunionWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - List> zunionWithScores(long numkey, K... keys); + List> zunionWithScores(K... keys); /** * Add multiple sorted sets and store the resulting sorted set in a new key. @@ -1337,9 +1329,9 @@ public interface RedisSortedSetCommands { * Add multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - Long zunionstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + Long zunionstore(K destination, ZStoreArgs storeArgs, K... keys); } diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionSortedSetAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionSortedSetAsyncCommands.java index bbc2296b5b..2184098223 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionSortedSetAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionSortedSetAsyncCommands.java @@ -212,44 +212,40 @@ public interface NodeSelectionSortedSetAsyncCommands { /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - AsyncExecutions> zinter(long numkey, K... keys); + AsyncExecutions> zinter(K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - AsyncExecutions> zinter(long numkey, ZAggregateArgs aggregateArgs, K... keys); + AsyncExecutions> zinter(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - AsyncExecutions>> zinterWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + AsyncExecutions>> zinterWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - AsyncExecutions>> zinterWithScores(long numkey, K... keys); + AsyncExecutions>> zinterWithScores(K... keys); /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. @@ -264,11 +260,11 @@ public interface NodeSelectionSortedSetAsyncCommands { * Intersect multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - AsyncExecutions zinterstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + AsyncExecutions zinterstore(K destination, ZStoreArgs storeArgs, K... keys); /** * Count the number of members in a sorted set between a given lexicographical range. @@ -1285,44 +1281,40 @@ public interface NodeSelectionSortedSetAsyncCommands { /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - AsyncExecutions> zunion(long numkey, K... keys); + AsyncExecutions> zunion(K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - AsyncExecutions> zunion(long numkey, ZAggregateArgs aggregateArgs, K... keys); + AsyncExecutions> zunion(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - AsyncExecutions>> zunionWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + AsyncExecutions>> zunionWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - AsyncExecutions>> zunionWithScores(long numkey, K... keys); + AsyncExecutions>> zunionWithScores(K... keys); /** * Add multiple sorted sets and store the resulting sorted set in a new key. @@ -1337,9 +1329,9 @@ public interface NodeSelectionSortedSetAsyncCommands { * Add multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - AsyncExecutions zunionstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + AsyncExecutions zunionstore(K destination, ZStoreArgs storeArgs, K... keys); } diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionSortedSetCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionSortedSetCommands.java index 8521633874..98ea54e05a 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionSortedSetCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionSortedSetCommands.java @@ -212,44 +212,40 @@ public interface NodeSelectionSortedSetCommands { /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - Executions> zinter(long numkey, K... keys); + Executions> zinter(K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - Executions> zinter(long numkey, ZAggregateArgs aggregateArgs, K... keys); + Executions> zinter(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - Executions>> zinterWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + Executions>> zinterWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - Executions>> zinterWithScores(long numkey, K... keys); + Executions>> zinterWithScores(K... keys); /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. @@ -264,11 +260,11 @@ public interface NodeSelectionSortedSetCommands { * Intersect multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - Executions zinterstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + Executions zinterstore(K destination, ZStoreArgs storeArgs, K... keys); /** * Count the number of members in a sorted set between a given lexicographical range. @@ -1285,44 +1281,40 @@ public interface NodeSelectionSortedSetCommands { /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - Executions> zunion(long numkey, K... keys); + Executions> zunion(K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - Executions> zunion(long numkey, ZAggregateArgs aggregateArgs, K... keys); + Executions> zunion(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - Executions>> zunionWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + Executions>> zunionWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - Executions>> zunionWithScores(long numkey, K... keys); + Executions>> zunionWithScores(K... keys); /** * Add multiple sorted sets and store the resulting sorted set in a new key. @@ -1337,9 +1329,9 @@ public interface NodeSelectionSortedSetCommands { * Add multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - Executions zunionstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + Executions zunionstore(K destination, ZStoreArgs storeArgs, K... keys); } diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommands.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommands.kt index 82657b508a..87fa6446db 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommands.kt @@ -187,44 +187,43 @@ interface RedisSortedSetCoroutinesCommands { /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List array-reply list of elements. * @since 6.1 */ - fun zinter(numkey: Long, vararg keys: K): Flow + fun zinter(vararg keys: K): Flow /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List array-reply list of elements. * @since 6.1 */ - fun zinter(numkey: Long, aggregateArgs: ZAggregateArgs, vararg keys: K): Flow + fun zinter(aggregateArgs: ZAggregateArgs, vararg keys: K): Flow /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List array-reply list of scored values. * @since 6.1 */ - fun zinterWithScores(numkey: Long, aggregateArgs: ZAggregateArgs, vararg keys: K): Flow> + fun zinterWithScores( + aggregateArgs: ZAggregateArgs, + vararg keys: K + ): Flow> /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List array-reply list of scored values. * @since 6.1 */ - fun zinterWithScores(numkey: Long, vararg keys: K): Flow> + fun zinterWithScores(vararg keys: K): Flow> /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. @@ -239,11 +238,11 @@ interface RedisSortedSetCoroutinesCommands { * Intersect multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at `destination`. */ - suspend fun zinterstore(destination: K, aggregateArgs: ZAggregateArgs, vararg keys: K): Long? + suspend fun zinterstore(destination: K, storeArgs: ZStoreArgs, vararg keys: K): Long? /** * Count the number of members in a sorted set between a given lexicographical range. @@ -260,10 +259,10 @@ interface RedisSortedSetCoroutinesCommands { * * @param key the key. * @param members the member type: value. - * @return List array-reply list of scores or nil associated with the specified member values. + * @return List array-reply list of scores or nil associated with the specified member values. * @since 6.1 */ - suspend fun zmscore(key: K, vararg members: V): List + suspend fun zmscore(key: K, vararg members: V): List /** * Removes and returns up to count members with the lowest scores in the sorted set stored at key. @@ -579,44 +578,43 @@ interface RedisSortedSetCoroutinesCommands { /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List array-reply list of elements. * @since 6.1 */ - fun zunion(numkey: Long, vararg keys: K): Flow + fun zunion(vararg keys: K): Flow /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List array-reply list of elements. * @since 6.1 */ - fun zunion(numkey: Long, aggregateArgs: ZAggregateArgs, vararg keys: K): Flow + fun zunion(aggregateArgs: ZAggregateArgs, vararg keys: K): Flow /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List array-reply list of scored values. * @since 6.1 */ - fun zunionWithScores(numkey: Long, aggregateArgs: ZAggregateArgs, vararg keys: K): Flow> + fun zunionWithScores( + aggregateArgs: ZAggregateArgs, + vararg keys: K + ): Flow> /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List array-reply list of scored values. * @since 6.1 */ - fun zunionWithScores(numkey: Long, vararg keys: K): Flow> + fun zunionWithScores(vararg keys: K): Flow> /** * Add multiple sorted sets and store the resulting sorted set in a new key. @@ -631,11 +629,11 @@ interface RedisSortedSetCoroutinesCommands { * Add multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at `destination`. */ - suspend fun zunionstore(destination: K, aggregateArgs: ZAggregateArgs, vararg keys: K): Long? + suspend fun zunionstore(destination: K, storeArgs: ZStoreArgs, vararg keys: K): Long? } diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommandsImpl.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommandsImpl.kt index 23fdcb85c3..0b137f0f48 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommandsImpl.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisSortedSetCoroutinesCommandsImpl.kt @@ -62,21 +62,31 @@ internal class RedisSortedSetCoroutinesCommandsImpl(internal v override suspend fun zincrby(key: K, amount: Double, member: V): Double? = ops.zincrby(key, amount, member).awaitFirstOrNull() - override fun zinter(numkey: Long, vararg keys: K): Flow = ops.zinter(numkey, *keys).asFlow() + override fun zinter(vararg keys: K): Flow = ops.zinter(*keys).asFlow() - override fun zinter(numkey: Long, aggregateArgs: ZAggregateArgs, vararg keys: K): Flow = ops.zinter(numkey, aggregateArgs, *keys).asFlow() + override fun zinter(aggregateArgs: ZAggregateArgs, vararg keys: K): Flow = + ops.zinter(aggregateArgs, *keys).asFlow() - override fun zinterWithScores(numkey: Long, vararg keys: K): Flow> = ops.zinterWithScores(numkey, *keys).asFlow() + override fun zinterWithScores(vararg keys: K): Flow> = + ops.zinterWithScores(*keys).asFlow() - override fun zinterWithScores(numkey: Long, aggregateArgs: ZAggregateArgs, vararg keys: K): Flow> = ops.zinterWithScores(numkey, aggregateArgs, *keys).asFlow() + override fun zinterWithScores( + aggregateArgs: ZAggregateArgs, + vararg keys: K + ): Flow> = ops.zinterWithScores(aggregateArgs, *keys).asFlow() override suspend fun zinterstore(destination: K, vararg keys: K): Long? = ops.zinterstore(destination, *keys).awaitFirstOrNull() - override suspend fun zinterstore(destination: K, aggregateArgs: ZAggregateArgs, vararg keys: K): Long? = ops.zinterstore(destination, aggregateArgs, *keys).awaitFirstOrNull() + override suspend fun zinterstore( + destination: K, + storeArgs: ZStoreArgs, + vararg keys: K + ): Long? = ops.zinterstore(destination, storeArgs, *keys).awaitFirstOrNull() override suspend fun zlexcount(key: K, range: Range): Long? = ops.zlexcount(key, range).awaitFirstOrNull() - override suspend fun zmscore(key: K, vararg members: V): List = ops.zmscore(key, *members).awaitFirstOrNull().orEmpty() + override suspend fun zmscore(key: K, vararg members: V): List = + ops.zmscore(key, *members).awaitFirstOrNull().orEmpty() override suspend fun zpopmin(key: K): ScoredValue? = ops.zpopmin(key).awaitFirstOrNull() @@ -140,16 +150,25 @@ internal class RedisSortedSetCoroutinesCommandsImpl(internal v override suspend fun zscore(key: K, member: V): Double? = ops.zscore(key, member).awaitFirstOrNull() - override fun zunion(numkey: Long, vararg keys: K): Flow = ops.zunion(numkey, *keys).asFlow() + override fun zunion(vararg keys: K): Flow = ops.zunion(*keys).asFlow() - override fun zunion(numkey: Long, aggregateArgs: ZAggregateArgs, vararg keys: K): Flow = ops.zunion(numkey, aggregateArgs, *keys).asFlow() + override fun zunion(aggregateArgs: ZAggregateArgs, vararg keys: K): Flow = + ops.zunion(aggregateArgs, *keys).asFlow() - override fun zunionWithScores(numkey: Long, vararg keys: K): Flow> = ops.zunionWithScores(numkey, *keys).asFlow() + override fun zunionWithScores(vararg keys: K): Flow> = + ops.zunionWithScores(*keys).asFlow() - override fun zunionWithScores(numkey: Long, aggregateArgs: ZAggregateArgs, vararg keys: K): Flow> = ops.zunionWithScores(numkey, aggregateArgs, *keys).asFlow() + override fun zunionWithScores( + aggregateArgs: ZAggregateArgs, + vararg keys: K + ): Flow> = ops.zunionWithScores(aggregateArgs, *keys).asFlow() override suspend fun zunionstore(destination: K, vararg keys: K): Long? = ops.zunionstore(destination, *keys).awaitFirstOrNull() - override suspend fun zunionstore(destination: K, aggregateArgs: ZAggregateArgs, vararg keys: K): Long? = ops.zunionstore(destination, aggregateArgs, *keys).awaitFirstOrNull() + override suspend fun zunionstore( + destination: K, + storeArgs: ZStoreArgs, + vararg keys: K + ): Long? = ops.zunionstore(destination, storeArgs, *keys).awaitFirstOrNull() } diff --git a/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java b/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java index be9dee6df3..0c38224ffa 100644 --- a/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisSortedSetCommands.java @@ -211,44 +211,40 @@ public interface RedisSortedSetCommands { /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - List zinter(long numkey, K... keys); + List zinter(K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - List zinter(long numkey, ZAggregateArgs aggregateArgs, K... keys); + List zinter(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - List> zinterWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + List> zinterWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Intersect multiple sorted sets and returns the resulting sorted. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - List> zinterWithScores(long numkey, K... keys); + List> zinterWithScores(K... keys); /** * Intersect multiple sorted sets and store the resulting sorted set in a new key. @@ -263,11 +259,11 @@ public interface RedisSortedSetCommands { * Intersect multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - Long zinterstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + Long zinterstore(K destination, ZStoreArgs storeArgs, K... keys); /** * Count the number of members in a sorted set between a given lexicographical range. @@ -291,7 +287,6 @@ public interface RedisSortedSetCommands { */ Long zlexcount(K key, Range range); - /** * Returns the scores associated with the specified members in the sorted set stored at key. * @@ -1289,44 +1284,40 @@ Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, S /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - List zunion(long numkey, K... keys); + List zunion(K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of elements. * @since 6.1 */ - List zunion(long numkey, ZAggregateArgs aggregateArgs, K... keys); + List zunion(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. - * @param aggregateArgs the aggregateArgs. + * @param aggregateArgs arguments to define aggregation and weights. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - List> zunionWithScores(long numkey, ZAggregateArgs aggregateArgs, K... keys); + List> zunionWithScores(ZAggregateArgs aggregateArgs, K... keys); /** * Add multiple sorted sets and returns the resulting sorted set. * - * @param numkey the numeric key. * @param keys the keys. * @return List<V> array-reply list of scored values. * @since 6.1 */ - List> zunionWithScores(long numkey, K... keys); + List> zunionWithScores(K... keys); /** * Add multiple sorted sets and store the resulting sorted set in a new key. @@ -1341,10 +1332,10 @@ Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, S * Add multiple sorted sets and store the resulting sorted set in a new key. * * @param destination the destination. - * @param aggregateArgs the aggregateArgs. + * @param storeArgs arguments to define aggregation and weights. * @param keys the keys. * @return Long integer-reply the number of elements in the resulting sorted set at {@code destination}. */ - Long zunionstore(K destination, ZAggregateArgs aggregateArgs, K... keys); + Long zunionstore(K destination, ZStoreArgs storeArgs, K... keys); } diff --git a/src/test/java/io/lettuce/core/commands/SortedSetCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/SortedSetCommandIntegrationTests.java index 88a12792d9..1fe92749f0 100644 --- a/src/test/java/io/lettuce/core/commands/SortedSetCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/SortedSetCommandIntegrationTests.java @@ -15,15 +15,13 @@ */ package io.lettuce.core.commands; -import static io.lettuce.core.Range.Boundary.including; -import static io.lettuce.core.ZAggregateArgs.Builder.max; -import static io.lettuce.core.ZAggregateArgs.Builder.min; -import static io.lettuce.core.ZAggregateArgs.Builder.sum; -import static io.lettuce.core.ZAggregateArgs.Builder.weights; -import static java.lang.Double.NEGATIVE_INFINITY; -import static java.lang.Double.POSITIVE_INFINITY; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static io.lettuce.core.Range.Boundary.*; +import static io.lettuce.core.ZStoreArgs.Builder.*; +import static io.lettuce.core.ZStoreArgs.Builder.max; +import static io.lettuce.core.ZStoreArgs.Builder.min; +import static io.lettuce.core.ZStoreArgs.Builder.sum; +import static java.lang.Double.*; +import static org.assertj.core.api.Assertions.*; import static org.assertj.core.data.Offset.offset; import java.util.HashSet; @@ -49,6 +47,7 @@ * @author Will Glozer * @author Mark Paluch * @author dengliming + * @author Mikhael Sokolov */ @ExtendWith(LettuceExtension.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) @@ -829,7 +828,6 @@ void zremrangebylex() { setup100KeyValues(new HashSet<>()); assertThat(redis.zremrangebylex(key, Range.create("value", "zzz"))).isEqualTo(100); - } @Test @@ -844,8 +842,8 @@ void zunion() { assertThat(redis.zadd(zset2, 2.0, "b")).isEqualTo(1); assertThat(redis.zadd(zset2, 3.0, "c")).isEqualTo(1); - assertThat(redis.zunion(2, zset1, zset2)).isEqualTo(list("a", "c", "b")); - assertThat(redis.zunionWithScores(2, zset1, zset2)).isEqualTo(svlist(sv(2.0, "a"), sv(3.0, "c"), sv(4.0, "b"))); + assertThat(redis.zunion(zset1, zset2)).isEqualTo(list("a", "c", "b")); + assertThat(redis.zunionWithScores(zset1, zset2)).isEqualTo(svlist(sv(2.0, "a"), sv(3.0, "c"), sv(4.0, "b"))); } @Test @@ -860,8 +858,8 @@ void zinter() { assertThat(redis.zadd(zset2, 2.0, "b")).isEqualTo(1); assertThat(redis.zadd(zset2, 3.0, "c")).isEqualTo(1); - assertThat(redis.zinter(2, zset1, zset2)).isEqualTo(list("a", "b")); - assertThat(redis.zinterWithScores(2, zset1, zset2)).isEqualTo(svlist(sv(2.0, "a"), sv(4.0, "b"))); + assertThat(redis.zinter(zset1, zset2)).isEqualTo(list("a", "b")); + assertThat(redis.zinterWithScores(zset1, zset2)).isEqualTo(svlist(sv(2.0, "a"), sv(4.0, "b"))); } void setup100KeyValues(Set expect) { @@ -872,5 +870,4 @@ void setup100KeyValues(Set expect) { } } - }