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

Function test_binary_array_with_offsets

arrow-array/src/array/binary_array.rs:259–282  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

257
258 #[test]
259 fn test_binary_array_with_offsets() {
260 let values: [u8; 12] = [
261 b'h', b'e', b'l', b'l', b'o', b'p', b'a', b'r', b'q', b'u', b'e', b't',
262 ];
263 let offsets: [i32; 4] = [0, 5, 5, 12];
264
265 // Test binary array with offset
266 let array_data = ArrayData::builder(DataType::Binary)
267 .len(2)
268 .offset(1)
269 .add_buffer(Buffer::from_slice_ref(offsets))
270 .add_buffer(Buffer::from_slice_ref(values))
271 .build()
272 .unwrap();
273 let binary_array = BinaryArray::from(array_data);
274 assert_eq!(
275 [b'p', b'a', b'r', b'q', b'u', b'e', b't'],
276 binary_array.value(1)
277 );
278 assert_eq!(5, binary_array.value_offsets()[0]);
279 assert_eq!(0, binary_array.value_length(0));
280 assert_eq!(5, binary_array.value_offsets()[1]);
281 assert_eq!(7, binary_array.value_length(1));
282 }
283
284 #[test]
285 fn test_large_binary_array() {

Callers

nothing calls this directly

Calls 4

add_bufferMethod · 0.80
buildMethod · 0.45
offsetMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected