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::ColumnData Class Reference
Inheritance diagram for duckdb::ColumnData:
Collaboration diagram for duckdb::ColumnData:

Public Member Functions

 ColumnData (BlockManager &block_manager, DataTableInfo &info, idx_t column_index, LogicalType type, ColumnDataType data_type, optional_ptr< ColumnData > parent)
virtual FilterPropagateResult CheckZonemap (ColumnScanState &state, TableFilter &filter)
BlockManager & GetBlockManager () const
DatabaseInstance & GetDatabase () const
DataTableInfo & GetTableInfo () const
StorageManager & GetStorageManager () const
virtual idx_t GetMaxEntry ()
idx_t GetAllocationSize () const
optional_ptr< const CompressionFunction > GetCompressionFunction () const
virtual void SetDataType (ColumnDataType data_type)
ColumnDataType GetDataType () const
bool HasParent () const
void SetParent (optional_ptr< ColumnData > parent)
const ColumnData & Parent () const
virtual const BaseStatistics & GetChildStats (const ColumnData &child) const
const LogicalType & GetType () const
ColumnSegmentTree & GetSegmentTree ()
void SetCount (idx_t new_count)
bool HasUpdates () const
 Whether or not the column has any updates.
bool HasChanges (idx_t start_row, idx_t end_row) const
bool HasChanges () const
 Whether or not the column has changes at this level.
virtual bool HasAnyChanges () const
 Whether or not the column has ANY changes, including in child columns.
virtual ScanVectorType GetVectorScanType (ColumnScanState &state, idx_t scan_count, Vector &result)
 Whether or not we can scan an entire vector.
virtual void InitializePrefetch (PrefetchState &prefetch_state, ColumnScanState &scan_state, idx_t rows)
 Initialize prefetch state with required I/O data for the next N rows.
virtual void InitializeScan (ColumnScanState &state)
 Initialize a scan of the column.
virtual void InitializeScanWithOffset (ColumnScanState &state, idx_t row_idx)
 Initialize a scan starting at the specified offset.
idx_t Scan (TransactionData transaction, idx_t vector_index, ColumnScanState &state, Vector &result)
 Scan the next vector from the column.
virtual idx_t Scan (TransactionData transaction, idx_t vector_index, ColumnScanState &state, Vector &result, idx_t scan_count)
virtual void ScanCommittedRange (idx_t row_group_start, idx_t offset_in_row_group, idx_t count, Vector &result)
virtual idx_t ScanCount (ColumnScanState &state, Vector &result, idx_t count, idx_t result_offset=0)
virtual void Filter (TransactionData transaction, idx_t vector_index, ColumnScanState &state, Vector &result, SelectionVector &sel, idx_t &count, const TableFilter &filter, TableFilterState &filter_state)
 Select.
virtual void Select (TransactionData transaction, idx_t vector_index, ColumnScanState &state, Vector &result, SelectionVector &sel, idx_t count)
virtual void Skip (ColumnScanState &state, idx_t count=STANDARD_VECTOR_SIZE)
 Skip the scan forward by "count" rows.
virtual void InitializeAppend (ColumnAppendState &state)
 Initialize an appending phase for this column.
virtual void Append (BaseStatistics &stats, ColumnAppendState &state, Vector &vector, idx_t count)
 Append a vector of type [type] to the end of the column.
void Append (ColumnAppendState &state, Vector &vector, idx_t count)
 Append a vector of type [type] to the end of the column.
virtual void AppendData (BaseStatistics &stats, ColumnAppendState &state, UnifiedVectorFormat &vdata, idx_t count)
virtual void RevertAppend (row_t new_count)
 Revert a set of appends to the ColumnData.
virtual idx_t Fetch (ColumnScanState &state, row_t row_id, Vector &result)
 Fetch the vector from the column data that belongs to this specific row.
virtual void FetchRow (TransactionData transaction, ColumnFetchState &state, const StorageIndex &storage_index, row_t row_id, Vector &result, idx_t result_idx)
 Fetch a specific row id and append it to the vector.
virtual void Update (TransactionData transaction, DataTable &data_table, idx_t column_index, Vector &update_vector, row_t *row_ids, idx_t update_count, idx_t row_group_start)
virtual void UpdateColumn (TransactionData transaction, DataTable &data_table, const vector< column_t > &column_path, Vector &update_vector, row_t *row_ids, idx_t update_count, idx_t depth, idx_t row_group_start)
virtual unique_ptr< BaseStatistics > GetUpdateStatistics ()
virtual void VisitBlockIds (BlockIdVisitor &visitor) const
virtual unique_ptr< ColumnCheckpointState > CreateCheckpointState (const RowGroup &row_group, PartialBlockManager &partial_block_manager)
unique_ptr< ColumnCheckpointState > Checkpoint (const RowGroup &row_group, ColumnCheckpointInfo &info)
 If this is a nested column, "stats" are the corresponding statistics from the parent column Otherwise, "stats" == this->statistics->stats.
virtual unique_ptr< ColumnCheckpointState > Checkpoint (const RowGroup &row_group, ColumnCheckpointInfo &info, const BaseStatistics &stats)
virtual void CheckpointScan (ColumnSegment &segment, ColumnScanState &state, idx_t count, Vector &scan_vector) const
virtual bool IsPersistent ()
vector< DataPointer > GetDataPointers ()
virtual PersistentColumnData Serialize ()
void InitializeColumn (PersistentColumnData &column_data)
virtual void InitializeColumn (PersistentColumnData &column_data, BaseStatistics &target_stats)
virtual void GetColumnSegmentInfo (const QueryContext &context, idx_t row_group_index, vector< idx_t > col_path, vector< ColumnSegmentInfo > &result)
virtual void Verify (RowGroup &parent)
FilterPropagateResult CheckZonemap (const StorageIndex &index, TableFilter &filter)
void MergeStatistics (const BaseStatistics &other)
void MergeIntoStatistics (BaseStatistics &other)
unique_ptr< BaseStatistics > GetStatistics () const
const BaseStatistics & GetStatisticsRef () const
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const
Public Member Functions inherited from duckdb::enable_shared_from_this< ColumnData >
shared_ptr< ColumnData > shared_from_this ()

Static Public Member Functions

static shared_ptr< ColumnData > Deserialize (BlockManager &block_manager, DataTableInfo &info, idx_t column_index, ReadStream &source, const LogicalType &type)
static shared_ptr< ColumnData > CreateColumn (BlockManager &block_manager, DataTableInfo &info, idx_t column_index, const LogicalType &type, ColumnDataType data_type=ColumnDataType::MAIN_TABLE, optional_ptr< ColumnData > parent=nullptr)

Public Attributes

atomic< idx_t > count
 The count of the column data.
BlockManager & block_manager
 The block manager.
DataTableInfo & info
 Table info for the column.
idx_t column_index
 The column index of the column, either within the parent table or within the parent.
LogicalType type
 The type of the column.

Protected Member Functions

void AppendTransientSegment (SegmentLock &l, idx_t start_row)
 Append a transient segment.
void AppendSegment (SegmentLock &l, unique_ptr< ColumnSegment > segment)
void BeginScanVectorInternal (ColumnScanState &state)
idx_t ScanVector (ColumnScanState &state, Vector &result, idx_t remaining, ScanVectorType scan_type, idx_t result_offset=0)
 Scans a base vector from the column.
idx_t ScanVector (TransactionData transaction, idx_t vector_index, ColumnScanState &state, Vector &result, idx_t target_scan, ScanVectorType scan_type, UpdateScanType update_type)
 Scans a vector from the column merged with any potential updates.
