Documentation
¶
Index ¶
- Variables
- func RegisterTransactionCreator(creator LegacyTransactionCreator)
- type Engine
- type EngineFacade
- func (e *EngineFacade) ApplyBatch(entries []*wal.Entry) error
- func (e *EngineFacade) ApplyBatchInternal(entries []*wal.Entry) error
- func (e *EngineFacade) BeginTransaction(readOnly bool) (interfaces.Transaction, error)
- func (e *EngineFacade) Close() error
- func (e *EngineFacade) CompactRange(startKey, endKey []byte) error
- func (e *EngineFacade) Delete(key []byte) error
- func (e *EngineFacade) DeleteInternal(key []byte) error
- func (e *EngineFacade) FlushImMemTables() error
- func (e *EngineFacade) Get(key []byte) ([]byte, error)
- func (e *EngineFacade) GetCompactionStats() (map[string]interface{}, error)
- func (e *EngineFacade) GetIterator() (iterator.Iterator, error)
- func (e *EngineFacade) GetRWLock() *sync.RWMutex
- func (e *EngineFacade) GetRangeIterator(startKey, endKey []byte) (iterator.Iterator, error)
- func (e *EngineFacade) GetStats() map[string]interface{}
- func (e *EngineFacade) GetTransactionManager() transaction.TransactionManager
- func (e *EngineFacade) GetWAL() *wal.WAL
- func (e *EngineFacade) IncrementTxAborted()
- func (e *EngineFacade) IncrementTxCompleted()
- func (e *EngineFacade) IsDeleted(key []byte) (bool, error)
- func (e *EngineFacade) IsReadOnly() bool
- func (e *EngineFacade) Put(key, value []byte) error
- func (e *EngineFacade) PutInternal(key, value []byte) error
- func (e *EngineFacade) SetReadOnly(readOnly bool)
- func (e *EngineFacade) TriggerCompaction() error
- type IterSource
- type LegacyTransaction
- type LegacyTransactionCreator
- type MemTableSource
- type MergedIterator
- func (m *MergedIterator) IsTombstone() bool
- func (m *MergedIterator) Key() []byte
- func (m *MergedIterator) Next() bool
- func (m *MergedIterator) Seek(target []byte) bool
- func (m *MergedIterator) SeekToFirst()
- func (m *MergedIterator) SeekToLast()
- func (m *MergedIterator) Valid() bool
- func (m *MergedIterator) Value() []byte
- type SSTableSource
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEngineClosed is returned when operations are performed on a closed engine ErrEngineClosed = errors.New("engine is closed") // ErrKeyNotFound is returned when a key is not found ErrKeyNotFound = errors.New("key not found") // ErrReadOnlyMode is returned when write operations are attempted while the engine is in read-only mode ErrReadOnlyMode = errors.New("engine is in read-only mode (replica)") )
Functions ¶
func RegisterTransactionCreator ¶
func RegisterTransactionCreator(creator LegacyTransactionCreator)
RegisterTransactionCreator registers a function that can create transactions This is kept for backward compatibility
Types ¶
type Engine ¶
type Engine = EngineFacade
We keep the Engine name used in legacy code, but redirect it to our new implementation
type EngineFacade ¶ added in v1.2.0
type EngineFacade struct {
// contains filtered or unexported fields
}
EngineFacade implements the Engine interface and delegates to appropriate components
func NewEngine ¶
func NewEngine(dataDir string) (*EngineFacade, error)
NewEngine creates a new storage engine using the facade pattern This replaces the legacy implementation
func NewEngineFacade ¶ added in v1.2.0
func NewEngineFacade(dataDir string) (*EngineFacade, error)
NewEngineFacade creates a new storage engine using the facade pattern This will eventually replace NewEngine once the refactoring is complete
func (*EngineFacade) ApplyBatch ¶ added in v1.2.0
func (e *EngineFacade) ApplyBatch(entries []*wal.Entry) error
ApplyBatch atomically applies a batch of operations
func (*EngineFacade) ApplyBatchInternal ¶ added in v1.3.0
func (e *EngineFacade) ApplyBatchInternal(entries []*wal.Entry) error
ApplyBatchInternal atomically applies a batch of operations, bypassing the read-only check This is used by replication to apply batch operations even when in read-only mode
func (*EngineFacade) BeginTransaction ¶ added in v1.2.0
func (e *EngineFacade) BeginTransaction(readOnly bool) (interfaces.Transaction, error)
BeginTransaction starts a new transaction with the given read-only flag
func (*EngineFacade) Close ¶ added in v1.2.0
func (e *EngineFacade) Close() error
Close closes the storage engine
func (*EngineFacade) CompactRange ¶ added in v1.2.0
func (e *EngineFacade) CompactRange(startKey, endKey []byte) error
CompactRange forces compaction on a specific key range
func (*EngineFacade) Delete ¶ added in v1.2.0
func (e *EngineFacade) Delete(key []byte) error
Delete removes a key from the database
func (*EngineFacade) DeleteInternal ¶ added in v1.3.0
func (e *EngineFacade) DeleteInternal(key []byte) error
DeleteInternal removes a key from the database, bypassing the read-only check This is used by replication to apply delete operations even when in read-only mode
func (*EngineFacade) FlushImMemTables ¶ added in v1.2.0
func (e *EngineFacade) FlushImMemTables() error
FlushImMemTables flushes all immutable MemTables to disk
func (*EngineFacade) Get ¶ added in v1.2.0
func (e *EngineFacade) Get(key []byte) ([]byte, error)
Get retrieves the value for the given key
func (*EngineFacade) GetCompactionStats ¶ added in v1.2.0
func (e *EngineFacade) GetCompactionStats() (map[string]interface{}, error)
GetCompactionStats returns statistics about the compaction state
func (*EngineFacade) GetIterator ¶ added in v1.2.0
func (e *EngineFacade) GetIterator() (iterator.Iterator, error)
GetIterator returns an iterator over the entire keyspace
func (*EngineFacade) GetRWLock ¶ added in v1.2.0
func (e *EngineFacade) GetRWLock() *sync.RWMutex
GetRWLock is a compatibility method for the engine facade It returns a sync.RWMutex for use by the legacy transaction code
func (*EngineFacade) GetRangeIterator ¶ added in v1.2.0
func (e *EngineFacade) GetRangeIterator(startKey, endKey []byte) (iterator.Iterator, error)
GetRangeIterator returns an iterator limited to a specific key range
func (*EngineFacade) GetStats ¶ added in v1.2.0
func (e *EngineFacade) GetStats() map[string]interface{}
GetStats returns the current statistics for the engine
func (*EngineFacade) GetTransactionManager ¶ added in v1.3.1
func (e *EngineFacade) GetTransactionManager() transaction.TransactionManager
GetTransactionManager returns the transaction manager
func (*EngineFacade) GetWAL ¶ added in v1.3.0
func (e *EngineFacade) GetWAL() *wal.WAL
GetWAL exposes the WAL for replication purposes
func (*EngineFacade) IncrementTxAborted ¶ added in v1.2.0
func (e *EngineFacade) IncrementTxAborted()
IncrementTxAborted is a compatibility method for the engine facade
func (*EngineFacade) IncrementTxCompleted ¶ added in v1.2.0
func (e *EngineFacade) IncrementTxCompleted()
IncrementTxCompleted is a compatibility method for the engine facade
func (*EngineFacade) IsDeleted ¶ added in v1.2.0
func (e *EngineFacade) IsDeleted(key []byte) (bool, error)
IsDeleted returns true if the key exists and is marked as deleted
func (*EngineFacade) IsReadOnly ¶ added in v1.3.0
func (e *EngineFacade) IsReadOnly() bool
IsReadOnly returns true if the engine is in read-only mode
func (*EngineFacade) Put ¶ added in v1.2.0
func (e *EngineFacade) Put(key, value []byte) error
Put adds a key-value pair to the database
func (*EngineFacade) PutInternal ¶ added in v1.3.0
func (e *EngineFacade) PutInternal(key, value []byte) error
PutInternal adds a key-value pair to the database, bypassing the read-only check This is used by replication to apply entries even when in read-only mode
func (*EngineFacade) SetReadOnly ¶ added in v1.3.0
func (e *EngineFacade) SetReadOnly(readOnly bool)
SetReadOnly sets the engine to read-only mode for replicas
func (*EngineFacade) TriggerCompaction ¶ added in v1.2.0
func (e *EngineFacade) TriggerCompaction() error
TriggerCompaction forces a compaction cycle
type IterSource ¶
type IterSource interface {
// GetIterator returns an iterator for this source
GetIterator() iterator.Iterator
// GetLevel returns the level of this source (lower is newer)
GetLevel() int
}
IterSource is an interface for any source that can provide key-value pairs
type LegacyTransaction ¶ added in v1.2.0
type LegacyTransaction interface {
Get(key []byte) ([]byte, error)
Put(key, value []byte) error
Delete(key []byte) error
NewIterator() iterator.Iterator
NewRangeIterator(startKey, endKey []byte) iterator.Iterator
Commit() error
Rollback() error
IsReadOnly() bool
}
LegacyTransaction interface is kept for backward compatibility
func CreateTransactionWithCreator ¶ added in v1.2.0
func CreateTransactionWithCreator(engine interface{}, readOnly bool) (LegacyTransaction, error)
CreateTransactionWithCreator creates a transaction using the registered creator This is for internal use by the engine facade
type LegacyTransactionCreator ¶ added in v1.2.0
type LegacyTransactionCreator interface {
CreateTransaction(engine interface{}, readOnly bool) (LegacyTransaction, error)
}
LegacyTransactionCreator is kept for backward compatibility
func GetRegisteredTransactionCreator ¶ added in v1.2.0
func GetRegisteredTransactionCreator() LegacyTransactionCreator
GetRegisteredTransactionCreator returns the registered transaction creator This is for internal use by the engine facade
type MemTableSource ¶
type MemTableSource struct {
// contains filtered or unexported fields
}
MemTableSource is an iterator source backed by a MemTable
func (*MemTableSource) GetIterator ¶
func (m *MemTableSource) GetIterator() iterator.Iterator
func (*MemTableSource) GetLevel ¶
func (m *MemTableSource) GetLevel() int
type MergedIterator ¶
type MergedIterator struct {
// contains filtered or unexported fields
}
MergedIterator merges multiple iterators into a single sorted view It uses a heap to efficiently merge the iterators
func NewMergedIterator ¶
func NewMergedIterator(sources []IterSource) *MergedIterator
NewMergedIterator creates a new merged iterator from the given sources The sources should be provided in newest-to-oldest order
func (*MergedIterator) IsTombstone ¶
func (m *MergedIterator) IsTombstone() bool
IsTombstone returns true if the current entry is a deletion marker
func (*MergedIterator) Next ¶
func (m *MergedIterator) Next() bool
Next advances the iterator to the next key
func (*MergedIterator) Seek ¶
func (m *MergedIterator) Seek(target []byte) bool
Seek positions the iterator at the first key >= target
func (*MergedIterator) SeekToFirst ¶
func (m *MergedIterator) SeekToFirst()
SeekToFirst positions the iterator at the first key
func (*MergedIterator) SeekToLast ¶
func (m *MergedIterator) SeekToLast()
SeekToLast positions the iterator at the last key
func (*MergedIterator) Valid ¶
func (m *MergedIterator) Valid() bool
Valid returns true if the iterator is positioned at a valid entry
func (*MergedIterator) Value ¶
func (m *MergedIterator) Value() []byte
Value returns the current value
type SSTableSource ¶
type SSTableSource struct {
// contains filtered or unexported fields
}
SSTableSource is an iterator source backed by an SSTable
func (*SSTableSource) GetIterator ¶
func (s *SSTableSource) GetIterator() iterator.Iterator
func (*SSTableSource) GetLevel ¶
func (s *SSTableSource) GetLevel() int