From 66fb4123782a6957406bb377bc56fa2cf48236bc Mon Sep 17 00:00:00 2001 From: James Corbett Date: Wed, 30 Mar 2022 10:16:44 +0100 Subject: [PATCH] Adding size defaulting --- arrow/src/array/array_binary.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arrow/src/array/array_binary.rs b/arrow/src/array/array_binary.rs index a5decc21bc5f..900dba05db6a 100644 --- a/arrow/src/array/array_binary.rs +++ b/arrow/src/array/array_binary.rs @@ -531,7 +531,18 @@ impl FixedSizeBinaryArray { /// # Errors /// /// Returns error if argument has length zero, or sizes of nested slices don't match. - pub fn try_from_sparse_iter(mut iter: T) -> Result + pub fn try_from_sparse_iter(iter: T) -> Result + where + T: Iterator>, + U: AsRef<[u8]>, + { + Self::try_from_sparse_iter_sized(iter, 0) + } + + pub fn try_from_sparse_iter_sized( + mut iter: T, + default_size: usize, + ) -> Result where T: Iterator>, U: AsRef<[u8]>, @@ -583,7 +594,7 @@ impl FixedSizeBinaryArray { )); } - let size = size.unwrap_or(0); + let size = size.unwrap_or(default_size); let array_data = unsafe { ArrayData::new_unchecked( DataType::FixedSizeBinary(size as i32),