Documentation ¶
Overview ¶
Copied from https://github.com/etcd-io/etcd/blob/main/client/pkg/verify/verify.go
Index ¶
- Constants
- Variables
- func Assert(condition bool, msg string, v ...any)
- func CopyFile(srcPath, dstPath string) error
- 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 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 InBucket
- type Inode
- type Inodes
- type Meta
- func (m *Meta) Checksum() uint64
- 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) 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() *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) 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) 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
- type VerificationType
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 BranchPageElementSize = unsafe.Sizeof(branchPageElement{})
const BucketHeaderSize = int(unsafe.Sizeof(InBucket{}))
const (
BucketLeafFlag = 0x01
)
const ENV_VERIFY = "BBOLT_VERIFY"
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 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 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 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) 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 ( ENV_VERIFY_VALUE_ALL VerificationType = "all" ENV_VERIFY_VALUE_ASSERT VerificationType = "assert" )