checkpoint

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package checkpoint provides checkpoint management for XxSql storage engine.

Index

Constants

View Source
const (
	// CheckpointFileExt is the extension for checkpoint files.
	CheckpointFileExt = ".xckpt"

	// CheckpointMetaFile is the checkpoint metadata file.
	CheckpointMetaFile = "checkpoint.meta"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint struct {
	ID         uint64
	LSN        wal.LSN
	Timestamp  int64
	TableCount int
	RowCount   uint64
	PageCount  uint64
	ActiveTxns []uint64
	Metadata   map[string]string
}

Checkpoint represents a database checkpoint.

type CheckpointStats

type CheckpointStats struct {
	AutoEnabled        bool   `json:"auto_enabled"`
	Interval           string `json:"interval"`
	LastCheckpointID   uint64 `json:"last_checkpoint_id"`
	LastCheckpointLSN  uint64 `json:"last_checkpoint_lsn"`
	LastCheckpointTime string `json:"last_checkpoint_time"`
	PageCount          uint64 `json:"page_count"`
	RowCount           uint64 `json:"row_count"`
}

CheckpointStats holds checkpoint statistics.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages checkpoint operations.

func NewManager

func NewManager(config ManagerConfig) *Manager

NewManager creates a new checkpoint manager.

func (*Manager) Create

func (m *Manager) Create() (*Checkpoint, error)

Create creates a new checkpoint.

func (*Manager) DeleteCheckpoint

func (m *Manager) DeleteCheckpoint() error

DeleteCheckpoint removes checkpoint files.

func (*Manager) GetLastCheckpoint

func (m *Manager) GetLastCheckpoint() *Checkpoint

GetLastCheckpoint returns the last checkpoint.

func (*Manager) GetRecoveryInfo

func (m *Manager) GetRecoveryInfo() (*RecoveryInfo, error)

GetRecoveryInfo returns recovery information.

func (*Manager) NeedsCheckpoint

func (m *Manager) NeedsCheckpoint() (bool, error)

NeedsCheckpoint returns true if a checkpoint is needed.

func (*Manager) Recover

func (m *Manager) Recover() error

Recover performs recovery from the last checkpoint.

func (*Manager) SetBufferPool

func (m *Manager) SetBufferPool(bp *buffer.BufferPool)

SetBufferPool sets the buffer pool.

func (*Manager) SetRecoveryHandler

func (m *Manager) SetRecoveryHandler(handler RecoveryHandler)

SetRecoveryHandler sets the recovery handler for WAL replay.

func (*Manager) SetWALManager

func (m *Manager) SetWALManager(wm *wal.Manager)

SetWALManager sets the WAL manager.

func (*Manager) Start

func (m *Manager) Start() error

Start starts automatic checkpointing.

func (*Manager) Stats

func (m *Manager) Stats() CheckpointStats

Stats returns checkpoint statistics.

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops automatic checkpointing.

func (*Manager) TruncateWAL

func (m *Manager) TruncateWAL() error

TruncateWAL truncates the WAL after a successful checkpoint.

type ManagerConfig

type ManagerConfig struct {
	DataDir     string
	WALManager  *wal.Manager
	BufferPool  *buffer.BufferPool
	Interval    time.Duration
	MaxWALSize  int64
	AutoEnabled bool
}

ManagerConfig holds checkpoint manager configuration.

type RecoveryHandler

type RecoveryHandler interface {
	// ApplyInsert applies an insert operation during recovery.
	ApplyInsert(tableName string, data []byte) error
	// ApplyUpdate applies an update operation during recovery.
	ApplyUpdate(tableName string, data []byte) error
	// ApplyDelete applies a delete operation during recovery.
	ApplyDelete(tableName string, data []byte) error
	// ApplyPageWrite applies a page write operation during recovery.
	ApplyPageWrite(pageID uint64, data []byte) error
}

RecoveryHandler defines the interface for handling WAL record recovery.

type RecoveryInfo

type RecoveryInfo struct {
	CheckpointLSN wal.LSN
	CurrentLSN    wal.LSN
	Tables        []TableRecoveryInfo
}

RecoveryInfo holds information needed for recovery.

type TableRecoveryInfo

type TableRecoveryInfo struct {
	Name       string
	RootPageID page.PageID
	PageCount  uint64
}

TableRecoveryInfo holds recovery info for a table.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL