Kùzu C++ API
Loading...
Searching...
No Matches
data_chunk.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "copy_constructors.h"
7#include "data_chunk_state.h"
8#include "value_vector.h"
9
10namespace kuzu {
11namespace common {
12
13// A DataChunk represents tuples as a set of value vectors and a selector array.
14// The data chunk represents a subset of a relation i.e., a set of tuples as
15// lists of the same length. It is appended into DataChunks and passed as intermediate
16// representations between operators.
17// A data chunk further contains a DataChunkState, which keeps the data chunk's size, selector, and
18// currIdx (used when flattening and implies the value vector only contains the elements at currIdx
19// of each value vector).
20class DataChunk {
21public:
23 explicit DataChunk(uint32_t numValueVectors)
24 : DataChunk(numValueVectors, std::make_shared<DataChunkState>()){};
25
26 DataChunk(uint32_t numValueVectors, const std::shared_ptr<DataChunkState>& state)
27 : valueVectors(numValueVectors), state{state} {};
29
30 void insert(uint32_t pos, std::shared_ptr<ValueVector> valueVector);
31
33
34 inline uint32_t getNumValueVectors() const { return valueVectors.size(); }
35
36 inline const ValueVector& getValueVector(uint64_t valueVectorPos) const {
37 return *valueVectors[valueVectorPos];
38 }
39 inline ValueVector& getValueVectorMutable(uint64_t valueVectorPos) const {
40 return *valueVectors[valueVectorPos];
41 }
42
43public:
44 std::vector<std::shared_ptr<ValueVector>> valueVectors;
45 std::shared_ptr<DataChunkState> state;
46};
47
48} // namespace common
49} // namespace kuzu
Definition data_chunk.h:20
DELETE_COPY_DEFAULT_MOVE(DataChunk)
std::shared_ptr< DataChunkState > state
Definition data_chunk.h:45
DataChunk(uint32_t numValueVectors)
Definition data_chunk.h:23
DataChunk()
Definition data_chunk.h:22
const ValueVector & getValueVector(uint64_t valueVectorPos) const
Definition data_chunk.h:36
uint32_t getNumValueVectors() const
Definition data_chunk.h:34
ValueVector & getValueVectorMutable(uint64_t valueVectorPos) const
Definition data_chunk.h:39
void insert(uint32_t pos, std::shared_ptr< ValueVector > valueVector)
std::vector< std::shared_ptr< ValueVector > > valueVectors
Definition data_chunk.h:44
DataChunk(uint32_t numValueVectors, const std::shared_ptr< DataChunkState > &state)
Definition data_chunk.h:26
Definition data_chunk_state.h:14
Definition value_vector.h:20
Definition array_utils.h:7