Skip to content

Commit 9d104e8

Browse files
authored
Modify BZPOP[MAX/MIN] return types (#3439)
1 parent bad2394 commit 9d104e8

15 files changed

+77
-162
lines changed

docs/jedis5-breaking.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
# Jedis 5 Breaking Changes
22

3-
- `bzpopmax(double timeout, byte[]... keys)` now returns `List<Object>` (instead of `List<byte[]>`).
4-
- This is a three element list where the last element is a `Double`.
3+
- Both `bzpopmax(double timeout, String... keys)` and `bzpopmin(double timeout, String... keys)` now return `KeyValue<String, Tuple>` (instead of `KeyedZSetElement`).
54

6-
- `bzpopmin(double timeout, byte[]... keys)` now returns `List<Object>` (instead of `List<byte[]>`).
7-
- This is a three element list where the last element is a `Double`.
5+
- Both `bzpopmax(double timeout, byte[]... keys)` and `bzpopmin(double timeout, byte[]... keys)` now return `KeyValue<byte[], Tuple>` (instead of `List<byte[]>`).
86

97
- `getAgeSeconds()` in `AccessControlLogEntry` now returns `Double` instead of `String`.
108

119
- `graphSlowlog(String graphName)` now returns `List<List<Object>>` (instead of `List<List<String>>`).
1210

1311
- All _payload_ related parameters are removed from _search_ related classes; namely `Document`, `IndexDefinition`, `Query`.
1412

15-
- `Queable` class is removed.
13+
- `KeyedZSetElement` is removed.
1614

1715
- `STREAM_AUTO_CLAIM_ID_RESPONSE` in BuilderFactory has been renamed to `STREAM_AUTO_CLAIM_JUSTID_RESPONSE`.
1816

@@ -21,6 +19,8 @@
2119
- `BYTE_ARRAY_LIST` (use `BINARY_LIST`)
2220
- `BINARY_MAP_FROM_PAIRS`
2321

22+
- `Queable` class is removed.
23+
2424
- `Params` abstract class is removed.
2525
- `toString()` support used by its sub-classes is now unavailable.
2626

src/main/java/redis/clients/jedis/BuilderFactory.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,20 +494,37 @@ public String toString() {
494494
}
495495
};
496496

