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

Simplify DictionaryBuilder constructors (#2684) (#2054) #2685

Merged
merged 3 commits into from Sep 8, 2022

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Sep 8, 2022

Which issue does this PR close?

Closes #2684
Part of #2054

Rationale for this change

The previous constructors were confusing, unnecessarily verbose, and allowed creating invalid DictionaryArrays by passing in a non-empty keys builder

What changes are included in this PR?

Are there any user-facing changes?

Yes

@tustvold tustvold added the api-change Changes to the arrow API label Sep 8, 2022
@tustvold tustvold requested a review from viirya September 8, 2022 12:17
@github-actions github-actions bot added arrow Changes to the arrow crate parquet Changes to the parquet crate labels Sep 8, 2022
values_builder: StringBuilder::with_capacity(value_capacity, string_capacity),
}
}

/// Creates a new `StringDictionaryBuilder` from a keys builder and a dictionary
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Creates a new `StringDictionaryBuilder` from a keys builder and a dictionary
/// Creates a new `StringDictionaryBuilder` from a keys capacity and a dictionary

Comment on lines +112 to +115
pub fn new() -> Self {
Self {
keys_builder,
values_builder,
keys_builder: PrimitiveBuilder::new(),
values_builder: PrimitiveBuilder::new(),
Copy link
Member

@viirya viirya Sep 8, 2022

Choose a reason for hiding this comment

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

Although I think the updated API is more clear, I just wonder if the issue is provided key builder might be not empty, we can check the length of the key builder when it is passed in? The API could be unchanged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure, however, I'd argue it is a good opportunity to bring this API closer into alignment with the other builders. We don't require passing the various different inner builders to StringArray, for example. The only other place we do is ListArray, which again I think is a little odd.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Yea, it is somehow weird to provide key and value builders from outside of these dictionary builder.

Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>
@tustvold tustvold merged commit 5e2b4c7 into apache:master Sep 8, 2022
@ursabot
Copy link

ursabot commented Sep 8, 2022

Benchmark runs are scheduled for baseline = 2ee09bb and contender = 5e2b4c7. 5e2b4c7 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

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

Successfully merging this pull request may close these issues.

DictionaryBuilders can Create Invalid DictionaryArrays
3 participants