Documentation
¶
Overview ¶
Package buffer provides buffer pool management for XxSql storage engine.
Index ¶
- type BufferFrame
- type BufferPool
- func (bp *BufferPool) Clear() error
- func (bp *BufferPool) DeletePage(id page.PageID) error
- func (bp *BufferPool) FlushAll() error
- func (bp *BufferPool) FlushPage(id page.PageID) error
- func (bp *BufferPool) GetPage(id page.PageID) (*page.Page, error)
- func (bp *BufferPool) IsDirty(id page.PageID) bool
- func (bp *BufferPool) MarkDirty(id page.PageID)
- func (bp *BufferPool) NewPage() (*page.Page, error)
- func (bp *BufferPool) PinPage(id page.PageID) error
- func (bp *BufferPool) SetDiskManager(dm DiskManager)
- func (bp *BufferPool) Size() int
- func (bp *BufferPool) Stats() BufferPoolStats
- func (bp *BufferPool) UnpinPage(id page.PageID, isDirty bool) error
- type BufferPoolConfig
- type BufferPoolStats
- type DiskManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferFrame ¶
type BufferFrame struct {
Page *page.Page
PinCount int32
Dirty bool
Element *list.Element // LRU list element
}
BufferFrame represents a frame in the buffer pool.
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool manages a pool of cached pages.
func NewBufferPool ¶
func NewBufferPool(config BufferPoolConfig) *BufferPool
NewBufferPool creates a new buffer pool.
func (*BufferPool) Clear ¶
func (bp *BufferPool) Clear() error
Clear removes all pages from the buffer pool.
func (*BufferPool) DeletePage ¶
func (bp *BufferPool) DeletePage(id page.PageID) error
DeletePage removes a page from the buffer pool.
func (*BufferPool) FlushAll ¶
func (bp *BufferPool) FlushAll() error
FlushAll flushes all dirty pages to disk.
func (*BufferPool) FlushPage ¶
func (bp *BufferPool) FlushPage(id page.PageID) error
FlushPage flushes a specific page to disk.
func (*BufferPool) IsDirty ¶
func (bp *BufferPool) IsDirty(id page.PageID) bool
IsDirty returns whether a page is dirty.
func (*BufferPool) MarkDirty ¶
func (bp *BufferPool) MarkDirty(id page.PageID)
MarkDirty marks a page as dirty.
func (*BufferPool) NewPage ¶
func (bp *BufferPool) NewPage() (*page.Page, error)
NewPage creates a new page and adds it to the buffer pool.
func (*BufferPool) PinPage ¶
func (bp *BufferPool) PinPage(id page.PageID) error
PinPage increments the pin count of a page.
func (*BufferPool) SetDiskManager ¶
func (bp *BufferPool) SetDiskManager(dm DiskManager)
SetDiskManager sets the disk manager.
func (*BufferPool) Size ¶
func (bp *BufferPool) Size() int
Size returns the number of pages in the buffer.
func (*BufferPool) Stats ¶
func (bp *BufferPool) Stats() BufferPoolStats
Stats returns buffer pool statistics.
type BufferPoolConfig ¶
type BufferPoolConfig struct {
PoolSize int
PageSize int
DiskManager DiskManager
}
BufferPoolConfig holds buffer pool configuration.
type BufferPoolStats ¶
type BufferPoolStats struct {
PoolSize int `json:"pool_size"`
PageCount int `json:"page_count"`
DirtyPages int `json:"dirty_pages"`
PinnedPages int `json:"pinned_pages"`
Hits uint64 `json:"hits"`
Misses uint64 `json:"misses"`
Evictions uint64 `json:"evictions"`
}
BufferPoolStats holds buffer pool statistics.
func (BufferPoolStats) HitRate ¶
func (s BufferPoolStats) HitRate() float64
HitRate returns the buffer pool hit rate.