sstable

package
v0.0.0-...-61763e4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LimitReadSeeker

func LimitReadSeeker(r io.ReadSeeker, n int64) io.ReadSeeker

Types

type LimitedReadSeeker

type LimitedReadSeeker struct {
	R io.ReadSeeker
	N int64
}

LimitedReadSeeker provides the same interface for io.LimitedReader for types implementing io.ReadSeeker.

func (*LimitedReadSeeker) Read

func (l *LimitedReadSeeker) Read(p []byte) (n int, err error)

func (*LimitedReadSeeker) Seek

func (l *LimitedReadSeeker) Seek(offset int64, whence int) (int64, error)

type Segment

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

Segment implements kv.Segment using an SSTable. It uses a contingous body of read-only, ordered, and encoded KVPair's in order to store the contents of a MemoryStore into a more durable long-term format. Internally, it uses a MemoryStore in order to build a sparse index of its stored KVPair's to reduce the amount of IO required to find a key.

func NewSegment

func NewSegment(data io.ReadSeeker, encoder kv.Encoder, index kv.MemoryStore, size int) Segment

func (*Segment) Get

func (s *Segment) Get(key string) (*kv.KVPair, error)

Get searches the underlying SSTable for the given key by first checking the internal index table to locate the approximate position and then reading the contents of the SSTable at that position to find the key.

func (*Segment) ID

func (s *Segment) ID() kv.SegmentID

ID returns the unique ID of this segment.

func (*Segment) LoadIndex

func (s *Segment) LoadIndex() error

LoadIndex populates the internal index table of the segment by reading the index table data from the internal data stream.

func (*Segment) Max

func (s *Segment) Max() *kv.KVPair

Max returns the highest key stored in this segment.

func (*Segment) Min

func (s *Segment) Min() *kv.KVPair

Min returns the lowest key stored in this segment.

type SegmentBackend

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

SegmentBackend implements kv.SegmentBackend by providing persistent storage for Segment's using SSTable's stored on the local filesystem.

func NewSegmentBackend

func NewSegmentBackend(root string, encoder kv.Encoder, indexFactor int, storeFactory kv.MemoryStoreFactory) SegmentBackend

func (*SegmentBackend) Get

func (s *SegmentBackend) Get(id kv.SegmentID) (Segment, error)

Get returns the segment with the given SegmentID.

func (*SegmentBackend) New

func (s *SegmentBackend) New(id kv.SegmentID, store kv.MemoryStore) error

New creates a new segment from a MemoryStore and returns its ID.

func (*SegmentBackend) NewWriter

func (s *SegmentBackend) NewWriter(id kv.SegmentID) (kv.SegmentWriter, error)

NewWriter creates a new segment and returns it wrapped in a SegmentWriter.

type SegmentWriter

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

SegmentWriter implements kv.SegmentWriter for writing SSTable formatted segments to an underlying stream.

func NewSegmentWriter

func NewSegmentWriter(id kv.SegmentID, writer io.WriteCloser, encoder kv.Encoder, table kv.MemoryStore, indexFactor int) SegmentWriter

func (*SegmentWriter) Close

func (s *SegmentWriter) Close() error

Close writes the last written KVPair to the index table and proceeds to encode the index table, writing it along with it's length to the end of the underlying stream before calling Close() on the underlying strema.

func (*SegmentWriter) Write

func (s *SegmentWriter) Write(pair kv.KVPair) (int, error)

Write takes a KVPair and writes it to the underlying stream. An internal count is maintained for the number of writes made and is frequently checked in order to determine if a specific entry should be added to the index table based on the configured index factor. The first and last writes are always added to the index table.

func (*SegmentWriter) WriteAll

func (s *SegmentWriter) WriteAll(pairs []kv.KVPair) (int, error)

WriteAll takes a slice of KVPair's and calls Write() on each of them.

Jump to

Keyboard shortcuts

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