record

package
v0.0.0-...-f456d84 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCorruptData = errors.New("the record has been corrupted")

ErrCorruptData is returned when the data mismatches the stored checksum

View Source
var ErrInsufficientData = errors.New("could not parse bytes")

ErrInsufficientData is returned when the given data is not enouch to be parsed into a Record

Functions

This section is empty.

Types

type Record

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

Record is a database record

func FromBytes

func FromBytes(data []byte) (*Record, error)

FromBytes deserialize []byte into a record. If the data cannot be deserialized a wrapped ErrParse error will be returned.

func NewTombstone

func NewTombstone(key string) *Record

NewTombstone returns a new record of tombstone kind

func NewValue

func NewValue(key string, value []byte) *Record

NewValue returns a new record of value kind

func (*Record) IsTombstone

func (r *Record) IsTombstone() bool

IsTombstone returns true if the record is of tombstone kind

func (*Record) Key

func (r *Record) Key() string

Key returns the record key

func (*Record) Size

func (r *Record) Size() int

Size returns the serialized byte size

func (*Record) ToBytes

func (r *Record) ToBytes() []byte

ToBytes serializes the record into a sequence of bytes

func (*Record) Value

func (r *Record) Value() []byte

Value returns the record value

func (*Record) Write

func (r *Record) Write(w io.Writer) (int, error)

Write writes the record to the writer in binary format

type Scanner

type Scanner struct {
	*bufio.Scanner
}

Scanner implements the bufio.Scanner interface with a custom split function for tokenizing Records

func NewScanner

func NewScanner(r io.Reader, maxScanTokenSize int) (*Scanner, error)

NewScanner returns a new Record-Scanner for the reader. maxScanTokenSize is the largest possible size that the scanner will buffer and should be set to at least the byte size of the key and value combined.

func (*Scanner) Record

func (r *Scanner) Record() *Record

Record returns the most recent record generated by a call to scan, since Scanner keeps track of any error encountered we can ignore them here.

Jump to

Keyboard shortcuts

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