scoria

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package scoria provides the public API for ScoriaDB, a high-performance embedded LSM-based key-value store with MVCC, Column Families, and transaction support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch interface {
	AddPut(key, value []byte)
	AddDelete(key []byte)
	Commit() error
	Clear()
	Size() int
}

Batch represents an atomic batch of operations.

type CFDB

type CFDB interface {
	// Basic operations (default CF)
	Get(key []byte) ([]byte, error)
	Put(key, value []byte) error
	Delete(key []byte) error
	Scan(prefix []byte) Iterator

	// Column Family operations
	GetCF(cf string, key []byte) ([]byte, error)
	PutCF(cf string, key, value []byte) error
	DeleteCF(cf string, key []byte) error
	ScanCF(cf string, prefix []byte) Iterator

	// Transactions and batches
	NewTransaction() Transaction
	NewBatch() Batch
	NewBatchForCF(cfName string) Batch

	// Column Family administration
	CreateCF(name string) error
	DropCF(name string) error
	ListCFs() []string

	// Close
	Close() error
}

CFDB represents the public interface of ScoriaDB with support for Column Families, transactions, batches, and iterators.

func EmbeddedCFDB

func EmbeddedCFDB(dataDir string) (CFDB, error)

EmbeddedCFDB returns a CFDB interface for embedding.

type CompactionLevelOpts

type CompactionLevelOpts struct {
	// Level номер уровня (0, 1, …).
	Level int
	// MaxFiles максимальное количество SSTable на этом уровне.
	// Если 0, используется значение по умолчанию.
	MaxFiles int
	// TargetSize целевой размер уровня в байтах.
	// Если 0, используется значение по умолчанию.
	TargetSize int64
}

CompactionLevelOpts содержит настройки для одного уровня LSM-дерева.

type DB

type DB interface {
	Get(key []byte) ([]byte, error)
	Put(key, value []byte) error
	Delete(key []byte) error
	Close() error
}

DB is the base interface for operations without Column Families (default CF only).

func Open

func Open(opts Options) (DB, error)

Open opens (or creates) a ScoriaDB database with the given options.

type Iterator

type Iterator interface {
	Next() bool
	Key() []byte
	Value() []byte
	Err() error
	Close()
}

Iterator iterates over keys and values.

type Options

type Options struct {
	// WorkDir — рабочая директория, где будут храниться данные.
	WorkDir string
	// MemTableSize — максимальный размер MemTable в байтах перед flush.
	// Если 0, используется значение по умолчанию (64 MiB).
	MemTableSize int64
	// Levels — настройки уровней компакшена.
	// Если nil, используются настройки по умолчанию.
	Levels []CompactionLevelOpts
	// VFS — абстракция файловой системы.
	// Если nil, используется vfs.DefaultVFS.
	VFS vfs.VFS
	// WALOptions — настройки Write-Ahead Log.
	// Если nil, используются DefaultWALOptions() с групповым коммитом.
	// Для отключения группового коммита передайте WALOptions{GroupCommitEnabled: false}.
	WALOptions *engine.WALOptions
}

Options содержит настройки для открытия/создания базы данных.

func DefaultOptions

func DefaultOptions(workDir string) Options

DefaultOptions возвращает Options с настройками по умолчанию.

type ScoriaDB

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

ScoriaDB implements CFDB using the Column Family registry.

func NewScoriaDB

func NewScoriaDB(dataDir string) (*ScoriaDB, error)

NewScoriaDB creates a new ScoriaDB database with Column Family support.

func NewScoriaDBWithOptions added in v0.2.2

func NewScoriaDBWithOptions(dataDir string, walOpts engine.WALOptions) (*ScoriaDB, error)

NewScoriaDBWithOptions creates a new ScoriaDB with the specified WAL options.

func (*ScoriaDB) Close

func (db *ScoriaDB) Close() error

Close closes all Column Families and releases resources.

func (*ScoriaDB) CreateCF

func (db *ScoriaDB) CreateCF(name string) error

CreateCF creates a new Column Family.

func (*ScoriaDB) Delete

func (db *ScoriaDB) Delete(key []byte) error

Delete removes a key from the default CF.

func (*ScoriaDB) DeleteCF

func (db *ScoriaDB) DeleteCF(cfName string, key []byte) error

DeleteCF removes a key from the specified Column Family.

func (*ScoriaDB) DropCF

func (db *ScoriaDB) DropCF(name string) error

DropCF drops a Column Family. System CFs cannot be dropped.

func (*ScoriaDB) Get

func (db *ScoriaDB) Get(key []byte) ([]byte, error)

Get returns the value for a key from the default CF.

func (*ScoriaDB) GetCF

func (db *ScoriaDB) GetCF(cfName string, key []byte) ([]byte, error)

func (*ScoriaDB) ListCFs

func (db *ScoriaDB) ListCFs() []string

ListCFs returns a list of all Column Family names.

func (*ScoriaDB) NewBatch

func (db *ScoriaDB) NewBatch() Batch

NewBatch creates a new batch of operations bound to the default CF.

func (*ScoriaDB) NewBatchForCF

func (db *ScoriaDB) NewBatchForCF(cfName string) Batch

NewBatchForCF creates a new batch bound to the specified CF.

func (*ScoriaDB) NewTransaction

func (db *ScoriaDB) NewTransaction() Transaction

NewTransaction creates a new transaction on the default CF.

func (*ScoriaDB) Put

func (db *ScoriaDB) Put(key, value []byte) error

Put writes a key-value pair to the default CF.

func (*ScoriaDB) PutCF

func (db *ScoriaDB) PutCF(cfName string, key, value []byte) error

PutCF writes a key-value pair to the specified Column Family.

func (*ScoriaDB) Scan

func (db *ScoriaDB) Scan(prefix []byte) Iterator

Scan returns an iterator over keys with the given prefix in the default CF.

func (*ScoriaDB) ScanCF

func (db *ScoriaDB) ScanCF(cfName string, prefix []byte) Iterator

ScanCF returns an iterator over keys with the given prefix in the specified CF.

type Transaction

type Transaction interface {
	Get(key []byte) ([]byte, error)
	Put(key, value []byte) error
	Delete(key []byte) error
	Commit() error
	Rollback() error
}

Transaction represents an interactive transaction.

Jump to

Keyboard shortcuts

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