Skip to content

Commit 4316877

Browse files
authored
More RESP3 breaking and testing changes (#3399)
1 parent f517c05 commit 4316877

17 files changed

+61
-127
lines changed

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

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
import java.util.*;
55
import java.util.stream.Collectors;
66

7-
import redis.clients.jedis.resps.StreamConsumerFullInfo;
8-
import redis.clients.jedis.resps.StreamFullInfo;
9-
import redis.clients.jedis.resps.StreamGroupFullInfo;
7+
import redis.clients.jedis.resps.*;
108
import redis.clients.jedis.resps.LCSMatchResult.MatchedPosition;
119
import redis.clients.jedis.resps.LCSMatchResult.Position;
12-
import redis.clients.jedis.resps.*;
1310
import redis.clients.jedis.util.DoublePrecision;
1411
import redis.clients.jedis.util.JedisByteHashMap;
1512
import redis.clients.jedis.util.KeyValue;
@@ -200,36 +197,6 @@ public String toString() {
200197
}
201198
};
202199

203-
// TODO: remove
204-
public static final Builder<byte[]> BYTE_ARRAY = new Builder<byte[]>() {
205-
@Override
206-
public byte[] build(Object data) {
207-
return ((byte[]) data);
208-
}
209-
210-
@Override
211-
public String toString() {
212-
return "byte[]";
213-
}
214-
};
215-
216-
// TODO: remove
217-
public static final Builder<List<byte[]>> BYTE_ARRAY_LIST = new Builder<List<byte[]>>() {
218-
@Override
219-
@SuppressWarnings("unchecked")
220-
public List<byte[]> build(Object data) {
221-
if (null == data) {
222-
return null;
223-
}
224-
return (List<byte[]>) data;
225-
}
226-
227-
@Override
228-
public String toString() {
229-
return "List<byte[]>";
230-
}
231-
};
232-
233200
public static final Builder<byte[]> BINARY = new Builder<byte[]>() {
234201
@Override
235202
public byte[] build(Object data) {
@@ -308,7 +275,7 @@ public Map<byte[], byte[]> build(Object data) {
308275

309276
@Override
310277
public String toString() {
311-
return "Map<String, String>";
278+
return "Map<byte[], byte[]>";
312279
}
313280
};
314281

@@ -977,7 +944,7 @@ private Map<String, Builder> createDecoderMap() {
977944
tempMappingFunctions.put(AccessControlLogEntry.CONTEXT, STRING);
978945
tempMappingFunctions.put(AccessControlLogEntry.OBJECT, STRING);
979946
tempMappingFunctions.put(AccessControlLogEntry.USERNAME, STRING);
980-
// tempMappingFunctions.put(AccessControlLogEntry.AGE_SECONDS, STRING);
947+
tempMappingFunctions.put(AccessControlLogEntry.AGE_SECONDS, DOUBLE);
981948
tempMappingFunctions.put(AccessControlLogEntry.CLIENT_INFO, STRING);
982949
tempMappingFunctions.put(AccessControlLogEntry.ENTRY_ID, LONG);
983950
tempMappingFunctions.put(AccessControlLogEntry.TIMESTAMP_CREATED, LONG);
@@ -1174,7 +1141,7 @@ public List<Map.Entry<String, List<StreamEntry>>> build(Object data) {
11741141
List<Object> stream = (List<Object>) streamObj;
11751142
String streamKey = STRING.build(stream.get(0));
11761143
List<StreamEntry> streamEntries = STREAM_ENTRY_LIST.build(stream.get(1));
1177-
result.add(new AbstractMap.SimpleEntry<>(streamKey, streamEntries));
1144+
result.add(KeyValue.of(streamKey, streamEntries));
11781145
}
11791146

11801147
return result;
@@ -1198,7 +1165,7 @@ public List<Map.Entry<String, List<StreamEntry>>> build(Object data) {
11981165
while (iter.hasNext()) {
11991166
String streamKey = STRING.build(iter.next());
12001167
List<StreamEntry> streamEntries = STREAM_ENTRY_LIST.build(iter.next());
1201-
result.add(new AbstractMap.SimpleEntry<>(streamKey, streamEntries));
1168+
result.add(KeyValue.of(streamKey, streamEntries));
12021169
}
12031170

12041171
return result;

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

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,39 +1482,16 @@ public final CommandObject<KeyedZSetElement> bzpopmin(double timeout, String...
14821482
BuilderFactory.KEYED_ZSET_ELEMENT);
14831483
}
14841484

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

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

1495-
private Builder<List<byte[]>> getBZPopBuilder() {
1496-
if (proto == RedisProtocol.RESP3) return DUMMY_BZPOP_BUILDER;
1497-
return BuilderFactory.BINARY_LIST;
1498-
}
1499-
1500-
// TODO: remove
1501-
private static final Builder<List<byte[]>> DUMMY_BZPOP_BUILDER = new Builder<List<byte[]>>() {
1502-
@Override
1503-
public List<byte[]> build(Object data) {
1504-
if (data == null) return null;
1505-
List<Object> input = (List<Object>) data;
1506-
List<byte[]> output = new ArrayList<>(input.size());
1507-
for (Object in : input) {
1508-
if (in instanceof Double) {
1509-
output.add(Protocol.toByteArray((Double) in));
1510-
} else {
1511-
output.add((byte[]) in);
1512-
}
1513-
}
1514-
return output;
1515-
}
1516-
};
1517-
15181495
public final CommandObject<Long> zcount(String key, double min, double max) {
15191496
return new CommandObject<>(commandArguments(ZCOUNT).key(key).add(min).add(max), BuilderFactory.LONG);
15201497
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,12 +2630,12 @@ public KeyValue<byte[], List<byte[]>> blmpop(long timeout, ListDirection directi
26302630
}
26312631

26322632
@Override
2633-
public List<byte[]> bzpopmax(final double timeout, final byte[]... keys) {
2633+
public List<Object> bzpopmax(final double timeout, final byte[]... keys) {
26342634
return connection.executeCommand(commandObjects.bzpopmax(timeout, keys));
26352635
}
26362636

26372637
@Override
2638-
public List<byte[]> bzpopmin(final double timeout, final byte[]... keys) {
2638+
public List<Object> bzpopmin(final double timeout, final byte[]... keys) {
26392639
return connection.executeCommand(commandObjects.bzpopmin(timeout, keys));
26402640
}
26412641

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,12 +2946,12 @@ public Response<ScanResult<Tuple>> zscan(byte[] key, byte[] cursor, ScanParams p
29462946
}
29472947

29482948
@Override
2949-
public Response<List<byte[]>> bzpopmax(double timeout, byte[]... keys) {
2949+
public Response<List<Object>> bzpopmax(double timeout, byte[]... keys) {
29502950
return appendCommand(commandObjects.bzpopmax(timeout, keys));
29512951
}
29522952

29532953
@Override
2954-
public Response<List<byte[]>> bzpopmin(double timeout, byte[]... keys) {
2954+
public Response<List<Object>> bzpopmin(double timeout, byte[]... keys) {
29552955
return appendCommand(commandObjects.bzpopmin(timeout, keys));
29562956
}
29572957

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,12 +2899,12 @@ public Response<ScanResult<Tuple>> zscan(byte[] key, byte[] cursor, ScanParams p
28992899
}
29002900

29012901
@Override
2902-
public Response<List<byte[]>> bzpopmax(double timeout, byte[]... keys) {
2902+
public Response<List<Object>> bzpopmax(double timeout, byte[]... keys) {
29032903
return appendCommand(commandObjects.bzpopmax(timeout, keys));
29042904
}
29052905

29062906
@Override
2907-
public Response<List<byte[]>> bzpopmin(double timeout, byte[]... keys) {
2907+
public Response<List<Object>> bzpopmin(double timeout, byte[]... keys) {
29082908
return appendCommand(commandObjects.bzpopmin(timeout, keys));
29092909
}
29102910

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
import redis.clients.jedis.util.IOUtils;
99

1010
/**
11+
* WARNING: RESP3 is not properly implemented for ShardedPipeline.
12+
*
1113
* @deprecated Sharding/Sharded feature will be removed in next major release.
1214
*/
1315
@Deprecated
14-
// TODO: RESP3
1516
public class ShardedPipeline extends MultiNodePipelineBase {
1617

1718
private final ShardedConnectionProvider provider;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,12 +2996,12 @@ public Response<ScanResult<Tuple>> zscan(byte[] key, byte[] cursor, ScanParams p
29962996
}
29972997

29982998
@Override
2999-
public Response<List<byte[]>> bzpopmax(double timeout, byte[]... keys) {
2999+
public Response<List<Object>> bzpopmax(double timeout, byte[]... keys) {
30003000
return appendCommand(commandObjects.bzpopmax(timeout, keys));
30013001
}
30023002

30033003
@Override
3004-
public Response<List<byte[]>> bzpopmin(double timeout, byte[]... keys) {
3004+
public Response<List<Object>> bzpopmin(double timeout, byte[]... keys) {
30053005
return appendCommand(commandObjects.bzpopmin(timeout, keys));
30063006
}
30073007

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,12 +2339,12 @@ public KeyedZSetElement bzpopmin(double timeout, String... keys) {
23392339
}
23402340

23412341
@Override
2342-
public List<byte[]> bzpopmax(double timeout, byte[]... keys) {
2342+
public List<Object> bzpopmax(double timeout, byte[]... keys) {
23432343
return executeCommand(commandObjects.bzpopmax(timeout, keys));
23442344
}
23452345

23462346
@Override
2347-
public List<byte[]> bzpopmin(double timeout, byte[]... keys) {
2347+
public List<Object> bzpopmin(double timeout, byte[]... keys) {
23482348
return executeCommand(commandObjects.bzpopmin(timeout, keys));
23492349
}
23502350

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<byte[]> bzpopmax(double timeout, byte[]... keys);
133+
List<Object> bzpopmax(double timeout, byte[]... keys);
134134

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

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

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<byte[]>> bzpopmax(double timeout, byte[]... keys);
134+
Response<List<Object>> bzpopmax(double timeout, byte[]... keys);
135135

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

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

0 commit comments

Comments
 (0)