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

Function test_bounded

arrow-csv/src/reader/mod.rs:2123–2162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2121
2122 #[test]
2123 fn test_bounded() {
2124 let schema = Schema::new(vec![Field::new("int", DataType::UInt32, false)]);
2125 let data = [
2126 vec!["0"],
2127 vec!["1"],
2128 vec!["2"],
2129 vec!["3"],
2130 vec!["4"],
2131 vec!["5"],
2132 vec!["6"],
2133 ];
2134
2135 let data = data
2136 .iter()
2137 .map(|x| x.join(","))
2138 .collect::<Vec<_>>()
2139 .join("\n");
2140 let data = data.as_bytes();
2141
2142 let reader = std::io::Cursor::new(data);
2143
2144 let mut csv = ReaderBuilder::new(Arc::new(schema))
2145 .with_batch_size(2)
2146 .with_projection(vec![0])
2147 .with_bounds(2, 6)
2148 .build_buffered(reader)
2149 .unwrap();
2150
2151 let batch = csv.next().unwrap().unwrap();
2152 let a = batch.column(0);
2153 let a = a.as_any().downcast_ref::<UInt32Array>().unwrap();
2154 assert_eq!(a, &UInt32Array::from(vec![2, 3]));
2155
2156 let batch = csv.next().unwrap().unwrap();
2157 let a = batch.column(0);
2158 let a = a.as_any().downcast_ref::<UInt32Array>().unwrap();
2159 assert_eq!(a, &UInt32Array::from(vec![4, 5]));
2160
2161 assert!(csv.next().is_none());
2162 }
2163
2164 #[test]
2165 fn test_empty_projection() {

Callers

nothing calls this directly

Calls 10

joinMethod · 0.80
build_bufferedMethod · 0.80
with_boundsMethod · 0.80
iterMethod · 0.45
as_bytesMethod · 0.45
with_projectionMethod · 0.45
with_batch_sizeMethod · 0.45
nextMethod · 0.45
columnMethod · 0.45
as_anyMethod · 0.45

Tested by

no test coverage detected