From b45d358abfc7ebcc15a3fdd331f8a19fe68a0dba Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 23 Feb 2022 10:30:32 +0100 Subject: [PATCH] Move Tuple, Limit, and Weights to top-level types. See: #2273 Original Pull Request: #2276 --- .../springframework/data/redis/Version.java | 103 -------- .../data/redis/VersionParser.java | 58 ----- .../DefaultStringRedisConnection.java | 35 ++- .../redis/connection/DefaultStringTuple.java | 3 +- .../connection/DefaultedRedisConnection.java | 22 +- .../data/redis/connection/Limit.java | 73 ++++++ .../connection/ReactiveStreamCommands.java | 1 - .../connection/ReactiveZSetCommands.java | 6 +- .../redis/connection/RedisStreamCommands.java | 1 - .../redis/connection/RedisZSetCommands.java | 239 ++---------------- .../connection/StringRedisConnection.java | 26 +- .../redis/connection/convert/Converters.java | 2 +- .../jedis/JedisClusterStreamCommands.java | 6 +- .../jedis/JedisClusterZSetCommands.java | 18 +- .../connection/jedis/JedisConverters.java | 4 +- .../connection/jedis/JedisStreamCommands.java | 6 +- .../redis/connection/jedis/JedisUtils.java | 4 +- .../connection/jedis/JedisZSetCommands.java | 18 +- .../connection/lettuce/LettuceConverters.java | 12 +- .../lettuce/LettuceReactiveZSetCommands.java | 6 +- .../lettuce/LettuceStreamCommands.java | 2 +- .../lettuce/LettuceZSetCommands.java | 16 +- .../connection/{ => zset}/DefaultTuple.java | 6 +- .../data/redis/connection/zset/Tuple.java | 43 ++++ .../data/redis/connection/zset/Weights.java | 165 ++++++++++++ .../data/redis/core/AbstractOperations.java | 4 +- .../redis/core/BoundStreamOperations.java | 2 +- .../data/redis/core/BoundZSetOperations.java | 6 +- .../core/DefaultBoundStreamOperations.java | 2 +- .../core/DefaultBoundZSetOperations.java | 4 +- .../core/DefaultReactiveStreamOperations.java | 2 +- .../core/DefaultReactiveZSetOperations.java | 9 +- .../redis/core/DefaultStreamOperations.java | 2 +- .../redis/core/DefaultZSetOperations.java | 6 +- .../redis/core/ReactiveStreamOperations.java | 16 +- .../redis/core/ReactiveZSetOperations.java | 6 +- .../data/redis/core/RedisTemplate.java | 2 +- .../data/redis/core/StreamOperations.java | 15 +- .../data/redis/core/ZSetOperations.java | 6 +- .../support/collections/DefaultRedisZSet.java | 2 +- .../redis/support/collections/RedisZSet.java | 15 +- .../ReactiveStreamOperationsExtensions.kt | 2 +- .../core/ReactiveZSetOperationsExtensions.kt | 25 +- .../data/redis/VersionParserUnitTests.java | 56 ---- .../AbstractConnectionIntegrationTests.java | 4 +- .../DefaultStringRedisConnectionTests.java | 6 +- .../connection/RedisConnectionUnitTests.java | 15 +- .../redis/connection/WeightsUnitTests.java | 8 +- .../jedis/JedisClusterConnectionTests.java | 4 +- .../jedis/JedisConnectionUnitTests.java | 2 +- .../LettuceClusterConnectionTests.java | 3 + .../lettuce/LettuceConvertersUnitTests.java | 7 +- ...eactiveStreamCommandsIntegrationTests.java | 2 +- ...eReactiveZSetCommandsIntegrationTests.java | 2 +- ...ctiveStreamOperationsIntegrationTests.java | 2 +- ...eactiveZSetOperationsIntegrationTests.java | 4 +- ...faultStreamOperationsIntegrationTests.java | 2 +- ...DefaultZSetOperationsIntegrationTests.java | 9 +- .../AbstractRedisZSetTestIntegration.java | 7 +- ...tiveStreamOperationsExtensionsUnitTests.kt | 2 +- ...activeZSetOperationsExtensionsUnitTests.kt | 18 +- 61 files changed, 525 insertions(+), 629 deletions(-) delete mode 100644 src/main/java/org/springframework/data/redis/Version.java delete mode 100644 src/main/java/org/springframework/data/redis/VersionParser.java create mode 100644 src/main/java/org/springframework/data/redis/connection/Limit.java rename src/main/java/org/springframework/data/redis/connection/{ => zset}/DefaultTuple.java (92%) create mode 100644 src/main/java/org/springframework/data/redis/connection/zset/Tuple.java create mode 100644 src/main/java/org/springframework/data/redis/connection/zset/Weights.java delete mode 100644 src/test/java/org/springframework/data/redis/VersionParserUnitTests.java diff --git a/src/main/java/org/springframework/data/redis/Version.java b/src/main/java/org/springframework/data/redis/Version.java deleted file mode 100644 index 8bac1c9e2..000000000 --- a/src/main/java/org/springframework/data/redis/Version.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2011-2022 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 org.springframework.data.redis; - -/** - * A {@link Comparable} software version - * - * @author Jennifer Hickey - * @author Christoph Strobl - * @deprecated since 2.0, use {@link org.springframework.data.util.Version}. - */ -public class Version implements Comparable { - - public static final Version UNKNOWN = new Version(0, 0, 0); - - Integer major; - Integer minor; - Integer patch; - - public Version(int major, int minor, int patch) { - this.major = major; - this.minor = minor; - this.patch = patch; - } - - public int compareTo(Version o) { - if (this.major != o.major) { - return this.major.compareTo(o.major); - } - if (this.minor != o.minor) { - return this.minor.compareTo(o.minor); - } - if (this.patch != o.patch) { - return this.patch.compareTo(o.patch); - } - return 0; - } - - @Override - public String toString() { - return "" + major + "." + minor + "." + patch; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((major == null) ? 0 : major.hashCode()); - result = prime * result + ((minor == null) ? 0 : minor.hashCode()); - result = prime * result + ((patch == null) ? 0 : patch.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!(obj instanceof Version)) { - return false; - } - Version other = (Version) obj; - if (major == null) { - if (other.major != null) { - return false; - } - } else if (!major.equals(other.major)) { - return false; - } - if (minor == null) { - if (other.minor != null) { - return false; - } - } else if (!minor.equals(other.minor)) { - return false; - } - if (patch == null) { - if (other.patch != null) { - return false; - } - } else if (!patch.equals(other.patch)) { - return false; - } - return true; - } - -} diff --git a/src/main/java/org/springframework/data/redis/VersionParser.java b/src/main/java/org/springframework/data/redis/VersionParser.java deleted file mode 100644 index 963935f22..000000000 --- a/src/main/java/org/springframework/data/redis/VersionParser.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2014-2022 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 org.springframework.data.redis; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.springframework.lang.Nullable; - -/** - * Central class for reading version string (eg. {@literal 1.3.1}) into {@link Version}. - * - * @author Christoph Strobl - * @since 1.3 - * @deprecated since 2.0, use {@link org.springframework.data.util.Version}. - */ -public class VersionParser { - - private static final Pattern VERSION_MATCHER = Pattern.compile("([0-9]+)\\.([0-9]+)(\\.([0-9]+))?(.*)"); - - /** - * Parse version string {@literal eg. 1.1.1} to {@link Version}. - * - * @param version can be {@literal null}. - * @return never {@literal null}. - */ - public static Version parseVersion(@Nullable String version) { - - if (version == null) { - return Version.UNKNOWN; - } - - Matcher matcher = VERSION_MATCHER.matcher(version); - if (matcher.matches()) { - String major = matcher.group(1); - String minor = matcher.group(2); - String patch = matcher.group(4); - return new Version(Integer.parseInt(major), minor != null ? Integer.parseInt(minor) : 0, - patch != null ? Integer.parseInt(patch) : 0); - } - - return Version.UNKNOWN; - } - -} diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java index 9c621b50b..4baa3834c 100644 --- a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java @@ -48,6 +48,9 @@ import org.springframework.data.redis.connection.stream.StreamInfo.XInfoStream; import org.springframework.data.redis.connection.stream.StreamOffset; import org.springframework.data.redis.connection.stream.StreamReadOptions; import org.springframework.data.redis.connection.stream.StringRecord; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.ConvertingCursor; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; @@ -1042,7 +1045,7 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco } @Override - public Set zRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.zRangeByScore(key, range, limit), Converters.identityConverter()); } @@ -1063,7 +1066,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco } @Override - public Set zRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.zRangeByScoreWithScores(key, range, limit), Converters.identityConverter()); } @@ -1093,7 +1097,7 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco } @Override - public Set zRevRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.zRevRangeByScore(key, range, limit), Converters.identityConverter()); } @@ -1109,7 +1113,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco } @Override - public Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.zRevRangeByScoreWithScores(key, range, limit), Converters.identityConverter()); } @@ -2589,7 +2594,7 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco } @Override - public Set zRangeByLex(byte[] key, Range range, Limit limit) { + public Set zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.zRangeByLex(key, range, limit), Converters.identityConverter()); } @@ -2600,21 +2605,21 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco @Override public Set zRangeByLex(String key, Range range) { - return zRangeByLex(key, range, Limit.unlimited()); + return zRangeByLex(key, range, org.springframework.data.redis.connection.Limit.unlimited()); } @Override - public Set zRangeByLex(String key, Range range, Limit limit) { + public Set zRangeByLex(String key, Range range, org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.zRangeByLex(serialize(key), range, limit), byteSetToStringSet); } @Override - public Set zRevRangeByLex(byte[] key, Range range, Limit limit) { + public Set zRevRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.zRevRangeByLex(key, range, limit), Converters.identityConverter()); } @Override - public Set zRevRangeByLex(String key, Range range, Limit limit) { + public Set zRevRangeByLex(String key, Range range, org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.zRevRangeByLex(serialize(key), range, limit), byteSetToStringSet); } @@ -2720,7 +2725,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco } @Override - public List xRange(String key, org.springframework.data.domain.Range range, Limit limit) { + public List xRange(String key, org.springframework.data.domain.Range range, + org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.xRange(serialize(key), range, limit), listByteMapRecordToStringMapRecordConverter); } @@ -2739,7 +2745,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco } @Override - public List xRevRange(String key, org.springframework.data.domain.Range range, Limit limit) { + public List xRevRange(String key, org.springframework.data.domain.Range range, + org.springframework.data.redis.connection.Limit limit) { return convertAndReturn(delegate.xRevRange(serialize(key), range, limit), listByteMapRecordToStringMapRecordConverter); @@ -2831,7 +2838,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco } @Override - public List xRange(byte[] key, org.springframework.data.domain.Range range, Limit limit) { + public List xRange(byte[] key, org.springframework.data.domain.Range range, + org.springframework.data.redis.connection.Limit limit) { return delegate.xRange(key, range, limit); } @@ -2847,7 +2855,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco } @Override - public List xRevRange(byte[] key, org.springframework.data.domain.Range range, Limit limit) { + public List xRevRange(byte[] key, org.springframework.data.domain.Range range, + org.springframework.data.redis.connection.Limit limit) { return delegate.xRevRange(key, range, limit); } diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java b/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java index f681d992e..6735c21ff 100644 --- a/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java +++ b/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java @@ -17,8 +17,9 @@ package org.springframework.data.redis.connection; import java.nio.charset.StandardCharsets; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.connection.StringRedisConnection.StringTuple; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.util.ObjectUtils; /** diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java index 419127bf6..2b01db7a0 100644 --- a/src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java @@ -40,6 +40,8 @@ import org.springframework.data.redis.connection.stream.StreamInfo.XInfoGroups; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoStream; import org.springframework.data.redis.connection.stream.StreamOffset; import org.springframework.data.redis.connection.stream.StreamReadOptions; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.types.Expiration; @@ -585,7 +587,8 @@ public interface DefaultedRedisConnection extends RedisConnection { /** @deprecated in favor of {@link RedisConnection#streamCommands()}}. */ @Override @Deprecated - default List xRange(byte[] key, org.springframework.data.domain.Range range, Limit limit) { + default List xRange(byte[] key, org.springframework.data.domain.Range range, + org.springframework.data.redis.connection.Limit limit) { return streamCommands().xRange(key, range, limit); } @@ -628,7 +631,8 @@ public interface DefaultedRedisConnection extends RedisConnection { /** @deprecated in favor of {@link RedisConnection#streamCommands()}}. */ @Override @Deprecated - default List xRevRange(byte[] key, org.springframework.data.domain.Range range, Limit limit) { + default List xRevRange(byte[] key, org.springframework.data.domain.Range range, + org.springframework.data.redis.connection.Limit limit) { return streamCommands().xRevRange(key, range, limit); } @@ -1137,28 +1141,29 @@ public interface DefaultedRedisConnection extends RedisConnection { /** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */ @Override @Deprecated - default Set zRangeByLex(byte[] key, Range range, Limit limit) { + default Set zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return zSetCommands().zRangeByLex(key, range, limit); } /** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */ @Override @Deprecated - default Set zRevRangeByLex(byte[] key, Range range, Limit limit) { + default Set zRevRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return zSetCommands().zRevRangeByLex(key, range, limit); } /** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */ @Override @Deprecated - default Set zRangeByScore(byte[] key, Range range, Limit limit) { + default Set zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return zSetCommands().zRangeByScore(key, range, limit); } /** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */ @Override @Deprecated - default Set zRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + default Set zRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { return zSetCommands().zRangeByScoreWithScores(key, range, limit); } @@ -1172,14 +1177,15 @@ public interface DefaultedRedisConnection extends RedisConnection { /** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */ @Override @Deprecated - default Set zRevRangeByScore(byte[] key, Range range, Limit limit) { + default Set zRevRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return zSetCommands().zRevRangeByScore(key, range, limit); } /** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */ @Override @Deprecated - default Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + default Set zRevRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { return zSetCommands().zRevRangeByScoreWithScores(key, range, limit); } diff --git a/src/main/java/org/springframework/data/redis/connection/Limit.java b/src/main/java/org/springframework/data/redis/connection/Limit.java new file mode 100644 index 000000000..7e8a6b866 --- /dev/null +++ b/src/main/java/org/springframework/data/redis/connection/Limit.java @@ -0,0 +1,73 @@ +/* + * Copyright 2022 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 org.springframework.data.redis.connection; + +/** + * @author Christoph Strobl + * @since 1.6 + */ +public class Limit { + + private static final Limit UNLIMITED = new Limit() { + + @Override + public int getCount() { + return -1; + } + + @Override + public int getOffset() { + return super.getOffset(); + } + }; + + int offset; + int count; + + public static Limit limit() { + return new Limit(); + } + + public Limit offset(int offset) { + this.offset = offset; + return this; + } + + public Limit count(int count) { + this.count = count; + return this; + } + + public int getCount() { + return count; + } + + public int getOffset() { + return offset; + } + + public boolean isUnlimited() { + return this.equals(UNLIMITED); + } + + /** + * @return new {@link Limit} indicating no limit; + * @since 1.3 + */ + public static Limit unlimited() { + return UNLIMITED; + } +} diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java index 40db4e319..1720d8e8a 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java @@ -33,7 +33,6 @@ import org.springframework.data.redis.connection.ReactiveRedisConnection.KeyComm import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse; import org.springframework.data.redis.connection.RedisStreamCommands.XClaimOptions; import org.springframework.data.redis.connection.RedisStreamCommands.XPendingOptions; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.stream.ByteBufferRecord; import org.springframework.data.redis.connection.stream.Consumer; import org.springframework.data.redis.connection.stream.PendingMessage; diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java index f8fe28d25..0b7de03e1 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java @@ -34,9 +34,9 @@ import org.reactivestreams.Publisher; import org.springframework.data.domain.Range; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.util.ByteUtils; import org.springframework.lang.Nullable; diff --git a/src/main/java/org/springframework/data/redis/connection/RedisStreamCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisStreamCommands.java index a7a52b9b5..1b587530a 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisStreamCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisStreamCommands.java @@ -24,7 +24,6 @@ import java.util.Map; import java.util.stream.Collectors; import org.springframework.data.domain.Range; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.stream.*; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoConsumers; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoGroups; diff --git a/src/main/java/org/springframework/data/redis/connection/RedisZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisZSetCommands.java index 161913c33..a85be1de7 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisZSetCommands.java @@ -15,18 +15,13 @@ */ package org.springframework.data.redis.connection; -import java.util.Arrays; -import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; -import java.util.function.DoubleUnaryOperator; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.lang.Nullable; @@ -52,160 +47,6 @@ public interface RedisZSetCommands { SUM, MIN, MAX; } - /** - * Value object encapsulating a multiplication factor for each input sorted set. This means that the score of every - * element in every input sorted set is multiplied by this factor before being passed to the aggregation function. - * - * @author Mark Paluch - * @author Christoph Strobl - * @since 2.1 - */ - class Weights { - - private final List weights; - - private Weights(List weights) { - this.weights = weights; - } - - /** - * Create new {@link Weights} given {@code weights} as {@code int}. - * - * @param weights must not be {@literal null}. - * @return the {@link Weights} for {@code weights}. - */ - public static Weights of(int... weights) { - - Assert.notNull(weights, "Weights must not be null!"); - return new Weights(Arrays.stream(weights).mapToDouble(value -> value).boxed().collect(Collectors.toList())); - } - - /** - * Create new {@link Weights} given {@code weights} as {@code double}. - * - * @param weights must not be {@literal null}. - * @return the {@link Weights} for {@code weights}. - */ - public static Weights of(double... weights) { - - Assert.notNull(weights, "Weights must not be null!"); - - return new Weights(DoubleStream.of(weights).boxed().collect(Collectors.toList())); - } - - /** - * Creates equal {@link Weights} for a number of input sets {@code count} with a weight of one. - * - * @param count number of input sets. Must be greater or equal to zero. - * @return equal {@link Weights} for a number of input sets with a weight of one. - */ - public static Weights fromSetCount(int count) { - - Assert.isTrue(count >= 0, "Count of input sorted sets must be greater or equal to zero!"); - - return new Weights(IntStream.range(0, count).mapToDouble(value -> 1).boxed().collect(Collectors.toList())); - } - - /** - * Creates a new {@link Weights} object that contains all weights multiplied by {@code multiplier} - * - * @param multiplier multiplier used to multiply each weight with. - * @return equal {@link Weights} for a number of input sets with a weight of one. - */ - public Weights multiply(int multiplier) { - return apply(it -> it * multiplier); - } - - /** - * Creates a new {@link Weights} object that contains all weights multiplied by {@code multiplier} - * - * @param multiplier multiplier used to multiply each weight with. - * @return equal {@link Weights} for a number of input sets with a weight of one. - */ - public Weights multiply(double multiplier) { - return apply(it -> it * multiplier); - } - - /** - * Creates a new {@link Weights} object that contains all weights with {@link Function} applied. - * - * @param operator operator function. - * @return the new {@link Weights} with {@link DoubleUnaryOperator} applied. - */ - public Weights apply(Function operator) { - return new Weights(weights.stream().map(operator).collect(Collectors.toList())); - } - - /** - * Retrieve the weight at {@code index}. - * - * @param index the weight index. - * @return the weight at {@code index}. - * @throws IndexOutOfBoundsException if the index is out of range - */ - public double getWeight(int index) { - return weights.get(index); - } - - /** - * @return number of weights. - */ - public int size() { - return weights.size(); - } - - /** - * @return an array containing all of the weights in this list in proper sequence (from first to last element). - */ - public double[] toArray() { - return weights.stream().mapToDouble(Double::doubleValue).toArray(); - } - - /** - * @return a {@link List} containing all of the weights in this list in proper sequence (from first to last - * element). - */ - public List toList() { - return Collections.unmodifiableList(weights); - } - - @Override - public boolean equals(Object o) { - - if (this == o) { - return true; - } - - if (!(o instanceof Weights)) { - return false; - } - - Weights that = (Weights) o; - return ObjectUtils.nullSafeEquals(this.weights, that.weights); - } - - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(weights); - } - } - - /** - * ZSet tuple. - */ - interface Tuple extends Comparable { - - /** - * @return the raw value of the member. - */ - byte[] getValue(); - - /** - * @return the member score value used for sorting. - */ - Double getScore(); - } - /** * {@link Range} defines {@literal min} and {@literal max} values to retrieve from a {@literal ZSET}. * @@ -336,58 +177,11 @@ public interface RedisZSetCommands { /** * @author Christoph Strobl * @since 1.6 + * @deprecated since 3.0, use {@link org.springframework.data.redis.connection.Limit} instead. */ - class Limit { + @Deprecated + class Limit extends org.springframework.data.redis.connection.Limit { - private static final Limit UNLIMITED = new Limit() { - - @Override - public int getCount() { - return -1; - } - - @Override - public int getOffset() { - return super.getOffset(); - } - }; - - int offset; - int count; - - public static Limit limit() { - return new Limit(); - } - - public Limit offset(int offset) { - this.offset = offset; - return this; - } - - public Limit count(int count) { - this.count = count; - return this; - } - - public int getCount() { - return count; - } - - public int getOffset() { - return offset; - } - - public boolean isUnlimited() { - return this.equals(UNLIMITED); - } - - /** - * @return new {@link Limit} indicating no limit; - * @since 1.3 - */ - public static Limit unlimited() { - return UNLIMITED; - } } /** @@ -787,7 +581,8 @@ public interface RedisZSetCommands { @Nullable default Set zRangeByScore(byte[] key, double min, double max, long offset, long count) { return zRangeByScore(key, new Range().gte(min).lte(max), - new Limit().offset(Long.valueOf(offset).intValue()).count(Long.valueOf(count).intValue())); + new org.springframework.data.redis.connection.Limit().offset(Long.valueOf(offset).intValue()) + .count(Long.valueOf(count).intValue())); } /** @@ -806,7 +601,8 @@ public interface RedisZSetCommands { @Nullable default Set zRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) { return zRangeByScoreWithScores(key, new Range().gte(min).lte(max), - new Limit().offset(Long.valueOf(offset).intValue()).count(Long.valueOf(count).intValue())); + new org.springframework.data.redis.connection.Limit().offset(Long.valueOf(offset).intValue()) + .count(Long.valueOf(count).intValue())); } /** @@ -822,7 +618,7 @@ public interface RedisZSetCommands { * @see Redis Documentation: ZRANGEBYSCORE */ @Nullable - Set zRangeByScoreWithScores(byte[] key, Range range, Limit limit); + Set zRangeByScoreWithScores(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit); /** * Get elements in range from {@code start} to {@code end} from sorted set ordered from high to low. @@ -928,7 +724,7 @@ public interface RedisZSetCommands { * @see Redis Documentation: ZREVRANGEBYSCORE */ @Nullable - Set zRevRangeByScore(byte[] key, Range range, Limit limit); + Set zRevRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit); /** * Get set of {@link Tuple} in range from {@code start} to {@code end} where score is between {@code min} and @@ -946,7 +742,8 @@ public interface RedisZSetCommands { default Set zRevRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) { return zRevRangeByScoreWithScores(key, new Range().gte(min).lte(max), - new Limit().offset(Long.valueOf(offset).intValue()).count(Long.valueOf(count).intValue())); + new org.springframework.data.redis.connection.Limit().offset(Long.valueOf(offset).intValue()) + .count(Long.valueOf(count).intValue())); } /** @@ -976,7 +773,7 @@ public interface RedisZSetCommands { * @see Redis Documentation: ZREVRANGEBYSCORE */ @Nullable - Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit); + Set zRevRangeByScoreWithScores(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit); /** * Count number of elements within sorted set with scores between {@code min} and {@code max}. @@ -1454,7 +1251,7 @@ public interface RedisZSetCommands { * @see Redis Documentation: ZRANGEBYSCORE */ @Nullable - Set zRangeByScore(byte[] key, Range range, Limit limit); + Set zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit); /** * Get all the elements in the sorted set at {@literal key} in lexicographical ordering. @@ -1495,7 +1292,7 @@ public interface RedisZSetCommands { * @see Redis Documentation: ZRANGEBYLEX */ @Nullable - Set zRangeByLex(byte[] key, Range range, Limit limit); + Set zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit); /** * Get all the elements in the sorted set at {@literal key} in reversed lexicographical ordering. @@ -1521,7 +1318,7 @@ public interface RedisZSetCommands { */ @Nullable default Set zRevRangeByLex(byte[] key, Range range) { - return zRevRangeByLex(key, range, Limit.unlimited()); + return zRevRangeByLex(key, range, org.springframework.data.redis.connection.Limit.unlimited()); } /** @@ -1536,6 +1333,6 @@ public interface RedisZSetCommands { * @see Redis Documentation: ZREVRANGEBYLEX */ @Nullable - Set zRevRangeByLex(byte[] key, Range range, Limit limit); + Set zRevRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit); } diff --git a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java index 3a917d83d..8a71eed03 100644 --- a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java @@ -41,6 +41,8 @@ import org.springframework.data.redis.connection.stream.StreamOffset; import org.springframework.data.redis.connection.stream.StreamReadOptions; import org.springframework.data.redis.connection.stream.StreamRecords; import org.springframework.data.redis.connection.stream.StringRecord; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.ScanOptions; @@ -1929,7 +1931,7 @@ public interface StringRedisConnection extends RedisConnection { /** * Get all the elements in {@link Range} from the sorted set at {@literal key} in lexicographical ordering. Result is - * limited via {@link Limit}. + * limited via {@link org.springframework.data.redis.connection.Limit}. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. @@ -1939,7 +1941,7 @@ public interface StringRedisConnection extends RedisConnection { * @see Redis Documentation: ZRANGEBYLEX * @see RedisZSetCommands#zRangeByLex(byte[], Range, Limit) */ - Set zRangeByLex(String key, Range range, Limit limit); + Set zRangeByLex(String key, Range range, org.springframework.data.redis.connection.Limit limit); /** * Get all the elements in the sorted set at {@literal key} in reversed lexicographical ordering. @@ -1965,12 +1967,12 @@ public interface StringRedisConnection extends RedisConnection { * @see RedisZSetCommands#zRevRangeByLex(byte[], Range) */ default Set zRevRangeByLex(String key, Range range) { - return zRevRangeByLex(key, range, Limit.unlimited()); + return zRevRangeByLex(key, range, org.springframework.data.redis.connection.Limit.unlimited()); } /** * Get all the elements in {@link Range} from the sorted set at {@literal key} in reversed lexicographical ordering. - * Result is limited via {@link Limit}. + * Result is limited via {@link org.springframework.data.redis.connection.Limit}. * * @param key must not be {@literal null}. * @param range must not be {@literal null}. @@ -1980,7 +1982,7 @@ public interface StringRedisConnection extends RedisConnection { * @see Redis Documentation: ZREVRANGEBYLEX * @see RedisZSetCommands#zRevRangeByLex(byte[], Range, Limit) */ - Set zRevRangeByLex(String key, Range range, Limit limit); + Set zRevRangeByLex(String key, Range range, org.springframework.data.redis.connection.Limit limit); // ------------------------------------------------------------------------- // Methods dealing with Redis Hashes @@ -2866,11 +2868,12 @@ public interface StringRedisConnection extends RedisConnection { */ @Nullable default List xRange(String key, org.springframework.data.domain.Range range) { - return xRange(key, range, Limit.unlimited()); + return xRange(key, range, org.springframework.data.redis.connection.Limit.unlimited()); } /** - * Read records from a stream within a specific {@link Range} applying a {@link Limit}. + * Read records from a stream within a specific {@link Range} applying a + * {@link org.springframework.data.redis.connection.Limit}. * * @param key the stream key. * @param range must not be {@literal null}. @@ -2880,7 +2883,8 @@ public interface StringRedisConnection extends RedisConnection { * @see Redis Documentation: XRANGE */ @Nullable - List xRange(String key, org.springframework.data.domain.Range range, Limit limit); + List xRange(String key, org.springframework.data.domain.Range range, + org.springframework.data.redis.connection.Limit limit); /** * Read records from one or more {@link StreamOffset}s. @@ -3007,7 +3011,8 @@ public interface StringRedisConnection extends RedisConnection { } /** - * Read records from a stream within a specific {@link Range} applying a {@link Limit} in reverse order. + * Read records from a stream within a specific {@link Range} applying a + * {@link org.springframework.data.redis.connection.Limit} in reverse order. * * @param key the stream key. * @param range must not be {@literal null}. @@ -3017,7 +3022,8 @@ public interface StringRedisConnection extends RedisConnection { * @see Redis Documentation: XREVRANGE */ @Nullable - List xRevRange(String key, org.springframework.data.domain.Range range, Limit limit); + List xRevRange(String key, org.springframework.data.domain.Range range, + org.springframework.data.redis.connection.Limit limit); /** * Trims the stream to {@code count} elements. diff --git a/src/main/java/org/springframework/data/redis/connection/convert/Converters.java b/src/main/java/org/springframework/data/redis/connection/convert/Converters.java index d3a9f27d7..10ac7fd7a 100644 --- a/src/main/java/org/springframework/data/redis/connection/convert/Converters.java +++ b/src/main/java/org/springframework/data/redis/connection/convert/Converters.java @@ -39,7 +39,7 @@ import org.springframework.data.redis.connection.RedisClusterNode.SlotRange; import org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; import org.springframework.data.redis.connection.RedisNode.NodeType; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.util.ByteUtils; import org.springframework.lang.Nullable; diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStreamCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStreamCommands.java index f659db0f5..c0092fde9 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStreamCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStreamCommands.java @@ -26,8 +26,8 @@ import java.util.List; import org.springframework.dao.DataAccessException; import org.springframework.data.domain.Range; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisStreamCommands; -import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.connection.stream.ByteRecord; import org.springframework.data.redis.connection.stream.Consumer; import org.springframework.data.redis.connection.stream.MapRecord; @@ -223,7 +223,7 @@ class JedisClusterStreamCommands implements RedisStreamCommands { } @Override - public List xRange(byte[] key, Range range, RedisZSetCommands.Limit limit) { + public List xRange(byte[] key, Range range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); @@ -289,7 +289,7 @@ class JedisClusterStreamCommands implements RedisStreamCommands { } @Override - public List xRevRange(byte[] key, Range range, RedisZSetCommands.Limit limit) { + public List xRevRange(byte[] key, Range range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java index 6c7e208ac..9e92134a1 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java @@ -27,9 +27,11 @@ import java.util.stream.Collectors; import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.redis.connection.ClusterSlotHashUtil; -import org.springframework.data.redis.connection.DefaultTuple; import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.connection.convert.SetConverter; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanCursor; import org.springframework.data.redis.core.ScanIteration; @@ -201,7 +203,8 @@ class JedisClusterZSetCommands implements RedisZSetCommands { } @Override - public Set zRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range cannot be null for ZRANGEBYSCOREWITHSCORES."); @@ -221,7 +224,7 @@ class JedisClusterZSetCommands implements RedisZSetCommands { } @Override - public Set zRevRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range cannot be null for ZREVRANGEBYSCORE."); @@ -240,7 +243,8 @@ class JedisClusterZSetCommands implements RedisZSetCommands { } @Override - public Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range cannot be null for ZREVRANGEBYSCOREWITHSCORES."); @@ -391,7 +395,7 @@ class JedisClusterZSetCommands implements RedisZSetCommands { } @Override - public Set zRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range cannot be null for ZRANGEBYSCORE."); @@ -410,7 +414,7 @@ class JedisClusterZSetCommands implements RedisZSetCommands { } @Override - public Set zRangeByLex(byte[] key, Range range, Limit limit) { + public Set zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null for ZRANGEBYLEX!"); @@ -446,7 +450,7 @@ class JedisClusterZSetCommands implements RedisZSetCommands { } @Override - public Set zRevRangeByLex(byte[] key, Range range, Limit limit) { + public Set zRevRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null for ZREVRANGEBYLEX!"); diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java index 004d604ec..105661bf5 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java @@ -52,7 +52,6 @@ import org.springframework.data.redis.connection.BitFieldSubCommands; import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldIncrBy; import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldSet; import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldSubCommand; -import org.springframework.data.redis.connection.DefaultTuple; import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; @@ -64,7 +63,6 @@ import org.springframework.data.redis.connection.RedisServerCommands; import org.springframework.data.redis.connection.RedisStringCommands.BitOperation; import org.springframework.data.redis.connection.RedisStringCommands.SetOption; import org.springframework.data.redis.connection.RedisZSetCommands.Range.Boundary; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.connection.RedisZSetCommands.ZAddArgs; import org.springframework.data.redis.connection.SortParameters; import org.springframework.data.redis.connection.SortParameters.Order; @@ -75,6 +73,8 @@ import org.springframework.data.redis.connection.convert.ListConverter; import org.springframework.data.redis.connection.convert.MapConverter; import org.springframework.data.redis.connection.convert.SetConverter; import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.types.Expiration; import org.springframework.data.redis.core.types.RedisClientInfo; diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisStreamCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisStreamCommands.java index 307f4b1a6..b176b6f11 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisStreamCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisStreamCommands.java @@ -28,8 +28,8 @@ import java.util.Collections; import java.util.List; import org.springframework.data.domain.Range; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisStreamCommands; -import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.connection.stream.ByteRecord; import org.springframework.data.redis.connection.stream.Consumer; import org.springframework.data.redis.connection.stream.MapRecord; @@ -236,7 +236,7 @@ class JedisStreamCommands implements RedisStreamCommands { } @Override - public List xRange(byte[] key, Range range, RedisZSetCommands.Limit limit) { + public List xRange(byte[] key, Range range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); @@ -293,7 +293,7 @@ class JedisStreamCommands implements RedisStreamCommands { } @Override - public List xRevRange(byte[] key, Range range, RedisZSetCommands.Limit limit) { + public List xRevRange(byte[] key, Range range, Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range must not be null!"); diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisUtils.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisUtils.java index 3d5c9da2d..f87c5cb57 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisUtils.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisUtils.java @@ -41,14 +41,14 @@ import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.redis.RedisConnectionFailureException; import org.springframework.data.redis.RedisSystemException; -import org.springframework.data.redis.connection.DefaultTuple; import org.springframework.data.redis.connection.MessageListener; import org.springframework.data.redis.connection.RedisListCommands.Position; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.connection.ReturnType; import org.springframework.data.redis.connection.SortParameters; import org.springframework.data.redis.connection.SortParameters.Order; import org.springframework.data.redis.connection.SortParameters.Range; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.util.Assert; /** diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java index e9bf958de..7a8d1960f 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java @@ -28,8 +28,10 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.springframework.data.redis.connection.DefaultTuple; import org.springframework.data.redis.connection.RedisZSetCommands; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.KeyBoundCursor; import org.springframework.data.redis.core.ScanIteration; @@ -171,7 +173,8 @@ class JedisZSetCommands implements RedisZSetCommands { } @Override - public Set zRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZRANGEBYSCOREWITHSCORES must not be null!"); @@ -210,7 +213,7 @@ class JedisZSetCommands implements RedisZSetCommands { } @Override - public Set zRevRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZREVRANGEBYSCORE must not be null!"); @@ -229,7 +232,8 @@ class JedisZSetCommands implements RedisZSetCommands { } @Override - public Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZREVRANGEBYSCOREWITHSCORES must not be null!"); @@ -611,7 +615,7 @@ class JedisZSetCommands implements RedisZSetCommands { } @Override - public Set zRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZRANGEBYSCORE must not be null!"); @@ -629,7 +633,7 @@ class JedisZSetCommands implements RedisZSetCommands { } @Override - public Set zRangeByLex(byte[] key, Range range, Limit limit) { + public Set zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZRANGEBYLEX must not be null!"); @@ -647,7 +651,7 @@ class JedisZSetCommands implements RedisZSetCommands { } @Override - public Set zRevRangeByLex(byte[] key, Range range, Limit limit) { + public Set zRevRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZREVRANGEBYLEX must not be null!"); diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java index 633ca3ae7..1180def27 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java @@ -40,6 +40,7 @@ import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldInc import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldIncrBy.Overflow; import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldSet; import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldSubCommand; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisClusterNode.Flag; import org.springframework.data.redis.connection.RedisClusterNode.LinkState; import org.springframework.data.redis.connection.RedisClusterNode.SlotRange; @@ -48,11 +49,12 @@ import org.springframework.data.redis.connection.RedisListCommands.Position; import org.springframework.data.redis.connection.RedisNode.NodeType; import org.springframework.data.redis.connection.RedisStringCommands.SetOption; import org.springframework.data.redis.connection.RedisZSetCommands.Range.Boundary; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.connection.SortParameters.Order; import org.springframework.data.redis.connection.convert.Converters; import org.springframework.data.redis.connection.convert.LongToBooleanConverter; import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.KeyScanOptions; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.types.Expiration; @@ -266,15 +268,15 @@ public abstract class LettuceConverters extends Converters { } /** - * Convert a {@link org.springframework.data.redis.connection.RedisZSetCommands.Limit} to a Lettuce - * {@link io.lettuce.core.Limit}. + * Convert a {@link Limit} to a Lettuce {@link io.lettuce.core.Limit}. * * @param limit * @return a lettuce {@link io.lettuce.core.Limit}. * @since 2.0 */ - public static io.lettuce.core.Limit toLimit(RedisZSetCommands.Limit limit) { - return limit.isUnlimited() ? Limit.unlimited() : Limit.create(limit.getOffset(), limit.getCount()); + public static io.lettuce.core.Limit toLimit(Limit limit) { + return limit.isUnlimited() ? io.lettuce.core.Limit.unlimited() + : io.lettuce.core.Limit.create(limit.getOffset(), limit.getCount()); } /** diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommands.java index 5ab6f3c89..3bf31487f 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommands.java @@ -21,7 +21,6 @@ import io.lettuce.core.ScoredValue; import io.lettuce.core.Value; import io.lettuce.core.ZAddArgs; import io.lettuce.core.ZStoreArgs; -import org.springframework.data.redis.core.TimeoutUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -32,7 +31,6 @@ import java.util.concurrent.TimeUnit; import org.reactivestreams.Publisher; import org.springframework.data.domain.Sort.Direction; -import org.springframework.data.redis.connection.DefaultTuple; import org.springframework.data.redis.connection.ReactiveRedisConnection.CommandResponse; import org.springframework.data.redis.connection.ReactiveRedisConnection.KeyCommand; import org.springframework.data.redis.connection.ReactiveRedisConnection.KeyScanCommand; @@ -40,7 +38,9 @@ import org.springframework.data.redis.connection.ReactiveRedisConnection.MultiVa import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse; import org.springframework.data.redis.connection.ReactiveZSetCommands; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.core.TimeoutUtils; import org.springframework.data.redis.util.ByteUtils; import org.springframework.lang.Nullable; import org.springframework.util.Assert; diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStreamCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStreamCommands.java index 60b266b34..b10c264c0 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStreamCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStreamCommands.java @@ -28,8 +28,8 @@ import java.util.Objects; import java.util.function.Function; import org.springframework.data.domain.Range; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisStreamCommands; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.stream.ByteRecord; import org.springframework.data.redis.connection.stream.Consumer; import org.springframework.data.redis.connection.stream.MapRecord; diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceZSetCommands.java index 332a0eaf9..14614056b 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceZSetCommands.java @@ -30,6 +30,8 @@ import java.util.concurrent.TimeUnit; import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.connection.RedisZSetCommands.ZAddArgs.Flag; import org.springframework.data.redis.connection.convert.Converters; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.KeyBoundCursor; import org.springframework.data.redis.core.ScanIteration; @@ -161,7 +163,8 @@ class LettuceZSetCommands implements RedisZSetCommands { } @Override - public Set zRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZRANGEBYSCOREWITHSCORES must not be null!"); @@ -198,7 +201,7 @@ class LettuceZSetCommands implements RedisZSetCommands { } @Override - public Set zRevRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZREVRANGEBYSCORE must not be null!"); @@ -217,7 +220,8 @@ class LettuceZSetCommands implements RedisZSetCommands { } @Override - public Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZREVRANGEBYSCOREWITHSCORES must not be null!"); @@ -584,7 +588,7 @@ class LettuceZSetCommands implements RedisZSetCommands { } @Override - public Set zRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZRANGEBYSCORE must not be null!"); @@ -600,7 +604,7 @@ class LettuceZSetCommands implements RedisZSetCommands { } @Override - public Set zRangeByLex(byte[] key, Range range, Limit limit) { + public Set zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZRANGEBYLEX must not be null!"); @@ -617,7 +621,7 @@ class LettuceZSetCommands implements RedisZSetCommands { } @Override - public Set zRevRangeByLex(byte[] key, Range range, Limit limit) { + public Set zRevRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(range, "Range for ZREVRANGEBYLEX must not be null!"); diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultTuple.java b/src/main/java/org/springframework/data/redis/connection/zset/DefaultTuple.java similarity index 92% rename from src/main/java/org/springframework/data/redis/connection/DefaultTuple.java rename to src/main/java/org/springframework/data/redis/connection/zset/DefaultTuple.java index 1a115571e..42808c890 100644 --- a/src/main/java/org/springframework/data/redis/connection/DefaultTuple.java +++ b/src/main/java/org/springframework/data/redis/connection/zset/DefaultTuple.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2022 the original author or authors. + * Copyright 2022 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. @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.redis.connection; +package org.springframework.data.redis.connection.zset; import java.util.Arrays; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; - /** * Default implementation for {@link Tuple} interface. * diff --git a/src/main/java/org/springframework/data/redis/connection/zset/Tuple.java b/src/main/java/org/springframework/data/redis/connection/zset/Tuple.java new file mode 100644 index 000000000..d720351a0 --- /dev/null +++ b/src/main/java/org/springframework/data/redis/connection/zset/Tuple.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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 org.springframework.data.redis.connection.zset; + +/** + * ZSet tuple. + */ +public interface Tuple extends Comparable { + + /** + * @return the raw value of the member. + */ + byte[] getValue(); + + /** + * @return the member score value used for sorting. + */ + Double getScore(); + + /** + * Create a new {@link Tuple}. + * + * @param value + * @param score + * @return + */ + static Tuple of(byte[] value, Double score) { + return new DefaultTuple(value, score); + } +} diff --git a/src/main/java/org/springframework/data/redis/connection/zset/Weights.java b/src/main/java/org/springframework/data/redis/connection/zset/Weights.java new file mode 100644 index 000000000..946aa7416 --- /dev/null +++ b/src/main/java/org/springframework/data/redis/connection/zset/Weights.java @@ -0,0 +1,165 @@ +/* + * Copyright 2022 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 org.springframework.data.redis.connection.zset; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.function.DoubleUnaryOperator; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; + +import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; + +/** + * Value object encapsulating a multiplication factor for each input sorted set. This means that the score of every + * element in every input sorted set is multiplied by this factor before being passed to the aggregation function. + * + * @author Mark Paluch + * @author Christoph Strobl + * @since 2.1 + */ +public class Weights { + + private final List weights; + + private Weights(List weights) { + this.weights = weights; + } + + /** + * Create new {@link Weights} given {@code weights} as {@code int}. + * + * @param weights must not be {@literal null}. + * @return the {@link Weights} for {@code weights}. + */ + public static Weights of(int... weights) { + + Assert.notNull(weights, "Weights must not be null!"); + return new Weights(Arrays.stream(weights).mapToDouble(value -> value).boxed().collect(Collectors.toList())); + } + + /** + * Create new {@link Weights} given {@code weights} as {@code double}. + * + * @param weights must not be {@literal null}. + * @return the {@link Weights} for {@code weights}. + */ + public static Weights of(double... weights) { + + Assert.notNull(weights, "Weights must not be null!"); + + return new Weights(DoubleStream.of(weights).boxed().collect(Collectors.toList())); + } + + /** + * Creates equal {@link Weights} for a number of input sets {@code count} with a weight of one. + * + * @param count number of input sets. Must be greater or equal to zero. + * @return equal {@link Weights} for a number of input sets with a weight of one. + */ + public static Weights fromSetCount(int count) { + + Assert.isTrue(count >= 0, "Count of input sorted sets must be greater or equal to zero!"); + + return new Weights(IntStream.range(0, count).mapToDouble(value -> 1).boxed().collect(Collectors.toList())); + } + + /** + * Creates a new {@link Weights} object that contains all weights multiplied by {@code multiplier} + * + * @param multiplier multiplier used to multiply each weight with. + * @return equal {@link Weights} for a number of input sets with a weight of one. + */ + public Weights multiply(int multiplier) { + return apply(it -> it * multiplier); + } + + /** + * Creates a new {@link Weights} object that contains all weights multiplied by {@code multiplier} + * + * @param multiplier multiplier used to multiply each weight with. + * @return equal {@link Weights} for a number of input sets with a weight of one. + */ + public Weights multiply(double multiplier) { + return apply(it -> it * multiplier); + } + + /** + * Creates a new {@link Weights} object that contains all weights with {@link Function} applied. + * + * @param operator operator function. + * @return the new {@link Weights} with {@link DoubleUnaryOperator} applied. + */ + public Weights apply(Function operator) { + return new Weights(weights.stream().map(operator).collect(Collectors.toList())); + } + + /** + * Retrieve the weight at {@code index}. + * + * @param index the weight index. + * @return the weight at {@code index}. + * @throws IndexOutOfBoundsException if the index is out of range + */ + public double getWeight(int index) { + return weights.get(index); + } + + /** + * @return number of weights. + */ + public int size() { + return weights.size(); + } + + /** + * @return an array containing all of the weights in this list in proper sequence (from first to last element). + */ + public double[] toArray() { + return weights.stream().mapToDouble(Double::doubleValue).toArray(); + } + + /** + * @return a {@link List} containing all of the weights in this list in proper sequence (from first to last element). + */ + public List toList() { + return Collections.unmodifiableList(weights); + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + + if (!(o instanceof Weights)) { + return false; + } + + Weights that = (Weights) o; + return ObjectUtils.nullSafeEquals(this.weights, that.weights); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(weights); + } +} diff --git a/src/main/java/org/springframework/data/redis/core/AbstractOperations.java b/src/main/java/org/springframework/data/redis/core/AbstractOperations.java index 69842638d..da6a56d0f 100644 --- a/src/main/java/org/springframework/data/redis/core/AbstractOperations.java +++ b/src/main/java/org/springframework/data/redis/core/AbstractOperations.java @@ -25,11 +25,11 @@ import java.util.Map; import java.util.Set; import org.springframework.data.geo.GeoResults; -import org.springframework.data.redis.connection.DefaultTuple; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.connection.convert.Converters; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.SerializationUtils; diff --git a/src/main/java/org/springframework/data/redis/core/BoundStreamOperations.java b/src/main/java/org/springframework/data/redis/core/BoundStreamOperations.java index b591c95dd..ac9265e12 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundStreamOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundStreamOperations.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.Map; import org.springframework.data.domain.Range; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.stream.Consumer; import org.springframework.data.redis.connection.stream.MapRecord; import org.springframework.data.redis.connection.stream.ReadOffset; diff --git a/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java b/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java index 70cb8344f..2dc8433ec 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java @@ -22,11 +22,11 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Range; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; import org.springframework.lang.Nullable; import org.springframework.util.Assert; diff --git a/src/main/java/org/springframework/data/redis/core/DefaultBoundStreamOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultBoundStreamOperations.java index c36741bce..579c527b3 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultBoundStreamOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultBoundStreamOperations.java @@ -20,13 +20,13 @@ import java.util.Map; import org.springframework.data.domain.Range; import org.springframework.data.redis.connection.DataType; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.stream.Consumer; import org.springframework.data.redis.connection.stream.MapRecord; import org.springframework.data.redis.connection.stream.ReadOffset; import org.springframework.data.redis.connection.stream.RecordId; import org.springframework.data.redis.connection.stream.StreamOffset; import org.springframework.data.redis.connection.stream.StreamReadOptions; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.lang.Nullable; /** diff --git a/src/main/java/org/springframework/data/redis/core/DefaultBoundZSetOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultBoundZSetOperations.java index 0fbe1dc78..b440ba08f 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultBoundZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultBoundZSetOperations.java @@ -22,10 +22,10 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.springframework.data.redis.connection.DataType; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Range; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; import org.springframework.lang.Nullable; diff --git a/src/main/java/org/springframework/data/redis/core/DefaultReactiveStreamOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultReactiveStreamOperations.java index 101f5d0ce..9cf9e65ba 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultReactiveStreamOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultReactiveStreamOperations.java @@ -30,8 +30,8 @@ import org.reactivestreams.Publisher; import org.springframework.core.convert.ConversionService; import org.springframework.data.domain.Range; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.ReactiveStreamCommands; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.convert.Converters; import org.springframework.data.redis.connection.stream.ByteBufferRecord; import org.springframework.data.redis.connection.stream.Consumer; diff --git a/src/main/java/org/springframework/data/redis/core/DefaultReactiveZSetOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultReactiveZSetOperations.java index 02585b5df..c2e041321 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultReactiveZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultReactiveZSetOperations.java @@ -27,13 +27,14 @@ import java.util.List; import java.util.function.Function; import org.reactivestreams.Publisher; + import org.springframework.data.domain.Range; -import org.springframework.data.redis.connection.DefaultTuple; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.ReactiveZSetCommands; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; import org.springframework.data.redis.serializer.RedisSerializationContext; import org.springframework.data.redis.util.ByteUtils; diff --git a/src/main/java/org/springframework/data/redis/core/DefaultStreamOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultStreamOperations.java index f5359c331..de5a95577 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultStreamOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultStreamOperations.java @@ -24,8 +24,8 @@ import java.util.Map; import org.springframework.core.convert.ConversionService; import org.springframework.data.domain.Range; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisConnection; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.stream.ByteRecord; import org.springframework.data.redis.connection.stream.Consumer; import org.springframework.data.redis.connection.stream.MapRecord; diff --git a/src/main/java/org/springframework/data/redis/core/DefaultZSetOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultZSetOperations.java index 8c1d07288..e04838179 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultZSetOperations.java @@ -22,12 +22,12 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Range; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; import org.springframework.data.redis.connection.RedisZSetCommands.ZAddArgs; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.lang.Nullable; import org.springframework.util.Assert; diff --git a/src/main/java/org/springframework/data/redis/core/ReactiveStreamOperations.java b/src/main/java/org/springframework/data/redis/core/ReactiveStreamOperations.java index 0df964e9c..ff6e662f3 100644 --- a/src/main/java/org/springframework/data/redis/core/ReactiveStreamOperations.java +++ b/src/main/java/org/springframework/data/redis/core/ReactiveStreamOperations.java @@ -22,24 +22,14 @@ import java.util.Arrays; import java.util.Map; import org.reactivestreams.Publisher; + import org.springframework.data.domain.Range; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; -import org.springframework.data.redis.connection.stream.ByteBufferRecord; -import org.springframework.data.redis.connection.stream.Consumer; -import org.springframework.data.redis.connection.stream.MapRecord; -import org.springframework.data.redis.connection.stream.ObjectRecord; -import org.springframework.data.redis.connection.stream.PendingMessage; -import org.springframework.data.redis.connection.stream.PendingMessages; -import org.springframework.data.redis.connection.stream.PendingMessagesSummary; -import org.springframework.data.redis.connection.stream.ReadOffset; +import org.springframework.data.redis.connection.Limit; +import org.springframework.data.redis.connection.stream.*; import org.springframework.data.redis.connection.stream.Record; -import org.springframework.data.redis.connection.stream.RecordId; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoConsumer; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoGroup; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoStream; -import org.springframework.data.redis.connection.stream.StreamOffset; -import org.springframework.data.redis.connection.stream.StreamReadOptions; -import org.springframework.data.redis.connection.stream.StreamRecords; import org.springframework.data.redis.hash.HashMapper; import org.springframework.lang.Nullable; import org.springframework.util.Assert; diff --git a/src/main/java/org/springframework/data/redis/core/ReactiveZSetOperations.java b/src/main/java/org/springframework/data/redis/core/ReactiveZSetOperations.java index 2fd239d40..168e8ee26 100644 --- a/src/main/java/org/springframework/data/redis/core/ReactiveZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/ReactiveZSetOperations.java @@ -24,10 +24,10 @@ import java.util.Collections; import java.util.List; import org.springframework.data.domain.Range; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; /** diff --git a/src/main/java/org/springframework/data/redis/core/RedisTemplate.java b/src/main/java/org/springframework/data/redis/core/RedisTemplate.java index dc35f5eec..1ddc971e9 100644 --- a/src/main/java/org/springframework/data/redis/core/RedisTemplate.java +++ b/src/main/java/org/springframework/data/redis/core/RedisTemplate.java @@ -36,8 +36,8 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisKeyCommands; import org.springframework.data.redis.connection.RedisServerCommands; import org.springframework.data.redis.connection.RedisTxCommands; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.connection.SortParameters; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; import org.springframework.data.redis.core.query.QueryUtils; import org.springframework.data.redis.core.query.SortQuery; diff --git a/src/main/java/org/springframework/data/redis/core/StreamOperations.java b/src/main/java/org/springframework/data/redis/core/StreamOperations.java index c9498dee5..e0f758cc2 100644 --- a/src/main/java/org/springframework/data/redis/core/StreamOperations.java +++ b/src/main/java/org/springframework/data/redis/core/StreamOperations.java @@ -22,23 +22,12 @@ import java.util.List; import java.util.Map; import org.springframework.data.domain.Range; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; -import org.springframework.data.redis.connection.stream.ByteRecord; -import org.springframework.data.redis.connection.stream.Consumer; -import org.springframework.data.redis.connection.stream.MapRecord; -import org.springframework.data.redis.connection.stream.ObjectRecord; -import org.springframework.data.redis.connection.stream.PendingMessage; -import org.springframework.data.redis.connection.stream.PendingMessages; -import org.springframework.data.redis.connection.stream.PendingMessagesSummary; -import org.springframework.data.redis.connection.stream.ReadOffset; +import org.springframework.data.redis.connection.Limit; +import org.springframework.data.redis.connection.stream.*; import org.springframework.data.redis.connection.stream.Record; -import org.springframework.data.redis.connection.stream.RecordId; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoConsumers; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoGroups; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoStream; -import org.springframework.data.redis.connection.stream.StreamOffset; -import org.springframework.data.redis.connection.stream.StreamReadOptions; -import org.springframework.data.redis.connection.stream.StreamRecords; import org.springframework.data.redis.hash.HashMapper; import org.springframework.lang.Nullable; import org.springframework.util.Assert; diff --git a/src/main/java/org/springframework/data/redis/core/ZSetOperations.java b/src/main/java/org/springframework/data/redis/core/ZSetOperations.java index ece1603c6..280d32550 100644 --- a/src/main/java/org/springframework/data/redis/core/ZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/ZSetOperations.java @@ -22,11 +22,11 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Range; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.lang.Nullable; import org.springframework.util.Assert; diff --git a/src/main/java/org/springframework/data/redis/support/collections/DefaultRedisZSet.java b/src/main/java/org/springframework/data/redis/support/collections/DefaultRedisZSet.java index dfdec74d0..f28421c2a 100644 --- a/src/main/java/org/springframework/data/redis/support/collections/DefaultRedisZSet.java +++ b/src/main/java/org/springframework/data/redis/support/collections/DefaultRedisZSet.java @@ -22,7 +22,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.springframework.data.redis.connection.DataType; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Range; import org.springframework.data.redis.core.BoundZSetOperations; import org.springframework.data.redis.core.ConvertingCursor; diff --git a/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java b/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java index 44784c9e2..3d2db6f58 100644 --- a/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java +++ b/src/main/java/org/springframework/data/redis/support/collections/RedisZSet.java @@ -23,9 +23,9 @@ import java.util.Set; import java.util.SortedSet; import java.util.concurrent.TimeUnit; -import org.springframework.data.redis.connection.RedisZSetCommands; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Range; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.BoundZSetOperations; import org.springframework.data.redis.core.RedisOperations; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; @@ -333,7 +333,7 @@ public interface RedisZSet extends RedisCollection, Set { Set reverseRangeByScore(double min, double max); /** - * Get set of {@link RedisZSetCommands.Tuple}s between {@code start} and {@code end} from sorted set. + * Get set of {@link Tuple}s between {@code start} and {@code end} from sorted set. * * @param start * @param end @@ -342,8 +342,7 @@ public interface RedisZSet extends RedisCollection, Set { Set> rangeWithScores(long start, long end); /** - * Get set of {@link RedisZSetCommands.Tuple}s in range from {@code start} to {@code end} from sorted set ordered from - * high to low. + * Get set of {@link Tuple}s in range from {@code start} to {@code end} from sorted set ordered from high to low. * * @param start * @param end @@ -352,7 +351,7 @@ public interface RedisZSet extends RedisCollection, Set { Set> reverseRangeWithScores(long start, long end); /** - * Get set of {@link RedisZSetCommands.Tuple}s where score is between {@code min} and {@code max} from sorted set. + * Get set of {@link Tuple}s where score is between {@code min} and {@code max} from sorted set. * * @param min * @param max @@ -361,8 +360,8 @@ public interface RedisZSet extends RedisCollection, Set { Set> rangeByScoreWithScores(double min, double max); /** - * Get set of {@link RedisZSetCommands.Tuple}s where score is between {@code min} and {@code max} from sorted set - * ordered from high to low. + * Get set of {@link Tuple}s where score is between {@code min} and {@code max} from sorted set ordered from high to + * low. * * @param min * @param max diff --git a/src/main/kotlin/org/springframework/data/redis/core/ReactiveStreamOperationsExtensions.kt b/src/main/kotlin/org/springframework/data/redis/core/ReactiveStreamOperationsExtensions.kt index 04c07bd99..0b858c834 100644 --- a/src/main/kotlin/org/springframework/data/redis/core/ReactiveStreamOperationsExtensions.kt +++ b/src/main/kotlin/org/springframework/data/redis/core/ReactiveStreamOperationsExtensions.kt @@ -20,7 +20,7 @@ import kotlinx.coroutines.reactive.asFlow import kotlinx.coroutines.reactive.asPublisher import kotlinx.coroutines.reactive.awaitSingle import org.springframework.data.domain.Range -import org.springframework.data.redis.connection.RedisZSetCommands.Limit +import org.springframework.data.redis.connection.Limit import org.springframework.data.redis.connection.stream.* /** diff --git a/src/main/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensions.kt b/src/main/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensions.kt index d6cdaaef0..03ead1eb6 100644 --- a/src/main/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensions.kt +++ b/src/main/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensions.kt @@ -20,9 +20,10 @@ import kotlinx.coroutines.reactive.asFlow import kotlinx.coroutines.reactive.awaitFirstOrNull import kotlinx.coroutines.reactive.awaitSingle import org.springframework.data.domain.Range +import org.springframework.data.redis.connection.Limit import org.springframework.data.redis.connection.RedisZSetCommands -import org.springframework.data.redis.connection.RedisZSetCommands.Limit -import org.springframework.data.redis.core.ZSetOperations.* +import org.springframework.data.redis.connection.zset.Weights +import org.springframework.data.redis.core.ZSetOperations.TypedTuple /** * Coroutines variant of [ReactiveZSetOperations.add]. @@ -237,8 +238,14 @@ suspend fun ReactiveZSetOperations.unionAndStoreAndAwai * @author Mark Paluch * @since 2.2 */ -suspend fun ReactiveZSetOperations.unionAndStoreAndAwait(key: K, otherKeys: Collection, destKey: K, aggregate: RedisZSetCommands.Aggregate, weights: RedisZSetCommands.Weights): Long = - unionAndStore(key, otherKeys, destKey, aggregate, weights).awaitSingle() +suspend fun ReactiveZSetOperations.unionAndStoreAndAwait( + key: K, + otherKeys: Collection, + destKey: K, + aggregate: RedisZSetCommands.Aggregate, + weights: Weights +): Long = + unionAndStore(key, otherKeys, destKey, aggregate, weights).awaitSingle() /** * Coroutines variant of [ReactiveZSetOperations.intersectAndStore]. @@ -273,8 +280,14 @@ suspend fun ReactiveZSetOperations.intersectAndStoreAnd * @author Mark Paluch * @since 2.2 */ -suspend fun ReactiveZSetOperations.intersectAndStoreAndAwait(key: K, otherKeys: Collection, destKey: K, aggregate: RedisZSetCommands.Aggregate, weights: RedisZSetCommands.Weights): Long = - intersectAndStore(key, otherKeys, destKey, aggregate, weights).awaitSingle() +suspend fun ReactiveZSetOperations.intersectAndStoreAndAwait( + key: K, + otherKeys: Collection, + destKey: K, + aggregate: RedisZSetCommands.Aggregate, + weights: Weights +): Long = + intersectAndStore(key, otherKeys, destKey, aggregate, weights).awaitSingle() /** * Coroutines variant of [ReactiveZSetOperations.rangeByLex]. diff --git a/src/test/java/org/springframework/data/redis/VersionParserUnitTests.java b/src/test/java/org/springframework/data/redis/VersionParserUnitTests.java deleted file mode 100644 index c1f6c22da..000000000 --- a/src/test/java/org/springframework/data/redis/VersionParserUnitTests.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2014-2022 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 org.springframework.data.redis; - -import static org.assertj.core.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -/** - * @author Christoph Strobl - */ -class VersionParserUnitTests { - - @Test - void shouldParseNullToUnknown() { - assertThat(VersionParser.parseVersion(null)).isEqualTo(Version.UNKNOWN); - } - - @Test - void shouldParseEmptyVersionStringToUnknown() { - assertThat(VersionParser.parseVersion("")).isEqualTo(Version.UNKNOWN); - } - - @Test - void shouldParseInvalidVersionStringToUnknown() { - assertThat(VersionParser.parseVersion("ThisIsNoValidVersion")).isEqualTo(Version.UNKNOWN); - } - - @Test - void shouldParseMajorMinorWithoutPatchCorrectly() { - assertThat(VersionParser.parseVersion("1.2")).isEqualTo(new Version(1, 2, 0)); - } - - @Test - void shouldParseMajorMinorPatchCorrectly() { - assertThat(VersionParser.parseVersion("1.2.3")).isEqualTo(new Version(1, 2, 3)); - } - - @Test - void shouldParseMajorWithoutMinorPatchCorrectly() { - assertThat(VersionParser.parseVersion("1.2.3.a")).isEqualTo(new Version(1, 2, 3)); - } -} diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java index a385f9ae5..dba642ff4 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java @@ -59,9 +59,7 @@ import org.springframework.data.redis.connection.RedisStreamCommands.XClaimOptio import org.springframework.data.redis.connection.RedisStringCommands.BitOperation; import org.springframework.data.redis.connection.RedisStringCommands.SetOption; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.RedisZSetCommands.Range; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.connection.RedisZSetCommands.ZAddArgs; import org.springframework.data.redis.connection.SortParameters.Order; import org.springframework.data.redis.connection.StringRedisConnection.StringTuple; @@ -77,6 +75,8 @@ import org.springframework.data.redis.connection.stream.StreamInfo.XInfoGroups; import org.springframework.data.redis.connection.stream.StreamInfo.XInfoStream; import org.springframework.data.redis.connection.stream.StreamOffset; import org.springframework.data.redis.connection.stream.StringRecord; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.KeyScanOptions; import org.springframework.data.redis.core.ScanOptions; diff --git a/src/test/java/org/springframework/data/redis/connection/DefaultStringRedisConnectionTests.java b/src/test/java/org/springframework/data/redis/connection/DefaultStringRedisConnectionTests.java index 7c500100e..8d8261693 100644 --- a/src/test/java/org/springframework/data/redis/connection/DefaultStringRedisConnectionTests.java +++ b/src/test/java/org/springframework/data/redis/connection/DefaultStringRedisConnectionTests.java @@ -50,9 +50,6 @@ import org.springframework.data.redis.connection.RedisServerCommands.ShutdownOpt import org.springframework.data.redis.connection.RedisStreamCommands.XAddOptions; import org.springframework.data.redis.connection.RedisStringCommands.BitOperation; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; import org.springframework.data.redis.connection.StringRedisConnection.StringTuple; import org.springframework.data.redis.connection.convert.Converters; import org.springframework.data.redis.connection.stream.Consumer; @@ -61,6 +58,9 @@ import org.springframework.data.redis.connection.stream.RecordId; import org.springframework.data.redis.connection.stream.StreamOffset; import org.springframework.data.redis.connection.stream.StreamReadOptions; import org.springframework.data.redis.connection.stream.StreamRecords; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.serializer.StringRedisSerializer; /** diff --git a/src/test/java/org/springframework/data/redis/connection/RedisConnectionUnitTests.java b/src/test/java/org/springframework/data/redis/connection/RedisConnectionUnitTests.java index 0dc1999af..3c5948a69 100644 --- a/src/test/java/org/springframework/data/redis/connection/RedisConnectionUnitTests.java +++ b/src/test/java/org/springframework/data/redis/connection/RedisConnectionUnitTests.java @@ -35,6 +35,8 @@ import org.springframework.data.geo.GeoResults; import org.springframework.data.geo.Metric; import org.springframework.data.geo.Point; import org.springframework.data.redis.connection.RedisNode.RedisNodeBuilder; +import org.springframework.data.redis.connection.zset.Tuple; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.types.Expiration; @@ -947,12 +949,13 @@ class RedisConnectionUnitTests { } @Override - public Set zRangeByLex(byte[] key, Range range, Limit limit) { + public Set zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return delegate.zRangeByLex(key, range, limit); } @Override - public Set zRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { return delegate.zRangeByScoreWithScores(key, range, limit); } @@ -962,12 +965,14 @@ class RedisConnectionUnitTests { } @Override - public Set zRevRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScore(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { return delegate.zRevRangeByScore(key, range, limit); } @Override - public Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) { + public Set zRevRangeByScoreWithScores(byte[] key, Range range, + org.springframework.data.redis.connection.Limit limit) { return delegate.zRevRangeByScoreWithScores(key, range, limit); } @@ -992,7 +997,7 @@ class RedisConnectionUnitTests { } @Override - public Set zRangeByScore(byte[] key, Range range, Limit limit) { + public Set zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) { return delegate.zRangeByScore(key, range, limit); } diff --git a/src/test/java/org/springframework/data/redis/connection/WeightsUnitTests.java b/src/test/java/org/springframework/data/redis/connection/WeightsUnitTests.java index fe936b69d..f54225216 100644 --- a/src/test/java/org/springframework/data/redis/connection/WeightsUnitTests.java +++ b/src/test/java/org/springframework/data/redis/connection/WeightsUnitTests.java @@ -15,14 +15,14 @@ */ package org.springframework.data.redis.connection; -import org.junit.jupiter.api.Test; - import static org.assertj.core.api.Assertions.*; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; +import org.junit.jupiter.api.Test; + +import org.springframework.data.redis.connection.zset.Weights; /** - * Unit tests for {@link org.springframework.data.redis.connection.RedisZSetCommands.Weights}. + * Unit tests for {@link Weights}. * * @author Mark Paluch */ diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java index 8c45079de..6c5606aeb 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java @@ -56,7 +56,7 @@ import org.springframework.data.redis.connection.ClusterConnectionTests; import org.springframework.data.redis.connection.ClusterSlotHashUtil; import org.springframework.data.redis.connection.DataType; import org.springframework.data.redis.connection.DefaultSortParameters; -import org.springframework.data.redis.connection.DefaultTuple; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisClusterNode.SlotRange; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; @@ -66,6 +66,8 @@ import org.springframework.data.redis.connection.RedisStringCommands.BitOperatio import org.springframework.data.redis.connection.RedisStringCommands.SetOption; import org.springframework.data.redis.connection.ReturnType; import org.springframework.data.redis.connection.ValueEncoding.RedisValueEncoding; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.script.DigestUtils; diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionUnitTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionUnitTests.java index fc2f7a67e..256b3d4a1 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionUnitTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionUnitTests.java @@ -37,7 +37,7 @@ import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.InvalidDataAccessResourceUsageException; import org.springframework.data.redis.connection.AbstractConnectionUnitTestBase; import org.springframework.data.redis.connection.RedisServerCommands.ShutdownOption; -import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.test.util.ReflectionTestUtils; diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java index 898a35587..476214a55 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java @@ -49,6 +49,7 @@ import org.springframework.data.geo.Distance; import org.springframework.data.geo.GeoResults; import org.springframework.data.geo.Point; import org.springframework.data.redis.connection.*; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisClusterNode.SlotRange; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; import org.springframework.data.redis.connection.RedisListCommands.Position; @@ -56,6 +57,8 @@ import org.springframework.data.redis.connection.RedisServerCommands.FlushOption import org.springframework.data.redis.connection.RedisStringCommands.BitOperation; import org.springframework.data.redis.connection.RedisStringCommands.SetOption; import org.springframework.data.redis.connection.ValueEncoding.RedisValueEncoding; +import org.springframework.data.redis.connection.zset.DefaultTuple; +import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.types.Expiration; diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConvertersUnitTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConvertersUnitTests.java index 0838b5cee..df1e85655 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConvertersUnitTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConvertersUnitTests.java @@ -40,7 +40,6 @@ import org.springframework.data.redis.connection.RedisClusterNode.LinkState; import org.springframework.data.redis.connection.RedisPassword; import org.springframework.data.redis.connection.RedisSentinelConfiguration; import org.springframework.data.redis.connection.RedisStringCommands.SetOption; -import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.core.types.Expiration; import org.springframework.data.redis.core.types.RedisClientInfo; @@ -204,15 +203,15 @@ class LettuceConvertersUnitTests { @Test // DATAREDIS-981 void toLimit() { - Limit limit = LettuceConverters.toLimit(RedisZSetCommands.Limit.unlimited()); + Limit limit = LettuceConverters.toLimit(org.springframework.data.redis.connection.Limit.unlimited()); assertThat(limit.isLimited()).isFalse(); assertThat(limit.getCount()).isEqualTo(-1L); - limit = LettuceConverters.toLimit(RedisZSetCommands.Limit.limit().count(-1)); + limit = LettuceConverters.toLimit(org.springframework.data.redis.connection.Limit.limit().count(-1)); assertThat(limit.isLimited()).isTrue(); assertThat(limit.getCount()).isEqualTo(-1L); - limit = LettuceConverters.toLimit(RedisZSetCommands.Limit.limit().count(5)); + limit = LettuceConverters.toLimit(org.springframework.data.redis.connection.Limit.limit().count(5)); assertThat(limit.isLimited()).isTrue(); assertThat(limit.getCount()).isEqualTo(5L); } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStreamCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStreamCommandsIntegrationTests.java index d459b68e2..87b742b40 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStreamCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStreamCommandsIntegrationTests.java @@ -28,8 +28,8 @@ import org.junit.Ignore; import org.springframework.data.domain.Range; import org.springframework.data.redis.RedisSystemException; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisStreamCommands.XClaimOptions; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.stream.Consumer; import org.springframework.data.redis.connection.stream.ReadOffset; import org.springframework.data.redis.connection.stream.RecordId; diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommandsIntegrationTests.java index 11e29e22a..7d952b74a 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommandsIntegrationTests.java @@ -26,7 +26,7 @@ import java.time.Duration; import java.util.Arrays; import org.springframework.data.domain.Range; -import org.springframework.data.redis.connection.DefaultTuple; +import org.springframework.data.redis.connection.zset.DefaultTuple; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.test.condition.EnabledOnCommand; import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveStreamOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveStreamOperationsIntegrationTests.java index 7ecf51368..499dfb6bb 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveStreamOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveStreamOperationsIntegrationTests.java @@ -30,9 +30,9 @@ import org.springframework.data.domain.Range.Bound; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.Person; import org.springframework.data.redis.PersonObjectFactory; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.stream.Consumer; import org.springframework.data.redis.connection.stream.MapRecord; import org.springframework.data.redis.connection.stream.ReadOffset; diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveZSetOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveZSetOperationsIntegrationTests.java index a5a2f3e81..654f8d83b 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveZSetOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveZSetOperationsIntegrationTests.java @@ -32,11 +32,11 @@ import org.junit.jupiter.api.Disabled; import org.springframework.data.domain.Range; import org.springframework.data.redis.ByteBufferObjectFactory; import org.springframework.data.redis.ObjectFactory; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.ReactiveOperationsTestParams.Fixture; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; diff --git a/src/test/java/org/springframework/data/redis/core/DefaultStreamOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultStreamOperationsIntegrationTests.java index 8a6410fa9..895e921ad 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultStreamOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultStreamOperationsIntegrationTests.java @@ -29,8 +29,8 @@ import org.springframework.data.domain.Range; import org.springframework.data.domain.Range.Bound; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.Person; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.connection.RedisZSetCommands.Limit; import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; diff --git a/src/test/java/org/springframework/data/redis/core/DefaultZSetOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultZSetOperationsIntegrationTests.java index 93a036b7a..ae9347c3b 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultZSetOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultZSetOperationsIntegrationTests.java @@ -35,8 +35,9 @@ import org.springframework.data.redis.LongAsStringObjectFactory; import org.springframework.data.redis.LongObjectFactory; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.RawObjectFactory; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisZSetCommands; -import org.springframework.data.redis.connection.RedisZSetCommands.Weights; +import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; import org.springframework.data.redis.test.condition.EnabledOnCommand; import org.springframework.data.redis.test.extension.parametrized.MethodSource; @@ -348,7 +349,7 @@ public class DefaultZSetOperationsIntegrationTests { zSetOps.add(key, value2, 3.7); zSetOps.add(key, value3, 5.8); Set tuples = zSetOps.rangeByLex(key, RedisZSetCommands.Range.unbounded(), - RedisZSetCommands.Limit.limit().count(2).offset(1)); + Limit.limit().count(2).offset(1)); assertThat(tuples).hasSize(2).containsSequence(value2, value3); } @@ -368,7 +369,7 @@ public class DefaultZSetOperationsIntegrationTests { zSetOps.add(key, value2, 3.7); zSetOps.add(key, value3, 5.8); Set tuples = zSetOps.reverseRangeByLex(key, RedisZSetCommands.Range.unbounded(), - RedisZSetCommands.Limit.limit().count(2).offset(1)); + Limit.limit().count(2).offset(1)); assertThat(tuples).hasSize(2).containsSequence(value2, value1); } @@ -388,7 +389,7 @@ public class DefaultZSetOperationsIntegrationTests { zSetOps.add(key, value2, 3.7); zSetOps.add(key, value3, 5.8); Set tuples = zSetOps.rangeByLex(key, RedisZSetCommands.Range.range().gte(value1), - RedisZSetCommands.Limit.limit().count(1).offset(1)); + Limit.limit().count(1).offset(1)); assertThat(tuples).hasSize(1).startsWith(value2); } diff --git a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java index 458716150..15bcc2ac5 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java +++ b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java @@ -34,6 +34,7 @@ import org.springframework.data.redis.DoubleObjectFactory; import org.springframework.data.redis.LongAsStringObjectFactory; import org.springframework.data.redis.LongObjectFactory; import org.springframework.data.redis.ObjectFactory; +import org.springframework.data.redis.connection.Limit; import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.core.BoundZSetOperations; import org.springframework.data.redis.core.Cursor; @@ -441,7 +442,7 @@ public abstract class AbstractRedisZSetTestIntegration extends AbstractRedisC zSet.add(t2, 2); zSet.add(t3, 3); Set tuples = zSet.rangeByLex(RedisZSetCommands.Range.unbounded(), - RedisZSetCommands.Limit.limit().count(1).offset(1)); + Limit.limit().count(1).offset(1)); assertThat(tuples).hasSize(1); T tuple = tuples.iterator().next(); @@ -462,7 +463,7 @@ public abstract class AbstractRedisZSetTestIntegration extends AbstractRedisC zSet.add(t2, 2); zSet.add(t3, 3); Set tuples = zSet.rangeByLex(RedisZSetCommands.Range.range().gte(t1), - RedisZSetCommands.Limit.limit().count(2).offset(1)); + Limit.limit().count(2).offset(1)); assertThat(tuples).hasSize(2).containsSequence(t2, t3); } @@ -481,7 +482,7 @@ public abstract class AbstractRedisZSetTestIntegration extends AbstractRedisC zSet.add(t2, 2); zSet.add(t3, 3); Set tuples = zSet.reverseRangeByLex(RedisZSetCommands.Range.range().gte(t1), - RedisZSetCommands.Limit.limit().count(2).offset(1)); + Limit.limit().count(2).offset(1)); assertThat(tuples).hasSize(2).containsSequence(t2, t1); } diff --git a/src/test/kotlin/org/springframework/data/redis/core/ReactiveStreamOperationsExtensionsUnitTests.kt b/src/test/kotlin/org/springframework/data/redis/core/ReactiveStreamOperationsExtensionsUnitTests.kt index 14a2ed8aa..e2425e099 100644 --- a/src/test/kotlin/org/springframework/data/redis/core/ReactiveStreamOperationsExtensionsUnitTests.kt +++ b/src/test/kotlin/org/springframework/data/redis/core/ReactiveStreamOperationsExtensionsUnitTests.kt @@ -25,7 +25,7 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.reactivestreams.Publisher import org.springframework.data.domain.Range -import org.springframework.data.redis.connection.RedisZSetCommands.Limit +import org.springframework.data.redis.connection.Limit import org.springframework.data.redis.connection.stream.* import reactor.core.publisher.Flux import reactor.core.publisher.Mono diff --git a/src/test/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensionsUnitTests.kt b/src/test/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensionsUnitTests.kt index 4c30996ab..36821190b 100644 --- a/src/test/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensionsUnitTests.kt +++ b/src/test/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensionsUnitTests.kt @@ -23,10 +23,10 @@ import kotlinx.coroutines.runBlocking import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.data.domain.Range -import org.springframework.data.redis.connection.RedisZSetCommands +import org.springframework.data.redis.connection.Limit import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate -import org.springframework.data.redis.connection.RedisZSetCommands.Weights -import org.springframework.data.redis.core.ZSetOperations.* +import org.springframework.data.redis.connection.zset.Weights +import org.springframework.data.redis.core.ZSetOperations.TypedTuple import reactor.core.publisher.Flux import reactor.core.publisher.Mono @@ -204,7 +204,7 @@ class ReactiveZSetOperationsExtensionsUnitTests { } verify { - operations.rangeByScore("foo", range, RedisZSetCommands.Limit.unlimited()) + operations.rangeByScore("foo", range, Limit.unlimited()) } } @@ -221,7 +221,7 @@ class ReactiveZSetOperationsExtensionsUnitTests { } verify { - operations.rangeByScoreWithScores("foo", range, RedisZSetCommands.Limit.unlimited()) + operations.rangeByScoreWithScores("foo", range, Limit.unlimited()) } } @@ -270,7 +270,7 @@ class ReactiveZSetOperationsExtensionsUnitTests { } verify { - operations.reverseRangeByScore("foo", range, RedisZSetCommands.Limit.unlimited()) + operations.reverseRangeByScore("foo", range, Limit.unlimited()) } } @@ -287,7 +287,7 @@ class ReactiveZSetOperationsExtensionsUnitTests { } verify { - operations.reverseRangeByScoreWithScores("foo", range, RedisZSetCommands.Limit.unlimited()) + operations.reverseRangeByScoreWithScores("foo", range, Limit.unlimited()) } } @@ -527,7 +527,7 @@ class ReactiveZSetOperationsExtensionsUnitTests { } verify { - operations.rangeByLex("foo", Range.just("bar"), RedisZSetCommands.Limit.unlimited()) + operations.rangeByLex("foo", Range.just("bar"), Limit.unlimited()) } } @@ -542,7 +542,7 @@ class ReactiveZSetOperationsExtensionsUnitTests { } verify { - operations.reverseRangeByLex("foo", Range.just("bar"), RedisZSetCommands.Limit.unlimited()) + operations.reverseRangeByLex("foo", Range.just("bar"), Limit.unlimited()) } }