keyenc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package keyenc encodes DynamoDB key attribute values (S, N, B) into byte strings whose lexicographic order matches DynamoDB's key order — so bbolt cursors give range queries for free. The load-bearing property, fuzz-tested:

CompareValues(a, b) == bytes.Compare(Encode(a), Encode(b))

Layout per value: a type byte, then the payload:

S/B: payload with 0x00 escaped as 0x00 0xFF, terminated by 0x00 0x01
     (terminator sorts below any escaped or literal byte, so prefixes
     sort first).
N:   sign class byte (2=positive, 1=zero, 0=negative), then for nonzero:
     biased exponent (uint16), then BCD-ish digit bytes terminated by 0x00.
     For negatives, exponent and digits are bitwise complemented so
     bigger magnitudes sort earlier.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareValues

func CompareValues(a, b item.Value) int

CompareValues orders two key values the way DynamoDB does (needed by tests and by scan segmentation). Mixed types order by type tag, mirroring Encode.

func Composite

func Composite(pk item.Value, sk *item.Value) ([]byte, error)

Composite encodes a partition key followed by an optional sort key.

func Encode

func Encode(v item.Value) ([]byte, error)

Encode renders one key value. Only S, N, and B are legal DynamoDB key types; anything else errors.

Types

This section is empty.

Jump to

Keyboard shortcuts

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