Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::UpdateInfo Struct Reference
Collaboration diagram for duckdb::UpdateInfo:

Public Member Functions

sel_t * GetTuples ()
 The row ids of the tuples that have been updated. This should always be kept sorted!
data_ptr_t GetValues ()
 The update values.
template<class T>
T * GetData ()
bool AppliesToTransaction (transaction_t start_time, transaction_t transaction_id)
Value GetValue (idx_t index)
string ToString ()
void Print ()
void Verify ()
bool HasPrev () const
bool HasNext () const

Static Public Member Functions

template<class T>
static void UpdatesForTransaction (UpdateInfo &current, transaction_t start_time, transaction_t transaction_id, T &&callback)
static UpdateInfo & Get (UndoBufferReference &entry)
static idx_t GetAllocSize (idx_t type_size)
 Returns the total allocation size for an UpdateInfo entry, together with space for the tuple data.
static void Initialize (UpdateInfo &info, DataTable &data_table, transaction_t transaction_id, idx_t row_group_start)
 Initialize an UpdateInfo struct that has been allocated using GetAllocSize (i.e. has extra space after it).

Public Attributes

UpdateSegment * segment
 The update segment that this update info affects.
DataTable * table
 The table this was update was made on.
idx_t column_index
 The column index of which column we are updating.
idx_t row_group_start
 The start index of the row group.
atomic< transaction_t > version_number
 The version number.
idx_t vector_index
 The vector index within the uncompressed segment.
sel_t N
 The amount of updated tuples.
sel_t max
 The maximum amount of tuples that can fit into this UpdateInfo.
UndoBufferPointer prev
 The previous update info (or nullptr if it is the base).
UndoBufferPointer next
 The next update info in the chain (or nullptr if it is the last).

Detailed Description

UpdateInfo is a class that represents a set of updates applied to a single vector. The UpdateInfo struct contains metadata associated with the update. After the UpdateInfo, we must ALWAYS allocate the list of tuples and the data as contiguous arrays: [UpdateInfo][TUPLES (sel_t[max])][DATA (T[max])] The required allocation size can be obtained using UpdateInfo::GetAllocSize

Member Function Documentation

◆ GetTuples()

sel_t * duckdb::UpdateInfo::GetTuples ( )

The row ids of the tuples that have been updated. This should always be kept sorted!

438921 {
438922 return reinterpret_cast<sel_t *>(data_ptr_cast(this) + sizeof(UpdateInfo));
438923}
uint32_t sel_t
Type used for the selection vector.
Definition duckdb.hpp:251
Here is the caller graph for this function:

◆ GetValues()

data_ptr_t duckdb::UpdateInfo::GetValues ( )

The update values.

438925 {
438926 return reinterpret_cast<data_ptr_t>(data_ptr_cast(this) + sizeof(UpdateInfo) + sizeof(sel_t) * max);
438927}
sel_t max
The maximum amount of tuples that can fit into this UpdateInfo.
Definition duckdb.cpp:438787

◆ GetData()

template<class T>
T * duckdb::UpdateInfo::GetData ( )
inline
438800 {
438801 return reinterpret_cast<T *>(GetValues());
438802 }
data_ptr_t GetValues()
The update values.
Definition duckdb.cpp:438925

◆ AppliesToTransaction()

bool duckdb::UpdateInfo::AppliesToTransaction ( transaction_t start_time,
transaction_t transaction_id )
inline
438804 {
438805 // these tuples were either committed AFTER this transaction started or are not committed yet, use
438806 // tuples stored in this version
438807 if (version_number == TRANSACTION_ID_START - 1) {
438808 // dummy transaction number for the root element - should always match
438809 return true;
438810 }
438811 return version_number > start_time && version_number != transaction_id;
438812 }
atomic< transaction_t > version_number
The version number.
Definition duckdb.cpp:438781

◆ UpdatesForTransaction()

template<class T>
void duckdb::UpdateInfo::UpdatesForTransaction ( UpdateInfo & current,
transaction_t start_time,
transaction_t transaction_id,
T && callback )
inlinestatic

Loop over the update chain and execute the specified callback on all UpdateInfo's that are relevant for that transaction in-order of newest to oldest

438818 {
438819 if (current.AppliesToTransaction(start_time, transaction_id)) {
438820 callback(current);
438821 }
438822 auto update_ptr = current.next;
438823 while (update_ptr.IsSet()) {
438824 auto pin = update_ptr.Pin();
438825 auto &info = Get(pin);
438826 if (info.AppliesToTransaction(start_time, transaction_id)) {
438827 callback(info);
438828 }
438829 update_ptr = info.next;
438830 }
438831 }

◆ GetValue()

