pulsar
pulsar copied to clipboard
[Enhancement] Support getting message index in `ManagedLedger` interface
Search before reporting
- [x] I searched in the issues and found nothing similar.
Motivation
-
PIP-415 supports getting a message ID by index. This capability relies on
broker entry metadatato obtain the message index. However, custom message layer implementations (e.g., StreamNative's Ursa engine) may not utilize broker entry metadata for this purpose. see more details in https://github.com/apache/pulsar/pull/24222#issuecomment-2921951865 - The current implement of searching message index is inefficient, that needs to traverse all entries and check whether their indexes meet the requirements.
Solution
- Add a method
findMessageIndexByPositionto themanagerLedgerinterface. - Record the first entry index in
LedgerInfo—the manager ledger can directly compute the index based on the message ID, significantly improving API efficiency and avoiding read amplification.
Alternatives
Add a method
Anything else?
No response
Are you willing to submit a PR?
- [x] I'm willing to submit a PR!