Class TwoPhaseCompactor

java.lang.Object
org.apache.pulsar.compaction.Compactor
org.apache.pulsar.compaction.TwoPhaseCompactor

public class TwoPhaseCompactor extends Compactor
Compaction will go through the topic in two passes. The first pass selects latest offset for each key in the topic. Then the second pass writes these values to a ledger.

The two passes are required to avoid holding the payloads of each of the latest values in memory, as the payload can be many orders of magnitude larger than a message id.

  • Constructor Details

    • TwoPhaseCompactor

      public TwoPhaseCompactor(org.apache.pulsar.broker.ServiceConfiguration conf, org.apache.pulsar.client.api.PulsarClient pulsar, org.apache.bookkeeper.client.BookKeeper bk, ScheduledExecutorService scheduler)
  • Method Details

    • doCompaction

      protected CompletableFuture<Long> doCompaction(RawReader reader, org.apache.bookkeeper.client.BookKeeper bk)
      Specified by:
      doCompaction in class Compactor
    • getPhaseOneLoopReadTimeoutInSeconds

      public long getPhaseOneLoopReadTimeoutInSeconds()