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

Track number of non-user offsets used in chunk header #99

Open
kjnilsson opened this issue Aug 8, 2022 · 0 comments
Open

Track number of non-user offsets used in chunk header #99

kjnilsson opened this issue Aug 8, 2022 · 0 comments

Comments

@kjnilsson
Copy link
Contributor

One requested feature that we cannot currently provide is the total number of messages in a stream (or "user entries"). The reason that simply taking the first offset in a stream and subtracting this from the last offset is that there are non-user offsets used for internal purposes such as offset and writer tracking. To accurately calculate the number of user entries we'd need to know the number of non-user entries in a stream.

The chunk header has 4 bytes of reserved data which could be used for a "non-user offset" counter. If we had this information we could calculate the number of messages in a stream by doing: (LastOffset - FirstOffset) - (LastNonUserCount - FirstNonUserCount) - which only requires us to read the chunk header of the first and last chunks of the stream.

Potential issues:

  • for existing streams the count would not be correct until we'd flushed out all segments that do not have this information
  • The non-user entry counter is limited to 32 bits, we'd have to consider if it is likely to ever reach this value and what to do if it does.
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

No branches or pull requests

1 participant