From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:Realm database file" |
|---|
| claim | "Every Realm array node (src/realm/node_header.hpp) starts with an 8-byte header: bytes 0-2 capacity/8 as a 24-bit big-endian number, byte 3 untouched by the getters/setters, byte 4 flags and width, bytes 5-7 element count as 24-bit big-endian. The ref of a node points at the data, the header sits 8 bytes before." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:Realm database file" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "NodeHeader" |
|---|
| size | 8 |
|---|
| endianness | "big (multi-byte fields are assembled byte by byte)" |
|---|
| fields | | offset | "0x0" |
|---|
| size | 3 |
|---|
| type | "uint8_t[3]" |
|---|
| name | "capacity_div8" |
|---|
| bits | "capacity in bytes = (h0<<19)+(h1<<11)+(h2<<3)" |
|---|
|
| offset | "0x3" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "unused_by_accessors" |
|---|
|
| offset | "0x4" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "flags_width" |
|---|
| bits | "bit7 is_inner_bptree_node, bit6 hasrefs, bit5 context_flag, bits3-4 width type (0 bits per element, 1 bytes per element, 2 each element is 1 byte), bits0-2 width code: element width = (1<<code)>>1" |
|---|
|
| offset | "0x5" |
|---|
| size | 3 |
|---|
| type | "uint8_t[3]" |
|---|
| name | "size" |
|---|
| bits | "element count = (h5<<16)+(h6<<8)+h7" |
|---|
|
|
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "header_size = 8; getters read h[4] masks 0x80/0x40/0x20/0x18/0x07, size from h[5..7], capacity from h[0..2]; set_capacity_in_header writes only h[0..2]." |
|---|
| repo | "https://github.com/realm/realm-core" |
|---|
| commit | "f8752e180b7f288feadffafdef818068755efe0a" |
|---|
| path | "src/realm/node_header.hpp" |
|---|
| lines | "34-127, 193-201" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Realm node header" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-19T11:32:06.561Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T12:01:02.581Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read src/realm/node_header.hpp 30-230 at the cited commit: header_size 8; h[4] masks 0x80 inner B+tree, 0x40 hasrefs, 0x20 context flag, 0x18 width type (bits/multiply/ignore = 0/1/2), 0x07 width code with width = (1<<code)>>1; size = h[5]<<16 | h[6]<<8 | h[7]; capacity = (h[0]<<19)+(h[1]<<11)+(h[2]<<3); set_capacity writes only h[0..2]; byte 3 untouched." |
|---|
|
|
|---|