Documentation
¶
Index ¶
- Variables
- type Batch
- type BatchOptions
- type DB
- func (db *DB) Backup(dir string) error
- func (db *DB) Close() error
- func (db *DB) Delete(key []byte) error
- func (db *DB) Fold(fn func(key []byte, value []byte) bool) error
- func (db *DB) Get(key []byte) ([]byte, error)
- func (db *DB) ListKeys() [][]byte
- func (db *DB) Merge() error
- func (db *DB) NewBatch(options BatchOptions) *Batch
- func (db *DB) NewIterator(opts IteratorOptions) *Iterator
- func (db *DB) Put(key []byte, value []byte) error
- func (db *DB) Stat() *Stat
- func (db *DB) Sync() error
- type Iterator
- type IteratorOptions
- type Options
- type Stat
- type SyncStrategy
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyIsEmpty = errors.New("the key is empty") ErrIndexUpdateFailed = errors.New("failed to update index") ErrKeyNotFound = errors.New("key not found in database") ErrDataFileNotFound = errors.New("datafile file is not found") ErrDataDirectoryCorrupted = errors.New("the database directory maybe corrupted") ErrDBClosed = errors.New("the database is closed") ErrBatchCommitted = errors.New("the batch is committed") ErrBatchRollbacked = errors.New("the batch is rollbacked") ErrMergeIsProgress = errors.New("merge is in progress, try again later") ErrDatabaseIsUsing = errors.New("the database directory is used by another process") ErrMergeRatioUnreached = errors.New("the merge ratio do not reach the option") ErrNoEnoughSpaceForMerge = errors.New("no enough disk space for merge") )
View Source
var DefaultBatchOptions = BatchOptions{ Sync: false, }
DefaultBatchOptions 默认事务 Options, 供测试使用
View Source
var DefaultIteratorOptions = IteratorOptions{ Prefix: nil, Reverse: false, }
DefaultIteratorOptions 默认迭代器Options, 供测试使用
View Source
var DefaultOptions = Options{ DirPath: os.TempDir(), DataFileSize: 512 * 1024 * 1024, SyncStrategy: No, BytesPerSync: 1024 * 1024, EnableBackgroundMerge: false, IndexType: index.HashMap, ShardNum: 16, FileIOType: fio.StandardFIO, DataFileMergeRatio: 0.5, }
DefaultOptions 默认Options, 供示例程序使用
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB bitcask存储引擎客户端
func (*DB) NewBatch ¶
func (db *DB) NewBatch(options BatchOptions) *Batch
func (*DB) NewIterator ¶
func (db *DB) NewIterator(opts IteratorOptions) *Iterator
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator 数据库层迭代器, 面向用户
type IteratorOptions ¶
IteratorOptions 索引迭代器配置项
type Options ¶
type Options struct {
DirPath string // 数据目录
DataFileSize int64 // 数据文件最大容量, 单位字节
SyncStrategy SyncStrategy // 持久化策略
BytesPerSync uint // 新写入数据量阈值
IndexType index.IndexType // 索引类型
FileIOType fio.FileIOType // 文件 IO 类型
EnableBackgroundMerge bool // 是否启用后台定时 merge
DataFileMergeRatio float32 // 执行 merge 的无效数据占比阈值
ShardNum int // 索引分片数量
}
Options 用户配置项
type Stat ¶
type Stat struct {
KeyNum int // 当前 key 的数量
DataFileNum int // 当前数据文件数量
ReclaimableSize int64 // 当前 merge 可回收的数据量, 单位字节
DiskSize int64 // 数据目录的磁盘占用空间大小
}
Stat 实时统计信息
type SyncStrategy ¶
type SyncStrategy byte
const ( No SyncStrategy = iota // 由操作系统决定 Always // 立即持久化 Threshold // 新写入数据量达到阈值持久化 )
Click to show internal directories.
Click to hide internal directories.
