Kùzu C++ API
Loading...
Searching...
No Matches
update_info.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4
5#include "column_chunk_data.h"
6#include "constants.h"
7#include "types.h"
8
9namespace kuzu {
10namespace common {
11class ValueVector;
12} // namespace common
13
14namespace transaction {
15class Transaction;
16} // namespace transaction
17
18namespace storage {
19
20class ColumnChunkData;
23 std::array<common::sel_t, common::DEFAULT_VECTOR_CAPACITY> rowsInVector;
25 // Older versions.
26 std::unique_ptr<VectorUpdateInfo> prev;
27 // Newer versions.
29
30 std::unique_ptr<ColumnChunkData> data;
31
32 explicit VectorUpdateInfo(const common::transaction_t transactionID,
33 common::LogicalType dataType)
34 : version{transactionID}, rowsInVector{}, numRowsUpdated{0}, prev{nullptr}, next{nullptr} {
35 data = ColumnChunkFactory::createColumnChunkData(std::move(dataType), false,
37 }
38
39 std::unique_ptr<VectorUpdateInfo> movePrev() { return std::move(prev); }
40 void setPrev(std::unique_ptr<VectorUpdateInfo> prev) { this->prev = std::move(prev); }
41 VectorUpdateInfo* getPrev() const { return prev.get(); }
42 void setNext(VectorUpdateInfo* next) { this->next = next; }
43 VectorUpdateInfo* getNext() const { return next; }
44};
45
47public:
49
51 common::sel_t rowIdxInVector, const common::ValueVector& values);
52
53 void setVectorInfo(common::idx_t vectorIdx, std::unique_ptr<VectorUpdateInfo> vectorInfo) {
54 vectorsInfo[vectorIdx] = std::move(vectorInfo);
55 }
56 void clearVectorInfo(common::idx_t vectorIdx) { vectorsInfo[vectorIdx] = nullptr; }
57
58 common::idx_t getNumVectors() const { return vectorsInfo.size(); }
60 common::idx_t idx) const;
61
63
64 bool hasUpdates(const transaction::Transaction* transaction, common::row_idx_t startRow,
65 common::length_t numRows) const;
66
67private:
68 VectorUpdateInfo& getOrCreateVectorInfo(const transaction::Transaction* transaction,
69 common::idx_t vectorIdx, common::sel_t rowIdxInVector, const common::LogicalType& dataType);
70
71private:
72 std::vector<std::unique_ptr<VectorUpdateInfo>> vectorsInfo;
73};
74
75} // namespace storage
76} // namespace kuzu
Definition types.h:201
Definition value_vector.h:20
Definition update_info.h:46
void clearVectorInfo(common::idx_t vectorIdx)
Definition update_info.h:56
UpdateInfo()
Definition update_info.h:48
VectorUpdateInfo * getVectorInfo(const transaction::Transaction *transaction, common::idx_t idx) const
bool hasUpdates(const transaction::Transaction *transaction, common::row_idx_t startRow, common::length_t numRows) const
common::row_idx_t getNumUpdatedRows(const transaction::Transaction *transaction) const
void setVectorInfo(common::idx_t vectorIdx, std::unique_ptr< VectorUpdateInfo > vectorInfo)
Definition update_info.h:53
VectorUpdateInfo * update(const transaction::Transaction *transaction, common::idx_t vectorIdx, common::sel_t rowIdxInVector, const common::ValueVector &values)
common::idx_t getNumVectors() const
Definition update_info.h:58
Definition transaction.h:28
uint64_t length_t
Definition types.h:53
uint32_t idx_t
Definition types.h:39
constexpr uint64_t DEFAULT_VECTOR_CAPACITY
Definition constants.h:12
uint64_t transaction_t
Definition types.h:57
uint64_t sel_t
Definition types.h:24
uint64_t row_idx_t
Definition types.h:46
Definition alter_type.h:5
static std::unique_ptr< ColumnChunkData > createColumnChunkData(common::LogicalType dataType, bool enableCompression, uint64_t capacity, ResidencyState residencyState, bool hasNullData=true)
Definition update_info.h:21
VectorUpdateInfo * getNext() const
Definition update_info.h:43
common::transaction_t version
Definition update_info.h:22
std::unique_ptr< ColumnChunkData > data
Definition update_info.h:30
common::sel_t numRowsUpdated
Definition update_info.h:24
VectorUpdateInfo * getPrev() const
Definition update_info.h:41
void setNext(VectorUpdateInfo *next)
Definition update_info.h:42
void setPrev(std::unique_ptr< VectorUpdateInfo > prev)
Definition update_info.h:40
std::array< common::sel_t, common::DEFAULT_VECTOR_CAPACITY > rowsInVector
Definition update_info.h:23
VectorUpdateInfo * next
Definition update_info.h:28
std::unique_ptr< VectorUpdateInfo > prev
Definition update_info.h:26
std::unique_ptr< VectorUpdateInfo > movePrev()
Definition update_info.h:39
VectorUpdateInfo(const common::transaction_t transactionID, common::LogicalType dataType)
Definition update_info.h:32