Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
IPC writer: take owned schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 16, 2023
1 parent 211be21 commit 017a9bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions examples/ipc_file_mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ fn write(
) -> Result<Vec<u8>, Error> {
let result = vec![];
let options = arrow2::io::ipc::write::WriteOptions { compression };
let mut writer =
arrow2::io::ipc::write::FileWriter::try_new(result, schema, ipc_fields.clone(), options)?;
let mut writer = arrow2::io::ipc::write::FileWriter::try_new(
result,
schema.clone(),
ipc_fields.clone(),
options,
)?;
for chunk in chunks {
writer.write(chunk, ipc_fields.as_ref().map(|x| x.as_ref()))?;
}
Expand Down
4 changes: 2 additions & 2 deletions src/io/ipc/write/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ impl<W: Write> FileWriter<W> {
/// Creates a new [`FileWriter`] and writes the header to `writer`
pub fn try_new(
writer: W,
schema: &Schema,
schema: Schema,
ipc_fields: Option<Vec<IpcField>>,
options: WriteOptions,
) -> Result<Self> {
let mut slf = Self::new(writer, schema.clone(), ipc_fields, options);
let mut slf = Self::new(writer, schema, ipc_fields, options);
slf.start()?;

Ok(slf)
Expand Down
2 changes: 1 addition & 1 deletion tests/it/io/ipc/write/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) fn write(
) -> Result<Vec<u8>> {
let result = vec![];
let options = WriteOptions { compression };
let mut writer = FileWriter::try_new(result, schema, ipc_fields.clone(), options)?;
let mut writer = FileWriter::try_new(result, schema.clone(), ipc_fields.clone(), options)?;
for batch in batches {
writer.write(batch, ipc_fields.as_ref().map(|x| x.as_ref()))?;
}
Expand Down

0 comments on commit 017a9bf

Please sign in to comment.