-
Notifications
You must be signed in to change notification settings - Fork 53
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
Java: Add overloads for XADD to allow duplicate entry keys #1970
Java: Add overloads for XADD to allow duplicate entry keys #1970
Conversation
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
Please fix CI breakage. |
There's a pretty sizable number of SpotBugs issues causing CI to fail that are unrelated to my changes here. I think I'll put the fixes for those in a separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add changelog and fix tests
java/client/src/main/java/glide/api/commands/StreamBaseCommands.java
Outdated
Show resolved
Hide resolved
java/integTest/src/test/java/glide/TransactionTestUtilities.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/StreamBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/StreamBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/StreamBaseCommands.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
@@ -896,7 +901,8 @@ private static Object[] streamCommands(BaseTransaction<?> transaction) { | |||
"0-1", // xadd(streamKey1, Map.of("field1", "value1"), ... .id("0-1").build()); | |||
"0-2", // xadd(streamKey1, Map.of("field2", "value2"), ... .id("0-2").build()); | |||
"0-3", // xadd(streamKey1, Map.of("field3", "value3"), ... .id("0-3").build()); | |||
3L, // xlen(streamKey1) | |||
"0-4", // xadd(streamKey4, new String[][] {{"field4", "value4"}, {"field4", "value5"}}), ... .id("0-4").build()); | |||
3L, // xlen(streamKey4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the xlen above is still passing streamKey1 (line 831)
3L, // xlen(streamKey4) | |
3L, // xlen(streamKey1) |
String timestamp = "1721748920942-0"; | ||
String[][] entry = new String[][] {{field, foo1}, {field, bar1}}; | ||
assertEquals( | ||
timestamp, | ||
client | ||
.xadd(key, entry) | ||
.get()); | ||
|
||
// get everything from the stream | ||
Map<String, String[][]> result = client.xrange(key, InfRangeBound.MIN, InfRangeBound.MAX).get(); | ||
assertEquals(1, result.size()); | ||
String[][] actualEntry = result.get(timestamp); | ||
assertDeepEquals(entry, actualEntry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding to Yury's comment, I don't think this will pass as is, but you can modify it to get it working like this:
String timestamp = "1721748920942-0"; | |
String[][] entry = new String[][] {{field, foo1}, {field, bar1}}; | |
assertEquals( | |
timestamp, | |
client | |
.xadd(key, entry) | |
.get()); | |
// get everything from the stream | |
Map<String, String[][]> result = client.xrange(key, InfRangeBound.MIN, InfRangeBound.MAX).get(); | |
assertEquals(1, result.size()); | |
String[][] actualEntry = result.get(timestamp); | |
assertDeepEquals(entry, actualEntry); | |
String[][] entry = new String[][] {{field, foo1}, {field, bar1}}; | |
String streamId = client.xadd(key, entry).get()); | |
// get everything from the stream | |
Map<String, String[][]> result = client.xrange(key, InfRangeBound.MIN, InfRangeBound.MAX).get(); | |
assertEquals(1, result.size()); | |
String[][] actualEntry = result.get(streamId); | |
assertDeepEquals(entry, actualEntry); |
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: Jonathan Louie <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spotless hates you
Signed-off-by: Jonathan Louie <[email protected]>
This fixes an issue with XADD where entries passed as input could not contain duplicate keys because the exposed API only took
Map
s.