This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 7c1e71c6b6 GH-35167: [Docs][C++] Use new API for
arrow::json::TableReader (#37301)
7c1e71c6b6 is described below
commit 7c1e71c6b672e606a0f5aaa513251dd2c3ef0648
Author: Rajat Subhra Mukherjee <[email protected]>
AuthorDate: Wed Aug 23 13:10:27 2023 +0530
GH-35167: [Docs][C++] Use new API for arrow::json::TableReader (#37301)
### Rationale for this change
The current document causes a build error.
### What changes are included in this PR?
Use the current API.
### Are these changes tested?
No.
### Are there any user-facing changes?
Yes.
* Closes: #35167
Lead-authored-by: Rajat Subhra Mukherjee <[email protected]>
Co-authored-by: Will Jones <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
docs/source/cpp/json.rst | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/docs/source/cpp/json.rst b/docs/source/cpp/json.rst
index 003e768529..3e49c045c8 100644
--- a/docs/source/cpp/json.rst
+++ b/docs/source/cpp/json.rst
@@ -49,7 +49,6 @@ the output table.
{
// ...
- arrow::Status st;
arrow::MemoryPool* pool = default_memory_pool();
std::shared_ptr<arrow::io::InputStream> input = ...;
@@ -57,20 +56,19 @@ the output table.
auto parse_options = arrow::json::ParseOptions::Defaults();
// Instantiate TableReader from input stream and options
- std::shared_ptr<arrow::json::TableReader> reader;
- st = arrow::json::TableReader::Make(pool, input, read_options,
- parse_options, &reader);
- if (!st.ok()) {
+ auto maybe_reader = arrow::json::TableReader::Make(pool, input,
read_options, parse_options);
+ if (!maybe_reader.ok()) {
// Handle TableReader instantiation error...
}
+ auto reader = *maybe_reader;
- std::shared_ptr<arrow::Table> table;
// Read table from JSON file
- st = reader->Read(&table);
- if (!st.ok()) {
+ auto maybe_table = reader->Read();
+ if (!maybe_table.ok()) {
// Handle JSON read error
// (for example a JSON syntax error or failed type conversion)
}
+ auto table = *maybe_table;
}
StreamingReader