sst

package
v0.0.0-...-1be9e8e Latest Latest
Warning

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

Go to latest
Published: May 13, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SstMagic = uint64(0xe489f8a9d479536b)
	// MaxSstKeySize is the max encoded keysize in an SST.
	// Slightly larger than DB MaxKeySize due to additional data.
	MaxSstKeySize = 8*1024 + 16
)

Variables

View Source
var (
	ErrNotFound   = errors.New("not found")
	ErrCorruption = errors.New("corruption detected")
)

Functions

This section is empty.

Types

type Cache

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

Cache is a cache of key -> bytes. Implements a segmented LRU algorithm.

func NewCache

func NewCache(targetSize int64) *Cache

NewCache returns a Cache.

func (*Cache) Get

func (c *Cache) Get(key string) []byte

Get retrieves k from cache. Returns nil if not found.

func (*Cache) Insert

func (c *Cache) Insert(key string, data []byte)

func (*Cache) NewID

func (c *Cache) NewID() uint64

NewID returns a new unique ID, typically used by callers to partition to cache space by pre-pending the ID to all cache keys.

type Iter

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

func (*Iter) Close

func (i *Iter) Close()

func (*Iter) Key

func (i *Iter) Key() string

func (*Iter) Next

func (i *Iter) Next() (bool, error)

Next advances the iterator. Returns true if there is a next value.

func (*Iter) Timestamp

func (i *Iter) Timestamp() int64

func (*Iter) Value

func (i *Iter) Value() []byte

type Iterator

type Iterator interface {
	// Key returns the current key.
	Key() string

	// Value returns the current value. Callers should not modify the returned value.
	// Returned value is only valid until the next call to Next.
	Value() []byte

	// Next advances the iterator. Returns whether there is another key/value.
	Next() bool

	// Close closes the iterator.
	Close()
}

Iterator is an iterator over keys and values. Iterators MUST be closed when done.

type Reader

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

Reader is an SSTable reader. Threadsafe.

func NewReader

func NewReader(filename string, cache *Cache) (*Reader, error)

NewReader returns a new SST reader for filename, already ref-ed once.

func (*Reader) Filename

func (r *Reader) Filename() string

Filename returns the full file path of the SST.

func (*Reader) Find

func (r *Reader) Find(ctx context.Context, key string) (value []byte, ts int64, err error)

Find returns the value of key in SST.

func (*Reader) NewIter

func (r *Reader) NewIter() (*Iter, error)

NewIter returns a new SST iterator. Must close after use.

func (*Reader) Ref

func (r *Reader) Ref()

Ref increases the refcount by 1.

func (*Reader) UnRef

func (r *Reader) UnRef()

UnRef decreases the refcount by 1.

type Writer

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

func NewWriter

func NewWriter(filename string) (*Writer, error)

func (*Writer) Append

func (s *Writer) Append(key string, timestamp int64, value []byte) error

Append writes a new row to the SSTable. Must be called in order, i.e. key asc, timestamp desc

func (*Writer) Close

func (s *Writer) Close() error

Close finalizes the SST being written.

Jump to

Keyboard shortcuts

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