batchstoredriver

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Copyright 2021 Matrix Origin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	DefaultRotateCheckerMaxSize = int(mpool.MB) * 64
)

Variables

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

Functions

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, observer ReplayObserver) (*rotateFile, error)

func ParseVersion

func ParseVersion(name, prefix, suffix string) (n int, ok bool)

Types

type File

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

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

type FileAppender

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

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
	Close()
}

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 ReplayObserver

type ReplayObserver interface {
	// contains filtered or unexported methods
}

type RotateChecker

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

type Store

type Store interface {
	io.Closer
	Append(*entry.Entry) error
	Truncate(lsn uint64) error
	GetTruncated() (lsn uint64, err error)
	Read(lsn uint64) (*entry.Entry, error)
	Close() error
	Replay(driver.ApplyHandle) error
	GetSynced(uint32) uint64
	GetCurrSeqNum(uint32) uint64
}

type StoreCfg

type StoreCfg struct {
	RotateChecker  RotateChecker
	HistoryFactory HistoryFactory
}

type VFile

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

	Replay(*replayer) error
	OnReplayCommitted()

	Load(lsn uint64) (*entry.Entry, error)
	LoadByOffset(offset int) (*entry.Entry, error)
}

type VFileAddress

type VFileAddress struct {
	LSN     uint64
	Version int
	Offset  int
}

type VFileUncommitInfo

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

Jump to

Keyboard shortcuts

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