encoding

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TombstoneValue byte = 0

	// Null
	NullValue byte = 2

	// Booleans
	FalseValue byte = 5
	TrueValue  byte = 6

	// Negative integers
	Int64Value byte = 12
	Int32Value byte = 13
	Int16Value byte = 14
	Int8Value  byte = 15

	// Contiguous block of 64 integers.
	// Types from 16 to 79 represent
	// values from -32 to 31
	IntSmallValue byte = 16

	// Positive integers
	Uint8Value  byte = 80
	Uint16Value byte = 81
	Uint32Value byte = 82
	Uint64Value byte = 83

	// Floating point numbers
	Float64Value byte = 90

	// Text
	TextValue byte = 98

	// Binary
	ByteaValue byte = 103

	// Arrays
	ArrayValue byte = 110

	// Objects
	ObjectValue byte = 120

	// DESC_ prefix means that the value is encoded in reverse order.
	DESC_ObjectValue   byte = 255 - ObjectValue
	DESC_ArrayValue    byte = 255 - ArrayValue
	DESC_ByteaValue    byte = 255 - ByteaValue
	DESC_TextValue     byte = 255 - TextValue
	DESC_Float64Value  byte = 255 - Float64Value
	DESC_Uint64Value   byte = 255 - Uint64Value
	DESC_Uint32Value   byte = 255 - Uint32Value
	DESC_Uint16Value   byte = 255 - Uint16Value
	DESC_Uint8Value    byte = 255 - Uint8Value
	DESC_IntSmallValue byte = 255 - IntSmallValue
	DESC_Int8Value     byte = 255 - Int8Value
	DESC_Int16Value    byte = 255 - Int16Value
	DESC_Int32Value    byte = 255 - Int32Value
	DESC_Int64Value    byte = 255 - Int64Value
	DESC_TrueValue     byte = 255 - TrueValue
	DESC_FalseValue    byte = 255 - FalseValue
	DESC_NullValue     byte = 255 - NullValue
)

Types used to encode values in the tree. They are sorted from the smallest to largest. Each type is encoded on 1 byte and describes two things: - the type of the field - the sort order of the field (ASC or DESC) The first 128 values are used for ASC order, the last 128 values are used for DESC order. A block of 64 is reserved for small integers in the range [-32, 31]. Gaps are left between each type to allow adding new types in the future.

Variables

View Source
var (
	Epoch   = time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC).UnixMicro()
	MaxTime = math.MaxInt64 - Epoch
	MinTime = math.MinInt64 + Epoch
)

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 Chai 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 ConvertToTimestamp

func ConvertToTimestamp(x int64) time.Time

func DecodeBoolean

func DecodeBoolean(b []byte) bool

func DecodeBytea added in v0.18.0

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

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 DecodeTimestamp

func DecodeTimestamp(b []byte) (time.Time, 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 Desc

func Desc(dst []byte, n int) ([]byte, int)

Desc changes the type of the encoded value to its descending counterpart. It is meant to be used in combination with one of the Encode* functions.

var buf []byte
buf, n = encoding.Desc(encoding.EncodeInt(buf, 10))

func EncodeBoolean

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

func EncodeBytea added in v0.18.0

func EncodeBytea(dst []byte, x []byte) []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 EncodeTimestamp

func EncodeTimestamp(dst []byte, t time.Time) []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 Equal

func Equal(a, b []byte) bool

func Separator

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

func Skip

func Skip(b []byte) int

func SkipArray

func SkipArray(b []byte) int

func SkipObject

func SkipObject(b []byte) int

func Split added in v0.17.0

func Split(k []byte) int

Split returns the length of the prefix (namespace) that should be used as the user key prefix for pebble. Our keys encode a namespace as the first integer value. Use DecodeInt to find its size.

Types

This section is empty.

Jump to

Keyboard shortcuts

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