Documentation ¶
Index ¶
- type BHashTable
- type BitCaskLogFile
- func (b *BitCaskLogFile) AppendRecord(r Record, sync bool) (int64, int, error)
- func (b *BitCaskLogFile) CloseFile(remove bool) error
- func (b *BitCaskLogFile) Deactivate() error
- func (b *BitCaskLogFile) IteratorRecord() ...
- func (b *BitCaskLogFile) ReadRecord(offset int64, len int, r *Record) error
- func (b *BitCaskLogFile) RemoveFile() error
- func (b *BitCaskLogFile) RenameFile(name string) error
- func (b *BitCaskLogFile) Sync() error
- type Bitcask
- type CreateOption
- type HashItem
- type Record
- type SimpleHashTable
- type WALFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BHashTable ¶
type BHashTable interface { Get(key string) (h HashItem, err error) Set(key string, h HashItem) error Del(key string) error Exists(key string) (exists bool) IteratorItem() <-chan struct { // contains filtered or unexported fields } }
BHashTable interface for bitcask hash table. it's used to find the location of the record in current version in wal file on disk, and to support the read request with only one disk seek and one disk read per request
type BitCaskLogFile ¶
type BitCaskLogFile struct { FileName string FileHandle *os.File FileHandleW *bufio.Writer FileHandleR *os.File // contains filtered or unexported fields }
BitCaskLogFile struct of the BitcaskLogFile implementation of WALFile interface
func CreateBitcaskLogFile ¶
func CreateBitcaskLogFile(filename string) *BitCaskLogFile
CreateBitcaskLogFile create a new BitcaskLogFile struct
func (*BitCaskLogFile) AppendRecord ¶
AppendRecord append a record to wal file return record offset and len return nil for error if success
func (*BitCaskLogFile) CloseFile ¶
func (b *BitCaskLogFile) CloseFile(remove bool) error
CloseFile close the file handle of the wal file on disk return nil if success
func (*BitCaskLogFile) Deactivate ¶
func (b *BitCaskLogFile) Deactivate() error
Deactivate deactivate the BitcaskLogFile by closing the write handle of the wal file if it's open return nil if success
func (*BitCaskLogFile) IteratorRecord ¶
func (b *BitCaskLogFile) IteratorRecord() <-chan struct { offset int r Record }
IteratorRecord return a channel of record for iterating
func (*BitCaskLogFile) ReadRecord ¶
func (b *BitCaskLogFile) ReadRecord(offset int64, len int, r *Record) error
ReadRecord read a record from wal file offset and [len] bytes return nil if success
func (*BitCaskLogFile) RemoveFile ¶
func (b *BitCaskLogFile) RemoveFile() error
RemoveFile remove the wal file on disk return nil if success
func (*BitCaskLogFile) RenameFile ¶
func (b *BitCaskLogFile) RenameFile(name string) error
RenameFile rename the wal file on disk return nil if success
type Bitcask ¶
type Bitcask struct {
// contains filtered or unexported fields
}
Bitcask the bitcask storage struct
func NewBitcask ¶
func NewBitcask(options CreateOption) *Bitcask
NewBitcask create a new Bitcask struct
func (*Bitcask) Close ¶
func (b *Bitcask) Close()
Close close the bitcask storage, with data on disk remain
func (*Bitcask) Destory ¶
func (b *Bitcask) Destory()
Destory destory the bitcask storage, with data on disk
type CreateOption ¶
type CreateOption struct { MaxKeySize int MaxValueSize int CompactSize int DataDir string ActiveDataDir string LogLevel string InfoLog *log.Logger DebugLog *log.Logger ErrorLog *log.Logger }
CreateOption options for bitcask creation
type Record ¶
Record struct of record of the bitcask wal file
func CreateTomStoneRecord ¶
CreateTomStoneRecord create a tomb stone record for key
type SimpleHashTable ¶
type SimpleHashTable struct {
// contains filtered or unexported fields
}
SimpleHashTable struct of hash table
func CreateSimpleHashTable ¶
func CreateSimpleHashTable() *SimpleHashTable
CreateSimpleHashTable create a new hash table
func (*SimpleHashTable) Del ¶
func (s *SimpleHashTable) Del(key string) error
Del delete value of key to the hash table
func (*SimpleHashTable) Exists ¶
func (s *SimpleHashTable) Exists(key string) (exists bool)
Exists check whether a key exists on the hash table
func (*SimpleHashTable) Get ¶
func (s *SimpleHashTable) Get(key string) (h HashItem, err error)
Get get value of key from the hash table
func (*SimpleHashTable) IteratorItem ¶
func (s *SimpleHashTable) IteratorItem() <-chan struct { key string value HashItem }
IteratorItem return a channel of the hash table for iterating
type WALFile ¶
type WALFile interface { RenameFile(name string) error RemoveFile() error CloseFile(remove bool) error Deactivate() error Sync() error AppendRecord(r Record, sync bool) (off int64, len int, err error) ReadRecord(off int64, len int, r *Record) error IteratorRecord() <-chan struct { // contains filtered or unexported fields } }
WALFile interface for bitcask wal file. It's used to contain the record on the disk to support durability and large writing throughput by appending new value to the end of itself without modifing the old value. when it gets large enough, it becomes read-only and records will be written to a new wal file (which is called the active one).