Skip to content
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

#1100: Fix LPOP to support multiple arguments #1231

Merged
merged 8 commits into from
Nov 8, 2024

Conversation

tren03
Copy link
Contributor

@tren03 tren03 commented Nov 1, 2024

This pull request addresses issue #1100, where the LPOP command needed to support an additional argument to specify the number of elements to pop from the left side of the list.

Changes:
Modified the LPOP command to accept either 1 or 2 arguments:
LPOP key: Pops a single element from the list (default behavior).
LPOP key count: Pops up to count elements from the list.

Validation:
If count is 0, an empty response is returned.

If count is negative, an "out of range" error is returned.
If count exceeds the number of available elements, it pops as many elements as available without error.
Invalid count (non-integer values) returns an appropriate error.
Popping from a non-existent or empty list returns nil.

Behavior:
Returns a single element if one element is popped.
Returns a list of elements if multiple elements are popped.

Added the unit test and integration test, added integration tests for http too.
Currently working on adding the websockets tests

@JyotinderSingh
Copy link
Collaborator

There are a few conflicts, please rebase on master.

@tren03 tren03 force-pushed the lpop-multiple-args-fix-1100 branch from 12f7b48 to 53f07c8 Compare November 6, 2024 15:44
@tren03
Copy link
Contributor Author

tren03 commented Nov 6, 2024

Yep done

Copy link
Collaborator

@JyotinderSingh JyotinderSingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these fixes @tren03! The changes look good overall, have left a few minor comments.

internal/eval/eval.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@JyotinderSingh JyotinderSingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requested changes

@tren03
Copy link
Contributor Author

tren03 commented Nov 7, 2024

I have implemented the changes. Any other modifications?

Copy link
Collaborator

@JyotinderSingh JyotinderSingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the comments @tren03, LGTM

@JyotinderSingh
Copy link
Collaborator

There is a segfault in one of the tests, could you please take a look?

@JyotinderSingh
Copy link
Collaborator

Looks like the test failure is unrelated to this PR. Merging this for now.

@JyotinderSingh JyotinderSingh changed the title Fix LPOP to support multiple arguments #1100 #1100: Fix LPOP to support multiple arguments Nov 8, 2024
@JyotinderSingh JyotinderSingh merged commit acd5dbe into DiceDB:master Nov 8, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants