| 1 | #include "duckdb/execution/operator/scan/physical_chunk_scan.hpp" |
|---|---|
| 2 | |
| 3 | using namespace duckdb; |
| 4 | using namespace std; |
| 5 | |
| 6 | class PhysicalChunkScanState : public PhysicalOperatorState { |
| 7 | public: |
| 8 | PhysicalChunkScanState() : PhysicalOperatorState(nullptr), chunk_index(0) { |
| 9 | } |
| 10 | |
| 11 | //! The current position in the scan |
| 12 | idx_t chunk_index; |
| 13 | }; |
| 14 | |
| 15 | void PhysicalChunkScan::GetChunkInternal(ClientContext &context, DataChunk &chunk, PhysicalOperatorState *state_) { |
| 16 | auto state = (PhysicalChunkScanState *)state_; |
| 17 | assert(collection); |
| 18 | if (collection->count == 0) { |
| 19 | return; |
| 20 | } |
| 21 | assert(chunk.GetTypes() == collection->types); |
| 22 | if (state->chunk_index >= collection->chunks.size()) { |
| 23 | return; |
| 24 | } |
| 25 | auto &collection_chunk = *collection->chunks[state->chunk_index]; |
| 26 | chunk.Reference(collection_chunk); |
| 27 | state->chunk_index++; |
| 28 | } |
| 29 | |
| 30 | unique_ptr<PhysicalOperatorState> PhysicalChunkScan::GetOperatorState() { |
| 31 | return make_unique<PhysicalChunkScanState>(); |
| 32 | } |
| 33 |