Skip to content

Commit

Permalink
create reader from iter (apache#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo authored and zhouyuan committed Apr 26, 2022
1 parent 7f954ab commit f8fabc2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cpp/src/arrow/record_batch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,13 @@ Result<std::shared_ptr<RecordBatchReader>> RecordBatchReader::Make(
return std::make_shared<SimpleRecordBatchReader>(std::move(batches), schema);
}

Result<std::shared_ptr<RecordBatchReader>> RecordBatchReader::Make(
Iterator<std::shared_ptr<RecordBatch>> it, std::shared_ptr<Schema> schema) {
if (schema == nullptr) {
return Status::Invalid("Cannot infer schema from nullptr");
}

return std::make_shared<SimpleRecordBatchReader>(std::move(it), schema);
}

} // namespace arrow
7 changes: 7 additions & 0 deletions cpp/src/arrow/record_batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ class ARROW_EXPORT RecordBatchReader {
/// element if not provided.
static Result<std::shared_ptr<RecordBatchReader>> Make(
RecordBatchVector batches, std::shared_ptr<Schema> schema = NULLPTR);

/// \brief Create a RecordBatchReader from an iterator of RecordBatch.
///
/// \param[in] iterator of RecordBatch to read from
/// \param[in] schema schema to conform to. A valid schema should be provided.
static Result<std::shared_ptr<RecordBatchReader>> Make(
Iterator<std::shared_ptr<RecordBatch>> it, std::shared_ptr<Schema> schema);
};

} // namespace arrow

0 comments on commit f8fabc2

Please sign in to comment.