Package org.apache.pulsar.compaction
Class PulsarTopicCompactionService
java.lang.Object
org.apache.pulsar.compaction.PulsarTopicCompactionService
- All Implemented Interfaces:
AutoCloseable,TopicCompactionService
-
Constructor Summary
ConstructorsConstructorDescriptionPulsarTopicCompactionService(String topic, BookKeeper bookKeeper, Supplier<Compactor> compactorSupplier) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()compact()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.
-
Constructor Details
-
PulsarTopicCompactionService
public PulsarTopicCompactionService(String topic, BookKeeper bookKeeper, Supplier<Compactor> compactorSupplier)
-
-
Method Details
-
compact
Description copied from interface:TopicCompactionServiceCompact 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.- Specified by:
compactin interfaceTopicCompactionService- Returns:
- a future that will be completed when the compaction is done.
-
readCompactedEntries
public CompletableFuture<List<Entry>> readCompactedEntries(@Nonnull Position startPosition, int numberOfEntriesToRead) Description copied from interface:TopicCompactionServiceRead the compacted entries from the TopicCompactionService.- Specified by:
readCompactedEntriesin interfaceTopicCompactionService- 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
Description copied from interface:TopicCompactionServiceRead the last compacted entry from the TopicCompactionService.- Specified by:
readLastCompactedEntryin interfaceTopicCompactionService- Returns:
- a future that will be completed with the compacted last entry, this entry can be null.
-
getLastCompactedPosition
Description copied from interface:TopicCompactionServiceGet the last compacted position from the TopicCompactionService.- Specified by:
getLastCompactedPositionin interfaceTopicCompactionService- Returns:
- a future that will be completed with the last compacted position, this position can be null.
-
findEntryByPublishTime
Description copied from interface:TopicCompactionServiceFind the first entry that greater or equal to target publishTime.- Specified by:
findEntryByPublishTimein interfaceTopicCompactionService- 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
Description copied from interface:TopicCompactionServiceFind 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.- Specified by:
findEntryByEntryIndexin interfaceTopicCompactionService- Parameters:
entryIndex- the index of entry.- Returns:
- the first entry that greater or equal to target entryIndex, this entry can be null.
-
getCompactedTopic
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-