idx_t ScanVector (TransactionData transaction, idx_t vector_index, ColumnScanState &state, Vector &result, idx_t target_scan, UpdateScanType update_type)
void SelectVector (ColumnScanState &state, Vector &result, idx_t target_count, const SelectionVector &sel, idx_t sel_count)
void FilterVector (ColumnScanState &state, Vector &result, idx_t target_count, SelectionVector &sel, idx_t &sel_count, const TableFilter &filter, TableFilterState &filter_state)
void FetchUpdates (TransactionData transaction, idx_t vector_index, Vector &result, idx_t scan_count, UpdateScanType update_type)
void FetchUpdateRow (TransactionData transaction, row_t row_id, Vector &result, idx_t result_idx)
void UpdateInternal (TransactionData transaction, DataTable &data_table, idx_t column_index, Vector &update_vector, row_t *row_ids, idx_t update_count, Vector &base_vector, idx_t row_group_start)
idx_t FetchUpdateData (ColumnScanState &state, row_t *row_ids, Vector &base_vector, idx_t row_group_start)
idx_t GetVectorCount (idx_t vector_index) const
Protected Member Functions inherited from duckdb::enable_shared_from_this< ColumnData >
enable_shared_from_this & operator= (enable_shared_from_this const &) noexcept

Protected Attributes

ColumnSegmentTree data
 The segments holding the data of this column segment.
mutex update_lock
 The lock for the updates.
unique_ptr< UpdateSegment > updates
 The updates for this column segment.
mutex stats_lock
 The lock for the stats.
atomic< idx_t > allocation_size
 Total transient allocation size.
unique_ptr< SegmentStatistics > stats
 The stats of the root segment.

Private Member Functions

void UpdateCompressionFunction (SegmentLock &l, const CompressionFunction &function)

Private Attributes

atomic< ColumnDataType > data_type
 Whether or not this column data belongs to a main table or if it is transaction local.
optional_ptr< ColumnData > parent
 The parent column (if any).
atomic_ptr< const CompressionFunction > compression
 The compression function used by the ColumnData This is empty if the segments have mixed compression or the ColumnData is empty.

Friends

class ColumnDataCheckpointer

Constructor & Destructor Documentation

◆ ColumnData()

duckdb::ColumnData::ColumnData ( BlockManager & block_manager,
DataTableInfo & info,
idx_t column_index,
LogicalType type,
ColumnDataType data_type,
optional_ptr< ColumnData > parent )
428880 : count(0), block_manager(block_manager), info(info), column_index(column_index), type(std::move(type_p)),
428881 allocation_size(0),
428882 data_type(data_type_p == ColumnDataType::CHECKPOINT_TARGET ? ColumnDataType::MAIN_TABLE : data_type_p),
428883 parent(parent_p) {
428884 if (!parent) {
428885 stats = make_uniq<SegmentStatistics>(type);
428886 }
428887}
unique_ptr< SegmentStatistics > stats
The stats of the root segment.
Definition duckdb.hpp:49465
atomic< idx_t > count
The count of the column data.
Definition duckdb.hpp:49273
atomic< ColumnDataType > data_type
Whether or not this column data belongs to a main table or if it is transaction local.
Definition duckdb.hpp:49469
optional_ptr< ColumnData > parent
The parent column (if any).
Definition duckdb.hpp:49471
LogicalType type
The type of the column.
Definition duckdb.hpp:49281
DataTableInfo & info
Table info for the column.
Definition duckdb.hpp:49277
idx_t column_index
The column index of the column, either within the parent table or within the parent.
Definition duckdb.hpp:49279
BlockManager & block_manager
The block manager.
Definition duckdb.hpp:49275
atomic< idx_t > allocation_size
Total transient allocation size.
Definition duckdb.hpp:49463

◆ ~ColumnData()

duckdb::ColumnData::~ColumnData ( )
virtual
428889 {
428890}

Member Function Documentation

◆ CheckZonemap() [1/2]

FilterPropagateResult duckdb::ColumnData::CheckZonemap ( ColumnScanState & state,
TableFilter & filter )
virtual
429236 {
429237 if (state.segment_checked) {
429238 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
429239 }
429240 if (!state.current) {
429241 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
429242 }
429243 // for dynamic filters we never consider the segment being "checked" as it can always change
429244 state.segment_checked = filter.filter_type != TableFilterType::DYNAMIC_FILTER;
429245 FilterPropagateResult prune_result;
429246 {
429247 lock_guard<mutex> l(stats_lock);
429248 prune_result = filter.CheckStatistics(state.current->GetNode().stats.statistics);
429249 if (prune_result == FilterPropagateResult::NO_PRUNING_POSSIBLE) {
429250 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
429251 }
429252 }
429253 lock_guard<mutex> l(update_lock);
429254 if (!updates) {
429255 // no updates - return original result
429256 return prune_result;
429257 }
429258 auto update_stats = updates->GetStatistics();
429259 // combine the update and original prune result
429260 FilterPropagateResult update_result = filter.CheckStatistics(*update_stats);
429261 if (prune_result == update_result) {
429262 return prune_result;
429263 }
429264 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
429265}
mutex stats_lock
The lock for the stats.
Definition duckdb.hpp:49461
mutex update_lock
The lock for the updates.
Definition duckdb.hpp:49457
unique_ptr< UpdateSegment > updates
The updates for this column segment.
Definition duckdb.hpp:49459
void filter(InputArray image, InputArray kernel, OutputArray output)

◆ GetBlockManager()

BlockManager & duckdb::ColumnData::GetBlockManager ( ) const
inline
49286 {
49287 return block_manager;
49288 }

◆ GetDatabase()

DatabaseInstance & duckdb::ColumnData::GetDatabase ( ) const
428896 {
428897 return info.GetDB().GetDatabase();
428898}

◆ GetTableInfo()

DataTableInfo & duckdb::ColumnData::GetTableInfo ( ) const
428900 {
428901 return info;
428902}

◆ GetStorageManager()

StorageManager & duckdb::ColumnData::GetStorageManager ( ) const
428904 {
428905 return info.GetDB().GetStorageManager();
428906}

◆ GetMaxEntry()

idx_t duckdb::ColumnData::GetMaxEntry ( )
virtual
428944 {
428945 return count;
428946}

◆ GetAllocationSize()

idx_t duckdb::ColumnData::GetAllocationSize ( ) const
inline
49294 {
49295 return allocation_size;
49296 }

◆ GetCompressionFunction()

optional_ptr< const CompressionFunction > duckdb::ColumnData::GetCompressionFunction ( ) const
inline
49297 {
49298 return compression.get();
49299 }
atomic_ptr< const CompressionFunction > compression
The compression function used by the ColumnData This is empty if the segments have mixed compression ...
Definition duckdb.hpp:49474

◆ SetDataType()

void duckdb::ColumnData::SetDataType ( ColumnDataType data_type)
virtual
428892 {
428893 this->data_type = data_type_p;
428894}

◆ GetDataType()

ColumnDataType duckdb::ColumnData::GetDataType ( ) const
inline
49301 {
49302 return data_type;
49303 }

◆ HasParent()

bool duckdb::ColumnData::HasParent ( ) const
inline
49305 {
49306 return parent;
49307 }

◆ SetParent()

void duckdb::ColumnData::SetParent ( optional_ptr< ColumnData > parent)
inline
49308 {
49309 this->parent = parent;
49310 }

◆ Parent()

const ColumnData & duckdb::ColumnData::Parent ( ) const
inline
49311 {
49312 D_ASSERT(HasParent());
49313 return *parent;
49314 }

◆ GetChildStats()

const BaseStatistics & duckdb::ColumnData::GetChildStats ( const ColumnData & child) const
virtual
429290 {
429291 throw InternalException("GetChildStats not implemented for ColumnData of type %s", type.ToString());
429292}

◆ GetType()

const LogicalType & duckdb::ColumnData::GetType ( ) const
inline
49318 {
49319 return type;
49320 }

◆ GetSegmentTree()

