Documentation
¶
Overview ¶
Package tidesdb_go Copyright (C) TidesDB
Original Author: Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.mozilla.org/en-US/MPL/2.0/
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package tidesdb_go Copyright (C) TidesDB
Original Author: Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.mozilla.org/en-US/MPL/2.0/
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func CfConfigSaveToIni(iniFile, sectionName string, config ColumnFamilyConfig) error
- func Finalize()
- func Init() error
- func RaiseOpenFileLimit(desired int64) int64
- type CacheStats
- type ColumnFamily
- func (cf *ColumnFamily) ClearCommitHook() error
- func (cf *ColumnFamily) Compact() error
- func (cf *ColumnFamily) CompactRange(startKey, endKey []byte) error
- func (cf *ColumnFamily) FlushMemtable() error
- func (cf *ColumnFamily) GetStats() (*Stats, error)
- func (cf *ColumnFamily) IsCompacting() bool
- func (cf *ColumnFamily) IsFlushing() bool
- func (cf *ColumnFamily) PurgeCF() error
- func (cf *ColumnFamily) RangeCost(keyA, keyB []byte) (float64, error)
- func (cf *ColumnFamily) SetCommitHook(fn CommitHookFunc) error
- func (cf *ColumnFamily) SyncWal() error
- func (cf *ColumnFamily) UpdateRuntimeConfig(config ColumnFamilyConfig, persistToDisk bool) error
- type ColumnFamilyConfig
- type CommitHookFunc
- type CommitOp
- type CompressionAlgorithm
- type Config
- type DbStats
- type IsolationLevel
- type Iterator
- func (iter *Iterator) Free()
- func (iter *Iterator) Key() ([]byte, error)
- func (iter *Iterator) KeyValue() ([]byte, []byte, error)
- func (iter *Iterator) Next() error
- func (iter *Iterator) Prev() error
- func (iter *Iterator) Seek(key []byte) error
- func (iter *Iterator) SeekForPrev(key []byte) error
- func (iter *Iterator) SeekToFirst() error
- func (iter *Iterator) SeekToLast() error
- func (iter *Iterator) Valid() bool
- func (iter *Iterator) Value() ([]byte, error)
- type LogLevel
- type ObjStore
- type ObjStoreBackend
- type ObjStoreConfig
- type Stats
- type SyncMode
- type TidesDB
- func (db *TidesDB) Backup(dir string) error
- func (db *TidesDB) BeginTxn() (*Transaction, error)
- func (db *TidesDB) BeginTxnWithIsolation(isolation IsolationLevel) (*Transaction, error)
- func (db *TidesDB) CancelBackgroundWork() error
- func (db *TidesDB) Checkpoint(checkpointDir string) error
- func (db *TidesDB) CloneColumnFamily(sourceName, destName string) error
- func (db *TidesDB) Close() error
- func (db *TidesDB) CreateColumnFamily(name string, config ColumnFamilyConfig) error
- func (db *TidesDB) DeleteColumnFamily(cf *ColumnFamily) error
- func (db *TidesDB) DropColumnFamily(name string) error
- func (db *TidesDB) GetCacheStats() (*CacheStats, error)
- func (db *TidesDB) GetColumnFamily(name string) (*ColumnFamily, error)
- func (db *TidesDB) GetComparator(name string) (bool, error)
- func (db *TidesDB) GetDbStats() (*DbStats, error)
- func (db *TidesDB) ListColumnFamilies() ([]string, error)
- func (db *TidesDB) PromoteToPrimary() error
- func (db *TidesDB) Purge() error
- func (db *TidesDB) RegisterComparator(name string, ctxStr string) error
- func (db *TidesDB) RenameColumnFamily(oldName, newName string) error
- type Transaction
- func (txn *Transaction) Commit() error
- func (txn *Transaction) Delete(cf *ColumnFamily, key []byte) error
- func (txn *Transaction) Free()
- func (txn *Transaction) Get(cf *ColumnFamily, key []byte) ([]byte, error)
- func (txn *Transaction) NewIterator(cf *ColumnFamily) (*Iterator, error)
- func (txn *Transaction) Put(cf *ColumnFamily, key, value []byte, ttl int64) error
- func (txn *Transaction) ReleaseSavepoint(name string) error
- func (txn *Transaction) Reset(isolation IsolationLevel) error
- func (txn *Transaction) Rollback() error
- func (txn *Transaction) RollbackToSavepoint(name string) error
- func (txn *Transaction) Savepoint(name string) error
- func (txn *Transaction) SingleDelete(cf *ColumnFamily, key []byte) error
Constants ¶
const ( ErrSuccess = C.TDB_SUCCESS ErrMemory = C.TDB_ERR_MEMORY ErrInvalidArgs = C.TDB_ERR_INVALID_ARGS ErrNotFound = C.TDB_ERR_NOT_FOUND ErrIO = C.TDB_ERR_IO ErrCorruption = C.TDB_ERR_CORRUPTION ErrExists = C.TDB_ERR_EXISTS ErrConflict = C.TDB_ERR_CONFLICT ErrTooLarge = C.TDB_ERR_TOO_LARGE ErrMemoryLimit = C.TDB_ERR_MEMORY_LIMIT ErrInvalidDB = C.TDB_ERR_INVALID_DB ErrUnknown = C.TDB_ERR_UNKNOWN ErrLocked = C.TDB_ERR_LOCKED ErrReadonly = C.TDB_ERR_READONLY ErrBusy = C.TDB_ERR_BUSY )
Error codes from TidesDB
const ( // ComparatorMemcmp orders keys by unsigned byte-wise comparison (the default). ComparatorMemcmp = "memcmp" // ComparatorLexicographic orders keys lexicographically. ComparatorLexicographic = "lexicographic" // ComparatorUint64 interprets each 8-byte key as a uint64 in host byte order // (little-endian on most platforms). Keys whose length is not 8 fall back to // memcmp ordering. Encode keys with encoding/binary.NativeEndian to match. ComparatorUint64 = "uint64" // ComparatorInt64 interprets each 8-byte key as an int64 in host byte order // (little-endian on most platforms). Keys whose length is not 8 fall back to // memcmp ordering. Encode keys with encoding/binary.NativeEndian to match. ComparatorInt64 = "int64" // ComparatorReverse orders keys by reverse byte-wise comparison (descending). ComparatorReverse = "reverse" // ComparatorCaseInsensitive orders keys by case-insensitive byte-wise comparison. ComparatorCaseInsensitive = "case_insensitive" )
Built-in comparator names. Each is auto-registered when a database is opened, so any of these may be assigned to ColumnFamilyConfig.ComparatorName without first calling RegisterComparator.
Variables ¶
This section is empty.
Functions ¶
func CfConfigSaveToIni ¶ added in v0.8.8
func CfConfigSaveToIni(iniFile, sectionName string, config ColumnFamilyConfig) error
CfConfigSaveToIni saves a column family configuration to an INI file.
func Finalize ¶ added in v0.8.8
func Finalize()
Finalize finalizes TidesDB and resets the allocator. After calling this, Init can be called again.
func Init ¶ added in v0.8.8
func Init() error
Init initializes TidesDB with the system allocator. Must be called exactly once before any other TidesDB function. If not called, TidesDB auto-initializes on the first Open.
func RaiseOpenFileLimit ¶ added in v0.9.2
RaiseOpenFileLimit raises this process's open-file ceiling toward desired descriptors so a database can keep more sstables open. Because TidesDB sizes MaxOpenSSTables to fit this at open time, call it BEFORE Open. This is an explicit, opt-in operator action; TidesDB never raises the limit itself.
A desired value <= 0 just reports the current ceiling without changing it. A failed or partial raise is non-fatal. The returned value is the open-file ceiling in effect after the attempt.
Types ¶
type CacheStats ¶ added in v0.6.0
type CacheStats struct {
Enabled bool
TotalEntries uint64
TotalBytes uint64
Hits uint64
Misses uint64
HitRate float64
NumPartitions uint64
}
CacheStats is statistics about the block cache.
type ColumnFamily ¶ added in v0.5.0
type ColumnFamily struct {
// contains filtered or unexported fields
}
ColumnFamily is a TidesDB column family.
func (*ColumnFamily) ClearCommitHook ¶ added in v0.8.5
func (cf *ColumnFamily) ClearCommitHook() error
ClearCommitHook removes the commit hook callback from the column family.
func (*ColumnFamily) Compact ¶ added in v0.5.0
func (cf *ColumnFamily) Compact() error
Compact manually triggers compaction for a column family.
func (*ColumnFamily) CompactRange ¶ added in v0.9.1
func (cf *ColumnFamily) CompactRange(startKey, endKey []byte) error
CompactRange synchronously compacts every sstable whose key range overlaps [startKey, endKey). Output is merged toward the largest level affected. Both nil/empty endpoints is rejected - use Compact for full CF compaction. The call blocks until the merge commits or fails; the calling goroutine performs the work rather than enqueueing onto the compaction thread pool.
func (*ColumnFamily) FlushMemtable ¶ added in v0.6.0
func (cf *ColumnFamily) FlushMemtable() error
FlushMemtable manually triggers memtable flush for a column family.
func (*ColumnFamily) GetStats ¶ added in v0.6.0
func (cf *ColumnFamily) GetStats() (*Stats, error)
GetStats retrieves statistics about a column family.
func (*ColumnFamily) IsCompacting ¶ added in v0.7.0
func (cf *ColumnFamily) IsCompacting() bool
IsCompacting checks if a column family has a compaction operation in progress.
func (*ColumnFamily) IsFlushing ¶ added in v0.7.0
func (cf *ColumnFamily) IsFlushing() bool
IsFlushing checks if a column family has a flush operation in progress.
func (*ColumnFamily) PurgeCF ¶ added in v0.8.7
func (cf *ColumnFamily) PurgeCF() error
PurgeCF forces a synchronous flush and aggressive compaction for a single column family. Unlike FlushMemtable and Compact (which are non-blocking), PurgeCF blocks until all flush and compaction I/O is complete.
func (*ColumnFamily) RangeCost ¶ added in v0.8.4
func (cf *ColumnFamily) RangeCost(keyA, keyB []byte) (float64, error)
RangeCost estimates the computational cost of iterating between two keys in a column family. The returned value is an opaque double - meaningful only for comparison with other values from the same function. It uses only in-memory metadata and performs no disk I/O. Key order does not matter - the function normalizes the range internally.
func (*ColumnFamily) SetCommitHook ¶ added in v0.8.5
func (cf *ColumnFamily) SetCommitHook(fn CommitHookFunc) error
SetCommitHook sets a commit hook callback for the column family. The hook fires synchronously after WAL write, memtable apply, and commit status marking. Hook failure is logged but does not roll back the commit (data is already durable). Setting a new hook replaces any previously set hook for this column family. Pass nil to disable the hook (equivalent to ClearCommitHook).
func (*ColumnFamily) SyncWal ¶ added in v0.8.7
func (cf *ColumnFamily) SyncWal() error
SyncWal forces an immediate fsync of the active write-ahead log for a column family. This is useful for explicit durability control when using SyncNone or SyncInterval modes.
func (*ColumnFamily) UpdateRuntimeConfig ¶ added in v0.7.0
func (cf *ColumnFamily) UpdateRuntimeConfig(config ColumnFamilyConfig, persistToDisk bool) error
UpdateRuntimeConfig updates runtime-safe configuration settings for a column family. If persistToDisk is true, changes are saved to config.ini in the column family directory.
type ColumnFamilyConfig ¶ added in v0.3.0
type ColumnFamilyConfig struct {
Name string
WriteBufferSize uint64
LevelSizeRatio uint64
MinLevels int
DividingLevelOffset int
KlogValueThreshold uint64
CompressionAlgorithm CompressionAlgorithm
EnableBloomFilter bool
BloomFPR float64
EnableBlockIndexes bool
IndexSampleRatio int
BlockIndexPrefixLen int
SyncMode SyncMode
SyncIntervalUs uint64
ComparatorName string
ComparatorCtxStr string
SkipListMaxLevel int
SkipListProbability float32
DefaultIsolationLevel IsolationLevel
MinDiskSpace uint64
L1FileCountTrigger int
L0QueueStallThreshold int
TombstoneDensityTrigger float64
TombstoneDensityMinEntries uint64
UseBtree int
ObjectLazyCompaction int
ObjectPrefetchCompaction int
}
ColumnFamilyConfig is the configuration for a column family.
func CfConfigLoadFromIni ¶ added in v0.8.8
func CfConfigLoadFromIni(iniFile, sectionName string) (*ColumnFamilyConfig, error)
CfConfigLoadFromIni loads a column family configuration from an INI file.
func DefaultColumnFamilyConfig ¶ added in v0.5.0
func DefaultColumnFamilyConfig() ColumnFamilyConfig
DefaultColumnFamilyConfig returns a default column family configuration.
type CommitHookFunc ¶ added in v0.8.5
CommitHookFunc is the callback invoked synchronously after a transaction commits to a column family. ops contains the full batch of operations for that CF. commitSeq is a monotonic commit sequence number usable as a replication cursor. Return 0 on success, non-zero on failure (logged as warning by TidesDB).
type CommitOp ¶ added in v0.8.5
type CommitOp struct {
Key []byte // Key data (copied; safe to retain after callback returns)
Value []byte // Value data (nil for deletes; copied; safe to retain)
TTL int64 // Time-to-live Unix timestamp (0 = no expiry)
IsDelete bool // true if this is a delete operation, false for put
}
CommitOp represents a single operation in a committed transaction batch.
type CompressionAlgorithm ¶ added in v0.6.0
type CompressionAlgorithm int
CompressionAlgorithm the compression algorithm type.
const ( NoCompression CompressionAlgorithm = C.TDB_COMPRESS_NONE SnappyCompression CompressionAlgorithm = C.TDB_COMPRESS_SNAPPY LZ4Compression CompressionAlgorithm = C.TDB_COMPRESS_LZ4 ZstdCompression CompressionAlgorithm = C.TDB_COMPRESS_ZSTD LZ4FastCompression CompressionAlgorithm = C.TDB_COMPRESS_LZ4_FAST )
type Config ¶ added in v0.5.0
type Config struct {
DBPath string
NumFlushThreads int
NumCompactionThreads int
LogLevel LogLevel
BlockCacheSize uint64
MaxOpenSSTables uint64
MaxMemoryUsage uint64
LogToFile bool
LogTruncationAt uint64
UnifiedMemtable bool
UnifiedMemtableWriteBufferSize uint64
UnifiedMemtableSkipListMaxLevel int
UnifiedMemtableSkipListProbability float64
UnifiedMemtableSyncMode SyncMode
UnifiedMemtableSyncInterval uint64
MaxConcurrentFlushes int
FinishCompactionsOnClose bool
ObjectStore *ObjStore
ObjectStoreConfig *ObjStoreConfig
}
Config is the configuration for opening a TidesDB instance.
func DefaultConfig ¶ added in v0.6.0
func DefaultConfig() Config
DefaultConfig returns a default database configuration.
type DbStats ¶ added in v0.8.7
type DbStats struct {
NumColumnFamilies int
TotalMemory uint64
AvailableMemory uint64
ResolvedMemoryLimit uint64
MemoryPressureLevel int
FlushPendingCount int
TotalMemtableBytes int64
TotalImmutableCount int
TotalSstableCount int
TotalDataSizeBytes uint64
NumOpenSstables int
GlobalSeq uint64
TxnMemoryBytes int64
CompactionQueueSize uint64
FlushQueueSize uint64
UnifiedMemtableEnabled bool
UnifiedMemtableBytes int64
UnifiedImmutableCount int
UnifiedIsFlushing bool
UnifiedNextCFIndex uint32
UnifiedWalGeneration uint64
ObjectStoreEnabled bool
ObjectStoreConnector string
LocalCacheBytesUsed uint64
LocalCacheBytesMax uint64
LocalCacheNumFiles int
LastUploadedGeneration uint64
UploadQueueDepth uint64
TotalUploads uint64
TotalUploadFailures uint64
ReplicaMode bool
// Write-amplification counters (lifetime since open, on-disk framed bytes).
// UwalBytesWritten is the shared unified WAL volume (zero when unified mode is
// off); the remaining fields are summed across all column families. db-wide
// write amplification = (uwal + wal + flush + compaction) / user bytes.
// The *Count fields count output sstables, not logical runs.
UwalBytesWritten uint64
WalBytesWritten uint64
FlushBytesWritten uint64
CompactionBytesWritten uint64
CompactionBytesRead uint64
UserBytesWritten uint64
FlushCount uint64
CompactionCount uint64
}
DbStats is aggregate statistics across the entire database instance.
type IsolationLevel ¶ added in v0.6.0
type IsolationLevel int
IsolationLevel the transaction isolation level.
const ( IsolationReadUncommitted IsolationLevel = C.TDB_ISOLATION_READ_UNCOMMITTED IsolationReadCommitted IsolationLevel = C.TDB_ISOLATION_READ_COMMITTED IsolationRepeatableRead IsolationLevel = C.TDB_ISOLATION_REPEATABLE_READ IsolationSnapshot IsolationLevel = C.TDB_ISOLATION_SNAPSHOT IsolationSerializable IsolationLevel = C.TDB_ISOLATION_SERIALIZABLE )
type Iterator ¶ added in v0.5.0
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is a TidesDB iterator.
func (*Iterator) Free ¶ added in v0.5.0
func (iter *Iterator) Free()
Free frees the iterator resources.
func (*Iterator) KeyValue ¶ added in v0.8.8
KeyValue retrieves both the current key and value from the iterator in a single call. This is more efficient than calling Key() and Value() separately.
func (*Iterator) SeekForPrev ¶ added in v0.6.0
SeekForPrev positions the iterator at the last key <= target key.
func (*Iterator) SeekToFirst ¶ added in v0.5.0
SeekToFirst positions the iterator at the first key.
func (*Iterator) SeekToLast ¶ added in v0.5.0
SeekToLast positions the iterator at the last key.
type LogLevel ¶ added in v0.6.0
type LogLevel int
LogLevel the logging level.
const ( LogDebug LogLevel = C.TDB_LOG_DEBUG LogInfo LogLevel = C.TDB_LOG_INFO LogWarn LogLevel = C.TDB_LOG_WARN LogError LogLevel = C.TDB_LOG_ERROR LogFatal LogLevel = C.TDB_LOG_FATAL LogNone LogLevel = C.TDB_LOG_NONE )
type ObjStore ¶ added in v0.8.8
type ObjStore struct {
// contains filtered or unexported fields
}
ObjStore is an opaque object store connector handle.
func ObjStoreFsCreate ¶ added in v0.8.8
ObjStoreFsCreate creates a filesystem-backed object store connector for testing and local replication. Objects are stored as files under rootDir mirroring the key path structure.
type ObjStoreBackend ¶ added in v0.8.8
type ObjStoreBackend int
ObjStoreBackend identifies the object store backend in use.
const ( BackendFS ObjStoreBackend = C.TDB_BACKEND_FS BackendS3 ObjStoreBackend = C.TDB_BACKEND_S3 BackendUnknown ObjStoreBackend = C.TDB_BACKEND_UNKNOWN )
type ObjStoreConfig ¶ added in v0.8.8
type ObjStoreConfig struct {
LocalCachePath string
LocalCacheMaxBytes uint64
CacheOnRead bool
CacheOnWrite bool
MaxConcurrentUploads int
MaxConcurrentDownloads int
MultipartThreshold uint64
MultipartPartSize uint64
SyncManifestToObject bool
ReplicateWal bool
WalUploadSync bool
WalSyncThresholdBytes uint64
WalSyncOnCommit bool
ReplicaMode bool
ReplicaSyncIntervalUs uint64
ReplicaReplayWal bool
}
ObjStoreConfig configures object store mode behavior.
func ObjStoreDefaultConfig ¶ added in v0.8.8
func ObjStoreDefaultConfig() ObjStoreConfig
ObjStoreDefaultConfig returns the default object store configuration.
type Stats ¶ added in v0.6.0
type Stats struct {
NumLevels int
MemtableSize uint64
LevelSizes []uint64
LevelNumSSTables []int
Config *ColumnFamilyConfig
TotalKeys uint64
TotalDataSize uint64
AvgKeySize float64
AvgValueSize float64
LevelKeyCounts []uint64
ReadAmp float64
HitRate float64
UseBtree bool
BtreeTotalNodes uint64
BtreeMaxHeight uint32
BtreeAvgHeight float64
TotalTombstones uint64
TombstoneRatio float64
LevelTombstoneCounts []uint64
MaxSSTDensity float64
MaxSSTDensityLevel int
// Write-amplification counters (lifetime since open, on-disk framed bytes).
// Divide the write totals by UserBytesWritten for this CF's write amplification.
// WalBytesWritten is zero in unified mode; the shared WAL volume is reported
// db-wide via DbStats.UwalBytesWritten. The *Count fields count output sstables.
WalBytesWritten uint64
FlushBytesWritten uint64
CompactionBytesWritten uint64
CompactionBytesRead uint64
UserBytesWritten uint64
FlushCount uint64
CompactionCount uint64
}
Stats is statistics about a column family.
type SyncMode ¶ added in v0.6.0
type SyncMode int
SyncMode the sync mode for durability.
const ( SyncNone SyncMode = C.TDB_SYNC_NONE SyncFull SyncMode = C.TDB_SYNC_FULL SyncInterval SyncMode = C.TDB_SYNC_INTERVAL )
type TidesDB ¶
type TidesDB struct {
// contains filtered or unexported fields
}
TidesDB is a TidesDB instance.
func (*TidesDB) Backup ¶ added in v0.7.0
Backup creates an on-disk snapshot of an open database without blocking normal reads/writes. The dir parameter must be a non-existent directory or an empty directory.
func (*TidesDB) BeginTxn ¶
func (db *TidesDB) BeginTxn() (*Transaction, error)
BeginTxn begins a new transaction with default isolation level.
func (*TidesDB) BeginTxnWithIsolation ¶ added in v0.6.0
func (db *TidesDB) BeginTxnWithIsolation(isolation IsolationLevel) (*Transaction, error)
BeginTxnWithIsolation begins a new transaction with the specified isolation level.
func (*TidesDB) CancelBackgroundWork ¶ added in v0.9.2
CancelBackgroundWork cancels background compaction db-wide. In-flight merges bail out safely and queued compaction is skipped; flushes are unaffected so durability is preserved. The call blocks (bounded) until compaction is idle.
The cancellation is sticky for the session and is reset on the next Open. It is intended to be called right before Close for a fast shutdown.
func (*TidesDB) Checkpoint ¶ added in v0.8.2
Checkpoint creates a lightweight, near-instant snapshot of an open database using hard links instead of copying SSTable data. The checkpointDir parameter must be a non-existent directory or an empty directory. The checkpoint can be opened as a normal TidesDB database.
func (*TidesDB) CloneColumnFamily ¶ added in v0.8.1
CloneColumnFamily creates a complete copy of an existing column family with a new name. The clone contains all the data from the source at the time of cloning. Both column families exist independently after cloning.
func (*TidesDB) CreateColumnFamily ¶
func (db *TidesDB) CreateColumnFamily(name string, config ColumnFamilyConfig) error
CreateColumnFamily creates a new column family with the given configuration.
func (*TidesDB) DeleteColumnFamily ¶ added in v0.8.4
func (db *TidesDB) DeleteColumnFamily(cf *ColumnFamily) error
DeleteColumnFamily drops a column family by pointer. This is faster than DropColumnFamily when you already hold the ColumnFamily pointer, as it skips the internal name lookup.
func (*TidesDB) DropColumnFamily ¶
DropColumnFamily drops a column family and all associated data.
func (*TidesDB) GetCacheStats ¶ added in v0.6.0
func (db *TidesDB) GetCacheStats() (*CacheStats, error)
GetCacheStats retrieves statistics about the block cache.
func (*TidesDB) GetColumnFamily ¶ added in v0.5.0
func (db *TidesDB) GetColumnFamily(name string) (*ColumnFamily, error)
GetColumnFamily retrieves a column family by name.
func (*TidesDB) GetComparator ¶ added in v0.8.6
GetComparator retrieves a registered comparator by name. Returns true if the comparator is registered, false otherwise.
func (*TidesDB) GetDbStats ¶ added in v0.8.7
GetDbStats retrieves aggregate statistics across the entire database instance. Unlike GetStats (which heap-allocates), GetDbStats fills a caller-provided struct on the stack. No free is needed.
func (*TidesDB) ListColumnFamilies ¶
ListColumnFamilies lists all column families in the database.
func (*TidesDB) PromoteToPrimary ¶ added in v0.8.8
PromoteToPrimary switches a read-only replica database to primary mode.
func (*TidesDB) Purge ¶ added in v0.8.7
Purge forces a synchronous flush and aggressive compaction for all column families, then drains both the global flush and compaction queues. This blocks until all work is complete.
func (*TidesDB) RegisterComparator ¶ added in v0.6.0
RegisterComparator registers a custom comparator with the database.
func (*TidesDB) RenameColumnFamily ¶ added in v0.7.0
RenameColumnFamily atomically renames a column family and its underlying directory. Waits for any in-progress flush/compaction to complete before renaming.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction is a TidesDB transaction.
func (*Transaction) Delete ¶
func (txn *Transaction) Delete(cf *ColumnFamily, key []byte) error
Delete removes a key-value pair from the transaction.
func (*Transaction) Get ¶
func (txn *Transaction) Get(cf *ColumnFamily, key []byte) ([]byte, error)
Get retrieves a value from the transaction.
func (*Transaction) NewIterator ¶ added in v0.5.0
func (txn *Transaction) NewIterator(cf *ColumnFamily) (*Iterator, error)
NewIterator creates a new iterator for a column family within a transaction.
func (*Transaction) Put ¶
func (txn *Transaction) Put(cf *ColumnFamily, key, value []byte, ttl int64) error
Put adds a key-value pair to the transaction. TTL is Unix timestamp (seconds since epoch) for expiration, or -1 for no expiration.
func (*Transaction) ReleaseSavepoint ¶ added in v0.6.0
func (txn *Transaction) ReleaseSavepoint(name string) error
ReleaseSavepoint releases a savepoint without rolling back.
func (*Transaction) Reset ¶ added in v0.8.1
func (txn *Transaction) Reset(isolation IsolationLevel) error
Reset resets a committed or aborted transaction for reuse with a new isolation level. This avoids the overhead of freeing and reallocating transaction resources in hot loops. The transaction must be committed or aborted before reset; resetting an active transaction returns an error.
func (*Transaction) Rollback ¶
func (txn *Transaction) Rollback() error
Rollback rolls back the transaction.
func (*Transaction) RollbackToSavepoint ¶ added in v0.6.0
func (txn *Transaction) RollbackToSavepoint(name string) error
RollbackToSavepoint rolls back the transaction to a savepoint.
func (*Transaction) Savepoint ¶ added in v0.6.0
func (txn *Transaction) Savepoint(name string) error
Savepoint creates a savepoint within the transaction.
func (*Transaction) SingleDelete ¶ added in v0.9.0
func (txn *Transaction) SingleDelete(cf *ColumnFamily, key []byte) error
SingleDelete writes a tombstone carrying a caller-provided promise that the key has been put at most once since its previous single-delete (or since the start of history). This lets compaction drop the put and tombstone together as soon as both appear in the same merge input, rather than carrying the tombstone forward to the largest active level. Read semantics match Delete.
The engine does not verify the promise at runtime; violating it can leave older puts visible and is a bug in the caller. Use only for insert-once-then- delete patterns (classic insert benchmarks, secondary indexes on never-updated columns, log tables with scheduled purges). Not safe for repeated updates to the same key - when in doubt, prefer Delete.