Documentation ¶
Index ¶
- Variables
- 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, 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) NewIterator(opt *IteratorOption) *Iterator
- func (db *DB) NewWriteBatch(options WriteBatchOption) *WriteBatch
- func (db *DB) Put(key []byte, value []byte) error
- func (db *DB) Stat() *Stat
- func (db *DB) Sync() error
- type IndexType
- type Iterator
- type IteratorOption
- type Options
- type Stat
- type WriteBatch
- type WriteBatchOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyIsEmpty = errors.New("key is empty") ErrIndexUpdateFailed = errors.New("failed to update index") ErrKeyNotFound = errors.New("key not found") ErrFileNotFound = errors.New("file not found") ErrDataDirectoryCorrupted = errors.New("the database directory maybe corrupted") ErrExceedMaxBatchSize = errors.New("exceed max batch size") ErrMergeInProgress = errors.New("merge in progress") ErrDatabaseIsUsing = errors.New("the database directory is used by another process") ErrMergeThresholdNotReached = errors.New("the merge threshold does not reach the option") ErrInsufficientDiskSpace = errors.New("insufficient disk space") )
View Source
var DefaultOptions = Options{ DirPath: filepath.Join(os.TempDir(), "bitcask-go"), MaxFileSize: 256 * 1024 * 1024, SyncWrites: false, BytesPerSync: 0, IndexType: BTree, MMapAtStartup: true, DataFileMergeThreshold: 0.5, }
View Source
var DefaultWriteBatchOptions = WriteBatchOption{ MaxBatchSize: 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 *IteratorOption) *Iterator
func (*DB) NewWriteBatch ¶
func (db *DB) NewWriteBatch(options WriteBatchOption) *WriteBatch
type IteratorOption ¶
type Options ¶
type Options struct { DirPath string // 数据库数据目录 MaxFileSize int64 // 数据文件大小 SyncWrites bool // 是否同步写入,true 时每次写入都会持久化到磁盘当中 BytesPerSync uint // 每写入指定字节数后同步到磁盘 IndexType IndexType // 索引类型 MMapAtStartup bool // 是否在启动时将索引文件映射到内存当中 DataFileMergeThreshold float32 // 数据文件合并阈值, 无效数据文件占总数据文件大小的比例超过该阈值时触发合并 }
type Stat ¶
type Stat struct { KeyNum uint // key 的总数量 DataFileNum uint // 数据文件的数量 ReclaimableSize int64 // 可以进行 merge 回收的数据量,单位 byte DiskSize int64 // 数据目录占用的磁盘空间,单位 byte }
Stat 存储引擎的统计信息
type WriteBatch ¶
type WriteBatch struct {
// contains filtered or unexported fields
}
WriteBatch 原子批量写
type WriteBatchOption ¶
type WriteBatchOption struct { MaxBatchSize uint // 最大批量写入大小 SyncWrites bool // 是否同步写入,true 时每次写入都会持久化到磁盘当中 }
WriteBatchOption 批量写入配置项
Click to show internal directories.
Click to hide internal directories.