Skip to content

Commit d01f48b

Browse files
committed
test: demostrate that we already have the iterators implemented
1 parent 4a0bdde commit d01f48b

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

arrow-array/src/array/byte_array.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ impl<T: ByteArrayType> From<GenericByteArray<T>> for ArrayData {
544544
}
545545
}
546546

547+
/// This does the into_iter() for &'a GenericByteArray<T>
547548
impl<'a, T: ByteArrayType> IntoIterator for &'a GenericByteArray<T> {
548549
type Item = Option<&'a T::Native>;
549550
type IntoIter = ArrayIter<Self>;

arrow-array/src/array/byte_view_array.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ impl<'a, T: ByteViewType + ?Sized> ArrayAccessor for &'a GenericByteViewArray<T>
623623
}
624624
}
625625

626+
/// This does the into_iter() for &'a GenericByteViewArray<T>
626627
impl<'a, T: ByteViewType + ?Sized> IntoIterator for &'a GenericByteViewArray<T> {
627628
type Item = Option<&'a T::Native>;
628629
type IntoIter = ArrayIter<Self>;

arrow-array/src/array/fixed_size_binary_array.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ impl<'a> ArrayAccessor for &'a FixedSizeBinaryArray {
648648
}
649649
}
650650

651+
/// This does the into_iter() for &'a FixedSizeBinaryArray
651652
impl<'a> IntoIterator for &'a FixedSizeBinaryArray {
652653
type Item = Option<&'a [u8]>;
653654
type IntoIter = FixedSizeBinaryIter<'a>;

arrow-array/src/array/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,4 +1248,29 @@ mod tests {
12481248
let expected: Int32Array = vec![1, 2, 3].into_iter().map(Some).collect();
12491249
assert_eq!(array, expected);
12501250
}
1251+
1252+
use crate::builder::{BinaryViewBuilder, FixedSizeBinaryBuilder};
1253+
use crate::ArrayAccessor;
1254+
1255+
fn use_binary_array<'a>(array: impl ArrayAccessor<Item = &'a [u8]>) {
1256+
// Have to manually iterate over the array
1257+
for i in 0..array.len() {
1258+
dbg!(String::from_utf8(array.value(i).to_vec()).unwrap());
1259+
}
1260+
}
1261+
1262+
#[test]
1263+
fn binary_array() {
1264+
let mut builder = BinaryViewBuilder::new();
1265+
builder.append_value(b"foo");
1266+
builder.append_value(b"bar");
1267+
builder.append_value(b"baz");
1268+
use_binary_array(&builder.finish());
1269+
1270+
let mut builder = FixedSizeBinaryBuilder::new(3);
1271+
builder.append_value(b"foo").unwrap();
1272+
builder.append_value(b"bar").unwrap();
1273+
builder.append_value(b"baz").unwrap();
1274+
use_binary_array(&builder.finish());
1275+
}
12511276
}

0 commit comments

Comments
 (0)