Package org.apache.pulsar.compaction
Class StrategicTwoPhaseCompactor
java.lang.Object
org.apache.pulsar.compaction.Compactor
org.apache.pulsar.compaction.AbstractTwoPhaseCompactor<org.apache.pulsar.client.api.MessageId>
org.apache.pulsar.compaction.PublishingOrderCompactor
org.apache.pulsar.compaction.StrategicTwoPhaseCompactor
Compaction will go through the topic in two passes. The first pass
selects valid message(defined in the TopicCompactionStrategy.isValid())
for each key in the topic. Then, the second pass writes these values
to a ledger.
As the first pass caches the entire message(not just offset) for each key into a map, this compaction could be memory intensive if the message payload is large.
-
Field Summary
Fields inherited from class org.apache.pulsar.compaction.AbstractTwoPhaseCompactor
topicCompactionRetainNullKeyFields inherited from class org.apache.pulsar.compaction.Compactor
bk, COMPACTED_TOPIC_LEDGER_PROPERTY, COMPACTION_SUBSCRIPTION, conf, mxBean, pulsar, scheduler -
Constructor Summary
ConstructorsConstructorDescriptionStrategicTwoPhaseCompactor(ServiceConfiguration conf, org.apache.pulsar.client.api.PulsarClient pulsar, BookKeeper bk, ScheduledExecutorService scheduler) -
Method Summary
Modifier and TypeMethodDescription<T> CompletableFuture<Long><T> CompletableFuture<Long>compact(String topic, org.apache.pulsar.common.topics.TopicCompactionStrategy<T> strategy, org.apache.pulsar.client.api.CryptoKeyReader cryptoKeyReader) Methods inherited from class org.apache.pulsar.compaction.PublishingOrderCompactor
compactBatchMessage, compactMessage, extractIdsAndKeysAndSizeFromBatch, toLatestMessageIdForKeyMethods inherited from class org.apache.pulsar.compaction.AbstractTwoPhaseCompactor
closeLedger, createLedger, deleteLedger, doCompaction, extractKeyAndSize, getPhaseOneLoopReadTimeoutInSeconds, rebatchMessage
-
Constructor Details
-
StrategicTwoPhaseCompactor
public StrategicTwoPhaseCompactor(ServiceConfiguration conf, org.apache.pulsar.client.api.PulsarClient pulsar, BookKeeper bk, ScheduledExecutorService scheduler)
-
-
Method Details
-
compact
-
compact
public <T> CompletableFuture<Long> compact(String topic, org.apache.pulsar.common.topics.TopicCompactionStrategy<T> strategy) -
compact
public <T> CompletableFuture<Long> compact(String topic, org.apache.pulsar.common.topics.TopicCompactionStrategy<T> strategy, org.apache.pulsar.client.api.CryptoKeyReader cryptoKeyReader)
-