You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add EvalMap for pre-decoded JSON input (RecoLabs#2)
* Add EvalMap for pre-decoded JSON input
Add StreamEvaluator.EvalMap that accepts map[string]json.RawMessage
directly, avoiding the need to serialize data to []byte before
evaluation. Internally, DecodeRawMap converts each value individually
via DecodeJSON into an *OrderedMap, then delegates to the shared
evalInternal method (refactored out of EvalMany).
- Add DecodeRawMap to internal/evaluator/ordered_map.go
- Refactor EvalMany into evalInternal + thin EvalMany wrapper
- Add EvalMap with schemaKey support for GroupPlan caching
- Add resolveGjsonPath for O(1) map key lookup in fast paths
- Add tests for EvalMap (parity, multi-expr, nil/empty edge cases)
Signed-off-by: NirBarak-RecoLabs <nirb@recolabs.ai>
* Add EvalMap to README documentation
- Add EvalMap code example to Tier 3 StreamEvaluator section
- Add pre-decoded map input bullet to Streaming API key properties
- Update project structure to mention EvalMap in stream.go
Signed-off-by: NirBarak-RecoLabs <nirb@recolabs.ai>
---------
Signed-off-by: NirBarak-RecoLabs <nirb@recolabs.ai>
@@ -156,6 +159,7 @@ Hot Path (millions/day, lock-free)
156
159
-**Schema-keyed caching** — the `GroupPlan` (merged paths, expression groupings, selective unmarshal targets) is computed once per schema key and reused immutably.
157
160
-**Lock-free reads** — `BoundedCache` publishes an `atomic.Pointer` snapshot on every write; reads scan the snapshot without acquiring a lock. Writes are serialised by a mutex.
158
161
-**Selective unmarshal** — full-path expressions unmarshal only the subtrees they need (e.g., just the `items` array from a 10KB event), not the entire document.
162
+
-**Pre-decoded map input** — `EvalMap` accepts `map[string]json.RawMessage` directly, skipping full-document serialization when the caller already has individually-encoded fields. Fast paths resolve top-level keys via O(1) map lookup.
159
163
-**Dynamic mutation** — `Replace`, `Remove`, and `Reset` methods allow modifying registered expressions at runtime with automatic cache invalidation.
160
164
-**Observability** — implement `MetricsHook` to receive per-evaluation callbacks for cache hits/misses, eval latency, fast-path usage, and errors.
161
165
@@ -417,7 +421,7 @@ All standard regex features (character classes, quantifiers, alternation, groupi
417
421
```
418
422
gnata/
419
423
├── gnata.go # Public API: Compile, Eval, EvalBytes, EvalWithVars, CustomFunc
0 commit comments