1#include "duckdb/execution/operator/scan/physical_chunk_scan.hpp"
2
3using namespace duckdb;
4using namespace std;
5
6class PhysicalChunkScanState : public PhysicalOperatorState {
7public:
8 PhysicalChunkScanState() : PhysicalOperatorState(nullptr), chunk_index(0) {
9 }
10
11 //! The current position in the scan
12 idx_t chunk_index;
13};
14
15void 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
30unique_ptr<PhysicalOperatorState> PhysicalChunkScan::GetOperatorState() {
31 return make_unique<PhysicalChunkScanState>();
32}
33