ColumnSegmentTree & duckdb::ColumnData::GetSegmentTree ( )
inline
49321 {
49322 return data;
49323 }
ColumnSegmentTree data
The segments holding the data of this column segment.
Definition duckdb.hpp:49455

◆ SetCount()

void duckdb::ColumnData::SetCount ( idx_t new_count)
inline
49324 {
49325 this->count = new_count;
49326 }

◆ HasUpdates()

bool duckdb::ColumnData::HasUpdates ( ) const

Whether or not the column has any updates.

428908 {
428909 lock_guard<mutex> update_guard(update_lock);
428910 return updates.get();
428911}
Here is the caller graph for this function:

◆ HasChanges() [1/2]

bool duckdb::ColumnData::HasChanges ( idx_t start_row,
idx_t end_row ) const
428913 {
428914 if (!updates) {
428915 return false;
428916 }
428917 if (updates->HasUpdates(start_row, end_row)) {
428918 return true;
428919 }
428920 return false;
428921}

◆ HasChanges() [2/2]

bool duckdb::ColumnData::HasChanges ( ) const

Whether or not the column has changes at this level.

428923 {
428924 for (auto &segment_node : data.SegmentNodes()) {
428925 auto &segment = segment_node.GetNode();
428926 if (segment.segment_type == ColumnSegmentType::TRANSIENT) {
428927 // transient segment: always need to write to disk
428928 return true;
428929 }
428930 // persistent segment; check if there were any updates or deletions in this segment
428931 idx_t start_row_idx = segment_node.GetRowStart();
428932 idx_t end_row_idx = start_row_idx + segment.count;
428933 if (HasChanges(start_row_idx, end_row_idx)) {
428934 return true;
428935 }
428936 }
428937 return false;
428938}
bool HasChanges() const
Whether or not the column has changes at this level.
Definition duckdb.cpp:428923
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasAnyChanges()

bool duckdb::ColumnData::HasAnyChanges ( ) const
virtual

Whether or not the column has ANY changes, including in child columns.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::StandardColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

428940 {
428941 return HasChanges();
428942}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVectorScanType()

ScanVectorType duckdb::ColumnData::GetVectorScanType ( ColumnScanState & state,
idx_t scan_count,
Vector & result )
virtual

Whether or not we can scan an entire vector.

Reimplemented in duckdb::StandardColumnData.

428971 {
428972 if (result.GetVectorType() != VectorType::FLAT_VECTOR) {
428973 return ScanVectorType::SCAN_ENTIRE_VECTOR;
428974 }
428975 if (HasUpdates()) {
428976 // if we have updates we need to merge in the updates
428977 // always need to scan flat vectors
428978 return ScanVectorType::SCAN_FLAT_VECTOR;
428979 }
428980 // check if the current segment has enough data remaining
428981 auto &current = state.current->GetNode();
428982 idx_t remaining_in_segment = state.current->GetRowStart() + current.count - state.offset_in_column;
428983 if (remaining_in_segment < scan_count) {
428984 // there is not enough data remaining in the current segment so we need to scan across segments
428985 // we need flat vectors here
428986 return ScanVectorType::SCAN_FLAT_VECTOR;
428987 }
428988 return ScanVectorType::SCAN_ENTIRE_VECTOR;
428989}
bool HasUpdates() const
Whether or not the column has any updates.
Definition duckdb.cpp:428908
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializePrefetch()

void duckdb::ColumnData::InitializePrefetch ( PrefetchState & prefetch_state,
ColumnScanState & scan_state,
idx_t rows )
virtual

Initialize prefetch state with required I/O data for the next N rows.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::RowIdColumnData, duckdb::StandardColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

428991 {
428992 auto current_segment = scan_state.current;
428993 if (!current_segment) {
428994 return;
428995 }
428996 if (!scan_state.initialized) {
428997 // need to prefetch for the current segment if we have not yet initialized the scan for this segment
428998 current_segment->GetNode().InitializePrefetch(prefetch_state, scan_state);
428999 }
429000 idx_t row_index = scan_state.offset_in_column;
429001 while (remaining > 0) {
429002 auto &current = current_segment->GetNode();
429003 idx_t scan_count = MinValue<idx_t>(remaining, current_segment->GetRowStart() + current.count - row_index);
429004 remaining -= scan_count;
429005 row_index += scan_count;
429006 if (remaining > 0) {
429007 auto next = data.GetNextSegment(*current_segment);
429008 if (!next) {
429009 break;
429010 }
429011 next->GetNode().InitializePrefetch(prefetch_state, scan_state);
429012 current_segment = next;
429013 }
429014 }
429015}
Here is the caller graph for this function:

◆ InitializeScan()

void duckdb::ColumnData::InitializeScan ( ColumnScanState & state)
virtual

Initialize a scan of the column.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::RowIdColumnData, duckdb::StandardColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

428948 {
428949 state.current = data.GetRootSegment();
428950 state.segment_tree = &data;
428951 state.offset_in_column = state.current ? state.current->GetRowStart() : 0;
428952 state.internal_index = state.offset_in_column;
428953 state.initialized = false;
428954 state.scan_state.reset();
428955 state.last_offset = 0;
428956}
Here is the caller graph for this function:

◆ InitializeScanWithOffset()

void duckdb::ColumnData::InitializeScanWithOffset ( ColumnScanState & state,
idx_t row_idx )
virtual

Initialize a scan starting at the specified offset.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::RowIdColumnData, duckdb::StandardColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

428958 {
428959 if (row_idx > count) {
428960 throw InternalException("row_idx in InitializeScanWithOffset out of range");
428961 }
428962 state.current = data.GetSegment(row_idx);
428963 state.segment_tree = &data;
428964 state.offset_in_column = row_idx;
428965 state.internal_index = state.current->GetRowStart();
428966 state.initialized = false;
428967 state.scan_state.reset();
428968 state.last_offset = 0;
428969}
Here is the caller graph for this function:

◆ Scan() [1/2]

idx_t duckdb::ColumnData::Scan ( TransactionData transaction,
idx_t vector_index,
ColumnScanState & state,
Vector & result )

Scan the next vector from the column.

429166 {
429167 auto target_count = GetVectorCount(vector_index);
429168 return Scan(transaction, vector_index, state, result, target_count);
429169}
idx_t Scan(TransactionData transaction, idx_t vector_index, ColumnScanState &state, Vector &result)
Scan the next vector from the column.
Definition duckdb.cpp:429166
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Scan() [2/2]

idx_t duckdb::ColumnData::Scan ( TransactionData transaction,
idx_t vector_index,
ColumnScanState & state,
Vector & result,
idx_t scan_count )
virtual
429172 {
429173 return ScanVector(transaction, vector_index, state, result, scan_count, state.update_scan_type);
429174}
idx_t ScanVector(ColumnScanState &state, Vector &result, idx_t remaining, ScanVectorType scan_type, idx_t result_offset=0)
Scans a base vector from the column.
Definition duckdb.cpp:429036

◆ ScanCommittedRange()

void duckdb::ColumnData::ScanCommittedRange ( idx_t row_group_start,
idx_t offset_in_row_group,
idx_t count,
Vector & result )
virtual
429181 {
429182 ColumnScanState child_state(nullptr);
429183 InitializeScanWithOffset(child_state, offset_in_row_group);
429184 bool has_updates = HasUpdates();
429185 auto scan_count = ScanVector(child_state, result, s_count, ScanVectorType::SCAN_FLAT_VECTOR);
429186 if (has_updates) {
429187 D_ASSERT(result.GetVectorType() == VectorType::FLAT_VECTOR);
429188 result.Flatten(scan_count);
429189 updates->FetchCommittedRange(offset_in_row_group, s_count, result);
429190 }
429191}
virtual void InitializeScanWithOffset(ColumnScanState &state, idx_t row_idx)
Initialize a scan starting at the specified offset.
Definition duckdb.cpp:428958

