Skip to content

Use o.s.d.d.Range instead of inner Range class for ZSet operations #2292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0-GH-2288-SNAPSHOT</version>

<name>Spring Data Redis</name>
<description>Spring Data module for Redis</description>
Expand Down
17 changes: 13 additions & 4 deletions src/main/asciidoc/upgrading.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[[upgrading]]
= Upgrading

The following section provides information about changes that are likely to have an effect on the application and might even prevent it from compiling.
This section contains details about migration steps, deprecations, and removals.

[[upgrading.2-to-3]]
== Upgrading from 2.x to 3.x

=== Re-/moved Types

Expand All @@ -14,12 +17,18 @@ The following section provides information about changes that are likely to have
|o.s.d.redis.VersionParser
|-

|o.s.d.redis.connection.RedisZSetCommands.Aggregate
|o.s.d.redis.connection.zset.Aggregate

|o.s.d.redis.connection.RedisZSetCommands.Tuple
|o.s.d.redis.connection.zset.Tuple

|o.s.d.redis.connection.RedisZSetCommands.Weights
|o.s.d.redis.connection.zset.Weights

|o.s.d.redis.connection.RedisZSetCommands.Range
|o.s.d.domain.Range

|o.s.d.redis.connection.RedisZSetCommands.Limit
|o.s.d.redis.connection.Limit.java

Expand Down Expand Up @@ -228,16 +237,16 @@ The following section provides information about changes that are likely to have

|===

== Lettuce
=== Lettuce

=== Lettuce Pool
==== Lettuce Pool

`LettucePool` and its implementation `DefaultLettucePool` have been removed without replacement.
Please refer to the https://lettuce.io/core/release/reference/index.html#_connection_pooling[driver documentation] for driver native pooling capabilities.
Methods accepting pooling parameters have been updated.
This effects methods on `LettuceConnectionFactory` and `LettuceConnection`.

=== Lettuce Authentication
==== Lettuce Authentication

`AuthenticatingRedisClient` has been removed without replacement.
Please refer to the https://lettuce.io/core/release/reference/index.html#basic.redisuri[driver documentation] for `RedisURI` to set authentication data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
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.Aggregate;
import org.springframework.data.redis.connection.zset.DefaultTuple;
import org.springframework.data.redis.connection.zset.Tuple;
import org.springframework.data.redis.connection.zset.Weights;
Expand Down Expand Up @@ -990,7 +991,7 @@ public Long zCount(byte[] key, double min, double max) {
}

@Override
public Long zCount(byte[] key, Range range) {
public Long zCount(byte[] key, org.springframework.data.domain.Range<Number> range) {
return convertAndReturn(delegate.zCount(key, range), Converters.identityConverter());
}

Expand Down Expand Up @@ -1100,17 +1101,18 @@ public Set<byte[]> zRangeByScore(byte[] key, double min, double max, long offset
}

@Override
public Set<byte[]> zRangeByScore(byte[] key, Range range) {
public Set<byte[]> zRangeByScore(byte[] key, org.springframework.data.domain.Range<Number> range) {
return convertAndReturn(delegate.zRangeByScore(key, range), Converters.identityConverter());
}

@Override
public Set<byte[]> zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
public Set<byte[]> zRangeByScore(byte[] key, org.springframework.data.domain.Range<Number> range,
org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRangeByScore(key, range, limit), Converters.identityConverter());
}

@Override
public Set<Tuple> zRangeByScoreWithScores(byte[] key, Range range) {
public Set<Tuple> zRangeByScoreWithScores(byte[] key, org.springframework.data.domain.Range<Number> range) {
return convertAndReturn(delegate.zRangeByScoreWithScores(key, range), Converters.identityConverter());
}

Expand All @@ -1126,7 +1128,7 @@ public Set<Tuple> zRangeByScoreWithScores(byte[] key, double min, double max, lo
}

@Override
public Set<Tuple> zRangeByScoreWithScores(byte[] key, Range range,
public Set<Tuple> zRangeByScoreWithScores(byte[] key, org.springframework.data.domain.Range<Number> range,
org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRangeByScoreWithScores(key, range, limit), Converters.identityConverter());
}
Expand All @@ -1147,7 +1149,7 @@ public Set<byte[]> zRevRangeByScore(byte[] key, double min, double max, long off
}

@Override
public Set<byte[]> zRevRangeByScore(byte[] key, Range range) {
public Set<byte[]> zRevRangeByScore(byte[] key, org.springframework.data.domain.Range<Number> range) {
return convertAndReturn(delegate.zRevRangeByScore(key, range), Converters.identityConverter());
}

Expand All @@ -1157,7 +1159,8 @@ public Set<byte[]> zRevRangeByScore(byte[] key, double min, double max) {
}

@Override
public Set<byte[]> zRevRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
public Set<byte[]> zRevRangeByScore(byte[] key, org.springframework.data.domain.Range<Number> range,
org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRevRangeByScore(key, range, limit), Converters.identityConverter());
}

Expand All @@ -1168,12 +1171,12 @@ public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, double min, double max,
}

@Override
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range) {
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, org.springframework.data.domain.Range<Number> range) {
return convertAndReturn(delegate.zRevRangeByScoreWithScores(key, range), Converters.identityConverter());
}

