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

LedgerEntry#getLength does not do what the documentation says #1411

Open
ivankelly opened this issue May 17, 2018 · 12 comments
Open

LedgerEntry#getLength does not do what the documentation says #1411

ivankelly opened this issue May 17, 2018 · 12 comments

Comments

@ivankelly
Copy link
Contributor

You would expect getLength on a LedgerEntry to return the length of the data in the entry. The documentation says it does this, and the Mock implementation do so too. But this is not what it does. It in fact returns the length of the ledger up to and including this entry.

At the very least this is a documentation bug, but this name is super confusing even if the documentation is updated.

@eolivelli
Copy link
Contributor

good catch

@sijie
Copy link
Member

sijie commented May 17, 2018

for BC consideration, we can fix the documentation first.

We can consider deprecating getLength later, introducing getEntrySize to return the size of the entry and getOffset to return the offset of the entry in a ledger. entrySize + offset == getLength here.

Offset would be aligning with the proposal in #1376

@ivankelly
Copy link
Contributor Author

there shouldn't be a BC consideration for the new API

@sijie
Copy link
Member

sijie commented May 17, 2018

@ivankelly okay you are talking about the new API. for new API it is fine. I was talking about the old API. http://bookkeeper.apache.org/docs/latest/api/javadoc/org/apache/bookkeeper/client/LedgerEntry.html#getLength--

@ivankelly
Copy link
Contributor Author

Ya, old API can stay as it is. Maybe deprecate it. I seem to remember it being very broken at some point in any case, and noone complained.

@eolivelli
Copy link
Contributor

+1 for fixing only the new API and deprecate old API method

@sijie
Copy link
Member

sijie commented May 17, 2018

I seem to remember it being very broken at some point in any case, and noone complained.

why? it is not broken, we used that at twitter to know how many bytes a reader is lagging behind a writer, by comparing the lengths of two entries.

@sijie
Copy link
Member

sijie commented May 17, 2018

let's submit a BP and fix the new API and deprecate the method in the old API.

@ivankelly
Copy link
Contributor Author

@sijie This one (https://issues.apache.org/jira/browse/BOOKKEEPER-673). In my head it was more recent than almost 5 years ago. Getting old I guess.

@sijie
Copy link
Member

sijie commented May 17, 2018

@ivankelly I see. but that's more about consistency between metadata and the information in entries. I don't know a direct usage of length in metadata, but the information in entries is more useful.

@ivankelly
Copy link
Contributor Author

Pulsar tiered storage usage uses the length in the metadata.

@Shawyeok
Copy link
Contributor

Shawyeok commented Sep 1, 2023

I've also encountered this problem in a BookKeeper test. It seems to still exist in the latest version of BookKeeper. Currently, the LedgerEntry#getLength API is used in several BookKeeper shell commands to print the entry size, as well as in a Pulsar indicator called pulsar_ml_cursor_readLedgerSize. Should I first discuss this on the mailing list before attempting to fix it? @eolivelli @sijie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants