()
| 2645 | |
| 2646 | #[test] |
| 2647 | fn test_json_iterator() { |
| 2648 | let file = File::open("test/data/basic.json").unwrap(); |
| 2649 | let mut reader = BufReader::new(file); |
| 2650 | let (schema, _) = infer_json_schema(&mut reader, None).unwrap(); |
| 2651 | reader.rewind().unwrap(); |
| 2652 | |
| 2653 | let builder = ReaderBuilder::new(Arc::new(schema)).with_batch_size(5); |
| 2654 | let reader = builder.build(reader).unwrap(); |
| 2655 | let schema = reader.schema(); |
| 2656 | let (col_a_index, _) = schema.column_with_name("a").unwrap(); |
| 2657 | |
| 2658 | let mut sum_num_rows = 0; |
| 2659 | let mut num_batches = 0; |
| 2660 | let mut sum_a = 0; |
| 2661 | for batch in reader { |
| 2662 | let batch = batch.unwrap(); |
| 2663 | assert_eq!(8, batch.num_columns()); |
| 2664 | sum_num_rows += batch.num_rows(); |
| 2665 | num_batches += 1; |
| 2666 | let batch_schema = batch.schema(); |
| 2667 | assert_eq!(schema, batch_schema); |
| 2668 | let a_array = batch.column(col_a_index).as_primitive::<Int64Type>(); |
| 2669 | sum_a += (0..a_array.len()).map(|i| a_array.value(i)).sum::<i64>(); |
| 2670 | } |
| 2671 | assert_eq!(12, sum_num_rows); |
| 2672 | assert_eq!(3, num_batches); |
| 2673 | assert_eq!(100000000000011, sum_a); |
| 2674 | } |
| 2675 | |
| 2676 | #[test] |
| 2677 | fn test_decoder_error() { |
nothing calls this directly
no test coverage detected