coderzc commented on code in PR #21600:
URL: https://github.com/apache/pulsar/pull/21600#discussion_r1450044227
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -2882,28 +2882,47 @@ protected CompletableFuture<MessageId>
internalGetMessageIdByTimestampAsync(long
throw new RestException(Status.METHOD_NOT_ALLOWED,
"Get message ID by timestamp on a non-persistent topic
is not allowed");
}
- ManagedLedger ledger = ((PersistentTopic)
topic).getManagedLedger();
- return ledger.asyncFindPosition(entry -> {
- try {
- long entryTimestamp =
Commands.getEntryTimestamp(entry.getDataBuffer());
- return
MessageImpl.isEntryPublishedEarlierThan(entryTimestamp, timestamp);
- } catch (Exception e) {
- log.error("[{}] Error deserializing message for
message position find", topicName, e);
- } finally {
- entry.release();
- }
- return false;
- }).thenApply(position -> {
- if (position == null) {
- return null;
- } else {
- return new MessageIdImpl(position.getLedgerId(),
position.getEntryId(),
- topicName.getPartitionIndex());
- }
- });
+ return ((PersistentTopic)
topic).getTopicCompactionService().findEntryByPublishTime(timestamp)
Review Comment:
Good idea. I check publish time of the last compacted entry to determine
whether to find the entry from compacted ledger. PTAL~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]