wal

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilePrefix = "dat-"
	FileSuffix = ".seg"
)

Variables

View Source
var (
	ErrOutOfBounds    = errors.New("error: out of bounds")
	ErrSegmentFull    = errors.New("error: segment is full")
	ErrFileClosed     = errors.New("error: file closed")
	ErrBadArgument    = errors.New("error: bad argument")
	ErrNoPathProvided = errors.New("error: no path provided")
	ErrOptionsMissing = errors.New("error: options missing")
)

Functions

func GetIndexFromFileName

func GetIndexFromFileName(name string) (int64, error)

func MakeFileNameFromIndex

func MakeFileNameFromIndex(index int64) string

Types

type WAL

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

WAL is a write-ahead log structure

func OpenWAL

func OpenWAL(c *WALConfig) (*WAL, error)

OpenWAL opens and returns a new write-ahead log structure

func (*WAL) Close

func (l *WAL) Close() error

Close syncs and closes the write-ahead log

func (*WAL) CloseAndRemove added in v1.6.0

func (l *WAL) CloseAndRemove() error

func (*WAL) Count

func (l *WAL) Count() int

Count returns the number of entries currently in the write-ahead log

func (*WAL) FirstIndex

func (l *WAL) FirstIndex() int64

FirstIndex returns the write-ahead logs first index

func (*WAL) GetConfig added in v1.3.1

func (l *WAL) GetConfig() *WALConfig

func (*WAL) LastIndex

func (l *WAL) LastIndex() int64

LastIndex returns the write-ahead logs first index

func (*WAL) Read

func (l *WAL) Read(index int64) (*binary.Entry, error)

Read reads an segEntry from the write-ahead log at the specified index

func (*WAL) Scan

func (l *WAL) Scan(iter func(e *binary.Entry) bool) error

Scan provides an iterator method for the write-ahead log

func (*WAL) String

func (l *WAL) String() string

String is the stringer method for the write-ahead log

func (*WAL) Sync added in v1.3.1

func (l *WAL) Sync() error

func (*WAL) TruncateFront

func (l *WAL) TruncateFront(index int64) error

TruncateFront removes all segments and entries before specified index

func (*WAL) Write

func (l *WAL) Write(e *binary.Entry) (int64, error)

Write writes an segEntry to the write-ahead log in an append-only fashion

func (*WAL) WriteBatch added in v1.3.1

func (l *WAL) WriteBatch(batch *binary.Batch) error

WriteBatch writes a batch of entries performing no syncing until the end of the batch

type WALConfig added in v1.3.1

type WALConfig struct {
	BasePath    string // base storage path
	MaxFileSize int64  // memtable flush threshold in KB
	SyncOnWrite bool   // perform sync every time an entry is write
}

Jump to

Keyboard shortcuts

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