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 ArrayBuilder::finish_cloned() #3154

Closed
tustvold opened this issue Nov 21, 2022 · 3 comments · Fixed by #3158
Closed

Add ArrayBuilder::finish_cloned() #3154

tustvold opened this issue Nov 21, 2022 · 3 comments · Fixed by #3158
Assignees
Labels
arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog

Comments

@tustvold
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

The various array builders, provide a finish method which consumes the buffers, resetting the builder in the process.

When implementing a write path it is common to want to be able to "snapshot" a builder into an immutable Array for query, whilst retaining the builder state to allow for subsequent updates.

Describe the solution you'd like

Add a ArrayBuilder::finish_cloned() method that instead of consuming the buffers, clones the values.

i.e.

let mut builder = Int32Builder::new();
builder.append_value(23);
builder.append_value(45);
assert_eq!(builder.finish_cloned(), Int32Array::from(vec![23, 45]));
builder.append_value(56);
assert_eq!(builder.finish_cloned(), Int32Array::from(vec![23, 45, 56]));

Describe alternatives you've considered

Additional context

@tustvold tustvold added the enhancement Any new improvement worthy of a entry in the changelog label Nov 21, 2022
@askoa
Copy link
Contributor

askoa commented Nov 22, 2022

I'll pick this one.

Edit: I would like to submit a draft PR with small change and get comments before proceeding with all required changes.

@askoa
Copy link
Contributor

askoa commented Nov 22, 2022

@tustvold Can you take a look at the draft commit and let me know if I can extend the changes to all array builders?

@alamb
Copy link
Contributor

alamb commented Nov 25, 2022

label_issue.py automatically added labels {'arrow'} from #3158

@alamb alamb added the arrow Changes to the arrow crate label Nov 25, 2022
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 enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants