| 1 | //===----------------------------------------------------------------------===// |
|---|---|
| 2 | // DuckDB |
| 3 | // |
| 4 | // duckdb/common/arrow/arrow_appender.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "duckdb/common/arrow/arrow_converter.hpp" |
| 12 | |
| 13 | struct ArrowSchema; |
| 14 | |
| 15 | namespace duckdb { |
| 16 | |
| 17 | struct ArrowAppendData; |
| 18 | |
| 19 | //! The ArrowAppender class can be used to incrementally construct an arrow array by appending data chunks into it |
| 20 | class ArrowAppender { |
| 21 | public: |
| 22 | DUCKDB_API ArrowAppender(vector<LogicalType> types, idx_t initial_capacity, ArrowOptions options); |
| 23 | DUCKDB_API ~ArrowAppender(); |
| 24 | |
| 25 | //! Append a data chunk to the underlying arrow array |
| 26 | DUCKDB_API void Append(DataChunk &input, idx_t from, idx_t to, idx_t input_size); |
| 27 | //! Returns the underlying arrow array |
| 28 | DUCKDB_API ArrowArray Finalize(); |
| 29 | |
| 30 | private: |
| 31 | //! The types of the chunks that will be appended in |
| 32 | vector<LogicalType> types; |
| 33 | //! The root arrow append data |
| 34 | vector<unique_ptr<ArrowAppendData>> root_data; |
| 35 | //! The total row count that has been appended |
| 36 | idx_t row_count = 0; |
| 37 | |
| 38 | ArrowOptions options; |
| 39 | }; |
| 40 | |
| 41 | } // namespace duckdb |
| 42 |