Documentation
¶
Index ¶
Constants ¶
const ( DatabaseHeaderSize = 100 TableLeafHeaderSize = 8 TableInteriorHeaderSize = 12 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DatabaseHeader ¶
type DatabaseHeader tablePage
DatabaseHeader helps write the database header page
func NewDatabaseHeader ¶
func NewDatabaseHeader(pageSize int) *DatabaseHeader
NewDatabaseHeader returns an empty DatabaseHeader. The schema root page is configured to be a leaf node; to make it be an interior node, call Promote.
func (*DatabaseHeader) Add ¶
func (p *DatabaseHeader) Add(cell []byte) bool
Add tries to add a cell to a DatabaseHeader, returning true if it fits.
func (*DatabaseHeader) Finish ¶
func (p *DatabaseHeader) Finish(rightMostPointer uint32) []byte
Finish finishes writing the node, returning a page-sized slice with its contents. The DatabaseHeader is emptied and ready to reuse after Finish returns.
If the root page is an interior node (Promote was called), rightMostPointer must be nonzero. If the root page is a leaf node, rightMostPointer must be zero.
Note that Finish returns a reference to the DatabaseHeader's internal buffer; do not modify the return value.
func (*DatabaseHeader) Promote ¶
func (p *DatabaseHeader) Promote()
Promote clears the node contents and reconfigures the schema root page to be an interior node.
type PageNumber ¶
type PageNumber uint32
PageNumber annotates uint32s that are actually page numbers.
type TableInterior ¶
type TableInterior struct {
// contains filtered or unexported fields
}
TableInterior helps write table B-tree interior nodes.
func NewTableInterior ¶
func NewTableInterior(pageSize int) *TableInterior
NewTableInterior returns an empty TableInterior.
func (*TableInterior) Add ¶
func (ti *TableInterior) Add(pageNumber PageNumber, rowid int64) (ok bool)
Add adds a cell to a TableInterior. If Add returns false, a full page of cells has been buffered; call Put to write the page and make room for more.
func (*TableInterior) Length ¶
func (ti *TableInterior) Length() int
Length returns the number of children in the node, including excess cells.
func (*TableInterior) Put ¶
func (ti *TableInterior) Put(p []byte) (rightmostRowid int64, empty bool)
Put writes an interior B-tree page to p and removes all cells used from the buffer.
If the table is open, call Put once whenever Add returns false and ignore empty. If the table has been closed, keep calling Put until empty is true.
func (*TableInterior) Remove ¶
func (ti *TableInterior) Remove() (pageNumber PageNumber, rowid int64)
Remove removes the most recent cell added with Add.
type TableLeaf ¶
type TableLeaf tablePage
TableLeaf helps write table B-tree leaf nodes.
func NewTableLeaf ¶
NewTableLeaf returns an empty TableLeaf.