encoding

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NullValue  byte = 0x05
	FalseValue byte = 0x10 // 0x10 - 0x00 = 0x10 = 16
	TrueValue  byte = 0x11 // 0x11 - 0x10 = 0x01 = 1
	Int64Value byte = 0x20 // 0x20 - 0x11 = 0x0f = 15
	Int32Value byte = 0x21 // 0x21 - 0x20 = 0x01 = 1
	Int16Value byte = 0x22 // 0x22 - 0x21 = 0x01 = 1
	Int8Value  byte = 0x23 // 0x23 - 0x22 = 0x01 = 1
	// until -32
	IntSmallValue byte = 0x24 // 0x24 - 0x23 = 0x01 = 1
	// until 127
	Uint8Value    byte = 0xC4 // 0xC3 - 0x23 = 0xA0 = 160
	Uint16Value   byte = 0xC5 // 0xC4 - 0xC3 = 0x01 = 1
	Uint32Value   byte = 0xC6 // 0xC5 - 0xC4 = 0x01 = 1
	Uint64Value   byte = 0xC7 // 0xC6 - 0xC5 = 0x01 = 1
	Float64Value  byte = 0xD0 // 0xD0 - 0xC6 = 0x0a = 10
	Float32Value  byte = 0xD1 // 0xD1 - 0xD0 = 0x01 = 1 | not included in keys
	TextValue     byte = 0xDA // 0xDA - 0xD1 = 0x09 = 9
	BlobValue     byte = 0xE0 // 0xE0 - 0xDA = 0x06 = 6
	ArrayValue    byte = 0xE6 // 0xE6 - 0xE0 = 0x06 = 6
	DocumentValue byte = 0xF0 // 0xF0 - 0xE6 = 0x0e = 14
)

additional types sorted from the smallest to the largest

Variables

This section is empty.

Functions

func AbbreviatedKey

func AbbreviatedKey(key []byte) uint64

AbbreviatedKey returns a shortened version that is used for comparing keys during indexed batch comparisons. The key is not guaranteed to be unique, but it respects the same ordering as the original key. If two abbreviated keys are equal, Pebble will call the Equal function to determine if the original keys are equal. The key is constructed as follows: - 12 bits: the namespace, from 0 to 4096. If bigger than 4096, returns math.MaxUint64. - 4 bits: the Genji type of the first value. - 48 bits: a representation of the first value of the key, depending on its type.

func Compare

func Compare(a, b []byte) int

func DecodeArray

func DecodeArray(b []byte, intAsDouble bool) types.Array

func DecodeBlob

func DecodeBlob(b []byte) ([]byte, int)

func DecodeBoolean

func DecodeBoolean(b []byte) bool

func DecodeDocument

func DecodeDocument(b []byte, intAsDouble bool) types.Document

func DecodeFloat

func DecodeFloat(b []byte) (float64, int)

func DecodeFloat64

func DecodeFloat64(b []byte) float64

func DecodeInt

func DecodeInt(b []byte) (int64, int)

func DecodeInt16

func DecodeInt16(b []byte) int16

func DecodeInt32

func DecodeInt32(b []byte) int32

func DecodeInt64

func DecodeInt64(b []byte) int64

func DecodeInt8

func DecodeInt8(b []byte) int8

func DecodeText

func DecodeText(b []byte) (string, int)

func DecodeUint16

func DecodeUint16(b []byte) uint16

func DecodeUint32

func DecodeUint32(b []byte) uint32

func DecodeUint64

func DecodeUint64(b []byte) uint64

func DecodeUint8

func DecodeUint8(b []byte) uint8

func DecodeValue

func DecodeValue(b []byte, intAsDouble bool) (types.Value, int)

func EncodeArray

func EncodeArray(dst []byte, a types.Array) ([]byte, error)

func EncodeArrayLength

func EncodeArrayLength(dst []byte, l int) []byte

func EncodeBlob

func EncodeBlob(dst []byte, x []byte) []byte

func EncodeBoolean

func EncodeBoolean(dst []byte, x bool) []byte

func EncodeDocument

func EncodeDocument(dst []byte, d types.Document) ([]byte, error)

func EncodeDocumentLength

func EncodeDocumentLength(dst []byte, l int) []byte

func EncodeFloat

func EncodeFloat(dst []byte, x float64) []byte

func EncodeFloat64

func EncodeFloat64(dst []byte, x float64) []byte

func EncodeInt

func EncodeInt(dst []byte, n int64) []byte

func EncodeInt16

func EncodeInt16(dst []byte, n int16) []byte

func EncodeInt32

func EncodeInt32(dst []byte, n int32) []byte

func EncodeInt64

func EncodeInt64(dst []byte, n int64) []byte

func EncodeInt8

func EncodeInt8(dst []byte, n int8) []byte

func EncodeNull

func EncodeNull(dst []byte) []byte

func EncodeText

func EncodeText(dst []byte, x string) []byte

func EncodeUint

func EncodeUint(dst []byte, n uint64) []byte

func EncodeUint16

func EncodeUint16(dst []byte, n uint16) []byte

func EncodeUint32

func EncodeUint32(dst []byte, n uint32) []byte

func EncodeUint64

func EncodeUint64(dst []byte, n uint64) []byte

func EncodeUint8

func EncodeUint8(dst []byte, n uint8) []byte

func EncodeValue

func EncodeValue(dst []byte, v types.Value) ([]byte, error)

func Equal

func Equal(a, b []byte) bool

func Separator added in v0.15.1

func Separator(dst, a, b []byte) (foo []byte)

func Skip

func Skip(b []byte) int

func SkipArray

func SkipArray(b []byte) int

func SkipDocument

func SkipDocument(b []byte) int

func Successor

func Successor(dst, a []byte) []byte

Types

type EncodedArray

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

An EncodedArray implements the types.Array interface on top of an encoded representation of an array. It is useful for avoiding decoding the entire array when only a few values are needed.

func (*EncodedArray) GetByIndex

func (e *EncodedArray) GetByIndex(idx int) (v types.Value, err error)

GetByIndex returns a value by index of the array.

func (*EncodedArray) Iterate

func (e *EncodedArray) Iterate(fn func(i int, value types.Value) error) error

Iterate goes through all the values of the array and calls the given function by passing each one of them. If the given function returns an error, the iteration stops.

func (*EncodedArray) MarshalJSON

func (e *EncodedArray) MarshalJSON() ([]byte, error)

type EncodedDocument

type EncodedDocument struct {
	Encoded []byte
	// contains filtered or unexported fields
}

func (*EncodedDocument) GetByField

func (e *EncodedDocument) GetByField(field string) (types.Value, error)

func (*EncodedDocument) Iterate

func (e *EncodedDocument) Iterate(fn func(k string, v types.Value) error) error

func (*EncodedDocument) MarshalJSON

func (e *EncodedDocument) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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