internal

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySize   = 4
	ValueSize = 8
)
View Source
const (
	Int32Size  = 4
	Int64Size  = 8
	FileIDSize = Int32Size
	OffsetSize = Int64Size
	SizeSize   = Int64Size
)
View Source
const (
	DefaultDatafileFilename = "%09d.data"
)

Variables

View Source
var (
	ErrReadonly  = errors.New("error: read only datafile")
	ErrReadError = errors.New("error: read error")
)
View Source
var (
	// Version release version
	Version = "0.0.1"

	// Commit will be overwritten automatically by the build system
	Commit = "HEAD"
)

Functions

func DecodeWithoutPrefix added in v0.3.3

func DecodeWithoutPrefix(buf []byte, valueOffset uint64, v *Entry)

func DirSize added in v0.2.2

func DirSize(path string) (int64, error)

func Exists added in v0.2.2

func Exists(path string) bool

func FullVersion

func FullVersion() string

FullVersion returns the full version and commit hash

func GetDatafiles

func GetDatafiles(path string) ([]string, error)

func GetKeyValueSizes added in v0.3.3

func GetKeyValueSizes(buf []byte) (uint64, uint64)

func ParseIds

func ParseIds(fns []string) ([]int, error)

func ReadBytes added in v0.3.3

func ReadBytes(r io.Reader) ([]byte, error)

func ReadIndex added in v0.3.3

func ReadIndex(r io.Reader, t art.Tree) error

func WriteBytes added in v0.3.3

func WriteBytes(b []byte, w io.Writer) (int, error)

func WriteIndex added in v0.3.3

func WriteIndex(t art.Tree, w io.Writer) (err error)

func WriteItem added in v0.3.3

func WriteItem(item Item, w io.Writer) (int, error)

Types

type Datafile

type Datafile struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewDatafile

func NewDatafile(path string, id int, readonly bool) (*Datafile, error)

func (*Datafile) Close

func (df *Datafile) Close() error

func (*Datafile) FileID

func (df *Datafile) FileID() int

func (*Datafile) Name

func (df *Datafile) Name() string

func (*Datafile) Read

func (df *Datafile) Read() (e Entry, n int64, err error)

func (*Datafile) ReadAt

func (df *Datafile) ReadAt(index, size int64) (e Entry, err error)

func (*Datafile) Size

func (df *Datafile) Size() int64

func (*Datafile) Sync

func (df *Datafile) Sync() error

func (*Datafile) Write

func (df *Datafile) Write(e Entry) (int64, int64, error)

type Decoder added in v0.3.3

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

Decoder wraps an underlying io.Reader and allows you to stream Entry decodings on it.

func NewDecoder added in v0.3.3

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a streaming Entry decoder.

func (*Decoder) Decode added in v0.3.3

func (d *Decoder) Decode(v *Entry) (int64, error)

type Encoder added in v0.3.3

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

Encoder wraps an underlying io.Writer and allows you to stream Entry encodings on it.

func NewEncoder added in v0.3.3

func NewEncoder(w io.Writer) *Encoder

NewEncoder creates a streaming Entry encoder.

func (*Encoder) Encode added in v0.3.3

func (e *Encoder) Encode(msg Entry) (int64, error)

Encode takes any Entry and streams it to the underlying writer. Messages are framed with a key-length and value-length prefix.

type Entry added in v0.3.3

type Entry struct {
	Checksum uint32
	Key      []byte
	Offset   int64
	Value    []byte
}

Entry represents a key/value in the database

func NewEntry

func NewEntry(key, value []byte) Entry

type Item

type Item struct {
	FileID int   `json:"fileid"`
	Offset int64 `json:"offset"`
	Size   int64 `json:"size"`
}

func ReadItem added in v0.3.3

func ReadItem(r io.Reader) (Item, error)

Jump to

Keyboard shortcuts

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