storage

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 16 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

func TestAppendLogEntryWithoutCommitContext added in v0.5.0

func TestAppendLogEntryWithoutCommitContext(tb testing.TB, stg *Storage, llsn types.LLSN, glsn types.GLSN, data []byte)

TestAppendLogEntryWithoutCommitContext stores log entries without commit context.

func TestGetUnderlyingDB added in v0.5.0

func TestGetUnderlyingDB(tb testing.TB, stg *Storage) *pebble.DB

TestGetUnderlyingDB returns a pebble that is an internal database in the storage.

func TestSetCommitContext added in v0.5.0

func TestSetCommitContext(tb testing.TB, stg *Storage, cc CommitContext)

TestSetCommitContext stores only commit context.

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 ReadOnly added in v0.5.0

func ReadOnly() Option

ReadOnly makes storage read-only. It is helpful only for testing. Usually, users do not have to call it.

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() (err 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) ReadCommitContext added in v0.5.0

func (s *Storage) ReadCommitContext() (cc CommitContext, err error)

func (*Storage) ReadRecoveryPoints

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

ReadRecoveryPoints reads data necessary to restore the status of a log stream replica - the first and last log entries and commit context. Incompatible between the boundary of log entries and commit context is okay; thus, it returns nil as err. However, if there is a fatal error, such as missing data in a log entry, it returns an 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. Internally, it removes records for both data and commits but does not remove the commit context. It returns the ErrNoLogEntry 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