Documentation
¶
Index ¶
- Constants
- Variables
- func Assert(condition bool, msg string, v ...any)
- func DisableVerifications() func()
- func EnableAllVerifications() func()
- func EnableVerifications(verification VerificationType) func()
- func IsVerificationEnabled(verification VerificationType) bool
- func Mergepgids(dst, a, b Pgids)
- func NewLeafPageElement(flags, pos, ksize, vsize, hsize uint32) *leafPageElement
- func UnsafeAdd(base unsafe.Pointer, offset uintptr) unsafe.Pointer
- func UnsafeByteSlice(base unsafe.Pointer, offset uintptr, i, j int) []byte
- func UnsafeIndex(base unsafe.Pointer, offset uintptr, elemsz uintptr, n int) unsafe.Pointer
- func UsedSpaceInPage(inodes Inodes, p *Page) uint32
- func Verify(f func())
- func WriteInodeToPage(inodes Inodes, p *Page) uint32
- type InBTree
- func (b *InBTree) InSequence() uint64
- func (b *InBTree) IncSequence()
- func (b *InBTree) InlinePage(v []byte) *Page
- func (b *InBTree) Name() string
- func (b *InBTree) Overflow() uint32
- func (b *InBTree) RootPage() Pgid
- func (b *InBTree) SetInSequence(v uint64)
- func (b *InBTree) SetName(name string)
- func (b *InBTree) SetOverflow(overflow uint32)
- func (b *InBTree) SetRootPage(id Pgid)
- func (b *InBTree) String() string
- type Inode
- func (in *Inode) Flags() uint32
- func (in *Inode) Hash() []byte
- func (in *Inode) Key() []byte
- func (in *Inode) Overflow() uint32
- func (in *Inode) Pgid() Pgid
- func (in *Inode) SetFlags(flags uint32)
- func (in *Inode) SetHash(hash []byte)
- func (in *Inode) SetKey(key []byte)
- func (in *Inode) SetOverflow(overflow uint32)
- func (in *Inode) SetPgid(id Pgid)
- func (in *Inode) SetValue(value []byte)
- func (in *Inode) Value() []byte
- type Inodes
- type KV
- type KVS
- type Meta
- func (m *Meta) Checksum() uint64
- func (m *Meta) Copy(dest *Meta)
- func (m *Meta) DecTxid()
- func (m *Meta) Encode() []byte
- func (m *Meta) Flags() uint32
- func (m *Meta) Freelist() Pgid
- func (m *Meta) IncTxid()
- func (m *Meta) IsFreelistPersisted() bool
- func (m *Meta) Magic() uint32
- func (m *Meta) PageSize() uint32
- func (m *Meta) Pgid() Pgid
- func (m *Meta) Print(w io.Writer)
- func (m *Meta) RootBucket() *InBTree
- func (m *Meta) SetChecksum(v uint64)
- func (m *Meta) SetFlags(v uint32)
- func (m *Meta) SetFreelist(v Pgid)
- func (m *Meta) SetMagic(v uint32)
- func (m *Meta) SetPageSize(v uint32)
- func (m *Meta) SetPgid(id Pgid)
- func (m *Meta) SetRootBucket(b InBTree)
- func (m *Meta) SetTxid(id TxID)
- func (m *Meta) SetVersion(v uint32)
- func (m *Meta) Sum64() uint64
- func (m *Meta) Txid() TxID
- func (m *Meta) Validate() error
- func (m *Meta) Version() uint32
- func (m *Meta) Write(p *Page)
- type Page
- func (p *Page) BranchPageElement(index uint16) *branchPageElement
- func (p *Page) BranchPageElements() []branchPageElement
- func (p *Page) Count() uint16
- func (p *Page) FastCheck(id Pgid)
- func (p *Page) Flags() uint16
- func (p *Page) FreelistPageCount() (int, int)
- func (p *Page) FreelistPageIds() []Pgid
- func (p *Page) GetHash() [20]byte
- func (p *Page) Id() Pgid
- func (p *Page) IsBranchPage() bool
- func (p *Page) IsFreelistPage() bool
- func (p *Page) IsLeafPage() bool
- func (p *Page) IsMetaPage() bool
- func (p *Page) LeafPageElement(index uint16) *leafPageElement
- func (p *Page) LeafPageElements() []leafPageElement
- func (p *Page) Meta() *Meta
- func (p *Page) Overflow() uint32
- func (p *Page) PageElementSize() uintptr
- func (p *Page) SetCount(target uint16)
- func (p *Page) SetFlags(v uint16)
- func (p *Page) SetHash(hash []byte)
- func (p *Page) SetId(target Pgid)
- func (p *Page) SetOverflow(target uint32)
- func (p *Page) SetSize(target uint32)
- func (p *Page) Size() uint32
- func (p *Page) String() string
- func (p *Page) Typ() string
- type PageInfo
- type PageVersion
- type Pages
- type Pgid
- type Pgids
- type TxID
- type VerificationType
Constants ¶
const ( BranchPageFlag = 0x01 LeafPageFlag = 0x02 MetaPageFlag = 0x04 FreelistPageFlag = 0x10 )
const ( NormalTreeFlag = 0x01 SubTreeFlag = 0x02 )
const ( DefaultMaxBatchSize int = 1000 DefaultMaxBatchDelay = 10 * time.Millisecond DefaultAllocSize = 16 * 1024 * 1024 )
Default values if not set in a DB instance.
const BranchPageElementSize = unsafe.Sizeof(branchPageElement{})
const BucketHeaderSize = int(unsafe.Sizeof(InBTree{}))
const EnvVerify = "TSMM_VERIFY"
const HashSize = 20
const IgnoreNoSync = runtime.GOOS == "openbsd"
const LeafPageElementSize = unsafe.Sizeof(leafPageElement{})
const Magic uint32 = 0xED0CDAED
Magic represents a marker value to indicate that a file is a Bolt DB.
const MaxMmapStep = 1 << 30 // 1GB
MaxMmapStep is the largest step that can be taken when remapping the mmap.
const MetaSize = int(unsafe.Sizeof(Meta{}))
const MinKeysPerPage = 2
const PageHeaderSize = unsafe.Sizeof(Page{})
const Version uint32 = 2
Version represents the data file format version.
Variables ¶
var DefaultPageSize = os.Getpagesize()
DefaultPageSize is the default page size for db which is set to the OS page size.
Functions ¶
func DisableVerifications ¶
func DisableVerifications() func()
DisableVerifications unsets `ENV_VERIFY` and returns a function that can be used to bring the original settings.
func EnableAllVerifications ¶
func EnableAllVerifications() func()
EnableAllVerifications enables verification and returns a function that can be used to bring the original settings.
func EnableVerifications ¶
func EnableVerifications(verification VerificationType) func()
EnableVerifications sets `ENV_VERIFY` and returns a function that can be used to bring the original settings.
func IsVerificationEnabled ¶
func IsVerificationEnabled(verification VerificationType) bool
func Mergepgids ¶
func Mergepgids(dst, a, b Pgids)
Mergepgids copies the sorted union of a and b into dst. If dst is too small, it panics.
func NewLeafPageElement ¶
func NewLeafPageElement(flags, pos, ksize, vsize, hsize uint32) *leafPageElement
func UnsafeIndex ¶
func UsedSpaceInPage ¶
func Verify ¶
func Verify(f func())
Verify performs verification if the assertions are enabled. In the default setup running in tests and skipped in the production code.
func WriteInodeToPage ¶
Types ¶
type InBTree ¶
type InBTree struct {
// contains filtered or unexported fields
}
InBTree represents the on-file representation of a bucket. This is stored as the "value" of a tree key. If the tree is small enough, then its root page can be stored inline in the "value", after the tree header. In the case of inline trees, the "root" will be 0.
func (*InBTree) InSequence ¶
InSequence returns the sequence. The reason why not naming it `Sequence` is to avoid duplicated name as `(*Tree) Sequence()`
func (*InBTree) IncSequence ¶
func (b *InBTree) IncSequence()
func (*InBTree) InlinePage ¶
func (*InBTree) SetInSequence ¶
func (*InBTree) SetOverflow ¶
func (*InBTree) SetRootPage ¶
type Inode ¶
type Inode struct {
// contains filtered or unexported fields
}
Inode represents an internal node inside of a node. It can be used to point to elements in a page or point to an element which hasn't been added to a page yet.
func (*Inode) SetOverflow ¶
type Meta ¶
type Meta struct {
// contains filtered or unexported fields
}
Meta 版本信息
func (*Meta) IsFreelistPersisted ¶
func (*Meta) RootBucket ¶
func (*Meta) SetChecksum ¶
func (*Meta) SetFreelist ¶
func (*Meta) SetPageSize ¶
func (*Meta) SetRootBucket ¶
func (*Meta) SetVersion ¶
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
func (*Page) BranchPageElement ¶
BranchPageElement retrieves the branch node by index
func (*Page) BranchPageElements ¶
func (p *Page) BranchPageElements() []branchPageElement
BranchPageElements retrieves a list of branch nodes.
func (*Page) FreelistPageCount ¶
func (*Page) FreelistPageIds ¶
func (*Page) IsBranchPage ¶
func (*Page) IsFreelistPage ¶
func (*Page) IsLeafPage ¶
func (*Page) IsMetaPage ¶
func (*Page) LeafPageElement ¶
LeafPageElement retrieves the leaf node by index
func (*Page) LeafPageElements ¶
func (p *Page) LeafPageElements() []leafPageElement
LeafPageElements retrieves a list of leaf nodes.
func (*Page) PageElementSize ¶
func (*Page) SetOverflow ¶
type VerificationType ¶
type VerificationType string
const ( EnvVerifyValueAll VerificationType = "all" EnvVerifyValueAssert VerificationType = "assert" )