◆ ScanCount()

idx_t duckdb::ColumnData::ScanCount ( ColumnScanState & state,
Vector & result,
idx_t count,
idx_t result_offset = 0 )
virtual
429193 {
429194 if (scan_count == 0) {
429195 return 0;
429196 }
429197 // ScanCount can only be used if there are no updates
429198 D_ASSERT(!HasUpdates());
429199 return ScanVector(state, result, scan_count, ScanVectorType::SCAN_FLAT_VECTOR, result_offset);
429200}

◆ Filter()

void duckdb::ColumnData::Filter ( TransactionData transaction,
idx_t vector_index,
ColumnScanState & state,
Vector & result,
SelectionVector & sel,
idx_t & count,
const TableFilter & filter,
TableFilterState & filter_state )
virtual

Select.

Reimplemented in duckdb::RowIdColumnData, and duckdb::StandardColumnData.

429204 {
429205 idx_t scan_count = Scan(transaction, vector_index, state, result);
429206
429207 UnifiedVectorFormat vdata;
429208 result.ToUnifiedFormat(scan_count, vdata);
429209 ColumnSegment::FilterSelection(sel, result, vdata, filter, filter_state, scan_count, s_count);
429210}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Select()

void duckdb::ColumnData::Select ( TransactionData transaction,
idx_t vector_index,
ColumnScanState & state,
Vector & result,
SelectionVector & sel,
idx_t count )
virtual
429213 {
429214 Scan(transaction, vector_index, state, result);
429215 result.Slice(sel, s_count);
429216}

◆ Skip()

void duckdb::ColumnData::Skip ( ColumnScanState & state,
idx_t count = STANDARD_VECTOR_SIZE )
virtual

Skip the scan forward by "count" rows.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::RowIdColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

429218 {
429219 state.Next(s_count);
429220}
Here is the call graph for this function:

◆ InitializeAppend()

void duckdb::ColumnData::InitializeAppend ( ColumnAppendState & state)
virtual

Initialize an appending phase for this column.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::RowIdColumnData, duckdb::StandardColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

429318 {
429319 auto l = data.Lock();
429320 if (data.IsEmpty(l)) {
429321 // no segments yet, append an empty segment
429323 }
429324 auto segment = data.GetLastSegment(l);
429325 auto &last_segment = segment->GetNode();
429326 if (last_segment.segment_type == ColumnSegmentType::PERSISTENT ||
429327 !last_segment.GetCompressionFunction().init_append) {
429328 // we cannot append to this segment - append a new segment
429329 auto total_rows = segment->GetRowStart() + last_segment.count;
429330 AppendTransientSegment(l, total_rows);
429331 state.current = data.GetLastSegment(l);
429332 } else {
429333 state.current = segment;
429334 }
429335 auto &append_segment = state.current->GetNode();
429336 D_ASSERT(append_segment.segment_type == ColumnSegmentType::TRANSIENT);
429337 append_segment.InitializeAppend(state);
429338 D_ASSERT(append_segment.GetCompressionFunction().append);
429339}
void AppendTransientSegment(SegmentLock &l, idx_t start_row)
Append a transient segment.
Definition duckdb.cpp:429460
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Append() [1/2]

void duckdb::ColumnData::Append ( BaseStatistics & stats,
ColumnAppendState & state,
Vector & vector,
idx_t count )
virtual

Append a vector of type [type] to the end of the column.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::RowIdColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

429222 {
429223 UnifiedVectorFormat vdata;
429224 vector.ToUnifiedFormat(append_count, vdata);
429225 AppendData(append_stats, state, vdata, append_count);
429226}
Here is the caller graph for this function:

◆ Append() [2/2]

void duckdb::ColumnData::Append ( ColumnAppendState & state,
Vector & vector,
idx_t count )

Append a vector of type [type] to the end of the column.

429228 {
429229 if (!stats) {
429230 throw InternalException("ColumnData::Append called on a column with a parent or without stats");
429231 }
429232 lock_guard<mutex> l(stats_lock);
429233 Append(stats->statistics, state, vector, append_count);
429234}
virtual void Append(BaseStatistics &stats, ColumnAppendState &state, Vector &vector, idx_t count)
Append a vector of type [type] to the end of the column.
Definition duckdb.cpp:429222
Here is the call graph for this function:

◆ AppendData()

void duckdb::ColumnData::AppendData ( BaseStatistics & stats,
ColumnAppendState & state,
UnifiedVectorFormat & vdata,
idx_t count )
virtual
429342 {
429343 idx_t offset = 0;
429344 while (true) {
429345 // append the data from the vector
429346 auto &append_segment = state.current->GetNode();
429347 idx_t copied_elements = append_segment.Append(state, vdata, offset, append_count);
429348 this->count += copied_elements;
429349 append_stats.Merge(append_segment.stats.statistics);
429350 if (copied_elements == append_count) {
429351 // finished copying everything
429352 break;
429353 }
429354
429355 // we couldn't fit everything we wanted in the current column segment, create a new one
429356 {
429357 auto l = data.Lock();
429358 AppendTransientSegment(l, state.current->GetRowStart() + append_segment.count);
429359 state.current = data.GetLastSegment(l);
429360 state.current->GetNode().InitializeAppend(state);
429361 }
429362 offset += copied_elements;
429363 append_count -= copied_elements;
429364 }
429365}

◆ RevertAppend()

void duckdb::ColumnData::RevertAppend ( row_t new_count)
virtual

Revert a set of appends to the ColumnData.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::RowIdColumnData, duckdb::StandardColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

429367 {
429368 idx_t new_count = NumericCast<idx_t>(new_count_p);
429369 auto l = data.Lock();
429370 // check if this row is in the segment tree at all
429371 auto last_segment_node = data.GetLastSegment(l);
429372 if (!last_segment_node) {
429373 return;
429374 }
429375 auto &last_segment = last_segment_node->GetNode();
429376 if (new_count >= last_segment_node->GetRowStart() + last_segment.count) {
429377 // the start row is equal to the final portion of the column data: nothing was ever appended here
429378 D_ASSERT(new_count == last_segment_node->GetRowStart() + last_segment.count);
429379 return;
429380 }
429381 // find the segment index that the current row belongs to
429382 idx_t segment_index = data.GetSegmentIndex(l, new_count);
429383 auto segment = data.GetSegmentByIndex(l, UnsafeNumericCast<int64_t>(segment_index));
429384 if (segment->GetRowStart() == new_count) {
429385 // we are truncating exactly this segment - erase it entirely
429386 data.EraseSegments(l, segment_index);
429387 if (segment_index > 0) {
429388 // if we have a previous segment, we need to update the next pointer
429389 auto previous_segment = data.GetSegmentByIndex(l, UnsafeNumericCast<int64_t>(segment_index - 1));
429390 previous_segment->SetNext(nullptr);
429391 }
429392 } else {
429393 // we need to truncate within the segment
429394 // remove any segments AFTER this segment: they should be deleted entirely
429395 data.EraseSegments(l, segment_index + 1);
429396
429397 auto &transient = segment->GetNode();
429398 D_ASSERT(transient.segment_type == ColumnSegmentType::TRANSIENT);
429399 segment->SetNext(nullptr);
429400 transient.RevertAppend(new_count - segment->GetRowStart());
429401 }
429402
429403 this->count = new_count;
429404}
Here is the caller graph for this function:

◆ Fetch()

idx_t duckdb::ColumnData::Fetch ( ColumnScanState & state,
row_t row_id,
Vector & result )
virtual

Fetch the vector from the column data that belongs to this specific row.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::RowIdColumnData, duckdb::StandardColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

