Documentation ¶
Index ¶
- Constants
- Variables
- func Assert(condition bool, msg string, v ...interface{})
- func CopyFile(srcPath, dstPath string) error
- func Mergepgids(dst, a, b Pgids)
- func NewLeafPageElement(flags, pos, ksize, vsize 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 UnsafeSlice(slice, data unsafe.Pointer, len int)
- func UsedSpaceInPage(inodes Inodes, p *Page) uint32
- func WriteInodeToPage(inodes Inodes, p *Page) uint32
- type FreelistType
- type InBucket
- type Inode
- type Inodes
- type Meta
- func (m *Meta) Copy(dest *Meta)
- func (m *Meta) DecTxid()
- func (m *Meta) Flags() uint32
- func (m *Meta) Freelist() Pgid
- func (m *Meta) IncTxid()
- 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() *InBucket
- 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 InBucket)
- 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) 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) FlagsXOR(v uint16)
- func (p *Page) FreelistPageCount() (int, int)
- func (p *Page) FreelistPageIds() []Pgid
- 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) SetId(target Pgid)
- func (p *Page) SetOverflow(target uint32)
- func (p *Page) String() string
- func (p *Page) Typ() string
- type PageInfo
- type Pages
- type Pgid
- type Pgids
- type Txid
Constants ¶
const ( BranchPageFlag = 0x01 LeafPageFlag = 0x02 MetaPageFlag = 0x04 FreelistPageFlag = 0x10 )
const ( DefaultMaxBatchSize int = 1000 DefaultMaxBatchDelay = 10 * time.Millisecond DefaultAllocSize = 16 * 1024 * 1024 )
Default values if not set in a DB instance.
const ( // FreelistArrayType indicates backend freelist type is array FreelistArrayType = FreelistType("array") // FreelistMapType indicates backend freelist type is hashmap FreelistMapType = FreelistType("hashmap") )
const BranchPageElementSize = unsafe.Sizeof(branchPageElement{})
const BucketHeaderSize = int(unsafe.Sizeof(InBucket{}))
const (
BucketLeafFlag = 0x01
)
const IgnoreNoSync = runtime.GOOS == "openbsd"
IgnoreNoSync specifies whether the NoSync field of a DB is ignored when syncing changes to a file. This is required as some operating systems, such as OpenBSD, do not have a unified buffer cache (UBC) and writes must be synchronized using the msync(2) syscall.
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 MinKeysPerPage = 2
const PageHeaderSize = unsafe.Sizeof(Page{})
const Version = 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 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 uint32) *leafPageElement
func UnsafeIndex ¶
func UnsafeSlice ¶
UnsafeSlice modifies the data, len, and cap of a slice variable pointed to by the slice parameter. This helper should be used over other direct manipulation of reflect.SliceHeader to prevent misuse, namely, converting from reflect.SliceHeader to a Go slice type.
func UsedSpaceInPage ¶
func WriteInodeToPage ¶
Types ¶
type InBucket ¶
type InBucket struct {
// contains filtered or unexported fields
}
InBucket represents the on-file representation of a bucket. This is stored as the "value" of a bucket key. If the bucket is small enough, then its root page can be stored inline in the "value", after the bucket header. In the case of inline buckets, the "root" will be 0.
func LoadBucket ¶
func NewInBucket ¶
func (*InBucket) InSequence ¶
InSequence returns the sequence. The reason why not naming it `Sequence` is to avoid duplicated name as `(*Bucket) Sequence()`
func (*InBucket) IncSequence ¶
func (b *InBucket) IncSequence()
func (*InBucket) InlinePage ¶
func (*InBucket) SetInSequence ¶
func (*InBucket) 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.
type Meta ¶
type Meta struct {
// contains filtered or unexported fields
}
func LoadPageMeta ¶
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.