Package org.apache.pulsar.compaction
Interface TopicCompactionService
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
PulsarTopicCompactionService
-
Method Summary
Modifier and TypeMethodDescriptioncompact()Compact the topic.findEntryByEntryIndex(long entryIndex) Find the first entry that greater or equal to target entryIndex, if an entry that broker entry metadata is missed, then it will be skipped and find the next match entry.findEntryByPublishTime(long publishTime) Find the first entry that greater or equal to target publishTime.Get the last compacted position from the TopicCompactionService.readCompactedEntries(Position startPosition, int numberOfEntriesToRead) Read the compacted entries from the TopicCompactionService.Read the last compacted entry from the TopicCompactionService.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
compact
CompletableFuture<Void> compact()Compact the topic. Topic Compaction is a key-based retention mechanism. It keeps the most recent value for a given key and user reads compacted data from TopicCompactionService.- Returns:
- a future that will be completed when the compaction is done.
-
readCompactedEntries
CompletableFuture<List<Entry>> readCompactedEntries(@Nonnull Position startPosition, int numberOfEntriesToRead) Read the compacted entries from the TopicCompactionService.- Parameters:
startPosition- the position to start reading from.numberOfEntriesToRead- the maximum number of entries to read.- Returns:
- a future that will be completed with the list of entries, this list can be null.
-
readLastCompactedEntry
CompletableFuture<Entry> readLastCompactedEntry()Read the last compacted entry from the TopicCompactionService.- Returns:
- a future that will be completed with the compacted last entry, this entry can be null.
-
getLastCompactedPosition
CompletableFuture<Position> getLastCompactedPosition()Get the last compacted position from the TopicCompactionService.- Returns:
- a future that will be completed with the last compacted position, this position can be null.
-
findEntryByPublishTime
Find the first entry that greater or equal to target publishTime.- Parameters:
publishTime- the publish time of entry.- Returns:
- the first entry metadata that greater or equal to target publishTime, this entry can be null.
-
findEntryByEntryIndex
Find the first entry that greater or equal to target entryIndex, if an entry that broker entry metadata is missed, then it will be skipped and find the next match entry.- Parameters:
entryIndex- the index of entry.- Returns:
- the first entry that greater or equal to target entryIndex, this entry can be null.
-