LCOV - code coverage report
Current view: top level - pebble/internal/base - compaction.go (source / functions) Hit Total Coverage
Test: 2025-01-02 08:16Z f87b4ded - tests only.lcov Lines: 12 12 100.0 %
Date: 2025-01-02 08:18:00 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2024 The LevelDB-Go and Pebble Authors. All rights reserved. Use
       2             : // of this source code is governed by a BSD-style license that can be found in
       3             : // the LICENSE file.
       4             : 
       5             : package base
       6             : 
       7             : import "context"
       8             : 
       9             : type CompactionSlot interface {
      10             :         // CompactionSelected is called when a compaction is selected for execution in
      11             :         // this compaction slot. The firstInputLevel is the highest input level participating
      12             :         // in this compaction, and the outputLevel is the level that outputs are being
      13             :         // written to from this compaction. inputSize is the cumulative size of inputs participating
      14             :         // in this compaction, including the size of the memtable for flushes.
      15             :         CompactionSelected(firstInputLevel, outputLevel int, inputSize uint64)
      16             :         // UpdateMetrics is called periodically to update the number of disk bytes read and written
      17             :         // for this compaction slot. The metrics passed in are cumulative, not incremental
      18             :         // since the last UpdateMetrics call. The implementation of this method could
      19             :         // calculate deltas as necessary. For flushes, bytesRead will be bytes read from
      20             :         // the memtable.
      21             :         UpdateMetrics(bytesRead, bytesWritten uint64)
      22             :         // Release returns a compaction slot. Must be called once a compaction is
      23             :         // complete. After this method, no more calls must be made to other interface
      24             :         // methods on CompactionSlot.
      25             :         Release(totalBytesWritten uint64)
      26             : }
      27             : 
      28             : type CompactionLimiter interface {
      29             :         // TookWithoutPermission is called when a compaction is performed without
      30             :         // asking for permission. Pebble calls into this method for flushes as well
      31             :         // as for the first compaction in an instance, as those slots will always be
      32             :         // granted even in the case of slot exhaustion or overload.
      33             :         TookWithoutPermission(ctx context.Context) CompactionSlot
      34             :         // RequestSlot is called when a compaction is about to be scheduled. If the
      35             :         // compaction is allowed, the method returns a non-nil slot that must be released
      36             :         // after the compaction is complete. If a nil value is returned, the compaction is
      37             :         // disallowed due to possible overload.
      38             :         RequestSlot(ctx context.Context) (CompactionSlot, error)
      39             : }
      40             : 
      41             : type DefaultCompactionSlot struct{}
      42             : 
      43             : func (d *DefaultCompactionSlot) CompactionSelected(
      44             :         firstInputLevel, outputLevel int, inputSize uint64,
      45           1 : ) {
      46           1 : }
      47             : 
      48           1 : func (d *DefaultCompactionSlot) UpdateMetrics(bytesRead, bytesWritten uint64) {
      49           1 : }
      50             : 
      51           1 : func (d *DefaultCompactionSlot) Release(totalBytesWritten uint64) {
      52           1 : }
      53             : 
      54             : type DefaultCompactionLimiter struct{}
      55             : 
      56           1 : func (d *DefaultCompactionLimiter) TookWithoutPermission(ctx context.Context) CompactionSlot {
      57           1 :         return &DefaultCompactionSlot{}
      58           1 : }
      59             : 
      60           1 : func (d *DefaultCompactionLimiter) RequestSlot(ctx context.Context) (CompactionSlot, error) {
      61           1 :         return &DefaultCompactionSlot{}, nil
      62           1 : }

Generated by: LCOV version 1.14