@Override
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range,
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, org.springframework.data.domain.Range<Number> range,
org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRevRangeByScoreWithScores(key, range, limit), Converters.identityConverter());
}
Expand All @@ -1199,7 +1202,7 @@ public Long zRemRange(byte[] key, long start, long end) {
}

@Override
public Long zRemRangeByLex(byte[] key, Range range) {
public Long zRemRangeByLex(byte[] key, org.springframework.data.domain.Range<byte[]> range) {
return convertAndReturn(delegate.zRemRangeByLex(key, range), Converters.identityConverter());
}

Expand All @@ -1209,7 +1212,7 @@ public Long zRemRangeByScore(byte[] key, double min, double max) {
}

@Override
public Long zRemRangeByScore(byte[] key, Range range) {
public Long zRemRangeByScore(byte[] key, org.springframework.data.domain.Range<Number> range) {
return convertAndReturn(delegate.zRemRangeByScore(key, range), Converters.identityConverter());
}

Expand Down Expand Up @@ -1291,8 +1294,8 @@ public Long zUnionStore(byte[] destKey, byte[]... sets) {
}

@Override
public Long zLexCount(String key, Range range) {
return delegate.zLexCount(serialize(key), range);
public Long zLexCount(String key, org.springframework.data.domain.Range<String> range) {
return delegate.zLexCount(serialize(key), serialize(range));
}

@Override
Expand Down Expand Up @@ -1370,6 +1373,26 @@ private byte[] serialize(String data) {
return serializer.serialize(data);
}

private org.springframework.data.domain.Range<byte[]> serialize(org.springframework.data.domain.Range<String> range) {

if (!range.getLowerBound().isBounded() && !range.getUpperBound().isBounded()) {
return org.springframework.data.domain.Range.unbounded();
}

org.springframework.data.domain.Range.Bound<byte[]> lower = rawBound(range.getLowerBound());
org.springframework.data.domain.Range.Bound<byte[]> upper = rawBound(range.getUpperBound());

return org.springframework.data.domain.Range.of(lower, upper);
}

private org.springframework.data.domain.Range.Bound<byte[]> rawBound(
org.springframework.data.domain.Range.Bound<String> source) {
return source.getValue().map(this::serialize)
.map(it -> source.isInclusive() ? org.springframework.data.domain.Range.Bound.inclusive(it)
: org.springframework.data.domain.Range.Bound.exclusive(it))
.orElseGet(org.springframework.data.domain.Range.Bound::unbounded);
}

@SuppressWarnings("unchecked")
private GeoReference<byte[]> serialize(GeoReference<String> data) {
return data instanceof GeoReference.GeoMemberReference
Expand Down Expand Up @@ -1987,7 +2010,7 @@ public Long zCount(String key, double min, double max) {
}

@Override
public Long zLexCount(byte[] key, Range range) {
public Long zLexCount(byte[] key, org.springframework.data.domain.Range<byte[]> range) {
return delegate.zLexCount(key, range);
}

Expand Down Expand Up @@ -2165,8 +2188,8 @@ public Long zRemRange(String key, long start, long end) {
}

@Override
public Long zRemRangeByLex(String key, Range range) {
return zRemRangeByLex(serialize(key), range);
public Long zRemRangeByLex(String key, org.springframework.data.domain.Range<String> range) {
return zRemRangeByLex(serialize(key), serialize(range));
}

@Override
Expand Down Expand Up @@ -2655,38 +2678,42 @@ public Set<byte[]> zRangeByLex(byte[] key) {
}

@Override
public Set<byte[]> zRangeByLex(byte[] key, Range range) {
public Set<byte[]> zRangeByLex(byte[] key, org.springframework.data.domain.Range<byte[]> range) {
return convertAndReturn(delegate.zRangeByLex(key, range), Converters.identityConverter());
}

@Override
public Set<byte[]> zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
public Set<byte[]> zRangeByLex(byte[] key, org.springframework.data.domain.Range<byte[]> range,
org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRangeByLex(key, range, limit), Converters.identityConverter());
}

@Override
public Set<String> zRangeByLex(String key) {
return zRangeByLex(key, Range.unbounded());
return zRangeByLex(key, org.springframework.data.domain.Range.unbounded());
}

@Override
public Set<String> zRangeByLex(String key, Range range) {
public Set<String> zRangeByLex(String key, org.springframework.data.domain.Range<String> range) {
return zRangeByLex(key, range, org.springframework.data.redis.connection.Limit.unlimited());
}

@Override
public Set<String> zRangeByLex(String key, Range range, org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRangeByLex(serialize(key), range, limit), byteSetToStringSet);
public Set<String> zRangeByLex(String key, org.springframework.data.domain.Range<String> range,
org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRangeByLex(serialize(key), serialize(range), limit), byteSetToStringSet);
}

@Override
public Set<byte[]> zRevRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
public Set<byte[]> zRevRangeByLex(byte[] key, org.springframework.data.domain.Range<byte[]> range,
org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRevRangeByLex(key, range, limit), Converters.identityConverter());
}

@Override
public Set<String> zRevRangeByLex(String key, Range range, org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRevRangeByLex(serialize(key), range, limit), byteSetToStringSet);
public Set<String> zRevRangeByLex(String key, org.springframework.data.domain.Range<String> range,
org.springframework.data.redis.connection.Limit limit) {
return convertAndReturn(delegate.zRevRangeByLex(serialize(key), serialize(range), limit), byteSetToStringSet);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
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.Aggregate;
import org.springframework.data.redis.connection.zset.Tuple;
import org.springframework.data.redis.connection.zset.Weights;
import org.springframework.data.redis.core.Cursor;
Expand Down Expand Up @@ -967,7 +968,7 @@ default Long zCount(byte[] key, double min, double max) {
/** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */
@Override
@Deprecated
default Long zLexCount(byte[] key, Range range) {
default Long zLexCount(byte[] key, org.springframework.data.domain.Range<byte[]> range) {
return zSetCommands().zLexCount(key, range);
}

Expand Down Expand Up @@ -1016,7 +1017,7 @@ default Tuple bZPopMax(byte[] key, long timeout, TimeUnit unit) {
/** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */
@Override
@Deprecated
default Long zCount(byte[] key, Range range) {
default Long zCount(byte[] key, org.springframework.data.domain.Range<Number> range) {
return zSetCommands().zCount(key, range);
}

Expand Down Expand Up @@ -1142,28 +1143,31 @@ default Set<Tuple> zRangeWithScores(byte[] key, long start, long end) {
/** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */
@Override
@Deprecated
default Set<byte[]> zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
default Set<byte[]> zRangeByLex(byte[] key, org.springframework.data.domain.Range<byte[]> 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<byte[]> zRevRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
default Set<byte[]> zRevRangeByLex(byte[] key, org.springframework.data.domain.Range<byte[]> 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<byte[]> zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
default Set<byte[]> zRangeByScore(byte[] key, org.springframework.data.domain.Range<Number> 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<Tuple> zRangeByScoreWithScores(byte[] key, Range range,
default Set<Tuple> zRangeByScoreWithScores(byte[] key, org.springframework.data.domain.Range<Number> range,
org.springframework.data.redis.connection.Limit limit) {
return zSetCommands().zRangeByScoreWithScores(key, range, limit);
}
Expand All @@ -1178,14 +1182,15 @@ default Set<Tuple> zRevRangeWithScores(byte[] key, long start, long end) {
/** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */
@Override
@Deprecated
default Set<byte[]> zRevRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
default Set<byte[]> zRevRangeByScore(byte[] key, org.springframework.data.domain.Range<Number> 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<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range,
default Set<Tuple> zRevRangeByScoreWithScores(byte[] key, org.springframework.data.domain.Range<Number> range,
org.springframework.data.redis.connection.Limit limit) {
return zSetCommands().zRevRangeByScoreWithScores(key, range, limit);
}
Expand Down Expand Up @@ -1214,14 +1219,14 @@ default Long zRemRange(byte[] key, long start, long end) {
/** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */
@Override
@Deprecated
default Long zRemRangeByLex(byte[] key, Range range) {
default Long zRemRangeByLex(byte[] key, org.springframework.data.domain.Range<byte[]> range) {
return zSetCommands().zRemRangeByLex(key, range);
}

/** @deprecated in favor of {@link RedisConnection#zSetCommands()}}. */
@Override
@Deprecated
default Long zRemRangeByScore(byte[] key, Range range) {
default Long zRemRangeByScore(byte[] key, org.springframework.data.domain.Range<Number> range) {
return zSetCommands().zRemRangeByScore(key, range);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
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.zset.Aggregate;
import org.springframework.data.redis.connection.zset.DefaultTuple;
import org.springframework.data.redis.connection.zset.Tuple;
import org.springframework.data.redis.connection.zset.Weights;
Expand Down
Loading