Documentation
¶
Index ¶
- Variables
- 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) ReadPage(pageID uint64) ([]byte, error)
- func (p *Pager) SetPageCount(count uint64)
- 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 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 (*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) 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) 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.