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

API improvement: batches_to_flight_data forces clone #4656

Closed
amunra opened this issue Aug 7, 2023 · 1 comment · Fixed by #4665
Closed

API improvement: batches_to_flight_data forces clone #4656

amunra opened this issue Aug 7, 2023 · 1 comment · Fixed by #4665
Labels
api-change Changes to the arrow API arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog

Comments

@amunra
Copy link

amunra commented Aug 7, 2023

The API is pretty inconsistent, sometimes requiring a Schema and sometimes a SchemaRef.

For example I hold a SchemaRef, but batches_to_flight_data requires a Schema, forcing me to create a clone of the ref counted object.

Instead, the function should just take a &Schema.

pub fn batches_to_flight_data(
    schema: Schema,
    batches: Vec<RecordBatch>,
) -> Result<Vec<FlightData>, ArrowError> {
    let options = IpcWriteOptions::default();
    let schema_flight_data: FlightData = SchemaAsIpc::new(&schema, &options).into();
                                                          ^___ it's borrowed later anyways!
@amunra amunra added the bug label Aug 7, 2023
@jackwener jackwener changed the title API bug: batches_to_flight_data forces clone API improvement: batches_to_flight_data forces clone Aug 8, 2023
@jackwener jackwener added enhancement Any new improvement worthy of a entry in the changelog api-change Changes to the arrow API and removed bug labels Aug 8, 2023
@jackwener
Copy link
Member

Make sense to me

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 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