Skip to content

Do not use lifetime on FileWriter#820

Merged
eddyxu merged 1 commit intomainfrom
lei/writer_no_lifetime
May 2, 2023
Merged

Do not use lifetime on FileWriter#820
eddyxu merged 1 commit intomainfrom
lei/writer_no_lifetime

Conversation

@eddyxu
Copy link
Copy Markdown
Member

@eddyxu eddyxu commented May 2, 2023

Remove lifetime from FileWriter, because the pyo3 can not hold a struct with lifetime

@eddyxu eddyxu requested review from changhiskhan and gsilvestrin and removed request for gsilvestrin May 2, 2023 04:09
Comment thread rust/src/io/writer.rs
let arrs: Result<Vec<_>> = batch
pub async fn write(&mut self, batches: &[&RecordBatch]) -> Result<()> {
// Copy a list of fields to avoid borrow checker error.
let fields = self
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't understand why tho the code doesn't seem to modify the fields?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, so self.schema has a immuntable reference to self, but later it needs mutable reference self to call self.write_array

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Leave a comment here, in case some Rust guru knows how to do it better later.

@eddyxu eddyxu merged commit d4c9e38 into main May 2, 2023
@eddyxu eddyxu deleted the lei/writer_no_lifetime branch May 2, 2023 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants