Documentation
¶
Index ¶
- Constants
- func Copy(srcTab Table, srcPack Pack, dstTab Table, dstPack Pack) (int, error)
- func CreatePackFile(root *os.Root, prefix Prefix120, maxSize uint32) (*os.File, error)
- func CreateTableFile(root *os.Root, prefix Prefix120, maxSize uint32) (*os.File, error)
- func KeyCompare(a, b Key) int
- func LoadPackFile(root *os.Root, prefix Prefix120) (*os.File, error)
- func LoadTableFile(root *os.Root, prefix Prefix120) (*os.File, error)
- type BitMap
- type Key
- func (k Key) Bytes() []byte
- func (k Key) Data() (ret [16]byte)
- func (k Key) IsZero() bool
- func (k Key) Rotate(i int) Key
- func (k Key) ShiftIn(i int) Key
- func (k Key) ToPrefix(numBits uint8) Prefix120
- func (k Key) Uint16(i int) uint16
- func (k Key) Uint64(i int) uint64
- func (k Key) Uint8(i int) uint8
- func (k Key) Uint8Len() int
- type Pack
- type Prefix120
- func (prefix Prefix120) ChildrenDir() (string, error)
- func (p Prefix120) Data() (ret [15]byte)
- func (p Prefix120) Len() int
- func (p Prefix120) PackPath() (string, error)
- func (p Prefix120) Path() (string, error)
- func (p Prefix120) ShiftIn(i int) Prefix120
- func (p Prefix120) TablePath() (string, error)
- type Store
- type Table
- func (idx *Table) Append(ent TableEntry) uint32
- func (idx *Table) CanAppend() bool
- func (idx Table) Capacity() uint32
- func (idx *Table) Close() error
- func (idx *Table) Flush() error
- func (idx *Table) Len() uint32
- func (idx *Table) SetSlot(slot uint32, ent TableEntry)
- func (idx *Table) Slot(i uint32) (ret TableEntry)
- func (idx *Table) SlotOffset(i uint32) uint32
- func (idx *Table) SlotsLeft() uint32
- func (idx *Table) Tombstone(slot uint32)
- type TableEntry
Constants ¶
const ( TableFileExt = ".slot" PackFileExt = ".pack" )
const ( // TableEntrySize is the size of a row in the table. // It actually uses less space than this, but we want to align to 4096 bytes. TableEntrySize = 32 TableHeaderSize = 32 PageSize = 4096 EntriesPerPage = PageSize / TableEntrySize // DefaultMaxTableLen is the maximum length of a table in rows. DefaultMaxTableLen = (1<<20 - TableHeaderSize) / TableEntrySize )
const DefaultMaxPackSize = 1 << 26
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
Copy copies entries from src{Tab,Pack} to dst{Tab,Pack}. If there is not enough space available in either the table or the pack, then an error is returned. Copy will not copy tombstones, and will sort all the entries by key before copying.
func CreatePackFile ¶
CreatePackFile creates a file configured for a pack in the filesystem, and returns it.
func CreateTableFile ¶
CreateTableFile creates a file configured for a table in the filesystem, and returns it. maxSize is the maximum size of the table in bytes, NOT the number of rows.
func KeyCompare ¶
Types ¶
type Key ¶
type Key [2]uint64
Key is a 128 bit key. The 0th bit is considered the first bit, and that is at k[0] & (1 << 0).
func KeyFromBytes ¶
func (Key) ShiftIn ¶
ShiftIn shifts the key into 0. The lowest bits are discarded, zeros are shifted in to the highest bits.
func (Key) ToPrefix ¶
ToPrefix takes the first numBits bits of the key and includes those in a prefix. The last 7 bits of the key must be dropped. ToPrefix will panic, the same as NewPrefix120, if numBits is greater than 120.
type Pack ¶
type Pack struct {
// contains filtered or unexported fields
}
Pack is an append-only file on disk.
type Prefix120 ¶
type Prefix120 struct {
// contains filtered or unexported fields
}
Prefix120 is a prefix of at most 120 bits. Prefix120 takes up 128 bits. A prefix refers to a set of keys.
func NewPrefix121 ¶
func (Prefix120) ChildrenDir ¶
ChildrenDir returns the directory that contains all the children of this prefix.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store stores blobs on in the filesystem.
func (*Store) Get ¶
Get finds key if it exists and calls fn with the data. The data must not be used outside the callback.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is an unordered append-only list of entries. Each entry points into a pack, and all entries are the same size.
func NewTable ¶
NewTable mmaps a file and returns a Table. count should be the number of rows in the table.
func (*Table) Append ¶
func (idx *Table) Append(ent TableEntry) uint32
func (*Table) SetSlot ¶
func (idx *Table) SetSlot(slot uint32, ent TableEntry)
func (*Table) Slot ¶
func (idx *Table) Slot(i uint32) (ret TableEntry)
func (*Table) SlotOffset ¶
SlotOffset returns the offset of the i-th slot in the table. Slot 0 starts at 4 bytes, to make room for the row count at the beginning.
type TableEntry ¶
func (*TableEntry) IsTombstone ¶
func (ent *TableEntry) IsTombstone() bool