kevo/pkg/sstable/sstable.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

34 lines
920 B
Go

package sstable
import (
"errors"
"github.com/jer/kevo/pkg/sstable/block"
)
const (
// IndexBlockEntrySize is the approximate size of an index entry
IndexBlockEntrySize = 20
// DefaultBlockSize is the target size for data blocks
DefaultBlockSize = block.BlockSize
// IndexKeyInterval controls how frequently we add keys to the index
IndexKeyInterval = 64 * 1024 // Add index entry every ~64KB
)
var (
// ErrNotFound indicates a key was not found in the SSTable
ErrNotFound = errors.New("key not found in sstable")
// ErrCorruption indicates data corruption was detected
ErrCorruption = errors.New("sstable corruption detected")
)
// IndexEntry represents a block index entry
type IndexEntry struct {
// BlockOffset is the offset of the block in the file
BlockOffset uint64
// BlockSize is the size of the block in bytes
BlockSize uint32
// FirstKey is the first key in the block
FirstKey []byte
}