-
Notifications
You must be signed in to change notification settings - Fork 3
fix(query-engine): make heap top-k keys collision-safe #679
Open
Assignees
Description
Parent
What to build
Replace or harden delimiter-based label-key encoding used by CountMinSketchWithHeap. Semicolon-joined keys cannot safely represent label values containing semicolons and can decode to the wrong label vector.
Preserve compatibility with existing persisted data if required.
Acceptance criteria
- Distinct label vectors cannot encode to the same heap key.
- All supported label values round-trip losslessly.
- Existing persisted keys have a documented migration or compatibility strategy.
- Tests cover semicolons, empty values, and multiple labels.
Blocked by
None - can start immediately.
Concrete example
Current encoding:
let encoded = labels.join(";"); let decoded = encoded.split(';').collect::<Vec<_>>();
These distinct label vectors collide:
["a;b", "c"] -> "a;b;c"
["a", "b;c"] -> "a;b;c"
A value such as path="a;b" also decodes as two labels instead of one.
The replacement should use a structured or length-prefixed representation, for example:
[3]["a;b"][1]["c"]