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 a small doc example showing ArrowWriter being used with a cursor #1927

Closed
msalib opened this issue Jun 23, 2022 · 1 comment · Fixed by #1930
Closed

add a small doc example showing ArrowWriter being used with a cursor #1927

msalib opened this issue Jun 23, 2022 · 1 comment · Fixed by #1930
Assignees
Labels
documentation Improvements or additions to documentation enhancement Any new improvement worthy of a entry in the changelog good first issue Good for newcomers parquet Changes to the parquet crate

Comments

@msalib
Copy link
Contributor

msalib commented Jun 23, 2022

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

Now (as of version 15.0) that we can use std::io::Writer implementers with parquet::arrow::arrow_writer::ArrowWriter, we can just use std::io::Cursor instead of the now deleted InMemoryWriteableCursor. But there are no docs or examples of how to do that.

Describe the solution you'd like
I'd love to see just a tiny doc example showing that use case, something like this:

fn batch_to_bytes(batch: &RecordBatch) -> Result<Vec<u8>> {
    let mut buffer = std::io::Cursor::new(vec![]);
    let mut writer = ArrowWriter::try_new(&mut buffer, batch.schema(), None)?;
    writer.write(&batch)?;
    writer.close()?;
    Ok(buffer.into_inner())
}
@msalib msalib added the enhancement Any new improvement worthy of a entry in the changelog label Jun 23, 2022
@alamb alamb added good first issue Good for newcomers documentation Improvements or additions to documentation labels Jun 23, 2022
@tustvold
Copy link
Contributor

tustvold commented Jun 23, 2022

InMemoryWriteableCursor still exists it is just deprecated? You also can just use std::Vec directly, as suggested by the deprecation message?

fn batch_to_bytes(batch: &RecordBatch) -> Result<Vec<u8>> {
    let mut buffer = Vec::new();
    let mut writer = ArrowWriter::try_new(&mut buffer, batch.schema(), None)?;
    writer.write(&batch)?;
    writer.close()?;
    Ok(buffer)
}

@tustvold tustvold self-assigned this Jun 23, 2022
tustvold added a commit to tustvold/arrow-rs that referenced this issue Jun 23, 2022
tustvold added a commit to tustvold/arrow-rs that referenced this issue Jun 23, 2022
@alamb alamb added arrow Changes to the arrow crate parquet Changes to the parquet crate and removed arrow Changes to the arrow crate labels Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement Any new improvement worthy of a entry in the changelog good first issue Good for newcomers parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants