Kùzu C++ API
Loading...
Searching...
No Matches
auxiliary_buffer.h
Go to the documentation of this file.
1#pragma once
2
3#include "api.h"
5#include "types.h"
6
7namespace arrow {
8class ChunkedArray;
9} // namespace arrow
10
11namespace kuzu {
12namespace common {
13
14class ValueVector;
15
16// AuxiliaryBuffer holds data which is only used by the targeting dataType.
18public:
19 virtual ~AuxiliaryBuffer() = default;
20
21 template<class TARGET>
22 TARGET& cast() {
24 }
25
26 template<class TARGET>
27 const TARGET& constCast() const {
29 }
30};
31
33public:
34 explicit StringAuxiliaryBuffer(storage::MemoryManager* memoryManager) {
35 inMemOverflowBuffer = std::make_unique<InMemOverflowBuffer>(memoryManager);
36 }
37
38 InMemOverflowBuffer* getOverflowBuffer() const { return inMemOverflowBuffer.get(); }
39 uint8_t* allocateOverflow(uint64_t size) { return inMemOverflowBuffer->allocateSpace(size); }
40 void resetOverflowBuffer() const { inMemOverflowBuffer->resetBuffer(); }
41
42private:
43 std::unique_ptr<InMemOverflowBuffer> inMemOverflowBuffer;
44};
45
47public:
48 StructAuxiliaryBuffer(const LogicalType& type, storage::MemoryManager* memoryManager);
49
50 void referenceChildVector(idx_t idx, std::shared_ptr<ValueVector> vectorToReference) {
51 childrenVectors[idx] = std::move(vectorToReference);
52 }
53 const std::vector<std::shared_ptr<ValueVector>>& getFieldVectors() const {
54 return childrenVectors;
55 }
56
57private:
58 std::vector<std::shared_ptr<ValueVector>> childrenVectors;
59};
60
62 friend class ArrowColumnVector;
63
64private:
65 std::shared_ptr<arrow::ChunkedArray> column;
66};
67
68// ListVector layout:
69// To store a list value in the valueVector, we could use two separate vectors.
70// 1. A vector(called offset vector) for the list offsets and length(called list_entry_t): This
71// vector contains the starting indices and length for each list within the data vector.
72// 2. A data vector(called dataVector) to store the actual list elements: This vector holds the
73// actual elements of the lists in a flat, continuous storage. Each list would be represented as a
74// contiguous subsequence of elements in this vector.
76 friend class ListVector;
77
78public:
79 ListAuxiliaryBuffer(const LogicalType& dataVectorType, storage::MemoryManager* memoryManager);
80
81 void setDataVector(std::shared_ptr<ValueVector> vector) { dataVector = std::move(vector); }
82 ValueVector* getDataVector() const { return dataVector.get(); }
83 std::shared_ptr<ValueVector> getSharedDataVector() const { return dataVector; }
84
86
87 uint64_t getSize() const { return size; }
88
89 void resetSize() { size = 0; }
90
91 void resize(uint64_t numValues);
92
93private:
94 void resizeDataVector(ValueVector* dataVector);
95
96 void resizeStructDataVector(ValueVector* dataVector);
97
98private:
99 uint64_t capacity;
100 uint64_t size;
101
102 std::shared_ptr<ValueVector> dataVector;
103};
104
106public:
107 static std::unique_ptr<AuxiliaryBuffer> getAuxiliaryBuffer(LogicalType& type,
108 storage::MemoryManager* memoryManager);
109};
110
111} // namespace common
112} // namespace kuzu
#define KUZU_API
Definition api.h:25
Definition auxiliary_buffer.h:61
friend class ArrowColumnVector
Definition auxiliary_buffer.h:62
Definition auxiliary_buffer.h:105
static std::unique_ptr< AuxiliaryBuffer > getAuxiliaryBuffer(LogicalType &type, storage::MemoryManager *memoryManager)
Definition auxiliary_buffer.h:17
virtual ~AuxiliaryBuffer()=default
TARGET & cast()
Definition auxiliary_buffer.h:22
const TARGET & constCast() const
Definition auxiliary_buffer.h:27
Definition in_mem_overflow_buffer.h:30
Definition auxiliary_buffer.h:75
uint64_t getSize() const
Definition auxiliary_buffer.h:87
void resize(uint64_t numValues)
ValueVector * getDataVector() const
Definition auxiliary_buffer.h:82
std::shared_ptr< ValueVector > getSharedDataVector() const
Definition auxiliary_buffer.h:83
list_entry_t addList(list_size_t listSize)
ListAuxiliaryBuffer(const LogicalType &dataVectorType, storage::MemoryManager *memoryManager)
void resetSize()
Definition auxiliary_buffer.h:89
void setDataVector(std::shared_ptr< ValueVector > vector)
Definition auxiliary_buffer.h:81
Definition value_vector.h:150
Definition types.h:201
Definition auxiliary_buffer.h:32
StringAuxiliaryBuffer(storage::MemoryManager *memoryManager)
Definition auxiliary_buffer.h:34
void resetOverflowBuffer() const
Definition auxiliary_buffer.h:40
InMemOverflowBuffer * getOverflowBuffer() const
Definition auxiliary_buffer.h:38
uint8_t * allocateOverflow(uint64_t size)
Definition auxiliary_buffer.h:39
Definition auxiliary_buffer.h:46
void referenceChildVector(idx_t idx, std::shared_ptr< ValueVector > vectorToReference)
Definition auxiliary_buffer.h:50
StructAuxiliaryBuffer(const LogicalType &type, storage::MemoryManager *memoryManager)
const std::vector< std::shared_ptr< ValueVector > > & getFieldVectors() const
Definition auxiliary_buffer.h:53
Definition value_vector.h:20
Definition auxiliary_buffer.h:7
uint32_t idx_t
Definition types.h:39
uint32_t list_size_t
Definition types.h:54
TO ku_dynamic_cast(FROM old)
Definition cast.h:11
Definition alter_type.h:5
Definition types.h:70