Documentation
¶
Index ¶
- Variables
- type OpenOptions
- type Pager
- func (p *Pager) Alloc(count int) (uint64, error)
- func (p *Pager) Close() error
- func (p *Pager) Get(pageID uint64) ([]byte, error)
- func (p *Pager) GetForWrite(pageID uint64) ([]byte, error)
- func (p *Pager) IsVerified(pageID uint64) bool
- func (p *Pager) MarkUnverified(pageID uint64)
- func (p *Pager) MarkVerified(pageID uint64)
- func (p *Pager) PageCount() uint64
- func (p *Pager) PrefetchPage(pageID uint64)
- func (p *Pager) ReadPage(pageID uint64) ([]byte, error)
- func (p *Pager) SetPageCount(count uint64)
- func (p *Pager) SetSyncConcurrency(n int)
- func (p *Pager) SetVerifyOnRead(always bool)
- func (p *Pager) Sync() error
- func (p *Pager) Truncate(targetPages uint64) error
- func (p *Pager) VerifyOnRead() bool
- func (p *Pager) Write(pageID uint64, data []byte) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type OpenOptions ¶ added in v0.3.0
type OpenOptions struct {
// MmapPopulate enables MAP_POPULATE on Linux to pre-fault page tables for
// mmapped index chunks (best-effort; ignored on non-Linux).
MmapPopulate bool
// PrefetchOnRead enables best-effort read-side prefetch support (madvise
// WILLNEED). Callers can trigger prefetch explicitly via PrefetchPage.
PrefetchOnRead bool
}
type Pager ¶
type Pager struct {
// contains filtered or unexported fields
}
Pager manages the index.db file using chunked mmap.
func Open ¶
Open opens the pager at the given path. If the file doesn't exist, it creates it. chunkSize determines the size of each mmap region.
func OpenReadOnly ¶
OpenReadOnly opens an existing pager at path without modifying the underlying file.
The returned pager does not support Alloc/GetForWrite/Write/Sync.
func OpenReadOnlyWithOptions ¶ added in v0.3.0
func OpenReadOnlyWithOptions(path string, chunkSize int64, opts OpenOptions) (*Pager, error)
func OpenWithOptions ¶ added in v0.3.0
func OpenWithOptions(path string, chunkSize int64, opts OpenOptions) (*Pager, error)
OpenWithOptions opens the pager at the given path with optional mmap behavior controls (Linux-only flags may be ignored on other platforms).
func (*Pager) Alloc ¶
Alloc allocates `count` new pages and returns the ID of the first one. It grows the file if necessary.
func (*Pager) Get ¶
Get returns the byte slice for the given page ID. CAUTION: The returned slice points directly to mmapped memory. Do not hold references to it after closing the pager.
func (*Pager) GetForWrite ¶
GetForWrite returns the byte slice for the given page ID and marks the chunk dirty.
func (*Pager) IsVerified ¶
IsVerified returns true if the page has passed CRC verification. Thread-safe (protected by p.mu in caller, or we can add internal locking if needed, but Pager methods usually hold lock). Currently Pager.Get holds RLock.
func (*Pager) MarkUnverified ¶
MarkUnverified marks a page as unverified (dirty/reused).
func (*Pager) MarkVerified ¶
MarkVerified marks a page as verified.
func (*Pager) PrefetchPage ¶ added in v0.3.0
PrefetchPage issues a best-effort prefetch hint for the chunk containing pageID. It is safe for concurrent use.
func (*Pager) ReadPage ¶
ReadPage returns a copy of the page data. Safe for concurrent use including checksum verification.
func (*Pager) SetPageCount ¶
SetPageCount updates the logical page count. Should be called by the DB layer after recovery.
func (*Pager) SetSyncConcurrency ¶ added in v0.3.0
SetSyncConcurrency configures how many goroutines may msync dirty chunks in parallel. Values <= 0 default to 1.
func (*Pager) SetVerifyOnRead ¶
SetVerifyOnRead enables or disables checksum verification on every read.
func (*Pager) Truncate ¶
Truncate resizes the file to the specified number of pages. Safety: Shrinking is forbidden. Only growing is allowed.
func (*Pager) VerifyOnRead ¶
VerifyOnRead reports whether checksum verification should happen on every read.