Skip to content

Commit f0f6128

Browse files
authored
chore: update OffsetBuffer::from_lengths(std::iter::repeat_n(<val>, <repeat>)); with OffsetBuffer::from_repeated_length(<val>, <repeat>); (#8669)
# Which issue does this PR close? N/A # Rationale for this change Use the dedicated faster function for creating offset with the same length # What changes are included in this PR? replace ```rust OffsetBuffer::from_lengths(std::iter::repeat_n(<val>, <repeat>)); ``` with ```rust OffsetBuffer::from_repeated_length(<val>, <repeat>); ``` # Are these changes tested? Existing tests # Are there any user-facing changes? Nope ---- Related to: - #8656
1 parent c74cbf2 commit f0f6128

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

arrow-cast/src/cast/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(crate) fn cast_values_to_list<O: OffsetSizeTrait>(
2424
cast_options: &CastOptions,
2525
) -> Result<ArrayRef, ArrowError> {
2626
let values = cast_with_options(array, to.data_type(), cast_options)?;
27-
let offsets = OffsetBuffer::from_lengths(std::iter::repeat_n(1, values.len()));
27+
let offsets = OffsetBuffer::from_repeated_length(1, values.len());
2828
let list = GenericListArray::<O>::try_new(to.clone(), offsets, values, None)?;
2929
Ok(Arc::new(list))
3030
}

arrow-cast/src/cast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,7 @@ fn cast_numeric_to_binary<FROM: ArrowPrimitiveType, O: OffsetSizeTrait>(
23812381
) -> Result<ArrayRef, ArrowError> {
23822382
let array = array.as_primitive::<FROM>();
23832383
let size = std::mem::size_of::<FROM::Native>();
2384-
let offsets = OffsetBuffer::from_lengths(std::iter::repeat_n(size, array.len()));
2384+
let offsets = OffsetBuffer::from_repeated_length(size, array.len());
23852385
Ok(Arc::new(GenericBinaryArray::<O>::try_new(
23862386
offsets,
23872387
array.values().inner().clone(),

0 commit comments

Comments
 (0)