Value duckdb::UpdateInfo::GetValue ( idx_t index)
438888 {
438889 auto &type = segment->column_data.type;
438890
438891 auto tuple_data = GetValues();
438892 switch (type.id()) {
438893 case LogicalTypeId::VALIDITY:
438894 return Value::BOOLEAN(reinterpret_cast<bool *>(tuple_data)[index]);
438895 case LogicalTypeId::INTEGER:
438896 return Value::INTEGER(reinterpret_cast<int32_t *>(tuple_data)[index]);
438897 default:
438898 throw NotImplementedException("Unimplemented type for UpdateInfo::GetValue");
438899 }
438900}
static DUCKDB_API Value INTEGER(int32_t value)
Create an integer Value from a specified value.
Definition duckdb.cpp:132139
static DUCKDB_API Value BOOLEAN(bool value)
Create a boolean Value from a specified value.
Definition duckdb.cpp:132118
::int32_t int32_t
UpdateSegment * segment
The update segment that this update info affects.
Definition duckdb.cpp:438773

◆ ToString()

string duckdb::UpdateInfo::ToString ( )
438906 {
438907 auto &type = segment->column_data.type;
438908 string result = "Update Info [" + type.ToString() + ", Count: " + to_string(N) +
438909 ", Transaction Id: " + to_string(version_number) + "]\n";
438910 auto tuples = GetTuples();
438911 for (idx_t i = 0; i < N; i++) {
438912 result += to_string(tuples[i]) + ": " + GetValue(i).ToString() + "\n";
438913 }
438914 if (HasNext()) {
438915 auto next_pin = next.Pin();
438916 result += "\nChild Segment: " + Get(next_pin).ToString();
438917 }
438918 return result;
438919}
std::string to_string(const T &value)
Definition duckdb.cpp:19425
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
sel_t * GetTuples()
The row ids of the tuples that have been updated. This should always be kept sorted!
Definition duckdb.cpp:438921
sel_t N
The amount of updated tuples.
Definition duckdb.cpp:438785
UndoBufferPointer next
The next update info in the chain (or nullptr if it is the last).
Definition duckdb.cpp:438791

◆ Print()

void duckdb::UpdateInfo::Print ( )
438902 {
438903 Printer::Print(ToString());
438904}
static DUCKDB_API void Print(OutputStream stream, const string &str)
Print the object to the stream.
Definition duckdb.cpp:92556

◆ Verify()

void duckdb::UpdateInfo::Verify ( )
438957 {
438958#ifdef DEBUG
438959 auto tuples = GetTuples();
438960 for (idx_t i = 1; i < N; i++) {
438961 D_ASSERT(tuples[i] > tuples[i - 1] && tuples[i] < STANDARD_VECTOR_SIZE);
438962 }
438963#endif
438964}

◆ HasPrev()

bool duckdb::UpdateInfo::HasPrev ( ) const
438934 {
438935 return prev.entry;
438936}
UndoBufferPointer prev
The previous update info (or nullptr if it is the base).
Definition duckdb.cpp:438789

◆ HasNext()

bool duckdb::UpdateInfo::HasNext ( ) const
438938 {
438939 return next.entry;
438940}

◆ Get()

UpdateInfo & duckdb::UpdateInfo::Get ( UndoBufferReference & entry)
static
438929 {
438930 auto update_info = reinterpret_cast<UpdateInfo *>(entry.Ptr());
438931 return *update_info;
438932}

◆ GetAllocSize()

idx_t duckdb::UpdateInfo::GetAllocSize ( idx_t type_size)
static

Returns the total allocation size for an UpdateInfo entry, together with space for the tuple data.

438942 {
438943 return AlignValue<idx_t>(sizeof(UpdateInfo) + (sizeof(sel_t) + type_size) * STANDARD_VECTOR_SIZE);
438944}
static T AlignValue(T n)
Align value (ceiling) (not for pointer types).
Definition duckdb.hpp:2126
Here is the call graph for this function:

◆ Initialize()

void duckdb::UpdateInfo::Initialize ( UpdateInfo & info,
DataTable & data_table,
transaction_t transaction_id,
idx_t row_group_start )
static

Initialize an UpdateInfo struct that has been allocated using GetAllocSize (i.e. has extra space after it).

438947 {
438948 info.max = STANDARD_VECTOR_SIZE;
438949 info.row_group_start = row_group_start;
438950 info.version_number = transaction_id;
438951 info.table = &data_table;
438952 info.segment = nullptr;
438953 info.prev.entry = nullptr;
438954 info.next.entry = nullptr;
438955}
idx_t row_group_start
The start index of the row group.
Definition duckdb.cpp:438779

The documentation for this struct was generated from the following file: