Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

take list: do not collect array of pointers #229

Closed
wants to merge 1 commit into from

Conversation

ritchie46
Copy link
Collaborator

This PR proposes a new constructor method on GrowableList. This constructor is generic over &[AsRef[ListArray<O>> and can be constructed with an array over ListArray.

This removes a redundant vector allocation in the take kernel, where a Vec<ListArray> was converted to a Vec<&dyn Array> so that it could be passed to the constructor.

@codecov
Copy link

codecov bot commented Jul 26, 2021

Codecov Report

Merging #229 (edbaead) into main (7dd1cff) will increase coverage by 0.01%.
The diff coverage is 95.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #229      +/-   ##
==========================================
+ Coverage   76.93%   76.94%   +0.01%     
==========================================
  Files         229      229              
  Lines       19529    19542      +13     
==========================================
+ Hits        15025    15037      +12     
- Misses       4504     4505       +1     
Impacted Files Coverage Δ
src/compute/take/list.rs 99.06% <75.00%> (-0.94%) ⬇️
src/array/growable/list.rs 98.54% <100.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7dd1cff...edbaead. Read the comment docs.

.collect::<Vec<_>>();
Self::finish_new(arrays, inner, extend_null_bits, capacity, use_validity)
}

/// # Panics
/// This function panics if any of the `arrays` is not downcastable to `PrimitiveArray<T>`.
pub fn new(arrays: &[&'a dyn Array], mut use_validity: bool, capacity: usize) -> Self {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should make this expect a ListArray instead of &dyn Array. No need for two functions just because of a downcast, and this also makes it more explicit that there is an expectation.

fwiw, this signature is historical; e.g. GrowablePrimitive uses PrimitiveArray already.

@jorgecarleitao
Copy link
Owner

I will go ahead and change all signatures in growable to make this consistent across and avoid the extra allocation altogether.

@jorgecarleitao
Copy link
Owner

Proposal in #238

@jorgecarleitao
Copy link
Owner

I am closing this one since it was generalized by #238. Thanks a lot for the proposal, @ritchie46 !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants