encoding

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitpackDecode

func BitpackDecode(data []byte) ([]uint8, error)

BitpackDecode unpacks N-bit packed indices.

func BitpackEncode

func BitpackEncode(indices []uint8, bitsPerValue int) []byte

BitpackEncode packs uint8 indices into N bits per value. bitsPerValue must be 1-8. Returns: [1 byte bitsPerValue] [4 bytes count] [packed bits]

func BitsNeeded

func BitsNeeded(n int) int

BitsNeeded returns the minimum number of bits to represent n distinct values.

func Compress

func Compress(src []byte) []byte

Compress compresses data using zstd.

func DecodeUvarintSlice

func DecodeUvarintSlice(data []byte, count int) ([]uint64, error)

DecodeUvarintSlice decodes zstd + uvarint encoded uint64 values.

func DecodeVarintSlice

func DecodeVarintSlice(data []byte, count int) ([]int64, error)

DecodeVarintSlice decodes zstd + varint encoded int64 values.

func Decompress

func Decompress(src []byte) ([]byte, error)

Decompress decompresses zstd data.

func DeltaDecode

func DeltaDecode(data []byte, count int) ([]int64, error)

DeltaDecode decodes base + zigzag-varint deltas + zstd back to int64 values.

func DeltaEncode

func DeltaEncode(values []int64) []byte

DeltaEncode encodes a slice of int64 values as base + zigzag-varint deltas + zstd. Returns: [8 bytes base] [zstd(zigzag-varint deltas)]

func DictLookup

func DictLookup(d *DictEncoded) []string

DictLookup resolves dictionary indices back to strings.

func DictMarshal

func DictMarshal(d *DictEncoded) []byte

DictMarshal serializes a DictEncoded to bytes + zstd. Format: [2 bytes dict_len] [dict entries: 2-byte len + string]... [zstd(uint16 indices)]

func EncodeUvarintSlice

func EncodeUvarintSlice(values []uint64) []byte

EncodeUvarintSlice encodes a slice of uint64 values as uvarints + zstd.

func EncodeVarintSlice

func EncodeVarintSlice(values []int64) []byte

EncodeVarintSlice encodes a slice of int64 values as varints + zstd.

func Float64ToInt64

func Float64ToInt64(f float64) int64

Float64ToInt64 converts a float64 to int64 bits for storage.

func Int64ToFloat64

func Int64ToFloat64(i int64) float64

Int64ToFloat64 converts int64 bits back to float64.

func PutUvarint

func PutUvarint(dst []byte, v uint64) []byte

PutUvarint appends a uvarint-encoded uint64 to dst and returns the extended slice.

func PutVarint

func PutVarint(dst []byte, v int64) []byte

PutVarint appends a varint-encoded int64 to dst and returns the extended slice.

func SparseBool

func SparseBool(values []*bool) []byte

SparseBool encodes a slice of *bool where nil = null. Non-null values stored as a second bitmap.

func SparseBytes

func SparseBytes(values [][]byte) []byte

SparseBytes encodes a slice of []byte where nil = null. Used for body column (already compressed blobs).

func SparseInt64

func SparseInt64(values []*int64) []byte

SparseInt64 encodes a slice of *int64 where nil = null. Uses varint encoding for non-null values.

func SparseStrings

func SparseStrings(values []string) []byte

SparseStrings encodes a slice of strings where empty string = null. Format: [4 bytes non_null_count] [bitmap bytes] [zstd(length-prefixed non-null strings)]

func UnsparseBool

func UnsparseBool(data []byte, count int) ([]*bool, error)

UnsparseBool decodes sparse bool column.

func UnsparseBytes

func UnsparseBytes(data []byte, count int) ([][]byte, error)

UnsparseBytes decodes sparse byte slice column.

func UnsparseInt64

func UnsparseInt64(data []byte, count int) ([]*int64, error)

UnsparseInt64 decodes sparse int64 column.

func UnsparseStrings

func UnsparseStrings(data []byte, count int) ([]string, error)

UnsparseStrings decodes sparse string column.

func ZigZagDecode

func ZigZagDecode(v uint64) int64

ZigZagDecode converts a zigzag-encoded uint64 back to int64.

func ZigZagEncode

func ZigZagEncode(v int64) uint64

ZigZagEncode converts a signed int64 to an unsigned uint64 using zigzag encoding. This makes small negative numbers small unsigned numbers (good for varint).

func ZstdBlockDecodeInt64

func ZstdBlockDecodeInt64(data []byte, count int) ([]int64, error)

ZstdBlockDecodeInt64 decodes zstd + raw LE int64 values.

func ZstdBlockDecodeStrings

func ZstdBlockDecodeStrings(data []byte, count int) ([]string, error)

ZstdBlockDecodeStrings decodes zstd + length-prefixed strings.

func ZstdBlockEncodeInt64

func ZstdBlockEncodeInt64(values []int64) []byte

ZstdBlockEncodeInt64 encodes a slice of int64 as raw LE bytes + zstd. Used for ts column (not delta-encoded, may not be monotonic).

func ZstdBlockEncodeStrings

func ZstdBlockEncodeStrings(values []string) []byte

ZstdBlockEncodeStrings encodes a slice of strings as length-prefixed + zstd.

Types

type DictEncoded

type DictEncoded struct {
	Dict    []string // ordered dictionary: index → string
	Indices []uint16 // per-entry dictionary index
}

DictEncoded holds the result of dictionary encoding.

func DictEncode

func DictEncode(values []string) *DictEncoded

DictEncode builds a dictionary from string values and returns indices. Null/empty strings are stored as index 0 with dict[0] = "".

func DictUnmarshal

func DictUnmarshal(data []byte, count int) (*DictEncoded, error)

DictUnmarshal deserializes DictEncoded from bytes.

Jump to

Keyboard shortcuts

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