store

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRotateCheckerMaxSize = int(common.M) * 64
)

Variables

View Source
var (
	DefaultMaxBatchSize  = 500
	DefaultMaxSyncSize   = 10
	DefaultMaxCommitSize = 10
	DefaultBatchPerSync  = 100
	DefaultSyncDuration  = time.Millisecond * 2
	FlushEntry           entry.Entry
)
View Source
var (
	ErrGroupNotExist       = errors.New("group not existed")
	ErrLsnNotExist         = errors.New("lsn not existed")
	ErrVFileVersionTimeOut = errors.New("get vfile version timeout")
)
View Source
var (
	ErrVFileGroupNotExist = errors.New("vfile: group not existed")
	ErrVFileLsnNotExist   = errors.New("vfile: lsn not existed")
	ErrVFileOffsetTimeOut = errors.New("get vfile offset timeout")
	ErrReadMetaFailed     = errors.New("read meta failed")
)
View Source
var (
	DefaultHistoryFactory = func() History {
		return newHistory(nil)
	}
)
View Source
var (
	HistoryEntryNotFoundErr = errors.New("tae: history not found")
)
View Source
var Metasize = 2

Functions

func IsCheckpointed

func IsCheckpointed(gid uint32, lsn uint64, ckps map[uint32]*checkpointInfo) bool

func MakeVersionFile

func MakeVersionFile(dir, name string, version uint64) string

func NewBaseStore

func NewBaseStore(dir, name string, cfg *StoreCfg) (*baseStore, error)

func OpenRotateFile

func OpenRotateFile(dir, name string, mu *sync.RWMutex, rotateChecker RotateChecker,
	historyFactory HistoryFactory, bsInfo *storeInfo, postCommitFunc func(VFile)) (*rotateFile, error)

func ParseVersion

func ParseVersion(name, prefix, suffix string) (int, error)

Types

type ApplyHandle

type ApplyHandle = func(group uint32, commitId uint64, payload []byte, typ uint16, info any)

type File

type File interface {
	io.Closer
	sync.Locker
	RLock()
	RUnlock()
	FileReader

	GetEntryByVersion(version int) (VFile, error)
	Sync() error
	GetAppender() FileAppender
	Replay(*replayer, ReplayObserver) error
	GetHistory() History
	TryTruncate(int64) error
	Load(ver int, groupId uint32, lsn uint64) (entry.Entry, error)
}

type FileAppender

type FileAppender interface {
	Prepare(int, any) error
	Write([]byte) (int, error)
	Commit() error
	Rollback()
	Sync() error
	Revert()
}

type FileReader

type FileReader any

type History

type History interface {
	String() string
	Append(VFile)
	Extend(...VFile)
	Entries() int
	EntryIds() []int
	GetEntry(int) VFile
	DropEntry(int) (VFile, error)
	OldestEntry() VFile
	Empty() bool
	// Replay(*replayer, ReplayObserver) error
	TryTruncate(*compactor) error
}

type HistoryFactory

type HistoryFactory func() History

type MaxSizeRotateChecker

type MaxSizeRotateChecker struct {
	MaxSize int
}

func NewMaxSizeRotateChecker

func NewMaxSizeRotateChecker(size int) *MaxSizeRotateChecker

func (*MaxSizeRotateChecker) PrepareAppend

func (c *MaxSizeRotateChecker) PrepareAppend(vfile VFile, delta int) (needRot bool, err error)

type ReplayHandle

type ReplayHandle = func(VFile, ReplayObserver) error

type ReplayObserver

type ReplayObserver interface {
	OnNewEntry(int)
	OnLogInfo(*entry.Info)
}

type RotateChecker

type RotateChecker interface {
	PrepareAppend(VFile, int) (bool, error)
}

type Store

type Store interface {
	io.Closer
	Sync() error
	Replay(ApplyHandle) error
	GetCheckpointed(uint32) uint64
	GetSynced(uint32) uint64
	GetPenddingCnt(uint32) uint64
	GetCurrSeqNum(uint32) uint64
	AppendEntry(groupId uint32, e entry.Entry) (uint64, error)
	TryCompact() error
	TryTruncate(int64) error
	Load(groupId uint32, lsn uint64) (entry.Entry, error)
}

type StoreCfg

type StoreCfg struct {
	RotateChecker  RotateChecker
	HistoryFactory HistoryFactory
}

type VFile

type VFile interface {
	sync.Locker
	RLock()
	RUnlock()
	SizeLocked() int
	Destroy() error
	Id() int
	Name() string
	String() string

	IsToDelete(c *compactor) (toDelete bool)
	PrepareCompactor(c *compactor)
	// InCheckpoint(map[uint32]*common.ClosedIntervals) bool
	// InCommits(map[uint32]*common.ClosedIntervals) bool
	// InTxnCommits(map[uint32]map[uint64]uint64, map[uint32]*common.ClosedIntervals) bool
	// MergeCheckpoint(map[uint32]*common.ClosedIntervals)
	// MergeTidCidMap(map[uint32]map[uint64]uint64)
	Replay(*replayer, ReplayObserver) error
	ReplayCWithCkp(*replayer, ReplayObserver) error
	ReplayUCWithCkp(*replayer, ReplayObserver) error
	GetAddrs() (map[uint32]map[uint64]int, *sync.RWMutex)
	OnReplayCommitted()
	GetUncommitGidTid(lsn uint64) *entry.Tid

	Load(groupId uint32, lsn uint64) (entry.Entry, error)
	LoadByOffset(offset int) (entry.Entry, error)
	LoadMeta() error

	FreeMeta()
	OnReplay(r *replayer)
}

type VFileAddress

type VFileAddress struct {
	Group   uint32
	LSN     uint64
	Version int
	Offset  int
}

type VFileUncommitInfo

type VFileUncommitInfo struct {
	Index *roaring64.Bitmap
	Addr  *VFileAddress
}

type VGroup

type VGroup interface {
	Log(any) error
	OnCheckpoint(any) //ckp info
	IsCovered(c *compactor) bool
	MergeCheckpointInfo(c *compactor) //only commit group
	PrepareMerge(c *compactor)

	IsCheckpointGroup() bool
	IsUncommitGroup() bool
	IsCommitGroup() bool

	String() string
}

Jump to

Keyboard shortcuts

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