mattisonchao commented on code in PR #21208:
URL: https://github.com/apache/pulsar/pull/21208#discussion_r1360246670
##########
pulsar-broker/src/main/java/org/apache/pulsar/compaction/PulsarTopicCompactionService.java:
##########
@@ -106,6 +111,78 @@ public CompletableFuture<Position>
getLastCompactedPosition() {
return
CompletableFuture.completedFuture(compactedTopic.getCompactionHorizon().orElse(null));
}
+ @Override
+ public CompletableFuture<Entry> findEntryByPublishTime(long publishTime) {
+ final Predicate<Entry> predicate = entry -> {
+ try {
+ return
Commands.parseMessageMetadata(entry.getDataBuffer()).getPublishTime() >=
publishTime;
+ } finally {
+ entry.release();
+ }
+ };
+ return findFirstMatchEntry(predicate);
+ }
+
+ @Override
+ public CompletableFuture<Entry> findEntryByEntryIndex(long entryIndex) {
+ final Predicate<Entry> predicate = entry -> {
+ try {
+ BrokerEntryMetadata brokerEntryMetadata =
+
Commands.parseBrokerEntryMetadataIfExist(entry.getDataBuffer());
+ if (brokerEntryMetadata == null ||
!brokerEntryMetadata.hasIndex()) {
+ return false;
+ }
+ return brokerEntryMetadata.getIndex() >= entryIndex;
+ } finally {
+ entry.release();
Review Comment:
Well. I suggest it because I think we don't need to release it everywhere.
Do you agree with this idea?
--
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]