429406 {
429407 if (UnsafeNumericCast<idx_t>(row_id) > count) {
429408 throw InternalException("ColumnData::Fetch - row_id out of range");
429409 }
429410 D_ASSERT(row_id >= 0);
429411 // perform the fetch within the segment
429412 state.offset_in_column = UnsafeNumericCast<idx_t>(row_id) / STANDARD_VECTOR_SIZE * STANDARD_VECTOR_SIZE;
429413 state.current = data.GetSegment(state.offset_in_column);
429414 state.internal_index = state.current->GetRowStart();
429415 return ScanVector(state, result, STANDARD_VECTOR_SIZE, ScanVectorType::SCAN_FLAT_VECTOR);
429416}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FetchRow()

void duckdb::ColumnData::FetchRow ( TransactionData transaction,
ColumnFetchState & state,
const StorageIndex & storage_index,
row_t row_id,
Vector & result,
idx_t result_idx )
virtual

Fetch a specific row id and append it to the vector.

Reimplemented in duckdb::ArrayColumnData, duckdb::GeoColumnData, duckdb::ListColumnData, duckdb::RowIdColumnData, duckdb::StandardColumnData, duckdb::StructColumnData, and duckdb::VariantColumnData.

429419 {
429420 if (UnsafeNumericCast<idx_t>(row_id) > count) {
429421 throw InternalException("ColumnData::FetchRow - row_id out of range");
429422 }
429423 auto segment = data.GetSegment(UnsafeNumericCast<idx_t>(row_id));
429424
429425 // now perform the fetch within the segment
429426 auto index_in_segment = row_id - UnsafeNumericCast<row_t>(segment->GetRowStart());
429427 segment->GetNode().FetchRow(state, index_in_segment, result, result_idx);
429428 // merge any updates made to this row
429429
429430 FetchUpdateRow(transaction, row_id, result, result_idx);
429431}
Here is the caller graph for this function:

◆ Update()

void duckdb::ColumnData::Update ( TransactionData transaction,
DataTable & data_table,
idx_t column_index,
Vector & update_vector,
row_t * row_ids,
idx_t update_count,
idx_t row_group_start )
virtual
429443 {
429444 Vector base_vector(type);
429445 ColumnScanState state(nullptr);
429446 FetchUpdateData(state, row_ids, base_vector, row_group_start);
429447
429448 UpdateInternal(transaction, data_table, column_index, update_vector, row_ids, update_count, base_vector,
429449 row_group_start);
429450}

◆ UpdateColumn()

void duckdb::ColumnData::UpdateColumn ( TransactionData transaction,
DataTable & data_table,
const vector< column_t > & column_path,
Vector & update_vector,
row_t * row_ids,
idx_t update_count,
idx_t depth,
idx_t row_group_start )
virtual
429454 {
429455 // this method should only be called at the end of the path in the base column case
429456 D_ASSERT(depth >= column_path.size());
429457 ColumnData::Update(transaction, data_table, column_path[0], update_vector, row_ids, update_count, row_group_start);
429458}

◆ GetUpdateStatistics()

unique_ptr< BaseStatistics > duckdb::ColumnData::GetUpdateStatistics ( )
virtual
429113 {
429114 lock_guard<mutex> update_guard(update_lock);
429115 return updates ? updates->GetStatistics() : nullptr;
429116}

◆ VisitBlockIds()

void duckdb::ColumnData::VisitBlockIds ( BlockIdVisitor & visitor) const
virtual
429505 {
429506 for (auto &segment_p : data.Segments()) {
429507 auto &segment = segment_p;
429508 segment.VisitBlockIds(visitor);
429509 }
429510}

◆ CreateCheckpointState()

unique_ptr< ColumnCheckpointState > duckdb::ColumnData::CreateCheckpointState ( const RowGroup & row_group,
PartialBlockManager & partial_block_manager )
virtual
429513 {
429514 return make_uniq<ColumnCheckpointState>(row_group, *this, partial_block_manager);
429515}

◆ Checkpoint() [1/2]

unique_ptr< ColumnCheckpointState > duckdb::ColumnData::Checkpoint ( const RowGroup & row_group,
ColumnCheckpointInfo & info )

If this is a nested column, "stats" are the corresponding statistics from the parent column Otherwise, "stats" == this->statistics->stats.

429536 {
429537 if (!stats) {
429538 throw InternalException("ColumnData::Checkpoint called without stats on a nested column");
429539 }
429540 return Checkpoint(row_group, checkpoint_info, this->stats->statistics);
429541}
unique_ptr< ColumnCheckpointState > Checkpoint(const RowGroup &row_group, ColumnCheckpointInfo &info)
If this is a nested column, "stats" are the corresponding statistics from the parent column Otherwise...
Definition duckdb.cpp:429535
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Checkpoint() [2/2]

unique_ptr< ColumnCheckpointState > duckdb::ColumnData::Checkpoint ( const RowGroup & row_group,
ColumnCheckpointInfo & info,
const BaseStatistics & stats )
virtual

Reimplemented in duckdb::VariantColumnData.

429544 {
429545 // scan the segments of the column data
429546 // set up the checkpoint state
429547 auto &partial_block_manager = checkpoint_info.GetPartialBlockManager();
429548 auto checkpoint_state = CreateCheckpointState(row_group, partial_block_manager);
429549 checkpoint_state->global_stats = BaseStatistics::CreateEmpty(type).ToUnique();
429550
429551 if (!data.GetRootSegment()) {
429552 // empty table: flush the empty list
429553 return checkpoint_state;
429554 }
429555
429556 vector<reference<ColumnCheckpointState>> states {*checkpoint_state};
429557 ColumnDataCheckpointer checkpointer(states, GetStorageManager(), row_group, checkpoint_info);
429558 checkpointer.Checkpoint();
429559 checkpointer.FinalizeCheckpoint();
429560 return checkpoint_state;
429561}
static BaseStatistics CreateEmpty(LogicalType type)
Definition duckdb.cpp:422871

◆ CheckpointScan()

void duckdb::ColumnData::CheckpointScan ( ColumnSegment & segment,
ColumnScanState & state,
idx_t count,
Vector & scan_vector ) const
virtual
429518 {
429519 if (state.scan_options && state.scan_options->force_fetch_row) {
429520 for (idx_t i = 0; i < count; i++) {
429521 ColumnFetchState fetch_state;
429522 fetch_state.row_group = state.parent->row_group;
429523 segment.FetchRow(fetch_state, UnsafeNumericCast<row_t>(state.offset_in_column + i), scan_vector, i);
429524 }
429525 } else {
429526 segment.Scan(state, count, scan_vector, 0, ScanVectorType::SCAN_FLAT_VECTOR);
429527 }
429528
429529 if (updates) {
429530 D_ASSERT(scan_vector.GetVectorType() == VectorType::FLAT_VECTOR);
429531 updates->FetchCommittedRange(state.offset_in_column, count, scan_vector);
429532 }
429533}

◆ IsPersistent()

bool duckdb::ColumnData::IsPersistent ( )
virtual
429592 {
429593 for (auto &segment : data.Segments()) {
429594 if (segment.segment_type != ColumnSegmentType::PERSISTENT) {
429595 return false;
429596 }
429597 }
429598 return true;
429599}

◆ GetDataPointers()

vector< DataPointer > duckdb::ColumnData::GetDataPointers ( )
429601 {
429602 vector<DataPointer> pointers;
429603 idx_t row_start = 0;
429604 for (auto &segment : data.Segments()) {
429605 pointers.push_back(segment.GetDataPointer(row_start));
429606 row_start += segment.count;
429607 }
429608 return pointers;
429609}

◆ Serialize()

PersistentColumnData duckdb::ColumnData::Serialize ( )
virtual
429916 {
429917 auto result = count ? PersistentColumnData(type, GetDataPointers()) : PersistentColumnData(type);
429918 result.has_updates = HasUpdates();
429919 return result;
429920}

