MCPcopy Create free account
hub / github.com/apache/arrow-rs / assert_binary_json_with_writer

Function assert_binary_json_with_writer

arrow-json/src/lib.rs:325–347  ·  view source on GitHub ↗
(array: ArrayRef, builder: WriterBuilder)

Source from the content-addressed store, hash-verified

323 }
324
325 fn assert_binary_json_with_writer(array: ArrayRef, builder: WriterBuilder) {
326 let batch = RecordBatch::try_from_iter([("bytes", array)]).unwrap();
327
328 let mut buf = Vec::new();
329 let json_value: Value = {
330 let mut writer = builder.build::<_, JsonArray>(&mut buf);
331 writer.write(&batch).unwrap();
332 writer.close().unwrap();
333 serde_json::from_slice(&buf).unwrap()
334 };
335
336 let json_array = json_value.as_array().unwrap();
337
338 let decoded = {
339 let mut decoder = ReaderBuilder::new(batch.schema().clone())
340 .build_decoder()
341 .unwrap();
342 decoder.serialize(json_array).unwrap();
343 decoder.flush().unwrap().unwrap()
344 };
345
346 assert_eq!(batch, decoded);
347 }
348
349 fn assert_list_view_roundtrip<O: arrow_array::OffsetSizeTrait>() {
350 let flat_field = Arc::new(Field::new("item", DataType::Int32, true));

Callers 1

assert_binary_jsonFunction · 0.85

Calls 8

from_sliceFunction · 0.85
writeMethod · 0.45
closeMethod · 0.45
build_decoderMethod · 0.45
cloneMethod · 0.45
schemaMethod · 0.45
serializeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected