Documentation
¶
Overview ¶
Package aspectcodec implements the v2 aspect-segment codec (ADR-0182 SD1), shared by the three aspect vocabularies.
A segment is the ascending list of a set's aspect indices, one alphabet char per index at alphabet[i+1]. The empty set is the empty string; the legacy v1 empty marker "0" is accepted on decode but never produced. '0' (alphabet position 0) never occurs in a v2 segment; 'z' (position 61) is an escape prefix, each occurrence adding +60 to the digit it precedes, chainable. Single chars therefore cover indices 0..59. Canonical form is strictly ascending indices; decoders reject anything else, per element.
Index ¶
- Constants
- Variables
- func Contains[E IndexI](seg string, target E) (has bool)
- func Count(seg string) (n int, err error)
- func Decode[E IndexI](seg string, maxExcl E) (known []E, unknownCount int, err error)
- func Encode[E IndexI](indices []E) (seg string)
- func FirstExclusivityViolation[E IndexI](families []Family[E], contains func(E) bool) (name string)
- func IsEmpty(seg string) (empty bool)
- func KeepFirstPerExclusiveFamily[E IndexI](families []Family[E], aspects []E) (out []E)
- func MaxIndex(seg string) (max int, err error)
- func Union(a string, b string) (seg string, err error)
- func Validate(seg string) (err error)
- type Family
- type IndexI
Constants ¶
const Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Alphabet is the v2 digit alphabet, ASCII-sorted so alphabet order equals byte order; position 0 is the reserved '0', position 61 the escape. Exported for consumers that mirror the codec outside Go (SQL UDFs).
Variables ¶
var ErrEmptySet = eh.Errorf("encoding contains empty set")
var ErrInvalidEncoding = eh.Errorf("encoding is wrong")
var PackageProps = packageprops.Props{ WASMWASI: packageprops.WASMCompiles, WASMJS: packageprops.WASMCompiles, WASMFreestanding: packageprops.WASMCompiles, }
PackageProps records this package's curated properties (ADR-0080). Seeded by `boxer code analysis golang wasmsurvey props generate`; curate by hand. The same group's `props verify` reconciles it.
Functions ¶
func Contains ¶
Contains reports whether the segment's set contains target. It returns false on structurally invalid input.
func Decode ¶
Decode splits a structurally valid segment into the indices known to a vocabulary of size maxExcl and a count of unknown (too-new) indices. Unknown elements are individually skippable; they never poison the known part.
func Encode ¶
Encode returns the canonical v2 segment for the given aspects. Input may be unsorted and may contain duplicates; the result is their set. Every value of an ~uint8 index type is encodable, so Encode is total.
func FirstExclusivityViolation ¶
FirstExclusivityViolation returns the name of the first exclusive family with more than one member present (per contains), or "" when none is violated.
func IsEmpty ¶
IsEmpty reports whether the segment denotes the empty set ("" or the legacy v1 marker "0").
func KeepFirstPerExclusiveFamily ¶
KeepFirstPerExclusiveFamily drops all but the first-encountered member of each exclusive family, preserving input order; aspects outside any exclusive family pass through.
func MaxIndex ¶
MaxIndex returns the highest index in the segment's set; ErrEmptySet on an empty set.