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.
Index ¶
- Constants
- type CacheStats
- type ColumnFamily
- func (cf *ColumnFamily) Compact() 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) UpdateRuntimeConfig(config ColumnFamilyConfig, persistToDisk bool) error
- type ColumnFamilyConfig
- type CompressionAlgorithm
- type Config
- type IsolationLevel
- type Iterator
- func (iter *Iterator) Free()
- func (iter *Iterator) Key() ([]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 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) Close() error
- func (db *TidesDB) CreateColumnFamily(name string, config ColumnFamilyConfig) 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) ListColumnFamilies() ([]string, 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) Rollback() error
- func (txn *Transaction) RollbackToSavepoint(name string) error
- func (txn *Transaction) Savepoint(name string) 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 )
Error codes from TidesDB
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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) Compact ¶ added in v0.5.0
func (cf *ColumnFamily) Compact() error
Compact manually triggers compaction for a column family.
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) 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 {
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
SkipListMaxLevel int
SkipListProbability float32
DefaultIsolationLevel IsolationLevel
MinDiskSpace uint64
L1FileCountTrigger int
L0QueueStallThreshold int
}
ColumnFamilyConfig is the configuration for a column family.
func DefaultColumnFamilyConfig ¶ added in v0.5.0
func DefaultColumnFamilyConfig() ColumnFamilyConfig
DefaultColumnFamilyConfig returns a default column family configuration.
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
LogToFile bool
LogTruncationAt uint64
}
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 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) 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 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
}
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) CreateColumnFamily ¶
func (db *TidesDB) CreateColumnFamily(name string, config ColumnFamilyConfig) error
CreateColumnFamily creates a new column family with the given configuration.
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) ListColumnFamilies ¶
ListColumnFamilies lists all column families in the database.
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) 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.