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
[Feat] initial draft of structure-of-arrays using object schema
Using a payload-less object `${..}` as the schema following the optimized type marker `$` allows one to efficiently pack object data into an optimized container, ideally suited for table-like data.
```
[$ {<schema>} #<count> <payload> // row-major (interleaved)
{$ {<schema>} #<count> <payload> // column-major (columnar)
```
1. Fixed-length numeric types: `U i u I l m L M h d D C B`
702
+
2.`T` in schema means "boolean type" - each value is 1 byte (`T` or `F` marker) in payload
703
+
3.`Z` in schema means "null field" - no bytes in payload (placeholder/reserved field)
704
+
4.`S` and `H` require a length specifier, making them fixed-length
705
+
5. Nested objects `{...}` are allowed if all fields are fixed-length
706
+
6. Fixed arrays use regular syntax `[type type ...]` - no optimized containers inside schema
707
+
7.**No `$` or `#` markers allowed anywhere inside the schema**
708
+
8.`F` and `N` are not used in schema (use `T` for boolean, `Z` for null)
709
+
710
+
#### Fixed-Length Strings (`S`) and High-Precision Numbers (`H`)
711
+
712
+
In normal BJData, `S` and `H` are variable-length:
713
+
```
714
+
S i 5 h e l l o ; string value, length 5
715
+
H i 3 1 2 3 ; high-precision value "123"
716
+
```
717
+
718
+
In a **schema context**, they define fixed-length types:
719
+
```
720
+
{ i4 name S i 16 } ; "name" is a 16-byte fixed string
721
+
{ i5 value H i 32 } ; "value" is a 32-byte fixed high-precision number
722
+
```
723
+
724
+
In the payload, each record contributes exactly the specified bytes - no length prefix. Strings shorter than the length are right-padded with null bytes (0x00).
725
+
726
+
#### Boolean Type (`T`)
727
+
728
+
In normal BJData, `T` and `F` are zero-length value markers:
729
+
```
730
+
T ; true (no payload)
731
+
F ; false (no payload)
732
+
```
733
+
734
+
In a **schema context**, `T` means "boolean type" - a 1-byte field:
735
+
```
736
+
{ i6 active T } ; "active" is a boolean field
737
+
```
738
+
739
+
In the payload, each boolean value is stored as a single byte: `T` (0x54) for true, `F` (0x46) for false.
740
+
741
+
#### Null Type (`Z`)
742
+
743
+
In a **schema context**, `Z` means "null/placeholder field" with **zero bytes** in payload:
744
+
```
745
+
{
746
+
i2 id m ; uint32 (4 bytes)
747
+
i8 reserved Z ; placeholder (0 bytes)
748
+
i4 data d ; float64 (8 bytes)
749
+
}
750
+
```
751
+
752
+
This is useful for:
753
+
- Reserved fields for future expansion
754
+
- Marking fields that exist in the schema but carry no data
755
+
- Sparse structures where some fields are always null
756
+
757
+
---
758
+
759
+
### <aname="row-major_column-major"/>Row-Major vs Column-Major Layout
760
+
761
+
Using existing container markers (no new markers needed):
762
+
763
+
| Syntax | Layout | Description |
764
+
|--------|--------|-------------|
765
+
|`[$`|**Row-major (Interleaved)**| Array of records - each complete record stored sequentially |
766
+
|`{$`|**Column-major (Columnar)**| Object of arrays - all values of each field stored together |
767
+
768
+
#### Row-Major: `[$`
769
+
770
+
```
771
+
[$ {<schema>} #<count> <interleaved-payload>
772
+
```
773
+
774
+
Payload order: `<record1><record2><record3>...`
775
+
776
+
**Example:** 3 particles with `{x:float64, y:float64, id:uint32, active:bool}`
0 commit comments