◆ InitializeColumn() [1/2]

void duckdb::ColumnData::InitializeColumn ( PersistentColumnData & column_data)
429563 {
429564 InitializeColumn(column_data, stats->statistics);
429565}

◆ InitializeColumn() [2/2]

void duckdb::ColumnData::InitializeColumn ( PersistentColumnData & column_data,
BaseStatistics & target_stats )
virtual

Reimplemented in duckdb::VariantColumnData.

429567 {
429568 D_ASSERT(type.InternalType() == column_data.logical_type.InternalType());
429569 // construct the segments based on the data pointers
429570 this->count = 0;
429571 for (auto &data_pointer : column_data.pointers) {
429572 // Update the count and statistics
429573 data_pointer.row_start = count;
429574 this->count += data_pointer.tuple_count;
429575
429576 // Merge the statistics. If this is a child column, the target_stats reference will point into the parents stats
429577 // otherwise if this is a top level column, `stats->statistics` == `target_stats`
429578
429579 target_stats.Merge(data_pointer.statistics);
429580
429581 // create a persistent segment
429582 auto segment = ColumnSegment::CreatePersistentSegment(
429583 GetDatabase(), block_manager, data_pointer.block_pointer.block_id, data_pointer.block_pointer.offset, type,
429584 data_pointer.tuple_count, data_pointer.compression_type, std::move(data_pointer.statistics),
429585 std::move(data_pointer.segment_state));
429586
429587 auto l = data.Lock();
429588 AppendSegment(l, std::move(segment));
429589 }
429590}

◆ Deserialize()

shared_ptr< ColumnData > duckdb::ColumnData::Deserialize ( BlockManager & block_manager,
DataTableInfo & info,
idx_t column_index,
ReadStream & source,
const LogicalType & type )
static
429923 {
429924 auto entry = ColumnData::CreateColumn(block_manager, info, column_index, type);
429925
429926 // deserialize the persistent column data
429927 BinaryDeserializer deserializer(source);
429928 deserializer.Begin();
429929 deserializer.Set<DatabaseInstance &>(info.GetDB().GetDatabase());
429930 CompressionInfo compression_info(block_manager);
429931 deserializer.Set<const CompressionInfo &>(compression_info);
429932 deserializer.Set<const LogicalType &>(type);
429933
429934 auto &catalog = info.GetDB().GetStorageManager().GetAttached().GetCatalog();
429935 deserializer.Set<Catalog &>(catalog);
429936
429937 auto persistent_column_data = PersistentColumnData::Deserialize(deserializer);
429938
429939 deserializer.Unset<Catalog>();
429940 deserializer.Unset<LogicalType>();
429941 deserializer.Unset<const CompressionInfo>();
429942 deserializer.Unset<DatabaseInstance>();
429943 deserializer.End();
429944
429945 // initialize the column
429946 entry->InitializeColumn(persistent_column_data, entry->stats->statistics);
429947 return entry;
429948}

◆ GetColumnSegmentInfo()

void duckdb::ColumnData::GetColumnSegmentInfo ( const QueryContext & context,
idx_t row_group_index,
vector< idx_t > col_path,
vector< ColumnSegmentInfo > & result )
virtual
429962 {
429963 D_ASSERT(!col_path.empty());
429964
429965 // convert the column path to a string
429966 string col_path_str = "[";
429967 for (idx_t i = 0; i < col_path.size(); i++) {
429968 if (i > 0) {
429969 col_path_str += ", ";
429970 }
429971 col_path_str += to_string(col_path[i]);
429972 }
429973 col_path_str += "]";
429974
429975 // iterate over the segments
429976 idx_t segment_idx = 0;
429977 for (auto &segment_node : data.SegmentNodes()) {
429978 auto &segment = segment_node.GetNode();
429979 ColumnSegmentInfo column_info;
429980 column_info.row_group_index = row_group_index;
429981 column_info.column_id = col_path[0];
429982 column_info.column_path = col_path_str;
429983 column_info.segment_idx = segment_idx;
429984 column_info.segment_type = type.ToString();
429985 column_info.segment_start = segment_node.GetRowStart();
429986 column_info.segment_count = segment.count;
429987 column_info.compression_type = CompressionTypeToString(segment.GetCompressionFunction().type);
429988 {
429989 lock_guard<mutex> l(stats_lock);
429990 column_info.segment_stats = segment.stats.statistics.ToString();
429991 }
429992 column_info.has_updates = ColumnData::HasUpdates();
429993 // persistent
429994 // block_id
429995 // block_offset
429996 if (segment.segment_type == ColumnSegmentType::PERSISTENT) {
429997 column_info.persistent = true;
429998 column_info.block_id = segment.GetBlockId();
429999 column_info.block_offset = segment.GetBlockOffset();
430000 } else {
430001 column_info.persistent = false;
430002 column_info.block_id = INVALID_BLOCK;
430003 column_info.block_offset = 0;
430004 }
430005 auto &compression_function = segment.GetCompressionFunction();
430006 auto segment_state = segment.GetSegmentState();
430007 if (segment_state) {
430008 column_info.segment_info = segment_state->GetSegmentInfo();
430009 if (compression_function.visit_block_ids) {
430010 ListBlockIds list_block_ids(column_info.additional_blocks);
430011 compression_function.visit_block_ids(segment, list_block_ids);
430012 }
430013 }
430014 if (compression_function.get_segment_info) {
430015 auto segment_info = compression_function.get_segment_info(context, segment);
430016 vector<string> sinfo;
430017 for (auto &item : segment_info) {
430018 auto &mode = item.first;
430019 auto &count = item.second;
430020 sinfo.push_back(StringUtil::Format("%s: %s", mode, count));
430021 }
430022 column_info.segment_info = StringUtil::Join(sinfo, ", ");
430023 }
430024 result.emplace_back(column_info);
430025
430026 segment_idx++;
430027 }
430028}
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
static DUCKDB_API string Join(const vector< string > &input, const string &separator)
Join multiple strings into one string. Components are concatenated by the given separator.
Definition duckdb.cpp:109497
std::string to_string(const T &value)
Definition duckdb.cpp:19425

◆ Verify()

void duckdb::ColumnData::Verify ( RowGroup & parent)
virtual
430030 {
430031#ifdef DEBUG
430032 data.Verify();
430033
430034 bool is_geometry_child_column = false;
430035 if (type.id() == LogicalTypeId::GEOMETRY && this->parent && this->parent->type.id() == LogicalTypeId::GEOMETRY) {
430036 // Geometry child column
430037 is_geometry_child_column = true;
430038 }
430039
430040 if (type.InternalType() == PhysicalType::STRUCT || type.InternalType() == PhysicalType::ARRAY ||
430041 (type.id() == LogicalTypeId::GEOMETRY && !is_geometry_child_column)) {
430042 // structs and fixed size lists don't have segments
430043 D_ASSERT(!data.GetRootSegment());
430044 return;
430045 }
430046
430047 idx_t current_index = 0;
430048 idx_t current_start = 0;
430049 idx_t total_count = 0;
430050 for (auto &segment : data.SegmentNodes()) {
430051 D_ASSERT(segment.GetIndex() == current_index);
430052 D_ASSERT(segment.GetRowStart() == current_start);
430053 current_start += segment.GetNode().count;
430054 total_count += segment.GetNode().count;
430055 current_index++;
430056 }
430057 D_ASSERT(this->count == total_count);
430058#endif
430059}
@ STRUCT
Struct of logical types.
Definition duckdb.hpp:2816

◆ CheckZonemap() [2/2]

