Decoding with an Output Budget
An encoded record can reconstruct more data than its input size suggests. A decoder can enforce a documented limit on the actual output it builds.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a valid expansion
A run record with count 100 represents one hundred output symbols despite having a short encoded description. See run-length records.
Check the declared limit during processing
A safe reader counts actual reconstructed output and reports an exceeded limit coherently. Include a boundary case with a supported exact maximum. Bounded input processing describes the related resource contract.[1][2]
Check the remaining size limit before expanding a run
A toy decoder is permitted to emit at most twenty bytes. It has already produced sixteen and reads a run length six. Only four output bytes remain in budget, so under an all-or-nothing run rule the expansion is rejected before writing. See bounded imports.
Decoded so far 16
Limit 20
Next run 6 exceeds remaining 4
Report limit error without completing that run
Test exact boundary and repeated small expansions
A per-run maximum alone can miss cumulative overflow. Check the total before every committed expansion and define treatment of partial results. Include a run of four and then another positive-length run.