Some checks failed
Go Tests / Run Tests (1.24.2) (push) Has been cancelled
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)
34 lines
920 B
Go
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
|
|
}
|