MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / small_zero_width_record_array_decodes

Function small_zero_width_record_array_decodes

src/avro/src/decode.rs:345–373  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

343
344 #[mz_ore::test]
345 fn small_zero_width_record_array_decodes() {
346 // The node cap must not reject an ordinary, below-cap array of zero-width
347 // records: ten `record{null}`s encode (like `array<null>`) as just the
348 // block count followed by the terminating zero block.
349 use std::str::FromStr;
350
351 use super::{AvroDeserializer, GeneralDeserializer};
352 use crate::types::Value;
353 use crate::util::zig_i64;
354 use crate::{Schema, ValueDecoder};
355
356 let schema = Schema::from_str(
357 r#"{"type": "array", "items":
358 {"type": "record", "name": "R", "fields": [{"name": "g0", "type": "null"}]}}"#,
359 )
360 .unwrap();
361 let mut body = Vec::new();
362 zig_i64(10, &mut body);
363 body.push(0);
364 let dsr = GeneralDeserializer {
365 schema: schema.top_node(),
366 };
367 let mut reader: &[u8] = &body;
368 let decoded = dsr
369 .deserialize(&mut reader, ValueDecoder)
370 .expect("a below-cap array of zero-width records must decode, not be rejected");
371 let want = Value::Record(vec![("g0".to_string(), Value::Null)]);
372 assert_eq!(decoded, Value::Array(vec![want; 10]));
373 }
374
375 #[mz_ore::test]
376 fn nested_zero_width_collection_shares_node_budget() {

Callers

nothing calls this directly

Calls 7

zig_i64Function · 0.85
unwrapMethod · 0.80
top_nodeMethod · 0.80
expectMethod · 0.80
RecordClass · 0.70
pushMethod · 0.45
deserializeMethod · 0.45

Tested by

no test coverage detected