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

Add optional args to XLEN to specify start ID and direction #1251

Merged
merged 2 commits into from
Feb 8, 2023

Conversation

torwig
Copy link
Contributor

@torwig torwig commented Feb 8, 2023

Syntax: XLEN stream_name [entry_id] [direction].
Where direction can be '-' or '+' (special IDs mean respectively the first and the last elements in the stream). Default value: '+'.

If an optional entry ID is specified, the XLEN command returns the number of entries between that ID and the first/last element of the stream.

The element with the specified ID is not considered - it serves as an exclusive boundary. If the stream doesn't contain an entry with the specified ID, the command starts counting from the closest entry to the first/last element in the stream.

If the specified ID is equal to or greater than the last entry ID and:
a) direction is '+' - the command returns 0
b) direction is '-' - the command returns the stream's size

If the specified ID is equal to or less than the first entry ID and:
a) direction is '-' the command returns 0
b) direction is '+' the command returns stream's size

This feature is helpful in finding:
a) how many entries in the stream were processed so far
b) how many unprocessed entries (ahead of the current one) are in the stream

Complexity: O(n)

…tion

Syntax: `XLEN stream_name [entry_id] [direction]`.
Where direction can be '-' or '+' (special IDs mean respectively the first and the last elements in the stream). Default value: '+'.
If an optional entry ID is specified, the XLEN command returns the number of entries between that ID and the first/last element of the stream.
The element with the specified ID is not considered - it serves as an exclusive boundary.
If the stream doesn't contain an entry with the specified ID, the command starts counting from the closest entry to the first/last element in the stream.
If the specified ID is equal to or greater than the last entry ID and:
a) direction is '+' - the command returns 0
b) direction is '-' - the command returns stream's size
If the specified ID is equal to or less than the first entry ID and:
a) direction is '-' the command returns 0
b) direction is '+' the command returns stream's size
This feature is helpful in finding:
a) how many entries in the stream were processed so far
a) how many unprocessed (ahead of the current one) entries are in the stream
Complexity: O(n)
Copy link
Member

@git-hulk git-hulk left a comment

Choose a reason for hiding this comment

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

LGTM, has only one comment. @torwig's test cases in PR are always impressive.

src/commands/cmd_stream.cc Outdated Show resolved Hide resolved
@torwig
Copy link
Contributor Author

torwig commented Feb 8, 2023

Thanks all. Merging...

@torwig torwig merged commit 2c15fa4 into apache:unstable Feb 8, 2023
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.

3 participants