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

Function test_offset_buffer

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

Source from the content-addressed store, hash-verified

232
233 #[test]
234 fn test_offset_buffer() {
235 let mut buffer = OffsetBuffer::<i32>::with_capacity(0);
236 for v in ["hello", "world", "cupcakes", "a", "b", "c"] {
237 buffer.try_push(v.as_bytes(), false).unwrap()
238 }
239 let split = std::mem::replace(&mut buffer, OffsetBuffer::with_capacity(0));
240
241 let array = split.into_array(None, ArrowType::Utf8);
242 let strings = array.as_any().downcast_ref::<StringArray>().unwrap();
243 assert_eq!(
244 strings.iter().map(|x| x.unwrap()).collect::<Vec<_>>(),
245 vec!["hello", "world", "cupcakes", "a", "b", "c"]
246 );
247
248 buffer.try_push("test".as_bytes(), false).unwrap();
249 let array = buffer.into_array(None, ArrowType::Utf8);
250 let strings = array.as_any().downcast_ref::<StringArray>().unwrap();
251 assert_eq!(
252 strings.iter().map(|x| x.unwrap()).collect::<Vec<_>>(),
253 vec!["test"]
254 );
255 }
256
257 #[test]
258 fn test_offset_buffer_pad_nulls() {

Callers

nothing calls this directly

Calls 4

try_pushMethod · 0.80
as_bytesMethod · 0.45
into_arrayMethod · 0.45
as_anyMethod · 0.45

Tested by

no test coverage detected