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

Improve JSON reader documentation #1559

Merged
merged 2 commits into from
Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions arrow/src/json/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,11 @@ where
generate_schema(field_types)
}

/// JSON values to Arrow record batch decoder. Decoder's next_batch method takes a JSON Value
/// iterator as input and outputs Arrow record batch.
/// JSON values to Arrow record batch decoder.
///
/// A [`Decoder`] decodes arbitrary streams of [`serde_json::Value`]s and
/// converts them to [`RecordBatch`]es. To decode JSON formatted files,
/// see [`Reader`].
///
/// # Examples
/// ```
Expand Down Expand Up @@ -635,8 +638,9 @@ impl DecoderOptions {
}

impl Decoder {
/// Create a new JSON decoder from any value that implements the `Iterator<Item=Result<Value>>`
/// trait.
/// Create a new JSON decoder from some value that implements an
/// iterator over [`serde_json::Value`]s (aka implements the
/// `Iterator<Item=Result<Value>>` trait).
pub fn new(schema: SchemaRef, options: DecoderOptions) -> Self {
Self { schema, options }
}
Expand Down Expand Up @@ -664,7 +668,10 @@ impl Decoder {
}
}

/// Read the next batch of records
/// Read the next batch of [`serde_json::Value`] records from the
/// interator into a [`RecordBatch`].
///
/// Returns `None` if the input iterator is exhausted.
pub fn next_batch<I>(&self, value_iter: &mut I) -> Result<Option<RecordBatch>>
where
I: Iterator<Item = Result<Value>>,
Expand Down