Documentation ¶
Index ¶
- Variables
- type DB
- func (db *DB) Close() error
- func (db *DB) Delete(key []byte) error
- func (db *DB) Fold(f func(key []byte, value []byte) bool) error
- func (db *DB) Get(key []byte) ([]byte, error)
- func (db *DB) GetListKeys() [][]byte
- func (db *DB) Merge() error
- func (db *DB) NewIterator(opt IteratorOptions) *Iterator
- func (db *DB) NewWriteBatch(opt WriteBatchOptions) *WriteBatch
- func (db *DB) Put(key []byte, value []byte) error
- func (db *DB) Sync() error
- type IndexerType
- type Iterator
- type IteratorOptions
- type Options
- type WriteBatch
- type WriteBatchOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyIsEmpty = errors.New("KeyEmptyError : the key is empty") ErrIndexUpdateFailed = errors.New("IndexUpdateFailError : failed to update index") ErrKeyNotFound = errors.New("KeyNotFoundError : key is not found in database") ErrDataFailNotFound = errors.New("DataFailNotFoundError : data file is not found") ErrDataDirectoryCorrupted = errors.New("DataDirectoryCorruptedError : the databases directory maybe corrupted") ErrExceedMaxBatchNum = errors.New("ExceedMaxBatchNumError : exceed the max batch num") ErrMergeIsProgress = errors.New("MergeIsProgressError : merge is in progress, try again later") ErrOptionDirPathIsEmpty = errors.New("OptionDirPathError : database dir path is empty") ErrOptionDataFileSizeNotPositive = errors.New("OptionDataFileSizeError : database data file size must be greater than 0") )
View Source
var DefaultIteratorOptions = IteratorOptions{ Prefix: nil, Reverse: false, }
View Source
var DefaultOptions = Options{ DirPath: os.TempDir(), DataFileSize: 256 * 1024 * 1024, SyncWrite: false, IndexType: Btree, }
View Source
var DefaultWriteBatchOptions = WriteBatchOptions{ MaxBatchNum: 10000, SyncWrites: true, }
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB bitcask 存储引擎实例
func (*DB) NewIterator ¶
func (db *DB) NewIterator(opt IteratorOptions) *Iterator
NewIterator 初始化迭代器
func (*DB) NewWriteBatch ¶
func (db *DB) NewWriteBatch(opt WriteBatchOptions) *WriteBatch
NewWriteBatch 初始化 WriteBatch
type IndexerType ¶
type IndexerType = int8
const ( // Btree 索引 Btree IndexerType = iota + 1 // ART (Adpative Radix Tree) 自适应基数树 ART )
type IteratorOptions ¶
type IteratorOptions struct { // 遍历前缀为指定值的 Key,默认为空 Prefix []byte // 是否反向遍历,默认 false 是正向 Reverse bool }
IteratorOptions 索引迭代器配置项
type Options ¶
type Options struct { DirPath string //数据库数据目录 DataFileSize int64 //数据文件的大小 SyncWrite bool // 每次写数据是否持久化 IndexType IndexerType }
type WriteBatch ¶
type WriteBatch struct {
// contains filtered or unexported fields
}
WriteBatch 原子批量写数据,保证操作原子性
type WriteBatchOptions ¶
type WriteBatchOptions struct { // 一个批次当中最大的数据量 MaxBatchNum uint // 提交时是否 sync 持久化 SyncWrites bool }
WriteBatchOptions 批量写入配置项
Click to show internal directories.
Click to hide internal directories.