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

Commit

Permalink
No unwraps and other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HagaiHargil committed Oct 17, 2021
1 parent eb51cbc commit f373afa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/io/ipc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@
//! # use arrow2::datatypes::{Field, Schema, DataType};
//! # use arrow2::array::Int32Array;
//! # use arrow2::record_batch::RecordBatch;
//! # use arrow2::error::ArrowError;
//! // Setup the writer
//! let path = "example.arrow".to_string();
//! let mut file = File::create(&path).unwrap();
//! let mut file = File::create(&path)?;
//! let x_coord = Field::new("x", DataType::Int32, false);
//! let y_coord = Field::new("y", DataType::Int32, false);
//! let schema = Schema::new(vec![x_coord, y_coord]);
//! let mut writer = FileWriter::try_new(file, &schema).unwrap();
//! let mut writer = FileWriter::try_new(file, &schema)?;
//!
//! // Setup the data
//! let x_data = Int32Array::from_slice([-1i32, 1]);
//! let y_data = Int32Array::from_slice([1i32, -1]);
//! let batch = RecordBatch::try_new(
//! Arc::new(schema),
//! vec![Arc::new(x_data), Arc::new(y_data)]
//! ).unwrap();
//! )?;
//!
//! // Write the messages and finalize the stream
//! for _ in 0..5 {
Expand All @@ -59,14 +60,14 @@
//! writer.finish();
//!
//! // Fetch some of the data and get the reader back
//! let mut reader = File::open(&path).unwrap();
//! let metadata = read_file_metadata(&mut reader).unwrap();
//! let mut reader = File::open(&path)?;
//! let metadata = read_file_metadata(&mut reader)?;
//! let mut filereader = FileReader::new(reader, metadata, None);
//! let row1 = filereader.next().unwrap(); // [[-1, 1], [1, -1]]
//! let row2 = filereader.next().unwrap(); // [[-1, 1], [1, -1]]
//! let mut reader = filereader.into_inner();
//! // Do more stuff with the reader, like seeking ahead.
//!
//! # Ok::<(), ArrowError>(())
//! ```
//!
//! For further information and examples please consult the
Expand Down
3 changes: 1 addition & 2 deletions src/io/ipc/read/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ pub fn read_next<R: Read>(
/// An [`Iterator`] over an Arrow stream that yields a result of [`StreamState`]s.
/// This is the recommended way to read an arrow stream (by iterating over its data).
///
/// For a full usage examples consult [this](https://github.com/jorgecarleitao/arrow2/tree/main/examples/ipc_pyarrow)
/// example in the main repository.
/// For a more thorough walkthrough consult [this example](https://github.com/jorgecarleitao/arrow2/tree/main/examples/ipc_pyarrow).
pub struct StreamReader<R: Read> {
reader: R,
metadata: StreamMetadata,
Expand Down
2 changes: 2 additions & 0 deletions src/io/ipc/write/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ use crate::record_batch::RecordBatch;
///
/// The data written by this writer must be read in order. To signal that no more
/// data is arriving through the stream call [`self.finish()`](StreamWriter::finish);
///
/// For a usage walkthrough consult [this example](https://github.com/jorgecarleitao/arrow2/tree/main/examples/ipc_pyarrow).
pub struct StreamWriter<W: Write> {
/// The object to write to
writer: BufWriter<W>,
Expand Down

0 comments on commit f373afa

Please sign in to comment.