Polishing.
Fix indention, variable names and add missing author tags. Original Pull Request: #2097
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
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.util.ObjectUtils;
|
||||
@@ -23,6 +25,8 @@ import org.springframework.util.ObjectUtils;
|
||||
* Default implementation for {@link StringTuple} interface.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class DefaultStringTuple extends DefaultTuple implements StringTuple {
|
||||
|
||||
@@ -35,6 +39,7 @@ public class DefaultStringTuple extends DefaultTuple implements StringTuple {
|
||||
* @param score
|
||||
*/
|
||||
public DefaultStringTuple(byte[] value, String valueAsString, Double score) {
|
||||
|
||||
super(value, score);
|
||||
this.valueAsString = valueAsString;
|
||||
|
||||
@@ -43,13 +48,12 @@ public class DefaultStringTuple extends DefaultTuple implements StringTuple {
|
||||
/**
|
||||
* Constructs a new <code>DefaultStringTuple</code> instance.
|
||||
*
|
||||
* @param valueAsString
|
||||
* @param valueAsString must not be {@literal null}.
|
||||
* @param score
|
||||
* @since 2.6
|
||||
*/
|
||||
public DefaultStringTuple(String valueAsString, double score) {
|
||||
super(valueAsString.getBytes(), score);
|
||||
this.valueAsString = valueAsString;
|
||||
this(valueAsString.getBytes(StandardCharsets.UTF_8), valueAsString, score);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,6 +63,7 @@ public class DefaultStringTuple extends DefaultTuple implements StringTuple {
|
||||
* @param valueAsString
|
||||
*/
|
||||
public DefaultStringTuple(Tuple tuple, String valueAsString) {
|
||||
|
||||
super(tuple.getValue(), tuple.getScore());
|
||||
this.valueAsString = valueAsString;
|
||||
}
|
||||
|
||||
@@ -916,38 +916,38 @@ public interface ZSetOperations<K, V> {
|
||||
@Nullable
|
||||
Set<V> rangeByLex(K key, Range range, Limit limit);
|
||||
|
||||
/**
|
||||
* Get all elements with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value between
|
||||
* {@link Range#getMin()} and {@link Range#getMax()}.
|
||||
*
|
||||
* @param key must not be {@literal null}.
|
||||
* @param range must not be {@literal null}.
|
||||
* @return {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
|
||||
*/
|
||||
@Nullable
|
||||
default Set<V> reverseRangeByLex(K key, Range range) {
|
||||
return reverseRangeByLex(key, range, Limit.unlimited());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at
|
||||
* {@link Limit#getOffset()} with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value
|
||||
* between {@link Range#getMin()} and {@link Range#getMax()}.
|
||||
*
|
||||
* @param key must not be {@literal null}
|
||||
* @param range must not be {@literal null}.
|
||||
* @param limit can be {@literal null}.
|
||||
* @return {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
|
||||
*/
|
||||
@Nullable
|
||||
Set<V> reverseRangeByLex(K key, Range range, Limit limit);
|
||||
|
||||
/**
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
RedisOperations<K, V> getOperations();
|
||||
/**
|
||||
* Get all elements with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value between
|
||||
* {@link Range#getMin()} and {@link Range#getMax()}.
|
||||
*
|
||||
* @param key must not be {@literal null}.
|
||||
* @param range must not be {@literal null}.
|
||||
* @return {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
|
||||
*/
|
||||
@Nullable
|
||||
default Set<V> reverseRangeByLex(K key, Range range) {
|
||||
return reverseRangeByLex(key, range, Limit.unlimited());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at
|
||||
* {@link Limit#getOffset()} with reverse lexicographical ordering from {@literal ZSET} at {@code key} with a value
|
||||
* between {@link Range#getMin()} and {@link Range#getMax()}.
|
||||
*
|
||||
* @param key must not be {@literal null}
|
||||
* @param range must not be {@literal null}.
|
||||
* @param limit can be {@literal null}.
|
||||
* @return {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/zrevrangebylex">Redis Documentation: ZREVRANGEBYLEX</a>
|
||||
*/
|
||||
@Nullable
|
||||
Set<V> reverseRangeByLex(K key, Range range, Limit limit);
|
||||
|
||||
/**
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
RedisOperations<K, V> getOperations();
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
|
||||
/**
|
||||
* Union this set and other {@link RedisZSet}s.
|
||||
*
|
||||
* @param set must not be {@literal null}.
|
||||
* @param sets must not be {@literal null}.
|
||||
* @return a {@link Set} containing the combined values with their scores.
|
||||
* @since 2.6
|
||||
*/
|
||||
|
||||
@@ -1878,6 +1878,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZIncrBy() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zAdd("myset", 4, "Joe"));
|
||||
@@ -1890,6 +1891,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
@Test // GH-2041
|
||||
@EnabledOnCommand("ZDIFF")
|
||||
void testZDiff() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zAdd("myset", 4, "Joe"));
|
||||
@@ -1904,6 +1906,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
@Test // GH-2041
|
||||
@EnabledOnCommand("ZDIFFSTORE")
|
||||
void testZDiffStore() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zAdd("myset", 4, "Joe"));
|
||||
@@ -1917,6 +1920,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
@Test // GH-2042
|
||||
@EnabledOnCommand("ZINTER")
|
||||
void testZInter() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zAdd("myset", 4, "Joe"));
|
||||
@@ -1932,6 +1936,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
@Test // GH-2042
|
||||
@EnabledOnCommand("ZINTER")
|
||||
void testZInterAggWeights() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zAdd("myset", 4, "Joe"));
|
||||
@@ -1947,6 +1952,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZInterStore() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zAdd("myset", 4, "Joe"));
|
||||
@@ -1960,6 +1966,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZInterStoreAggWeights() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zAdd("myset", 4, "Joe"));
|
||||
@@ -1975,6 +1982,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRangeWithScores() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRangeWithScores("myset", 0, -1));
|
||||
@@ -1985,6 +1993,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRangeByScore() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRangeByScore("myset", 1, 1));
|
||||
@@ -1993,6 +2002,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRangeByScoreOffsetCount() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRangeByScore("myset", 1d, 3d, 1, -1));
|
||||
@@ -2001,6 +2011,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRangeByScoreWithScores() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRangeByScoreWithScores("myset", 2d, 5d));
|
||||
@@ -2010,6 +2021,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRangeByScoreWithScoresOffsetCount() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRangeByScoreWithScores("myset", 1d, 5d, 0, 1));
|
||||
@@ -2019,6 +2031,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRevRange() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRevRange("myset", 0, -1));
|
||||
@@ -2027,6 +2040,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRevRangeWithScores() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRevRangeWithScores("myset", 0, -1));
|
||||
@@ -2037,6 +2051,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRevRangeByScoreOffsetCount() {
|
||||
|
||||
actual.add(connection.zAdd("myset".getBytes(), 2, "Bob".getBytes()));
|
||||
actual.add(connection.zAdd("myset".getBytes(), 1, "James".getBytes()));
|
||||
actual.add(connection.zRevRangeByScore("myset", 0d, 3d, 0, 5));
|
||||
@@ -2045,6 +2060,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRevRangeByScore() {
|
||||
|
||||
actual.add(connection.zAdd("myset".getBytes(), 2, "Bob".getBytes()));
|
||||
actual.add(connection.zAdd("myset".getBytes(), 1, "James".getBytes()));
|
||||
actual.add(connection.zRevRangeByScore("myset", 0d, 3d));
|
||||
@@ -2053,6 +2069,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRevRangeByScoreWithScoresOffsetCount() {
|
||||
|
||||
actual.add(connection.zAdd("myset".getBytes(), 2, "Bob".getBytes()));
|
||||
actual.add(connection.zAdd("myset".getBytes(), 1, "James".getBytes()));
|
||||
actual.add(connection.zRevRangeByScoreWithScores("myset", 0d, 3d, 0, 1));
|
||||
@@ -2062,6 +2079,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRevRangeByScoreWithScores() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zAdd("myset", 3, "Joe"));
|
||||
@@ -2073,6 +2091,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRank() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRank("myset", "James"));
|
||||
@@ -2082,6 +2101,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRem() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRem("myset", "James"));
|
||||
@@ -2091,6 +2111,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRemMultiple() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zAdd("myset", 0.5, "Joe"));
|
||||
@@ -2103,6 +2124,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testZRemRangeByRank() {
|
||||
|
||||
actual.add(connection.zAdd("myset", 2, "Bob"));
|
||||
actual.add(connection.zAdd("myset", 1, "James"));
|
||||
actual.add(connection.zRemRange("myset", 0L, 3L));
|
||||
|
||||
@@ -2008,6 +2008,7 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
|
||||
@Test // GH-2041
|
||||
public void zDiffShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
|
||||
|
||||
assertThatExceptionOfType(DataAccessException.class)
|
||||
.isThrownBy(() -> clusterConnection.zDiff(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
|
||||
assertThatExceptionOfType(DataAccessException.class)
|
||||
@@ -2046,6 +2047,7 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
|
||||
@Test // GH-2042
|
||||
public void zInterShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
|
||||
|
||||
assertThatExceptionOfType(DataAccessException.class)
|
||||
.isThrownBy(() -> clusterConnection.zInter(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
|
||||
assertThatExceptionOfType(DataAccessException.class)
|
||||
@@ -2068,6 +2070,7 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
|
||||
@Test // GH-2042
|
||||
public void zInterStoreShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
|
||||
|
||||
assertThatExceptionOfType(DataAccessException.class)
|
||||
.isThrownBy(() -> clusterConnection.zInterStore(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
|
||||
}
|
||||
|
||||
@@ -2049,6 +2049,7 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
|
||||
@Test // GH-2041
|
||||
public void zDiffShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
|
||||
|
||||
assertThatExceptionOfType(DataAccessException.class)
|
||||
.isThrownBy(() -> clusterConnection.zDiff(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
|
||||
assertThatExceptionOfType(DataAccessException.class)
|
||||
@@ -2087,6 +2088,7 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
|
||||
@Test // GH-2042
|
||||
public void zInterShouldThrowExceptionWhenKeysDoNotMapToSameSlots() {
|
||||
|
||||
assertThatExceptionOfType(DataAccessException.class)
|
||||
.isThrownBy(() -> clusterConnection.zInter(KEY_3_BYTES, KEY_1_BYTES, KEY_2_BYTES));
|
||||
assertThatExceptionOfType(DataAccessException.class)
|
||||
|
||||
Reference in New Issue
Block a user