@@ -316,6 +316,29 @@ impl<T: BinaryOffsetSizeTrait> From<GenericListArray<T>> for GenericBinaryArray<
316316}
317317
318318/// A type of `FixedSizeListArray` whose elements are binaries.
319+ ///
320+ /// # Examples
321+ ///
322+ /// Create an array from an iterable argument of byte slices.
323+ ///
324+ /// ```
325+ /// use arrow::array::{Array, FixedSizeBinaryArray};
326+ /// let input_arg = vec![ vec![1, 2], vec![3, 4], vec![5, 6] ];
327+ /// let arr = FixedSizeBinaryArray::try_from_iter(input_arg.into_iter()).unwrap();
328+ ///
329+ /// assert_eq!(3, arr.len());
330+ ///
331+ /// ```
332+ /// Create an array from an iterable argument of sparse byte slices.
333+ /// Sparsity means that the input argument can contain `None` items.
334+ /// ```
335+ /// use arrow::array::{Array, FixedSizeBinaryArray};
336+ /// let input_arg = vec![ None, Some(vec![7, 8]), Some(vec![9, 10]), None, Some(vec![13, 14]) ];
337+ /// let arr = FixedSizeBinaryArray::try_from_sparse_iter(input_arg.into_iter()).unwrap();
338+ /// assert_eq!(5, arr.len())
339+ ///
340+ /// ```
341+ ///
319342pub struct FixedSizeBinaryArray {
320343 data : ArrayData ,
321344 value_data : RawPtrBox < u8 > ,
@@ -364,7 +387,7 @@ impl FixedSizeBinaryArray {
364387 /// Sparsity means that items returned by the iterator are optional, i.e input argument can
365388 /// contain `None` items.
366389 ///
367- /// # Examles
390+ /// # Examples
368391 ///
369392 /// ```
370393 /// use arrow::array::FixedSizeBinaryArray;
@@ -449,7 +472,7 @@ impl FixedSizeBinaryArray {
449472
450473 /// Create an array from an iterable argument of byte slices.
451474 ///
452- /// # Examles
475+ /// # Examples
453476 ///
454477 /// ```
455478 /// use arrow::array::FixedSizeBinaryArray;
@@ -1154,4 +1177,28 @@ mod tests {
11541177 format!( "{:?}" , arr)
11551178 ) ;
11561179 }
1180+
1181+ #[ test]
1182+ fn test_fixed_size_binary_array_from_iter ( ) {
1183+ let input_arg = vec ! [ vec![ 1 , 2 ] , vec![ 3 , 4 ] , vec![ 5 , 6 ] ] ;
1184+ let arr = FixedSizeBinaryArray :: try_from_iter ( input_arg. into_iter ( ) ) . unwrap ( ) ;
1185+
1186+ assert_eq ! ( 2 , arr. value_length( ) ) ;
1187+ assert_eq ! ( 3 , arr. len( ) )
1188+ }
1189+
1190+ #[ test]
1191+ fn test_fixed_size_binary_array_from_sparse_iter ( ) {
1192+ let input_arg = vec ! [
1193+ None ,
1194+ Some ( vec![ 7 , 8 ] ) ,
1195+ Some ( vec![ 9 , 10 ] ) ,
1196+ None ,
1197+ Some ( vec![ 13 , 14 ] ) ,
1198+ ] ;
1199+ let arr =
1200+ FixedSizeBinaryArray :: try_from_sparse_iter ( input_arg. into_iter ( ) ) . unwrap ( ) ;
1201+ assert_eq ! ( 2 , arr. value_length( ) ) ;
1202+ assert_eq ! ( 5 , arr. len( ) )
1203+ }
11571204}
0 commit comments