FilterPropagateResult duckdb::ColumnData::CheckZonemap ( const StorageIndex & index,
TableFilter & filter )
429267 {
429268 if (!stats) {
429269 throw InternalException("ColumnData::CheckZonemap called on a column without stats");
429270 }
429271 lock_guard<mutex> l(stats_lock);
429272 if (index.IsPushdownExtract()) {
429273 auto child_stats = stats->statistics.PushdownExtract(index.GetChildIndex(0));
429274 if (!child_stats) {
429275 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
429276 }
429277 return filter.CheckStatistics(*child_stats);
429278 }
429279 return filter.CheckStatistics(stats->statistics);
429280}
index

◆ CreateColumn()

shared_ptr< ColumnData > duckdb::ColumnData::CreateColumn ( BlockManager & block_manager,
DataTableInfo & info,
idx_t column_index,
const LogicalType & type,
ColumnDataType data_type = ColumnDataType::MAIN_TABLE,
optional_ptr< ColumnData > parent = nullptr )
static
430063 {
430064 if (type.id() == LogicalTypeId::GEOMETRY) {
430065 return make_shared_ptr<GeoColumnData>(block_manager, info, column_index, type, data_type, parent);
430066 }
430067 if (type.id() == LogicalTypeId::VARIANT) {
430068 return make_shared_ptr<VariantColumnData>(block_manager, info, column_index, type, data_type, parent);
430069 }
430070 if (type.InternalType() == PhysicalType::STRUCT) {
430071 return make_shared_ptr<StructColumnData>(block_manager, info, column_index, type, data_type, parent);
430072 }
430073 if (type.InternalType() == PhysicalType::LIST) {
430074 return make_shared_ptr<ListColumnData>(block_manager, info, column_index, type, data_type, parent);
430075 }
430076 if (type.InternalType() == PhysicalType::ARRAY) {
430077 return make_shared_ptr<ArrayColumnData>(block_manager, info, column_index, type, data_type, parent);
430078 }
430079 if (type.id() == LogicalTypeId::VALIDITY) {
430080 return make_shared_ptr<ValidityColumnData>(block_manager, info, column_index, data_type, parent);
430081 }
430082 return make_shared_ptr<StandardColumnData>(block_manager, info, column_index, type, data_type, parent);
430083}
@ LIST
A list of some logical data type.
Definition duckdb.hpp:2813

◆ MergeStatistics()

void duckdb::ColumnData::MergeStatistics ( const BaseStatistics & other)
429302 {
429303 if (!stats) {
429304 throw InternalException("ColumnData::MergeStatistics called on a column without stats");
429305 }
429306 lock_guard<mutex> l(stats_lock);
429307 return stats->statistics.Merge(other);
429308}

◆ MergeIntoStatistics()

void duckdb::ColumnData::MergeIntoStatistics ( BaseStatistics & other)
429310 {
429311 if (!stats) {
429312 throw InternalException("ColumnData::MergeIntoStatistics called on a column without stats");
429313 }
429314 lock_guard<mutex> l(stats_lock);
429315 return other.Merge(stats->statistics);
429316}

◆ GetStatistics()

unique_ptr< BaseStatistics > duckdb::ColumnData::GetStatistics ( ) const
429294 {
429295 if (!stats) {
429296 throw InternalException("ColumnData::GetStatistics called on a column without stats");
429297 }
429298 lock_guard<mutex> l(stats_lock);
429299 return stats->statistics.ToUnique();
429300}

◆ GetStatisticsRef()

const BaseStatistics & duckdb::ColumnData::GetStatisticsRef ( ) const
429282 {
429283 if (stats) {
429284 return stats->statistics;
429285 }
429286 D_ASSERT(HasParent());
429287 return parent->GetChildStats(*this);
429288}

◆ AppendTransientSegment()

void duckdb::ColumnData::AppendTransientSegment ( SegmentLock & l,
idx_t start_row )
protected

Append a transient segment.

429460 {
429461 const auto block_size = block_manager.GetBlockSize();
429462 const auto type_size = GetTypeIdSize(type.InternalType());
429463 auto vector_segment_size = block_size;
429464
429465 if (data_type == ColumnDataType::INITIAL_TRANSACTION_LOCAL && start_row == 0) {
429466#if STANDARD_VECTOR_SIZE < 1024
429467 vector_segment_size = 1024 * type_size;
429468#else
429469 vector_segment_size = STANDARD_VECTOR_SIZE * type_size;
429470#endif
429471 }
429472
429473 // The segment size is bound by the block size, but can be smaller.
429474 idx_t segment_size = block_size < vector_segment_size ? block_size : vector_segment_size;
429475 allocation_size += segment_size;
429476
429477 auto &db = GetDatabase();
429478 auto &config = DBConfig::GetConfig(db);
429479 auto function = config.GetCompressionFunction(CompressionType::COMPRESSION_UNCOMPRESSED, type.InternalType());
429480
429481 auto new_segment = ColumnSegment::CreateTransientSegment(db, function, type, segment_size, block_manager);
429482 AppendSegment(l, std::move(new_segment));
429483}
db
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AppendSegment()

void duckdb::ColumnData::AppendSegment ( SegmentLock & l,
unique_ptr< ColumnSegment > segment )
protected
429500 {
429501 UpdateCompressionFunction(l, segment->GetCompressionFunction());
429502 data.AppendSegment(l, std::move(segment));
429503}

◆ BeginScanVectorInternal()

void duckdb::ColumnData::BeginScanVectorInternal ( ColumnScanState & state)
protected
429017 {
429018 D_ASSERT(state.current);
429019
429020 state.previous_states.clear();
429021 if (!state.initialized) {
429022 auto &current = state.current->GetNode();
429023 current.InitializeScan(state);
429024 state.internal_index = state.current->GetRowStart();
429025 state.initialized = true;
429026 }
429027 D_ASSERT(data.HasSegment(*state.current));
429028 D_ASSERT(state.internal_index <= state.offset_in_column);
429029 if (state.internal_index < state.offset_in_column) {
429030 auto &current = state.current->GetNode();
429031 current.Skip(state);
429032 }
429033 D_ASSERT(state.current->GetNode().type == type);
429034}

◆ ScanVector() [1/3]

idx_t duckdb::ColumnData::ScanVector ( ColumnScanState & state,
Vector & result,
idx_t remaining,
ScanVectorType scan_type,
idx_t result_offset = 0 )
protected

Scans a base vector from the column.

429037 {
429038 if (scan_type == ScanVectorType::SCAN_FLAT_VECTOR && result.GetVectorType() != VectorType::FLAT_VECTOR) {
429039 throw InternalException("ScanVector called with SCAN_FLAT_VECTOR but result is not a flat vector");
429040 }
429041 BeginScanVectorInternal(state);
429042 idx_t initial_remaining = remaining;
429043 while (remaining > 0) {
429044 auto &current = state.current->GetNode();
429045 auto current_start = state.current->GetRowStart();
429046 D_ASSERT(state.offset_in_column >= current_start && state.offset_in_column <= current_start + current.count);
429047 idx_t scan_count = MinValue<idx_t>(remaining, current_start + current.count - state.offset_in_column);
429048 idx_t result_offset = base_result_offset + initial_remaining - remaining;
429049 if (scan_count > 0) {
429050 if (state.scan_options && state.scan_options->force_fetch_row) {
429051 for (idx_t i = 0; i < scan_count; i++) {
429052 ColumnFetchState fetch_state;
429053 current.FetchRow(fetch_state, UnsafeNumericCast<row_t>(state.offset_in_column + i - current_start),
429054 result, result_offset + i);
429055 }
429056 } else {
429057 current.Scan(state, scan_count, result, result_offset, scan_type);
429058 }
429059
429060 state.offset_in_column += scan_count;
429061 remaining -= scan_count;
429062 }
429063
429064 if (remaining > 0) {
429065 auto next = data.GetNextSegment(*state.current);
429066 if (!next) {
429067 break;
429068 }
429069 state.previous_states.emplace_back(std::move(state.scan_state));
429070 state.current = next;
429071 state.current->GetNode().InitializeScan(state);
429072 state.segment_checked = false;
429073 D_ASSERT(state.offset_in_column >= state.current->GetRowStart() &&
429074 state.offset_in_column <= state.current->GetRowStart() + state.current->GetNode().count);
429075 }
429076 }
429077 state.internal_index = state.offset_in_column;
429078 return initial_remaining - remaining;
429079}
Here is the caller graph for this function:

