Documentation ¶
Overview ¶
Package bubt builds Btree bottoms up and keeps it immutable. By having it as immutable, it is possible to attain near 100% node utilization, and allow concurrent reads on fully built tree, without locks.
Index ¶
- Constants
- func LogComponents(components ...string)
- func PurgeSnapshot(name string, paths []string)
- type Bubt
- type Cursor
- func (cur *Cursor) Delcursor(lsm bool)
- func (cur *Cursor) Delete(key, oldvalue []byte, lsm bool) []byte
- func (cur *Cursor) GetNext() (key, value []byte, deleted bool, err error)
- func (cur *Cursor) Key() (key []byte, deleted bool)
- func (cur *Cursor) Set(key, value, oldvalue []byte) []byte
- func (cur *Cursor) Value() (value []byte)
- func (cur *Cursor) YNext(fin bool) (key, value []byte, seqno uint64, deleted bool, err error)
- type Snapshot
- func (snap *Snapshot) BeginTxn(id uint64) api.Transactor
- func (snap *Snapshot) Close()
- func (snap *Snapshot) Count() int64
- func (snap *Snapshot) Delete(key, oldvalue []byte, lsm bool) ([]byte, uint64)
- func (snap *Snapshot) Destroy()
- func (snap *Snapshot) Footprint() int64
- func (snap *Snapshot) Get(key, value []byte) (actualvalue []byte, cas uint64, deleted, ok bool)
- func (snap *Snapshot) Getseqno() uint64
- func (snap *Snapshot) ID() string
- func (snap *Snapshot) Info() s.Settings
- func (snap *Snapshot) Log()
- func (snap *Snapshot) Metadata() []byte
- func (snap *Snapshot) Scan() api.Iterator
- func (snap *Snapshot) ScanEntries() api.EntryIterator
- func (snap *Snapshot) Set(key, value, oldvalue []byte) (ov []byte, cas uint64)
- func (snap *Snapshot) SetCAS(key, value, oldvalue []byte, cas uint64) ([]byte, uint64, error)
- func (snap *Snapshot) Validate()
- func (snap *Snapshot) Valuelogs() []string
- func (snap *Snapshot) View(id uint64) api.Transactor
- type View
- func (view *View) Abort()
- func (view *View) Commit() error
- func (view *View) Delete(key, oldvalue []byte, lsm bool) []byte
- func (view *View) Get(key, value []byte) (v []byte, cas uint64, deleted, ok bool)
- func (view *View) ID() uint64
- func (view *View) OpenCursor(key []byte) (api.Cursor, error)
- func (view *View) Set(key, value, oldvalue []byte) []byte
Constants ¶
const MarkerBlocksize = 4096
MarkerBlocksize to close snapshot file.
const MarkerByte = 0xAB
MarkerByte to populate Markerblock.
Variables ¶
This section is empty.
Functions ¶
func LogComponents ¶
func LogComponents(components ...string)
LogComponents enable logging. By default logging is disabled, if applications want log information for bubt components call this function with "self" or "all" or "bubt" as argument.
func PurgeSnapshot ¶
PurgeSnapshot remove disk footprint of this snapshot.
Types ¶
type Bubt ¶
type Bubt struct {
// contains filtered or unexported fields
}
Bubt instance can be used to persist sorted {key,value} entries in immutable btree, built bottoms up and not updated there after.
func NewBubt ¶
func NewBubt( name string, paths []string, mblocksize, zblocksize, vblocksize int64) (tree *Bubt, err error)
NewBubt create a Bubt instance to build a new bottoms-up btree. If zblocksize == 0, then zblocksize will be same as mblocksize. if vblocksize == 0, then values will be stored in value log.
func (*Bubt) AppendValuelogs ¶
AppendValuelogs builder should use `valuelogs` files instead of creating a new set of value-logs corresponding to each z-index files, vblocksize should be same as used while creating `valuelogs`. appendid, should be same as the index.ID() whose value-logs are to be appended.
func (*Bubt) Build ¶
func (tree *Bubt) Build(itere api.EntryIterator, metadata []byte) (err error)
Build starts building the tree from iterator, iterator is expected to be a full-table scan over another data-store.
func (*Bubt) Close ¶
func (tree *Bubt) Close()
Close instance after building the btree. This will mark disk files as immutable for rest of its life-time. Use OpenSnapshot for reading.
func (*Bubt) TombstonePurge ¶
TombstonePurge to enable or disable purging tombstone entries while Building a bubt instance from an iterator.
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor object maintains an active pointer into index. Use OpenCursor on Txn object to create a new cursor.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot to read index entries persisted using Bubt builder. Since no writes are allowed on the btree, any number of snapshots can be opened for reading.
func OpenSnapshot ¶
OpenSnapshot from paths.
func (*Snapshot) BeginTxn ¶
func (snap *Snapshot) BeginTxn(id uint64) api.Transactor
BeginTxn is not allowed.
func (*Snapshot) Close ¶
func (snap *Snapshot) Close()
Close snapshot, will release all in-memory resources but will keep the disk files. All Opened-Snapshots must be closed before it can be destoryed.
func (*Snapshot) Destroy ¶
func (snap *Snapshot) Destroy()
Destroy snapshot will remove disk footprint of the btree. Can be called only after Close is called on all OpenSnapshots.
func (*Snapshot) Get ¶
Get value for key, if value argument is not nil it will be used to copy the entry's value. Also returns entry's cas, whether entry is marked as deleted by LSM. If ok is false, then key is not found.
func (*Snapshot) Info ¶
Info return parameters used to build the snapshot and statistical information.
mfile : m-index file name. zfiles : list of z-index file name. vfiles : list of value log files for each each z-index, if present. zblocksize : block size used for z-index file. mblocksize : block size used for m-index file. vblocksize : block size used for value log. buildtime : time taken, in nanoseconds, to build this snapshot. epoch : snapshot born time, in nanosec, after January 1, 1970 UTC. seqno : maximum seqno contained in this snapshot. keymem : total payload size for all keys. valmem : total payload size for all values. paddingmem : total bytes used for padding m-block and z-block alignment. numpaths : number of paths for this instance. n_zblocks : total number of blocks in z-index files. n_mblocks : total number of blocks in m-index files. n_ablocks : total number of blocks in value log, before appending. n_vblocks : total number of blocks in value log. n_count : number of entries in this snapshot, includes deleted. n_deleted : number of entries marked as deleted. footprint : disk footprint for this snapshot.
func (*Snapshot) Scan ¶
Scan return a full table iterator, if iteration is stopped before reaching end of table (io.EOF), application should call iterator with fin as true. EG: iter(true)
func (*Snapshot) ScanEntries ¶
func (snap *Snapshot) ScanEntries() api.EntryIterator
ScanEntry return a full table iterator, if iteration is stopped before reaching end of table (io.EOF), application should call iterator with fin as true. EG: iter(true)
type View ¶
type View struct {
// contains filtered or unexported fields
}
View read only transaction instance.
func (*View) Get ¶
Get value for key, if value argument is not nil it will be used to copy the entry's value. Also return whether entry is marked as deleted by LSM. If ok is false, then key is not found.
func (*View) OpenCursor ¶
OpenCursor open an active cursor, point at key, inside the index.