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

Function test_offset_buffer_pad_nulls

parquet/src/arrow/buffer/offset_buffer.rs:258–291  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

256
257 #[test]
258 fn test_offset_buffer_pad_nulls() {
259 let mut buffer = OffsetBuffer::<i32>::with_capacity(0);
260 let values = ["a", "b", "c", "def", "gh"];
261 for v in &values {
262 buffer.try_push(v.as_bytes(), false).unwrap()
263 }
264
265 let valid = [
266 true, false, false, true, false, true, false, true, true, false, false,
267 ];
268 let valid_mask = Buffer::from_iter(valid.iter().copied());
269
270 // Both trailing and leading nulls
271 buffer.pad_nulls(1, values.len() - 1, valid.len() - 1, valid_mask.as_slice());
272
273 let array = buffer.into_array(Some(valid_mask), ArrowType::Utf8);
274 let strings = array.as_any().downcast_ref::<StringArray>().unwrap();
275 assert_eq!(
276 strings.iter().collect::<Vec<_>>(),
277 vec![
278 Some("a"),
279 None,
280 None,
281 Some("b"),
282 None,
283 Some("c"),
284 None,
285 Some("def"),
286 Some("gh"),
287 None,
288 None
289 ]
290 );
291 }
292
293 #[test]
294 fn test_utf8_validation() {

Callers

nothing calls this directly

Calls 9

try_pushMethod · 0.80
from_iterFunction · 0.50
as_bytesMethod · 0.45
iterMethod · 0.45
pad_nullsMethod · 0.45
lenMethod · 0.45
as_sliceMethod · 0.45
into_arrayMethod · 0.45
as_anyMethod · 0.45

Tested by

no test coverage detected