storage

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultL0CompactionThreshold       = 4
	DefaultL0StopWritesThreshold       = 12
	DefaultLBaseMaxBytes               = 64 << 20
	DefaultMaxOpenFiles                = 1000
	DefaultMemTableSize                = 4 << 20
	DefaultMemTableStopWritesThreshold = 2
	DefaultMaxConcurrentCompactions    = 1
)

Variables

View Source
var (
	ErrNoLogEntry                   = errors.New("storage: no log entry")
	ErrNoCommitContext              = errors.New("storage: no commit context")
	ErrInconsistentWriteCommitState = errors.New("storage: inconsistent write and commit")
)

Functions

This section is empty.

Types

type CommitBatch

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

func (*CommitBatch) Apply

func (cb *CommitBatch) Apply() error

func (*CommitBatch) Close

func (cb *CommitBatch) Close() error

func (*CommitBatch) Set

func (cb *CommitBatch) Set(llsn types.LLSN, glsn types.GLSN) error

type CommitContext

type CommitContext struct {
	Version            types.Version
	HighWatermark      types.GLSN
	CommittedGLSNBegin types.GLSN
	CommittedGLSNEnd   types.GLSN
	CommittedLLSNBegin types.LLSN
}

func (CommitContext) Empty

func (cc CommitContext) Empty() bool

func (CommitContext) Equal

func (cc CommitContext) Equal(other CommitContext) bool

type Option

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

func WithL0CompactionThreshold

func WithL0CompactionThreshold(l0CompactionThreshold int) Option

func WithL0StopWritesThreshold

func WithL0StopWritesThreshold(l0StopWritesThreshold int) Option

func WithLBaseMaxBytes

func WithLBaseMaxBytes(lbaseMaxBytes int64) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithMaxConcurrentCompaction

func WithMaxConcurrentCompaction(maxConcurrentCompaction int) Option

func WithMaxOpenFiles

func WithMaxOpenFiles(maxOpenFiles int) Option

func WithMemTableSize

func WithMemTableSize(memTableSize int) Option

func WithMemTableStopWritesThreshold

func WithMemTableStopWritesThreshold(memTableStopWritesThreshold int) Option

func WithPath

func WithPath(path string) Option

func WithVerboseLogging

func WithVerboseLogging() Option

func WithoutSync

func WithoutSync() Option

func WithoutWAL

func WithoutWAL() Option

type ReadOption

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

func AtGLSN

func AtGLSN(glsn types.GLSN) ReadOption

func AtLLSN

func AtLLSN(llsn types.LLSN) ReadOption

type RecoveryPoints

type RecoveryPoints struct {
	LastCommitContext *CommitContext
	CommittedLogEntry struct {
		First *varlogpb.LogEntryMeta
		Last  *varlogpb.LogEntryMeta
	}
}

type ScanOption

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

func WithGLSN

func WithGLSN(begin, end types.GLSN) ScanOption

func WithLLSN

func WithLLSN(begin, end types.LLSN) ScanOption

type Scanner

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

func (*Scanner) Close

func (s *Scanner) Close() error

func (*Scanner) Next

func (s *Scanner) Next() bool

func (*Scanner) Valid

func (s *Scanner) Valid() bool

func (*Scanner) Value

func (s *Scanner) Value() (le varlogpb.LogEntry, err error)

type Storage

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

func New

func New(opts ...Option) (*Storage, error)

New creates a new storage.

func TestNewStorage

func TestNewStorage(tb testing.TB, opts ...Option) *Storage

func (*Storage) Close

func (s *Storage) Close() error

Close closes the storage.

func (*Storage) CommitContextOf

func (s *Storage) CommitContextOf(glsn types.GLSN) (cc CommitContext, err error)

CommitContextOf looks up a commit context that contains the log entry for the argument glsn.

func (*Storage) DiskUsage

func (s *Storage) DiskUsage() int64

func (*Storage) NewCommitBatch

func (s *Storage) NewCommitBatch(cc CommitContext) (*CommitBatch, error)

NewCommitBatch creates a batch for commit operations.

func (*Storage) NewScanner

func (s *Storage) NewScanner(opts ...ScanOption) *Scanner

NewScanner creates a scanner for the given key range.

func (*Storage) NewWriteBatch

func (s *Storage) NewWriteBatch() *WriteBatch

NewWriteBatch creates a batch for write operations.

func (*Storage) NextCommitContextOf

func (s *Storage) NextCommitContextOf(cc CommitContext) (next CommitContext, err error)

NextCommitContextOf returns the next commit context after the argument cc if exists.

func (*Storage) Path

func (s *Storage) Path() string

Path returns the path to the storage.

func (*Storage) Read

func (s *Storage) Read(opts ...ReadOption) (le varlogpb.LogEntry, err error)

Read reads the log entry at the glsn.

func (*Storage) ReadRecoveryPoints

func (s *Storage) ReadRecoveryPoints() (rp RecoveryPoints, err error)

func (*Storage) Trim

func (s *Storage) Trim(glsn types.GLSN) error

Trim deletes log entries whose GLSNs are less than or equal to the argument glsn. It returns the ErrNoCommitContext if there are no logs to delete.

type WriteBatch

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

WriteBatch is a batch of writes to storage.

func (*WriteBatch) Apply

func (wb *WriteBatch) Apply() error

Apply applies the batch to the underlying storage.

func (*WriteBatch) Close

func (wb *WriteBatch) Close() error

Close releases acquired resources.

func (*WriteBatch) Set

func (wb *WriteBatch) Set(llsn types.LLSN, data []byte) error

Set writes the given LLSN and data to the batch.

Jump to

Keyboard shortcuts

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