Skip to content

Commit d20ebc0

Browse files
alambtustvold
andauthored
Improve JSON reader documentation (#1559)
* Improve JSON reader documentation * Apply suggestions from code review Co-authored-by: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com> Co-authored-by: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com>
1 parent 228ee36 commit d20ebc0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

arrow/src/json/reader.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,11 @@ where
555555
generate_schema(field_types)
556556
}
557557

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

637640
impl Decoder {
638-
/// Create a new JSON decoder from any value that implements the `Iterator<Item=Result<Value>>`
639-
/// trait.
641+
/// Create a new JSON decoder from some value that implements an
642+
/// iterator over [`serde_json::Value`]s (aka implements the
643+
/// `Iterator<Item=Result<Value>>` trait).
640644
pub fn new(schema: SchemaRef, options: DecoderOptions) -> Self {
641645
Self { schema, options }
642646
}
@@ -664,7 +668,10 @@ impl Decoder {
664668
}
665669
}
666670

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

0 commit comments

Comments
 (0)