Documentation
¶
Overview ¶
Package numrange is the single compiled {label, start, end} model of GROUP_NUMERIC_RANGES and the numeric RangeTables the facade validates at pulse.New time, and the one reading of the grouper's params — shared by the operator factory (internal/processing) and predict (internal/descriptor) so both refuse the same request with the same code and message.
Bounds are HALF-OPEN: a range covers [start, end). It is the only semantics that cannot misplace a float — a value is never "between" two adjacent ranges and never in both — so [0, 91) and [91, 104) are adjacent, not overlapping, and the integer idiom {0, 91}, {91, 104} puts 90 in the first range and 91 in the second. An omitted (or null) bound is open: -inf below, +inf above.
Leaf: stdlib + the public errors / types packages + paramread + daterange (the shared source-ambiguity and table-kind refusals).
Index ¶
Constants ¶
const DefaultUnmatchedLabel = "unmatched"
DefaultUnmatchedLabel is the bucket label of a row outside every range.
const Operator = string(types.GROUP_NUMERIC_RANGES)
Operator is the type name every refusal names.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Set is the compiled inline range set; nil for a table source until
// Resolve runs.
Set *Set
// Order is the supplied range labels in author order (the emission
// order); nil for a table source until Resolve runs.
Order []string
// Table names a numeric range table, resolved later against the
// instance's registry; "" for an inline source.
Table string
// UnmatchedLabel is the bucket of a row outside every range.
UnmatchedLabel string
}
Config is a parsed GROUP_NUMERIC_RANGES configuration. Exactly one of an inline source (Set + Order resolved) or Table is set.
func Parse ¶
func Parse(raw json.RawMessage) (Config, error)
Parse validates raw GROUP_NUMERIC_RANGES params: malformed params (PROCESSING_CONFIG), not exactly one of ranges / table (PULSE_RANGE_SOURCE_AMBIGUOUS), and for an inline source every Compile refusal plus an unmatched label colliding with a range label (PROCESSING_CONFIG). A table source is resolved by Resolve.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a validated collection of labeled numeric ranges, stored sorted by lower bound (open-lower first). Validated non-overlapping, so at most one range contains any value.
func Compile ¶
Compile validates specs into a Set. Each failure carries its own code:
- empty spec set → PULSE_RANGE_EMPTY
- a non-finite bound, or start >= end when both bounds are present → PULSE_RANGE_INVALID
- two specs sharing a Label → PULSE_RANGE_DUPLICATE_LABEL
- two half-open ranges that share any value (open ends extend to ±inf) → PULSE_RANGE_OVERLAP
type Spec ¶
type Spec struct {
Label string `json:"label"`
Start *float64 `json:"start,omitempty"`
End *float64 `json:"end,omitempty"`
}
Spec is the wire-level shape of a single labeled numeric range, authored inline on a GROUP_NUMERIC_RANGES grouper or in a numeric range table. Start and End are JSON numbers; nil (omitted or null) is an open bound. The range covers [Start, End).