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

Function do_read

arrow-json/src/reader/mod.rs:873–911  ·  view source on GitHub ↗
(
        buf: &str,
        batch_size: usize,
        coerce_primitive: bool,
        strict_mode: bool,
        schema: SchemaRef,
    )

Source from the content-addressed store, hash-verified

871 use super::*;
872
873 fn do_read(
874 buf: &str,
875 batch_size: usize,
876 coerce_primitive: bool,
877 strict_mode: bool,
878 schema: SchemaRef,
879 ) -> Vec<RecordBatch> {
880 let mut unbuffered = vec![];
881
882 // Test with different batch sizes to test for boundary conditions
883 for batch_size in [1, 3, 100, batch_size] {
884 unbuffered = ReaderBuilder::new(schema.clone())
885 .with_batch_size(batch_size)
886 .with_coerce_primitive(coerce_primitive)
887 .build(Cursor::new(buf.as_bytes()))
888 .unwrap()
889 .collect::<Result<Vec<_>, _>>()
890 .unwrap();
891
892 for b in unbuffered.iter().take(unbuffered.len() - 1) {
893 assert_eq!(b.num_rows(), batch_size)
894 }
895
896 // Test with different buffer sizes to test for boundary conditions
897 for b in [1, 3, 5] {
898 let buffered = ReaderBuilder::new(schema.clone())
899 .with_batch_size(batch_size)
900 .with_coerce_primitive(coerce_primitive)
901 .with_strict_mode(strict_mode)
902 .build(BufReader::with_capacity(b, Cursor::new(buf.as_bytes())))
903 .unwrap()
904 .collect::<Result<Vec<_>, _>>()
905 .unwrap();
906 assert_eq!(unbuffered, buffered);
907 }
908 }
909
910 unbuffered
911 }
912
913 #[test]
914 fn test_basic() {

Callers 15

test_basicFunction · 0.85
test_stringFunction · 0.85
test_complexFunction · 0.85
test_projectionFunction · 0.85
test_mapFunction · 0.85
test_decimalFunction · 0.85
test_timestampFunction · 0.85
test_timeFunction · 0.85

Calls 9

with_coerce_primitiveMethod · 0.80
buildMethod · 0.45
with_batch_sizeMethod · 0.45
cloneMethod · 0.45
as_bytesMethod · 0.45
takeMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45
with_strict_modeMethod · 0.45

Tested by 15

test_basicFunction · 0.68
test_stringFunction · 0.68
test_complexFunction · 0.68
test_projectionFunction · 0.68
test_mapFunction · 0.68
test_decimalFunction · 0.68
test_timestampFunction · 0.68
test_timeFunction · 0.68