Class ParallelCompactor


  • public class ParallelCompactor
    extends ClassicCompactor
    This compactor implementation leverages the tree structure of the repository for concurrent compaction. It explores the tree breadth-first until the target node count (10000) is reached. Every node at this depth will be an entry point for asynchronous compaction. After the exploration phase, the main thread will collect these compaction results and write their parents' node state to disk.
    • Constructor Detail

      • ParallelCompactor

        public ParallelCompactor​(@NotNull
                                 @NotNull GCMonitor gcListener,
                                 @NotNull
                                 @NotNull CompactionWriter writer,
                                 @NotNull
                                 @NotNull GCNodeWriteMonitor compactionMonitor,
                                 int nThreads)
        Create a new instance based on the passed arguments.
        Parameters:
        gcListener - listener receiving notifications about the garbage collection process
        writer - segment writer used to serialise to segments
        compactionMonitor - notification call back for each compacted nodes, properties, and binaries
        nThreads - number of threads to use for parallel compaction, negative numbers are interpreted relative to the number of available processors
    • Method Detail

      • compact

        @Nullable
        protected @Nullable CompactedNodeState compact​(@NotNull
                                                       @NotNull NodeState before,
                                                       @NotNull
                                                       @NotNull NodeState after,
                                                       @NotNull
                                                       @NotNull NodeState onto,
                                                       @NotNull
                                                       @NotNull Canceller hardCanceller,
                                                       @Nullable
                                                       @Nullable Canceller softCanceller)
                                                throws IOException
        Description copied from class: ClassicCompactor
        Compact the differences between after and before on top of onto. The softCanceller must be null, unless after.equals(onto), i.e. if the method is called for a ClassicCompactor.compactDown(NodeState, NodeState, Canceller, Canceller) scenario. .
        Overrides:
        compact in class ClassicCompactor
        Parameters:
        before - The node state used as the baseline for the diff.
        after - The node state used as the target for the diff.
        onto - The node state to apply the diff to.
        hardCanceller - The trigger for hard cancellation, will abandon compaction if cancelled.
        softCanceller - The trigger for soft cancellation, will return partially compacted state if cancelled. Must be null unless after.equals(onto).
        Returns:
        The compacted node state or null if hard-cancelled.
        Throws:
        IOException - Will throw exception if any errors occur during compaction.