Documentation ¶
Overview ¶
Simple B+-Tree package. Meant for in memory indexes, and builds it in a log structure for values for optimal use of GC time. Also supports appending to an existing key's value.
Index ¶
- func NewInMemoryBtree() indexes.Index
- type Btree
- func (b *Btree) Append(key []byte, value []byte)
- func (b *Btree) CheckConsistency() error
- func (b *Btree) Dispose()
- func (b *Btree) Dump(out io.Writer)
- func (b *Btree) Get(key []byte) (value []byte, ok bool)
- func (b *Btree) Put(key []byte, valuev []byte) (replaced bool)
- func (b *Btree) PutNext(key, value []byte)
- func (b *Btree) Size() int64
- func (b *Btree) Start(prefix []byte) (it indexes.Iter)
- func (b *Btree) Stats() BtreeStats
- type BtreeStats
- type Key
- type Page
- type PageIter
- type Pager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewInMemoryBtree ¶
Types ¶
type Btree ¶
type Btree struct {
// contains filtered or unexported fields
}
B+ Tree. Consists of pages. Satisfies indexes.Index.
func (*Btree) CheckConsistency ¶
func (*Btree) PutNext ¶
Put a key that is strictly larger than the previous one. Assumes you're going to keep doing that and therefore does the bulk put operation.
func (*Btree) Stats ¶
func (b *Btree) Stats() BtreeStats
type BtreeStats ¶
type Page ¶
type Page interface { // Insert these bytes and reference as the key. In non-leaf // nodes, the references points to child nodes with keys equal // to or greater. In leaf nodes it points to a value. Returns // false if the key was not inserted. The only reason for not // inserting the key is that the page is full. The pager // promises to not be dependent on your copy of the byte slice // after this operation returns. Insert(k []byte, ref int) (ok bool) // Like insert, but you promise that you are inserting in // order. This is a special case of Insert. You can always // just call Insert inside PutNext. PutNext(k []byte, ref int) (ok bool) // Returns true and the key if it is found. Returns false and // one key smaller if not found so that btree can use its // reference to figure out in which child page it belongs... Search(k []byte) (key Key, ok bool) IsLeaf() bool // Return the next page at this level NextPage() (ref int) SetNextPage(ref int) // Iterator support. This iterator will stop at the end of the // page. It is the responsibility of the btree implementation // to find the next page and continue iteration. Start(prefix []byte) PageIter // Get the key and ref at this index. For leaves keys start at // 1. for internal nodes, key number 0 contains the left // reference, as set by SetFirst, and no actual key. GetKey(i int) ([]byte, int) // Split this page into the given one Split(newPageRef int, newPage Page) (splitKey []byte) First() int SetFirst(ref int) // Number of keys. See GetKey for an explanation of what to // expect around key 0. Size() int // Tie allocation of space for values to the pages. Only // relevant for leaf nodes. InsertValue(value []byte) int GetValue(ref int) []byte }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.