Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typed dictionary (#2136) #2297

Merged
merged 3 commits into from
Aug 5, 2022
Merged

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Aug 3, 2022

Which issue does this PR close?

Closes #2136

Rationale for this change

What changes are included in this PR?

Adds a TypedDictionaryArray and provides a method to downcast a DictionaryArray to it

Are there any user-facing changes?

No

type IntoIter = ArrayIter<Self>;

fn into_iter(self) -> Self::IntoIter {
ArrayIter::new(self)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a nice example of how the composability of traits can be better than macros

self.keys().equals_json(json)
}
}

impl<'a, K: ArrowPrimitiveType, V> JsonEqual for TypedDictionaryArray<'a, K, V> {
Copy link
Contributor Author

@tustvold tustvold Aug 3, 2022

Choose a reason for hiding this comment

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

I created #2294 to track this issue and #2296 to suggest removing JsonEqual

@github-actions github-actions bot added the arrow Changes to the arrow crate label Aug 3, 2022
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

I think this is a great convenience. I suggest adding a pointer / mention in the DictionaryArray docstring

what do you think @jhorstmann and @viirya ?

arrow/src/array/array_dictionary.rs Show resolved Hide resolved
@alamb
Copy link
Contributor

alamb commented Aug 3, 2022

I recommend we hold off on merging this until other people have had a chance to look at it

cc @HaoYang670

@tustvold
Copy link
Contributor Author

tustvold commented Aug 4, 2022

#2322 now builds on top of this, showing a concrete use-case

@tustvold
Copy link
Contributor Author

tustvold commented Aug 5, 2022

I intend to merge this today, so that it can make the arrow 20 release. We can always revisit this in the future

#[derive(Copy, Clone)]
pub struct TypedDictionaryArray<'a, K: ArrowPrimitiveType, V> {
/// The dictionary array
pub dictionary: &'a DictionaryArray<K>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the late.
I prefer to name it base, but never mind, this is really a small tip.
LGTM!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted to make these private for now, so we can always rename them later

@tustvold tustvold merged commit 4a3919b into apache:master Aug 5, 2022
@ursabot
Copy link

ursabot commented Aug 5, 2022

Benchmark runs are scheduled for baseline = b6eaf22 and contender = 4a3919b. 4a3919b is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add TypedDictionaryArray for more ergonomic interaction with DictionaryArray
5 participants