y

package
v0.0.0-...-e603270 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToU32

func BytesToU32(b []byte) uint32

BytesToU32 converts the given byte slice to uint32

func BytesToU32Slice

func BytesToU32Slice(b []byte) []uint32

BytesToU32Slice converts the given byte slice to uint32 slice

func CompareKeys

func CompareKeys(key1, key2 []byte) int

func Copy

func Copy(a []byte) []byte

Copy copies a byte slice and returns the copied slice.

func FormatKey

func FormatKey(key []byte) string

func KeyWithTs

func KeyWithTs(key []byte, ts uint64) []byte

KeyWithTs generates a new key by appending ts to key.

func ParseKey

func ParseKey(key []byte) []byte

ParseKey parses the actual key from the key bytes.

func ParseTs

func ParseTs(key []byte) uint64

ParseTs parses the timestamp from the key bytes.

func SafeCopy

func SafeCopy(a, src []byte) []byte

SafeCopy does append(a[:0], src...).

func SameKey

func SameKey(src, dst []byte) bool

SameKey checks for key equality ignoring the version timestamp suffix.

func U32SliceToBytes

func U32SliceToBytes(u32s []uint32) []byte

U32SliceToBytes converts the given Uint32 slice to byte slice

func U32ToBytes

func U32ToBytes(v uint32) []byte

U32ToBytes converts the given Uint32 to bytes

Types

type Iterator

type Iterator interface {
	Next()
	Rewind()
	Seek(key []byte)
	Key() []byte
	Value() ValueStruct
	Valid() bool

	// All iterators should be closed so that file garbage collection works.
	Close() error
}

Iterator is an interface for a basic iterator.

type ValueStruct

type ValueStruct struct {
	Meta      byte
	ExpiresAt uint64
	Value     []byte

	Version uint64 // This field is not serialized. Only for internal usage.
}

ValueStruct represents the value info that can be associated with a key, but also the internal Meta field.

func (*ValueStruct) Decode

func (v *ValueStruct) Decode(b []byte)

Decode uses the length of the slice to infer the length of the Value field.

func (*ValueStruct) Encode

func (v *ValueStruct) Encode(b []byte) uint32

Encode expects a slice of length at least v.EncodedSize().

func (*ValueStruct) EncodeTo

func (v *ValueStruct) EncodeTo(buf *bytes.Buffer)

EncodeTo should be kept in sync with the Encode function above. The reason this function exists is to avoid creating byte arrays per key-value pair in table/builder.go.

func (*ValueStruct) EncodedSize

func (v *ValueStruct) EncodedSize() uint32

EncodedSize is the size of the ValueStruct when encoded

func (*ValueStruct) Write

func (v *ValueStruct) Write(buf *bytes.Buffer)

EncodeTo should be kept in sync with the Encode function above. The reason this function exists is to avoid creating byte arrays per key-value pair in table/builder.go.

Jump to

Keyboard shortcuts

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