Help us shape the future of Go! Take the 2026 Go Developer Survey

compaction

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareEntryForCompaction

func PrepareEntryForCompaction(key, filePath string) ([]byte, []byte)

PrepareEntryForCompaction prepares the key and value to store in compaction index.

Types

type Compactor

type Compactor struct {
	// contains filtered or unexported fields
}

func NewCompactorWithConfig

func NewCompactorWithConfig(cfg *CompactorConfig) *Compactor

NewCompactorWithConfig creates a new compactor with configuration

func (*Compactor) Close

func (c *Compactor) Close()

Close stops the background compaction loop and waits for it to exit.

func (*Compactor) CompactFiles

func (c *Compactor) CompactFiles(ctx context.Context, workerID int) (int, int64)

CompactFiles scans the RocksDB file-index and migrates files into segments. The context parameter allows for cancellation of the compaction process. The workerID is used to partition work across multiple workers. Compaction continues until the current segment is full or there are no more entries. Returns the number of files processed.

func (*Compactor) Start

func (c *Compactor) Start()

Start launches background goroutines for file and segment compaction

type CompactorConfig

type CompactorConfig struct {
	MetaDB            *metadata.MetaDB
	FileManager       *files.FileManager
	SegmentManager    *segment.Manager
	DeletionQueue     *deletion.Queue
	CompactionThreads int // Number of compaction threads
	// Recompaction settings (optional)
	EnableRecompaction   bool
	FragThreshold        float64
	MinSegmentAge        time.Duration
	MinSegments          int
	RecompactionInterval time.Duration
}

CompactorConfig contains configuration for the compactor

type ErrFileSizeMismatch

type ErrFileSizeMismatch struct {
	Key          string
	FilePath     string
	ActualSize   int64
	ExpectedSize int64
}

ErrFileSizeMismatch is returned when a file's actual size doesn't match its metadata

func (*ErrFileSizeMismatch) Error

func (e *ErrFileSizeMismatch) Error() string

type SegmentRecompactor

type SegmentRecompactor struct {
	// contains filtered or unexported fields
}

SegmentRecompactor handles recompaction of fragmented segments

func NewSegmentRecompactor

func NewSegmentRecompactor(meta *metadata.MetaDB, sm *segment.Manager, deletionQueue *deletion.Queue, fragThreshold float64, minSegmentAge time.Duration, minSegments int) *SegmentRecompactor

NewSegmentRecompactor creates a new segment recompactor

func (*SegmentRecompactor) RecompactFragmentedSegments

func (sr *SegmentRecompactor) RecompactFragmentedSegments(ctx context.Context) error

RecompactFragmentedSegments identifies and recompacts fragmented segments

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL