Documentation ¶
Index ¶
- Constants
- Variables
- func Find(block, key []byte) [][]byte
- func Merge(name string, left *Table, right *Table) error
- func Next(block []byte, offset int64) ([]byte, []byte, int64, bool)
- func RemoveTableLogs(prefix string) error
- func Seek(file *File, offset int64) ([]byte, int64, bool)
- type BlockScanner
- type File
- type LeveledCompaction
- type MTable
- func (table *MTable) All() []MTableRecord
- func (table *MTable) Cleanup() error
- func (table *MTable) Close() error
- func (table *MTable) Compact() error
- func (table *MTable) Get(key []byte) [][]byte
- func (table *MTable) Merge(newer *MTable) error
- func (table *MTable) Put(key, value []byte) error
- func (mtable *MTable) ReadFrom(cached io.Reader) (int64, error)
- func (table *MTable) Size() int64
- type MTableRecord
- type RowScanner
- type Run
- type Scanner
- type Table
- type TableScanner
- type WTable
- type WritableAutoflushTable
Constants ¶
const ( RunPrefix = "level" MaxTableCacheTime = time.Minute DefaultLeveledBase = 5 DefaultLeveledCount = 10 DefaultLeveledSize = 2 << 26 DefaultLeveledFactor = 10 )
const ( // MaxBlockSize defines the maximum size of a table block. By default 64 KiB. MaxBlockSize = 2 << 16 // MaxCacheSize defines the maximum number of blocks cached in memory. By default 8 MiB. MaxCacheSize = 128 )
Variables ¶
var DefaultBucket = ratelimit.NewBucketWithRate(2<<21, 2<<22)
Functions ¶
func RemoveTableLogs ¶
RemoveTableLogs drops all tables logs associated with tables with the given prefix.
Types ¶
type BlockScanner ¶
type BlockScanner struct {
// contains filtered or unexported fields
}
func ScanBlocks ¶
func ScanBlocks(file *File) BlockScanner
ScanBlocks returns a block scanner for the given file.
func (*BlockScanner) Block ¶
func (scanner *BlockScanner) Block() []byte
func (*BlockScanner) Next ¶
func (scanner *BlockScanner) Next() bool
func (*BlockScanner) Peek ¶
func (scanner *BlockScanner) Peek() bool
func (*BlockScanner) Skip ¶
func (scanner *BlockScanner) Skip()
type LeveledCompaction ¶
type LeveledCompaction struct { Name string BaseSize, LevelSize, LevelSizeFactor int64 BaseCount, LevelCount, LevelCountFactor int Base []*Table Levels []*Run // contains filtered or unexported fields }
func NewLeveledCompaction ¶
func NewLeveledCompaction(name string) *LeveledCompaction
func (*LeveledCompaction) Add ¶
func (compaction *LeveledCompaction) Add(table *Table) error
func (*LeveledCompaction) Close ¶
func (compaction *LeveledCompaction) Close() error
func (*LeveledCompaction) Get ¶
func (compaction *LeveledCompaction) Get(key []byte) [][]byte
func (*LeveledCompaction) Restore ¶
func (compaction *LeveledCompaction) Restore(tables []*Table) error
type MTable ¶
type MTable struct { Name string // contains filtered or unexported fields }
MTable represents an in-memory table.
func NewMTable ¶
func NewMTable(log io.ReadWriteCloser, name string) (*MTable, error)
NewMTable initializes a new in-memory table.
func NewMTableFromFile ¶
NewMTableFromFile initializes a new MTable backed by disk.
func Recover ¶
Recover recovers a set of memtables matched by the given prefix and stores a merged version inside a single memtable.
func (*MTable) All ¶
func (table *MTable) All() []MTableRecord
All returns all stored MTable records.
func (*MTable) Compact ¶
Compact compacts the memtable to a disk-backed table. This does not remove the memtable log file.
type MTableRecord ¶
MTableRecord represents a single record in the MTable.
type RowScanner ¶
type RowScanner struct {
// contains filtered or unexported fields
}
func ScanRows ¶
func ScanRows(block []byte) RowScanner
ScanRows returns a row scanner for the given block.
func (*RowScanner) Key ¶
func (scanner *RowScanner) Key() []byte
func (*RowScanner) Next ¶
func (scanner *RowScanner) Next() bool
func (*RowScanner) Peek ¶
func (scanner *RowScanner) Peek() bool
func (*RowScanner) Skip ¶
func (scanner *RowScanner) Skip()
func (*RowScanner) Value ¶
func (scanner *RowScanner) Value() []byte
type Run ¶
type Run struct { Name string Tables []*Table MaxSize int64 MaxCount int // contains filtered or unexported fields }
func (*Run) Get ¶
Get retrieves the table associated with the given key. Since a table may cease to exist after the max table cache time the table has to be fetched each time it is looked up.
func (*Run) Join ¶
Join inserts a table vector replacing the tables at the given range. The tables are not range checked before insertion.
type Table ¶
type Table struct { Name string File *File // Table key range Begin, End []byte // Performance optimizations Index *index.Index Filter *index.Filter Cache *index.Cache // contains filtered or unexported fields }
Table is a key-sorted list of key-value pairs stored on disk. It is backed by multiple performance and size optimizations, such as block-based compression, key filtering using bloom filters, ARC cache for block accesses and RB tree based key indexing.
func Open ¶
Open a table-triple and initializes the table file and loads index and filter into memory.
func OpenTables ¶
OpenTables opens a slice of tables identified by a common prefix.
func (*Table) Scan ¶
func (table *Table) Scan() *TableScanner
type TableScanner ¶
type TableScanner struct {
// contains filtered or unexported fields
}
func (*TableScanner) Compare ¶
func (scanner *TableScanner) Compare(other *TableScanner) (int, []byte, []byte)
func (*TableScanner) Key ¶
func (scanner *TableScanner) Key() []byte
func (*TableScanner) Next ¶
func (scanner *TableScanner) Next() bool
func (*TableScanner) Peek ¶
func (scanner *TableScanner) Peek() bool
func (*TableScanner) Skip ¶
func (scanner *TableScanner) Skip()
func (*TableScanner) Value ¶
func (scanner *TableScanner) Value() []byte
type WTable ¶
type WTable struct { Name string // contains filtered or unexported fields }
WTable is an unfinished table in write mode. Values can only be written by increasing key order. WTable is not safe to use with multiple goroutines concurrently.
func OpenWTable ¶
func OpenWTable(name string, readWriteCloser io.ReadWriteCloser, bucket *ratelimit.Bucket) (*WTable, error)
OpenWTable opens a new write-only table.
func OpenWTableFromFile ¶
func (*WTable) FlushFilter ¶
func (*WTable) FlushIndex ¶
type WritableAutoflushTable ¶
type WritableAutoflushTable struct { Basename string MaxSize int64 Written []string // contains filtered or unexported fields }
func OpenWritableWithAutoflush ¶
func OpenWritableWithAutoflush(name string, size int64, bucket *ratelimit.Bucket) *WritableAutoflushTable
func (*WritableAutoflushTable) Append ¶
func (table *WritableAutoflushTable) Append(key, value []byte) error
func (*WritableAutoflushTable) Close ¶
func (table *WritableAutoflushTable) Close() error