kevo/pkg/compaction/compat.go
Jeremy Tregunna 6fc3be617d
Some checks failed
Go Tests / Run Tests (1.24.2) (push) Has been cancelled
feat: Initial release of kevo storage engine.
Adds a complete LSM-based storage engine with these features:
- Single-writer based architecture for the storage engine
- WAL for durability, and hey it's configurable
- MemTable with skip list implementation for fast read/writes
- SSTable with block-based structure for on-disk level-based storage
- Background compaction with tiered strategy
- ACID transactions
- Good documentation (I hope)
2025-04-20 14:06:50 -06:00

49 lines
1.7 KiB
Go

package compaction
import (
"time"
"github.com/jer/kevo/pkg/config"
)
// NewCompactionManager creates a new compaction manager with the old API
// This is kept for backward compatibility with existing code
func NewCompactionManager(cfg *config.Config, sstableDir string) *DefaultCompactionCoordinator {
// Create tombstone tracker with default 24-hour retention
tombstones := NewTombstoneTracker(24 * time.Hour)
// Create file tracker
fileTracker := NewFileTracker()
// Create compaction executor
executor := NewCompactionExecutor(cfg, sstableDir, tombstones)
// Create tiered compaction strategy
strategy := NewTieredCompactionStrategy(cfg, sstableDir, executor)
// Return the new coordinator
return NewCompactionCoordinator(cfg, sstableDir, CompactionCoordinatorOptions{
Strategy: strategy,
Executor: executor,
FileTracker: fileTracker,
TombstoneManager: tombstones,
CompactionInterval: cfg.CompactionInterval,
})
}
// Temporary alias types for backward compatibility
type CompactionManager = DefaultCompactionCoordinator
type Compactor = BaseCompactionStrategy
type TieredCompactor = TieredCompactionStrategy
// NewCompactor creates a new compactor with the old API (backward compatibility)
func NewCompactor(cfg *config.Config, sstableDir string, tracker *TombstoneTracker) *BaseCompactionStrategy {
return NewBaseCompactionStrategy(cfg, sstableDir)
}
// NewTieredCompactor creates a new tiered compactor with the old API (backward compatibility)
func NewTieredCompactor(cfg *config.Config, sstableDir string, tracker *TombstoneTracker) *TieredCompactionStrategy {
executor := NewCompactionExecutor(cfg, sstableDir, tracker)
return NewTieredCompactionStrategy(cfg, sstableDir, executor)
}