ADR 002: Length-Agnostic Implicit Array Encoding for Integer and Float #9
Replies: 4 comments 3 replies
-
|
Look at this ❤️ |
Beta Was this translation helpful? Give feedback.
-
|
@heartical I merged it, but it will not be propogated to main with the current. |
Beta Was this translation helpful? Give feedback.
-
|
@heartical I added simple test pseudo code if you have time, lets rewrite encode first this way. firstly strings(bytes) + int float arrays (which u implemented) , for maps, we may add extra restriction , like key strings are being less than some length(1kb or 2kb) and decide how to store them outside. in tree for making it easier bfs offset way concat, or just direct file write with named as offsets (filename.offset.data) (by default its dfs order reversed). as in this case triplets can be stored ordinary way without storing buffers as segments). and root file will be last one. and we can name it filename.root.data) after encoding decoding will be more straightforward. |
Beta Was this translation helpful? Give feedback.
-
|
@heartical I rebased ADR-02 into main. but Adr-01 will stay inside experimental for now due to being inconsistent with it.as we need to redo it gradual way. firstly starting encoding. thats why it needs to be [WIP (work in progress PR] for encoding, then later decoding thanks a lot |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
ADR 002: Length-Agnostic Implicit Array Encoding
Status
Proposed / Draft
Context
PackOS aims for extreme compactness. Conventional length-prefixed arrays (storing the count as a
uint32oruint64) add unnecessary bytes. We require a format for Integer and Floating-point arrays that minimizes metadata while remaining fully compatible with the chunking model defined in ADR 001.Decision
We introduce a unified array format for Type 1 (
TypeInteger) and Type 3 (TypeFloating). The distinction between a scalar and an array is derived purely from the payload size indicated in the 13-bit header.1. Encoding Rules
2. Implicit Count Logic
The element count is not stored in the binary. It is calculated at runtime by the decoder using this logic:
count = (payloadSize - 1) / elementSize3. Memory Alignment & Implementation Note
While the format is highly compact, it is important to note:
encoding/binary) to handle byte-to-type conversion, ensuring alignment and endianness are correctly managed regardless of the host architecture.4. Integration with ADR 001
If a numerical array exceeds the Adjustable Oversize Limit (default 4 KB), it is wrapped in a
TypeExtendedTagContainer. The array is split across segments, and the implicit count logic is applied locally to each segment's payload.Consequences
Beta Was this translation helpful? Give feedback.
All reactions