fileseg

package
v0.0.0-...-8a7ea67 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package fileseg implements segmented file based storage with a segmentation and compaction strategy. The Store object implements the Storer interface. It allows for compaction by virtualizing addresses through the use of hierarchical page tables. Hierarchical page tables comes with some storage overhead since we are maintaining multiple page tables instead of just one. The store maintains a page table with [<virtual-address> -> <segment-index>], with each segment maintaining its own page table with [<virtual-address> -> <offset>]. Each segment is backed by a file in a specified data directory. The Store orchestrates reads and writes to the various segments. The Store's page tables need to fit in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store provides operations for persisting to a data directory where storage segments are written as files. It implements the storage.Storer interface.

func NewStore

func NewStore(log *logrus.Logger, dir string, opts ...StoreOption) (*Store, error)

NewStore returns a new Store object or an error. It accepts a data directory and options for overriding default behavior.

func (*Store) Append

func (s *Store) Append(e *pb.Entry) (int64, error)

Append appends data to a storeage segment and returns its position or an error.

func (*Store) Begin

func (s *Store) Begin() storage.ForwardIterator

Begin returns a forward iterator to the beginning of the storage entries.

func (*Store) Close

func (s *Store) Close() error

Close closes all underlying segment files and stops background processes.

func (*Store) ReadAt

func (s *Store) ReadAt(position int64) (*pb.Entry, error)

ReadAt looks up the entries physical address in the page table. It returns the entry at that physical address or an error.

type StoreOption

type StoreOption func(*options)

StoreOption is func that modifies the store's configuration options.

func Compaction

func Compaction(enabled bool) StoreOption

Compaction turns segment compaction on or off, default is on.

func SegmentSize

func SegmentSize(n int) StoreOption

SegmentSize sets the max size for a given storage segment.

func SyncInterval

func SyncInterval(dur time.Duration) StoreOption

SyncInterval overrides the Index default sync interval.

Jump to

Keyboard shortcuts

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