-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add command LSET #312
Add command LSET #312
Conversation
java/client/src/main/java/glide/api/commands/ListBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/ListBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/ListBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/BaseTransaction.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/BaseTransaction.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/BaseTransaction.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/ListBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/ListBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/ListBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/BaseTransaction.java
Outdated
Show resolved
Hide resolved
String response = client.lset(key, index, element).get(); | ||
assertEquals(OK, response); | ||
String[] updatedList = client.lrange(key, 0, -1).get(); | ||
assertArrayEquals(updatedList, expectedList); |
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.
I think the expected list at this point should be:
String[] expectedList = {"zero", "three", "two", "one"};
since you're only modifying the value at index 0
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.
Lpush pushes each element in the input array to the front of the list, so the list starts as {"one", "two", "three", "four"}
@@ -298,6 +302,9 @@ private static Object[] listCommands(BaseTransaction<?> transaction) { | |||
4L, // linsert(listKey3, AFTER, value2, value2) | |||
new String[] {listKey3, value3}, // blpop(new String[] { listKey3 }, 0.01) | |||
new String[] {listKey3, value1}, // brpop(new String[] { listKey3 }, 0.01) | |||
2L, // lpush(listKey5, new String[] {value2, value3}) | |||
OK, // lset(listKey5, 0, value1) | |||
new String[] {value1, value2} // lrange(listKey5, 0, -1) |
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.
new String[] {value1, value2} // lrange(listKey5, 0, -1) | |
new String[] {value1, value3} // lrange(listKey5, 0, -1) |
aren't we changing the value at index 0 only?
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.
since lpush pushes to the front, the list looks like {value3, value2}
after first being pushed to, and after setting index 0 it becomes {value1, value2}
java/client/src/main/java/glide/api/models/BaseTransaction.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/BaseTransaction.java
Outdated
Show resolved
Hide resolved
* Add command LSET --------- Co-authored-by: TJ Zhang <tj.zhang@improving.com>
Add command LSET (#312) * Add command LSET --------- Co-authored-by: TJ Zhang <tj.zhang@improving.com>
Add command LSET (#312) * Add command LSET --------- Co-authored-by: TJ Zhang <tj.zhang@improving.com>
Adding command LSet