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

Function generic_string_with_non_zero_offset

arrow-string/src/substring.rs:762–790  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

760 }
761
762 fn generic_string_with_non_zero_offset<O: OffsetSizeTrait>() {
763 let values = b"hellotherearrow";
764 let offsets = &[
765 O::zero(),
766 O::from_usize(5).unwrap(),
767 O::from_usize(10).unwrap(),
768 O::from_usize(15).unwrap(),
769 ];
770 // set the first and third element to be valid
771 let bitmap = [0b101_u8];
772
773 let offsets = OffsetBuffer::new(Buffer::from_slice_ref(offsets).into());
774 let values = Buffer::from(values);
775 let nulls = Some(NullBuffer::new(BooleanBuffer::new(
776 Buffer::from(bitmap),
777 0,
778 3,
779 )));
780 // array is `[null, "arrow"]`
781 let array = GenericStringArray::<O>::new(offsets, values, nulls).slice(1, 2);
782 // result is `[null, "rrow"]`
783 let result = substring(&array, 1, None).unwrap();
784 let result = result
785 .as_any()
786 .downcast_ref::<GenericStringArray<O>>()
787 .unwrap();
788 let expected = GenericStringArray::<O>::from(vec![None, Some("rrow")]);
789 assert_eq!(result, &expected);
790 }
791
792 #[test]
793 fn string_with_non_zero_offset() {

Callers

nothing calls this directly

Calls 3

substringFunction · 0.70
sliceMethod · 0.45
as_anyMethod · 0.45

Tested by

no test coverage detected