497-
public static final Builder<KeyedZSetElement> KEYED_ZSET_ELEMENT = new Builder<KeyedZSetElement>() {
497+
public static final Builder<KeyValue<String, Tuple>> KEYED_TUPLE = new Builder<KeyValue<String, Tuple>>() {
498498
@Override
499499
@SuppressWarnings("unchecked")
500-
public KeyedZSetElement build(Object data) {
501-
List<byte[]> l = (List<byte[]>) data; // never null
500+
public KeyValue<String, Tuple> build(Object data) {
501+
List<Object> l = (List<Object>) data; // never null
502+
if (l.isEmpty()) {
503+
return null;
504+
}
505+
return KeyValue.of(STRING.build(l.get(0)), new Tuple(BINARY.build(l.get(1)), DOUBLE.build(l.get(2))));
506+
}
507+
508+
@Override
509+
public String toString() {
510+
return "KeyValue<String, Tuple>";
511+
}
512+
};
513+
514+
public static final Builder<KeyValue<byte[], Tuple>> BINARY_KEYED_TUPLE = new Builder<KeyValue<byte[], Tuple>>() {
515+
@Override
516+
@SuppressWarnings("unchecked")
517+
public KeyValue<byte[], Tuple> build(Object data) {
518+
List<Object> l = (List<Object>) data; // never null
502519
if (l.isEmpty()) {
503520
return null;
504521
}
505-
return new KeyedZSetElement(l.get(0), l.get(1), DOUBLE.build(l.get(2)));
522+
return KeyValue.of(BINARY.build(l.get(0)), new Tuple(BINARY.build(l.get(1)), DOUBLE.build(l.get(2))));
506523
}
507524

508525
@Override
509526
public String toString() {
510-
return "KeyedZSetElement";
527+
return "KeyValue<byte[], Tuple>";
511528
}
512529
};
513530

src/main/java/redis/clients/jedis/CommandObjects.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,24 +1472,24 @@ public final CommandObject<List<Tuple>> zpopmin(byte[] key, int count) {
14721472
return new CommandObject<>(commandArguments(ZPOPMIN).key(key).add(count), getTupleListBuilder());
14731473
}
14741474

1475-
public final CommandObject<KeyedZSetElement> bzpopmax(double timeout, String... keys) {
1475+
public final CommandObject<KeyValue<String, Tuple>> bzpopmax(double timeout, String... keys) {
14761476
return new CommandObject<>(commandArguments(BZPOPMAX).blocking().keys((Object[]) keys).add(timeout),
1477-
BuilderFactory.KEYED_ZSET_ELEMENT);
1477+
BuilderFactory.KEYED_TUPLE);
14781478
}
14791479

1480-
public final CommandObject<KeyedZSetElement> bzpopmin(double timeout, String... keys) {
1480+
public final CommandObject<KeyValue<String, Tuple>> bzpopmin(double timeout, String... keys) {
14811481
return new CommandObject<>(commandArguments(BZPOPMIN).blocking().keys((Object[]) keys).add(timeout),
1482-
BuilderFactory.KEYED_ZSET_ELEMENT);
1482+
BuilderFactory.KEYED_TUPLE);
14831483
}
14841484

1485-
public final CommandObject<List<Object>> bzpopmax(double timeout, byte[]... keys) {
1485+
public final CommandObject<KeyValue<byte[], Tuple>> bzpopmax(double timeout, byte[]... keys) {
14861486
return new CommandObject<>(commandArguments(BZPOPMAX).blocking().keys((Object[]) keys)
1487-
.add(timeout), BuilderFactory.RAW_OBJECT_LIST);
1487+
.add(timeout), BuilderFactory.BINARY_KEYED_TUPLE);
14881488
}
14891489

1490-
public final CommandObject<List<Object>> bzpopmin(double timeout, byte[]... keys) {
1490+
public final CommandObject<KeyValue<byte[], Tuple>> bzpopmin(double timeout, byte[]... keys) {
14911491
return new CommandObject<>(commandArguments(BZPOPMIN).blocking().keys((Object[]) keys)
1492-
.add(timeout), BuilderFactory.RAW_OBJECT_LIST);
1492+
.add(timeout), BuilderFactory.BINARY_KEYED_TUPLE);
14931493
}
14941494

14951495
public final CommandObject<Long> zcount(String key, double min, double max) {

src/main/java/redis/clients/jedis/Jedis.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,12 +2632,12 @@ public KeyValue<byte[], List<byte[]>> blmpop(long timeout, ListDirection directi
26322632
}
26332633

26342634
@Override
2635-
public List<Object> bzpopmax(final double timeout, final byte[]... keys) {
2635+
public KeyValue<byte[], Tuple> bzpopmax(final double timeout, final byte[]... keys) {
26362636
return connection.executeCommand(commandObjects.bzpopmax(timeout, keys));
26372637
}
26382638

26392639
@Override
2640-
public List<Object> bzpopmin(final double timeout, final byte[]... keys) {
2640+
public KeyValue<byte[], Tuple> bzpopmin(final double timeout, final byte[]... keys) {
26412641
return connection.executeCommand(commandObjects.bzpopmin(timeout, keys));
26422642
}
26432643

@@ -7030,13 +7030,13 @@ public KeyValue<String, List<String>> blmpop(long timeout, ListDirection directi
70307030
}
70317031

70327032
@Override
7033-
public KeyedZSetElement bzpopmax(double timeout, String... keys) {
7033+
public KeyValue<String, Tuple> bzpopmax(double timeout, String... keys) {
70347034
checkIsInMultiOrPipeline();
70357035
return connection.executeCommand(commandObjects.bzpopmax(timeout, keys));
70367036
}
70377037

70387038
@Override
7039-
public KeyedZSetElement bzpopmin(double timeout, String... keys) {
7039+
public KeyValue<String, Tuple> bzpopmin(double timeout, String... keys) {
70407040
checkIsInMultiOrPipeline();
70417041
return connection.executeCommand(commandObjects.bzpopmin(timeout, keys));
70427042
}

src/main/java/redis/clients/jedis/PipelineBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,12 +1106,12 @@ public Response<ScanResult<Tuple>> zscan(String key, String cursor, ScanParams p
11061106
}
11071107

11081108
@Override
1109-
public Response<KeyedZSetElement> bzpopmax(double timeout, String... keys) {
1109+
public Response<KeyValue<String, Tuple>> bzpopmax(double timeout, String... keys) {
11101110
return appendCommand(commandObjects.bzpopmax(timeout, keys));
11111111
}
11121112

11131113
@Override
1114-
public Response<KeyedZSetElement> bzpopmin(double timeout, String... keys) {
1114+
public Response<KeyValue<String, Tuple>> bzpopmin(double timeout, String... keys) {
11151115
return appendCommand(commandObjects.bzpopmin(timeout, keys));
11161116
}
11171117

@@ -2846,12 +2846,12 @@ public Response<ScanResult<Tuple>> zscan(byte[] key, byte[] cursor, ScanParams p
28462846
}
28472847

28482848
@Override
2849-
public Response<List<Object>> bzpopmax(double timeout, byte[]... keys) {
2849+
public Response<KeyValue<byte[], Tuple>> bzpopmax(double timeout, byte[]... keys) {
28502850
return appendCommand(commandObjects.bzpopmax(timeout, keys));
28512851
}
28522852

28532853
@Override
2854-
public Response<List<Object>> bzpopmin(double timeout, byte[]... keys) {
2854+
public Response<KeyValue<byte[], Tuple>> bzpopmin(double timeout, byte[]... keys) {
28552855
return appendCommand(commandObjects.bzpopmin(timeout, keys));
28562856
}
28572857

src/main/java/redis/clients/jedis/TransactionBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,12 +1264,12 @@ public Response<ScanResult<Tuple>> zscan(String key, String cursor, ScanParams p
12641264
}
12651265

12661266
@Override
1267-
public Response<KeyedZSetElement> bzpopmax(double timeout, String... keys) {
1267+
public Response<KeyValue<String, Tuple>> bzpopmax(double timeout, String... keys) {
12681268
return appendCommand(commandObjects.bzpopmax(timeout, keys));
12691269
}
12701270

12711271
@Override
1272-
public Response<KeyedZSetElement> bzpopmin(double timeout, String... keys) {
1272+
public Response<KeyValue<String, Tuple>> bzpopmin(double timeout, String... keys) {
12731273
return appendCommand(commandObjects.bzpopmin(timeout, keys));
12741274
}
12751275

@@ -3013,12 +3013,12 @@ public Response<ScanResult<Tuple>> zscan(byte[] key, byte[] cursor, ScanParams p
30133013
}
30143014

30153015
@Override
3016-
public Response<List<Object>> bzpopmax(double timeout, byte[]... keys) {
3016+
public Response<KeyValue<byte[], Tuple>> bzpopmax(double timeout, byte[]... keys) {
30173017
return appendCommand(commandObjects.bzpopmax(timeout, keys));
30183018
}
30193019

30203020
@Override
3021-
public Response<List<Object>> bzpopmin(double timeout, byte[]... keys) {
3021+
public Response<KeyValue<byte[], Tuple>> bzpopmin(double timeout, byte[]... keys) {
30223022
return appendCommand(commandObjects.bzpopmin(timeout, keys));
30233023
}
30243024

src/main/java/redis/clients/jedis/UnifiedJedis.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,22 +2331,22 @@ public ScanResult<Tuple> zscan(byte[] key, byte[] cursor, ScanParams params) {
23312331
}
23322332

23332333
@Override
2334-
public KeyedZSetElement bzpopmax(double timeout, String... keys) {
2334+
public KeyValue<String, Tuple> bzpopmax(double timeout, String... keys) {
23352335
return executeCommand(commandObjects.bzpopmax(timeout, keys));
23362336
}
23372337

23382338
@Override
2339-
public KeyedZSetElement bzpopmin(double timeout, String... keys) {
2339+
public KeyValue<String, Tuple> bzpopmin(double timeout, String... keys) {
23402340
return executeCommand(commandObjects.bzpopmin(timeout, keys));
23412341
}
23422342

23432343
@Override
2344-
public List<Object> bzpopmax(double timeout, byte[]... keys) {
2344+
public KeyValue<byte[], Tuple> bzpopmax(double timeout, byte[]... keys) {
23452345
return executeCommand(commandObjects.bzpopmax(timeout, keys));
23462346
}
23472347

23482348
@Override
2349-
public List<Object> bzpopmin(double timeout, byte[]... keys) {
2349+
public KeyValue<byte[], Tuple> bzpopmin(double timeout, byte[]... keys) {
23502350
return executeCommand(commandObjects.bzpopmin(timeout, keys));
23512351
}
23522352

src/main/java/redis/clients/jedis/commands/SortedSetBinaryCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ default ScanResult<Tuple> zscan(byte[] key, byte[] cursor) {
130130

131131
ScanResult<Tuple> zscan(byte[] key, byte[] cursor, ScanParams params);
132132

133-
List<Object> bzpopmax(double timeout, byte[]... keys);
133+
KeyValue<byte[], Tuple> bzpopmax(double timeout, byte[]... keys);
134134

135-
List<Object> bzpopmin(double timeout, byte[]... keys);
135+
KeyValue<byte[], Tuple> bzpopmin(double timeout, byte[]... keys);
136136

137137
Set<byte[]> zdiff(byte[]... keys);
138138

src/main/java/redis/clients/jedis/commands/SortedSetCommands.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import redis.clients.jedis.args.SortedSetOption;
88
import redis.clients.jedis.params.*;
9-
import redis.clients.jedis.resps.KeyedZSetElement;
109
import redis.clients.jedis.resps.ScanResult;
1110
import redis.clients.jedis.resps.Tuple;
1211
import redis.clients.jedis.util.KeyValue;
@@ -668,15 +667,15 @@ default ScanResult<Tuple> zscan(String key, String cursor) {
668667
* be used to block indefinitely.
669668
* @param keys
670669
*/
671-
KeyedZSetElement bzpopmax(double timeout, String... keys);
670+
KeyValue<String, Tuple> bzpopmax(double timeout, String... keys);
672671

673672
/**
674673
* The blocking version of {@link SortedSetCommands#zpopmin(String) ZPOPMIN}
675674
* @param timeout specifying the maximum number of seconds to block. A timeout of zero can
676675
* be used to block indefinitely.
677676
* @param keys
678677
*/
679-
KeyedZSetElement bzpopmin(double timeout, String... keys);
678+
KeyValue<String, Tuple> bzpopmin(double timeout, String... keys);
680679

681680
/**
682681
* Compute the difference between all the sets in the given keys.

src/main/java/redis/clients/jedis/commands/SortedSetPipelineBinaryCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ default Response<ScanResult<Tuple>> zscan(byte[] key, byte[] cursor) {
131131

132132
Response<ScanResult<Tuple>> zscan(byte[] key, byte[] cursor, ScanParams params);
133133

134-
Response<List<Object>> bzpopmax(double timeout, byte[]... keys);
134+
Response<KeyValue<byte[], Tuple>> bzpopmax(double timeout, byte[]... keys);
135135

136-
Response<List<Object>> bzpopmin(double timeout, byte[]... keys);
136+
Response<KeyValue<byte[], Tuple>> bzpopmin(double timeout, byte[]... keys);
137137

138138
Response<Set<byte[]>> zdiff(byte[]... keys);
139139

0 commit comments

Comments
 (0)