diff --git a/arrow/src/array/array_string.rs b/arrow/src/array/array_string.rs index d1826efaaed7..6af8bae073f9 100644 --- a/arrow/src/array/array_string.rs +++ b/arrow/src/array/array_string.rs @@ -137,34 +137,6 @@ impl GenericStringArray { Self::from(array_data) } - pub(crate) fn from_vec(v: Vec) -> Self - where - Ptr: AsRef, - { - let mut offsets = - MutableBuffer::new((v.len() + 1) * std::mem::size_of::()); - let mut values = MutableBuffer::new(0); - - let mut length_so_far = OffsetSize::zero(); - offsets.push(length_so_far); - - for s in &v { - length_so_far += OffsetSize::from_usize(s.as_ref().len()).unwrap(); - offsets.push(length_so_far); - values.extend_from_slice(s.as_ref().as_bytes()); - } - let array_data = ArrayData::builder(OffsetSize::DATA_TYPE) - .len(v.len()) - .add_buffer(offsets.into()) - .add_buffer(values.into()); - let array_data = unsafe { array_data.build_unchecked() }; - Self::from(array_data) - } - - pub(crate) fn from_opt_vec(v: Vec>) -> Self { - v.into_iter().collect() - } - /// Creates a `GenericStringArray` based on an iterator of values without nulls pub fn from_iter_values>(iter: I) -> Self where @@ -326,7 +298,7 @@ impl From>> for GenericStringArray { fn from(v: Vec>) -> Self { - GenericStringArray::::from_opt_vec(v) + v.into_iter().collect() } } @@ -334,7 +306,7 @@ impl From> for GenericStringArray { fn from(v: Vec<&str>) -> Self { - GenericStringArray::::from_vec(v) + GenericStringArray::::from_iter_values(v) } } @@ -342,7 +314,7 @@ impl From> for GenericStringArray { fn from(v: Vec) -> Self { - GenericStringArray::::from_vec(v) + GenericStringArray::::from_iter_values(v) } } diff --git a/arrow/src/array/equal/mod.rs b/arrow/src/array/equal/mod.rs index 742eeecd6d50..09ba0cd892b9 100644 --- a/arrow/src/array/equal/mod.rs +++ b/arrow/src/array/equal/mod.rs @@ -544,11 +544,9 @@ mod tests { let cases = binary_cases(); for (lhs, rhs, expected) in cases { - let lhs = lhs.iter().map(|x| x.as_deref()).collect(); - let rhs = rhs.iter().map(|x| x.as_deref()).collect(); - let lhs = GenericStringArray::::from_opt_vec(lhs); + let lhs: GenericStringArray = lhs.into_iter().collect(); let lhs = lhs.data(); - let rhs = GenericStringArray::::from_opt_vec(rhs); + let rhs: GenericStringArray = rhs.into_iter().collect(); let rhs = rhs.data(); test_equal(lhs, rhs, expected); }