MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / legacy_v3_tile_payload_readable

Function legacy_v3_tile_payload_readable

nodedb/tests/array_codec_roundtrip.rs:112–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

110/// with a v3-style payload.
111#[test]
112fn legacy_v3_tile_payload_readable() {
113 let s = simple_schema();
114 let mut b = SparseTileBuilder::new(&s);
115 for i in 0..5 {
116 b.push_row(SparseRow {
117 coord: &[CoordValue::Int64(i)],
118 attrs: &[CellValue::Int64(i * 10)],
119 surrogate: Surrogate::ZERO,
120 valid_from_ms: 0,
121 valid_until_ms: OPEN_UPPER,
122 kind: RowKind::Live,
123 })
124 .unwrap();
125 }
126 let tile = b.build();
127
128 // Simulate the v3 writer: raw zerompk with no tag byte.
129 let raw_msgpack = zerompk::to_msgpack_vec(&tile).unwrap();
130
131 // The codec's tag dispatch should fall back to zerompk for this payload
132 // (peek_tag returns None for any non-tag byte; reader then tries zerompk).
133 let decoded = nodedb_array::codec::tag::peek_tag(&raw_msgpack);
134 assert_eq!(
135 decoded, None,
136 "legacy payload should yield None from peek_tag"
137 );
138
139 // Directly decode via zerompk to confirm the legacy path produces the
140 // same tile the new path would.
141 let recovered: SparseTile = zerompk::from_msgpack(&raw_msgpack).unwrap();
142 assert_eq!(recovered.surrogates, tile.surrogates);
143 assert_eq!(recovered.attr_cols, tile.attr_cols);
144}
145
146/// Test 3: Compression ratio — structural codec ≤ 30% of raw msgpack for a
147/// sorted 1k-cell coordinate-heavy tile.

Callers

nothing calls this directly

Calls 4

peek_tagFunction · 0.85
push_rowMethod · 0.80
simple_schemaFunction · 0.70
buildMethod · 0.45

Tested by

no test coverage detected