◆ ScanVector() [2/3]

idx_t duckdb::ColumnData::ScanVector ( TransactionData transaction,
idx_t vector_index,
ColumnScanState & state,
Vector & result,
idx_t target_scan,
ScanVectorType scan_type,
UpdateScanType update_type )
protected

Scans a vector from the column merged with any potential updates.

429151 {
429152 auto scan_count = ScanVector(state, result, target_scan, scan_type);
429153 if (scan_type != ScanVectorType::SCAN_ENTIRE_VECTOR) {
429154 // if we are scanning an entire vector we cannot have updates
429155 FetchUpdates(transaction, vector_index, result, scan_count, update_type);
429156 }
429157 return scan_count;
429158}
Here is the call graph for this function:

◆ ScanVector() [3/3]

idx_t duckdb::ColumnData::ScanVector ( TransactionData transaction,
idx_t vector_index,
ColumnScanState & state,
Vector & result,
idx_t target_scan,
UpdateScanType update_type )
protected
429161 {
429162 auto scan_type = GetVectorScanType(state, target_scan, result);
429163 return ScanVector(transaction, vector_index, state, result, target_scan, scan_type, update_type);
429164}
virtual ScanVectorType GetVectorScanType(ColumnScanState &state, idx_t scan_count, Vector &result)
Whether or not we can scan an entire vector.
Definition duckdb.cpp:428971

◆ SelectVector()

void duckdb::ColumnData::SelectVector ( ColumnScanState & state,
Vector & result,
idx_t target_count,
const SelectionVector & sel,
idx_t sel_count )
protected
429082 {
429083 BeginScanVectorInternal(state);
429084 auto &current = state.current->GetNode();
429085 if (state.current->GetRowStart() + current.count - state.offset_in_column < target_count) {
429086 throw InternalException("ColumnData::SelectVector should be able to fetch everything from one segment");
429087 }
429088 if (state.scan_options && state.scan_options->force_fetch_row) {
429089 for (idx_t i = 0; i < sel_count; i++) {
429090 auto source_idx = sel.get_index(i);
429091 ColumnFetchState fetch_state;
429092 current.FetchRow(fetch_state, UnsafeNumericCast<row_t>(state.offset_in_column + source_idx), result, i);
429093 }
429094 } else {
429095 current.Select(state, target_count, result, sel, sel_count);
429096 }
429097 state.offset_in_column += target_count;
429098 state.internal_index = state.offset_in_column;
429099}

◆ FilterVector()

void duckdb::ColumnData::FilterVector ( ColumnScanState & state,
Vector & result,
idx_t target_count,
SelectionVector & sel,
idx_t & sel_count,
const TableFilter & filter,
TableFilterState & filter_state )
protected
429102 {
429103 BeginScanVectorInternal(state);
429104 auto &current = state.current->GetNode();
429105 if (state.current->GetRowStart() + current.count - state.offset_in_column < target_count) {
429106 throw InternalException("ColumnData::Filter should be able to fetch everything from one segment");
429107 }
429108 current.Filter(state, target_count, result, sel, sel_count, filter, filter_state);
429109 state.offset_in_column += target_count;
429110 state.internal_index = state.offset_in_column;
429111}

◆ FetchUpdates()

void duckdb::ColumnData::FetchUpdates ( TransactionData transaction,
idx_t vector_index,
Vector & result,
idx_t scan_count,
UpdateScanType update_type )
protected
429119 {
429120 lock_guard<mutex> update_guard(update_lock);
429121 if (!updates) {
429122 return;
429123 }
429124 if (update_type == UpdateScanType::DISALLOW_UPDATES && updates->HasUncommittedUpdates(vector_index)) {
429125 throw TransactionException("Cannot create index with outstanding updates");
429126 }
429127 result.Flatten(scan_count);
429128 updates->FetchUpdates(transaction, vector_index, result);
429129}

◆ FetchUpdateRow()

void duckdb::ColumnData::FetchUpdateRow ( TransactionData transaction,
row_t row_id,
Vector & result,
idx_t result_idx )
protected
429131 {
429132 lock_guard<mutex> update_guard(update_lock);
429133 if (!updates) {
429134 return;
429135 }
429136 updates->FetchRow(transaction, NumericCast<idx_t>(row_id), result, result_idx);
429137}

◆ UpdateInternal()

void duckdb::ColumnData::UpdateInternal ( TransactionData transaction,
DataTable & data_table,
idx_t column_index,
Vector & update_vector,
row_t * row_ids,
idx_t update_count,
Vector & base_vector,
idx_t row_group_start )
protected
429141 {
429142 lock_guard<mutex> update_guard(update_lock);
429143 if (!updates) {
429144 updates = make_uniq<UpdateSegment>(*this);
429145 }
429146 updates->Update(transaction, data_table, column_index, update_vector, row_ids, update_count, base_vector,
429147 row_group_start);
429148}

◆ FetchUpdateData()

idx_t duckdb::ColumnData::FetchUpdateData ( ColumnScanState & state,
row_t * row_ids,
Vector & base_vector,
idx_t row_group_start )
protected
429433 {
429434 if (row_ids[0] < UnsafeNumericCast<row_t>(row_group_start)) {
429435 throw InternalException("ColumnData::FetchUpdateData out of range");
429436 }
429437 auto fetch_count = ColumnData::Fetch(state, row_ids[0] - UnsafeNumericCast<row_t>(row_group_start), base_vector);
429438 base_vector.Flatten(fetch_count);
429439 return fetch_count;
429440}
virtual idx_t Fetch(ColumnScanState &state, row_t row_id, Vector &result)
Fetch the vector from the column data that belongs to this specific row.
Definition duckdb.cpp:429406

◆ GetVectorCount()

idx_t duckdb::ColumnData::GetVectorCount ( idx_t vector_index) const
protected
429176 {
429177 idx_t current_row = vector_index * STANDARD_VECTOR_SIZE;
429178 return MinValue<idx_t>(STANDARD_VECTOR_SIZE, count - current_row);
429179}

◆ UpdateCompressionFunction()

void duckdb::ColumnData::UpdateCompressionFunction ( SegmentLock & l,
const CompressionFunction & function )
private
429485 {
429486 if (!compression) {
429487 // compression is empty...
429488 // if we have no segments - we have not set it yet, so assign it
429489 // if we have segments, the compression is mixed, so ignore it
429490 if (data.GetSegmentCount(l) == 0) {
429491 compression.set(function);
429492 }
429493 } else if (compression->type != function.type) {
429494 // we already have compression set - and we are adding a segment with a different compression
429495 // compression in the segment is mixed - clear the compression pointer
429496 compression.reset();
429497 }
429498}

◆ Cast() [1/2]

template<class TARGET>
TARGET & duckdb::ColumnData::Cast ( )
inline
49478 {
49479 DynamicCastCheck<TARGET>(this);
49480 return reinterpret_cast<TARGET &>(*this);
49481 }

◆ Cast() [2/2]

template<class TARGET>
const TARGET & duckdb::ColumnData::Cast ( ) const
inline
49483 {
49484 DynamicCastCheck<TARGET>(this);
49485 return reinterpret_cast<const TARGET &>(*this);
49486 }

The documentation for this class was generated from the following files: