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::GeoColumnData Class Referencefinal
Inheritance diagram for duckdb::GeoColumnData:
Collaboration diagram for duckdb::GeoColumnData:

Public Member Functions

 GeoColumnData (BlockManager &block_manager, DataTableInfo &info, idx_t column_index, LogicalType type, ColumnDataType data_type, optional_ptr< ColumnData > parent)
idx_t GetMaxEntry () override
void InitializeChildScanStates (ColumnScanState &state)
void InitializePrefetch (PrefetchState &prefetch_state, ColumnScanState &scan_state, idx_t rows) override
 Initialize prefetch state with required I/O data for the next N rows.
void InitializeScan (ColumnScanState &state) override
 Initialize a scan of the column.
void InitializeScanWithOffset (ColumnScanState &state, idx_t row_idx) override
 Initialize a scan starting at the specified offset.
idx_t Scan (TransactionData transaction, idx_t vector_index, ColumnScanState &state, Vector &result, idx_t scan_count) override
idx_t ScanCount (ColumnScanState &state, Vector &result, idx_t count, idx_t result_offset=0) override
void Skip (ColumnScanState &state, idx_t count=STANDARD_VECTOR_SIZE) override
 Skip the scan forward by "count" rows.
void InitializeAppend (ColumnAppendState &state) override
 Initialize an appending phase for this column.
void Append (BaseStatistics &stats, ColumnAppendState &state, Vector &vector, idx_t count) override
 Append a vector of type [type] to the end of the column.
void RevertAppend (row_t new_count) override
 Revert a set of appends to the ColumnData.
idx_t Fetch (ColumnScanState &state, row_t row_id, Vector &result) override
 Fetch the vector from the column data that belongs to this specific row.
void FetchRow (TransactionData transaction, ColumnFetchState &state, const StorageIndex &storage_index, row_t row_id, Vector &result, idx_t result_idx) override
 Fetch a specific row id and append it to the vector.
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) override
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) override
unique_ptr< BaseStatistics > GetUpdateStatistics () override
unique_ptr< ColumnCheckpointState > CreateCheckpointState (const RowGroup &row_group, PartialBlockManager &partial_block_manager) override
unique_ptr< ColumnCheckpointState > Checkpoint (const RowGroup &row_group, ColumnCheckpointInfo &info, const BaseStatistics &old_stats) override
bool IsPersistent () override
bool HasAnyChanges () const override
 Whether or not the column has ANY changes, including in child columns.
PersistentColumnData Serialize () override
void InitializeColumn (PersistentColumnData &column_data, BaseStatistics &target_stats) override
void GetColumnSegmentInfo (const QueryContext &context, idx_t row_group_index, vector< idx_t > col_path, vector< ColumnSegmentInfo > &result) override
void Verify (RowGroup &parent) override
void VisitBlockIds (BlockIdVisitor &visitor) const override
Public Member Functions inherited from duckdb::ColumnData
 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
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 ScanVectorType GetVectorScanType (ColumnScanState &state, idx_t scan_count, Vector &result)
 Whether or not we can scan an entire vector.
idx_t Scan (TransactionData transaction, idx_t vector_index, ColumnScanState &state, Vector &result)
 Scan the next vector from the column.
virtual void ScanCommittedRange (idx_t row_group_start, idx_t offset_in_row_group, idx_t count, Vector &result)
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)
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)
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 void CheckpointScan (ColumnSegment &segment, ColumnScanState &state, idx_t count, Vector &scan_vector) const
vector< DataPointer > GetDataPointers ()
void InitializeColumn (PersistentColumnData &column_data)
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 ()

Public Attributes

shared_ptr< ColumnData > base_column
GeometryStorageType storage_type = GeometryStorageType::WKB
 Shredding state of the column.
Public Attributes inherited from duckdb::ColumnData
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.

Static Private Member Functions

static void Specialize (Vector &source, Vector &target, idx_t count, GeometryStorageType storage_type)
static void Reassemble (Vector &source, Vector &target, idx_t count, GeometryStorageType storage_type, idx_t offset)
static void InterpretStats (BaseStatistics &source, BaseStatistics &target, GeometryType geom_type, VertexType vert_type)

Additional Inherited Members

Static Public Member Functions inherited from duckdb::ColumnData
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)
Protected Member Functions inherited from duckdb::ColumnData
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 inherited from duckdb::ColumnData
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.

Constructor & Destructor Documentation

◆ GeoColumnData()

duckdb::GeoColumnData::GeoColumnData ( BlockManager & block_manager,
DataTableInfo & info,
idx_t column_index,
LogicalType type,
ColumnDataType data_type,
optional_ptr< ColumnData > parent )
431581 : ColumnData(block_manager, info, column_index, std::move(type_p), data_type, parent) {
431582 if (data_type != ColumnDataType::CHECKPOINT_TARGET) {
431583 base_column = make_shared_ptr<StandardColumnData>(block_manager, info, column_index, type, data_type, this);
431584 }
431585}
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
shared_ptr< ColumnData > base_column
Definition duckdb.cpp:428815

Member Function Documentation

◆ GetMaxEntry()

idx_t duckdb::GeoColumnData::GetMaxEntry ( )
overridevirtual

Reimplemented from duckdb::ColumnData.

432124 {
432125 return base_column->GetMaxEntry();
432126}

◆ InitializeChildScanStates()

void duckdb::GeoColumnData::InitializeChildScanStates ( ColumnScanState & state)
431595 {
431596 // Reset, inner layout might be different
431597 state.child_states.clear();
431598
431599 // Initialize using the type of the base column
431600 state.Initialize(state.context, base_column->type, state.scan_options);
431601}

◆ InitializePrefetch()

void duckdb::GeoColumnData::InitializePrefetch ( PrefetchState & prefetch_state,
ColumnScanState & scan_state,
idx_t rows )
overridevirtual

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

Reimplemented from duckdb::ColumnData.

431591 {
431592 return base_column->InitializePrefetch(prefetch_state, scan_state, rows);
431593}
int rows

◆ InitializeScan()

void duckdb::GeoColumnData::InitializeScan ( ColumnScanState & state)
overridevirtual

Initialize a scan of the column.

Reimplemented from duckdb::ColumnData.

431603 {
431604 InitializeChildScanStates(state);
431605 return base_column->InitializeScan(state);
431606}

◆ InitializeScanWithOffset()

void duckdb::GeoColumnData::InitializeScanWithOffset ( ColumnScanState & state,
idx_t row_idx )
overridevirtual

Initialize a scan starting at the specified offset.

Reimplemented from duckdb::ColumnData.

431608 {
431609 InitializeChildScanStates(state);
431610 return base_column->InitializeScanWithOffset(state, row_idx);
431611}

◆ Scan()

idx_t duckdb::GeoColumnData::Scan ( TransactionData transaction,
idx_t vector_index,
ColumnScanState & state,
Vector & result,
idx_t scan_count )
overridevirtual

Reimplemented from duckdb::ColumnData.

431614 {
431615 // Not a shredded column, so just emit the binary format immediately
431616 if (storage_type == GeometryStorageType::WKB) {
431617 return base_column->Scan(transaction, vector_index, state, result, target_count);
431618 }
431619
431620 // Setup an intermediate chunk to scan the actual data, based on how much we actually scanned
431621 // TODO: Put this in a scan state?
431622 DataChunk scan_chunk;
431623 scan_chunk.Initialize(Allocator::DefaultAllocator(), {base_column->GetType()}, target_count);
431624
431625 const auto scan_count = base_column->Scan(transaction, vector_index, state, scan_chunk.data[0], target_count);
431626
431627 // Now reassemble
431628 Reassemble(scan_chunk.data[0], result, scan_count, storage_type, 0);
431629 return scan_count;
431630}
DUCKDB_API void Initialize(ClientContext &context, const vector< LogicalType > &types, idx_t capacity=STANDARD_VECTOR_SIZE)
Definition duckdb.cpp:116791
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
GeometryStorageType storage_type
Shredding state of the column.
Definition duckdb.cpp:428818

◆ ScanCount()

idx_t duckdb::GeoColumnData::ScanCount ( ColumnScanState & state,
Vector & result,
idx_t count,
idx_t result_offset = 0 )
overridevirtual

Reimplemented from duckdb::ColumnData.

431632 {
431633 // Not a shredded column, so just emit the binary format immediately
431634 if (storage_type == GeometryStorageType::WKB) {
431635 return base_column->ScanCount(state, result, target_count, result_offset);
431636 }
431637
431638 // Setup an intermediate chunk to scan the actual data, based on how much we actually scanned
431639 // TODO: Put this in a scan state
431640 DataChunk scan_chunk;
431641 scan_chunk.Initialize(Allocator::DefaultAllocator(), {base_column->GetType()}, target_count);
431642
431643 const auto scan_count = base_column->ScanCount(state, scan_chunk.data[0], target_count, 0);
431644
431645 // Now reassemble
431646 Reassemble(scan_chunk.data[0], result, scan_count, storage_type, result_offset);
431647 return scan_count;
431648}

◆ Skip()

void duckdb::GeoColumnData::Skip ( ColumnScanState & state,
idx_t count = STANDARD_VECTOR_SIZE )
overridevirtual

Skip the scan forward by "count" rows.

Reimplemented from duckdb::ColumnData.

431650 {
431651 return base_column->Skip(state, count);
431652}
atomic< idx_t > count
The count of the column data.
Definition duckdb.hpp:49273

◆ InitializeAppend()

void duckdb::GeoColumnData::InitializeAppend ( ColumnAppendState & state)
overridevirtual

Initialize an appending phase for this column.

Reimplemented from duckdb::ColumnData.

431658 {
431659 base_column->InitializeAppend(state);
431660}

◆ Append()

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

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

Reimplemented from duckdb::ColumnData.

431661 {
431662 base_column->Append(stats, state, vector, add_count);
431663 count += add_count;
431664}
unique_ptr< SegmentStatistics > stats
The stats of the root segment.
Definition duckdb.hpp:49465

◆ RevertAppend()

void duckdb::GeoColumnData::RevertAppend ( row_t new_count)
overridevirtual

Revert a set of appends to the ColumnData.

Reimplemented from duckdb::ColumnData.

431665 {
431666 base_column->RevertAppend(new_count);
431667 count = UnsafeNumericCast<idx_t>(new_count);
431668}

◆ Fetch()

idx_t duckdb::GeoColumnData::Fetch ( ColumnScanState & state,
row_t row_id,
Vector & result )
overridevirtual

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

Reimplemented from duckdb::ColumnData.

431674 {
431675 // Not a shredded column, so just emit the binary format immediately
431676 if (storage_type == GeometryStorageType::WKB) {
431677 return base_column->Fetch(state, row_id, result);
431678 }
431679
431680 // Otherwise, we need to fetch and reassemble
431681 auto &layout_type = base_column->GetType();
431682
431683 DataChunk chunk;
431684 chunk.Initialize(Allocator::DefaultAllocator(), {layout_type}, 1);
431685
431686 const auto fetch_count = base_column->Fetch(state, row_id, chunk.data[0]);
431687
431688 Reassemble(chunk.data[0], result, fetch_count, storage_type, 0);
431689
431690 return fetch_count;
431691}
Here is the call graph for this function:

◆ FetchRow()

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

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

Reimplemented from duckdb::ColumnData.

431694 {
431695 // Not a shredded column, so just emit the binary format immediately
431696 if (storage_type == GeometryStorageType::WKB) {
431697 return base_column->FetchRow(transaction, state, storage_index, row_id, result, result_idx);
431698 }
431699
431700 // Otherwise, we need to fetch and reassemble
431701 DataChunk chunk;
431702 chunk.Initialize(Allocator::DefaultAllocator(), {base_column->GetType()}, 1);
431703
431704 base_column->FetchRow(transaction, state, storage_index, row_id, chunk.data[0], 0);
431705
431706 Reassemble(chunk.data[0], result, 1, storage_type, result_idx);
431707}
Here is the call graph for this function:

◆ Update()

void duckdb::GeoColumnData::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 )
overridevirtual

Reimplemented from duckdb::ColumnData.

431714 {
431715 throw NotImplementedException("GEOMETRY Update is not supported");
431716}

◆ UpdateColumn()

void duckdb::GeoColumnData::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 )
overridevirtual

Reimplemented from duckdb::ColumnData.

431720 {
431721 throw NotImplementedException("GEOMETRY Update is not supported");
431722}

◆ GetUpdateStatistics()

unique_ptr< BaseStatistics > duckdb::GeoColumnData::GetUpdateStatistics ( )
overridevirtual

Reimplemented from duckdb::ColumnData.

431724 {
431725 return nullptr;
431726}

◆ CreateCheckpointState()

unique_ptr< ColumnCheckpointState > duckdb::GeoColumnData::CreateCheckpointState ( const RowGroup & row_group,
PartialBlockManager & partial_block_manager )
overridevirtual

Reimplemented from duckdb::ColumnData.

431799 {
431800 return make_uniq<GeoColumnCheckpointState>(row_group, *this, partial_block_manager);
431801}

◆ Checkpoint()

unique_ptr< ColumnCheckpointState > duckdb::GeoColumnData::Checkpoint ( const RowGroup & row_group,
ColumnCheckpointInfo & info,
const BaseStatistics & old_stats )
overridevirtual

Reimplemented from duckdb::ColumnData.

431893 {
431894 auto &partial_block_manager = info.GetPartialBlockManager();
431895 auto checkpoint_state = make_uniq<GeoColumnCheckpointState>(row_group, *this, partial_block_manager);
431896
431897 auto &old_column_stats =
431898 base_column->GetType().id() == LogicalTypeId::GEOMETRY ? old_stats : base_column->GetStatisticsRef();
431899
431900 // Are there any changes?
431901 if (!HasAnyChanges()) {
431902 // No changes, keep column
431903 checkpoint_state->inner_column = base_column;
431904 checkpoint_state->inner_column_state =
431905 checkpoint_state->inner_column->Checkpoint(row_group, info, old_column_stats);
431906 return std::move(checkpoint_state);
431907 }
431908
431909 // Old storage version, write as old type
431910 if (GetStorageManager().GetStorageVersion() < 7) {
431911 auto legacy_type = Geometry::GetSpatialGeometryType();
431912 auto new_column =
431913 CreateColumn(block_manager, this->info, base_column->column_index, legacy_type, GetDataType(), this);
431914
431915 // Setup scan from the old column
431916 DataChunk scan_chunk;
431917 ColumnScanState scan_state(nullptr);
431918 scan_chunk.Initialize(Allocator::DefaultAllocator(), {base_column->type}, STANDARD_VECTOR_SIZE);
431919 InitializeScan(scan_state);
431920
431921 // Setup append to the new column
431922 DataChunk append_chunk;
431923 ColumnAppendState append_state;
431924 append_chunk.Initialize(Allocator::DefaultAllocator(), {new_column->type}, STANDARD_VECTOR_SIZE);
431925 new_column->InitializeAppend(append_state);
431926
431927 idx_t total_count = count.load();
431928 idx_t vector_index = 0;
431929
431930 // We need stats when appending
431931 auto empty_stats = BaseStatistics::CreateEmpty(new_column->GetType());
431932
431933 for (idx_t scanned = 0; scanned < total_count; scanned += STANDARD_VECTOR_SIZE) {
431934 scan_chunk.Reset();
431935
431936 auto to_scan = MinValue(total_count - scanned, static_cast<idx_t>(STANDARD_VECTOR_SIZE));
431937 Scan(TransactionData::Committed(), vector_index++, scan_state, scan_chunk.data[0], to_scan);
431938
431939 // Verify the scan chunk
431940 scan_chunk.Verify();
431941
431942 append_chunk.Reset();
431943 append_chunk.SetCardinality(to_scan);
431944
431945 // Make the split
431946 Specialize(scan_chunk.data[0], append_chunk.data[0], to_scan, GeometryStorageType::SPATIAL);
431947
431948 // Append into the new specialized column
431949 new_column->Append(empty_stats, append_state, append_chunk.data[0], to_scan);
431950 }
431951
431952 // Move then new column into our checkpoint state
431953 checkpoint_state->inner_column = new_column;
431954 checkpoint_state->inner_column_state = checkpoint_state->inner_column->Checkpoint(row_group, info, empty_stats);
431955 checkpoint_state->storage_type = GeometryStorageType::SPATIAL;
431956 checkpoint_state->global_stats = GeometryStats::CreateUnknown(type).ToUnique();
431957
431958 // Copy over the non-geometry stats from the old stats, since those are unaffected by the change in storage
431959 // layout
431960 checkpoint_state->global_stats->CopyBase(empty_stats);
431961
431962 return std::move(checkpoint_state);
431963 }
431964
431965 // Do we have enough rows to consider shredding?
431966 auto &table_info = row_group.GetTableInfo();
431967 auto &db = table_info.GetDB();
431968
431969 const auto shredding_threshold = Settings::Get<GeometryMinimumShreddingSize>(DBConfig::Get(db));
431970 const auto current_row_count = count.load();
431971
431972 auto should_shred = shredding_threshold >= 0 && current_row_count >= static_cast<idx_t>(shredding_threshold);
431973 if (!should_shred) {
431974 // Keep column
431975 checkpoint_state->inner_column = base_column;
431976 checkpoint_state->inner_column_state =
431977 checkpoint_state->inner_column->Checkpoint(row_group, info, old_column_stats);
431978 checkpoint_state->global_stats = checkpoint_state->inner_column_state->GetStatistics();
431979 return std::move(checkpoint_state);
431980 }
431981
431982 const auto &types = GeometryStats::GetTypes(old_stats);
431983 const auto &flags = GeometryStats::GetFlags(old_stats);
431984
431985 // Figure out if this segment can use an alternative type layout
431986 auto new_geom_type = GeometryType::POINT;
431987 auto new_vert_type = VertexType::XY;
431988
431989 auto has_mixed_type = !types.TryGetSingleType(new_geom_type, new_vert_type);
431990 auto has_only_geometry_collection = new_geom_type == GeometryType::GEOMETRYCOLLECTION;
431991 auto has_only_invalid = new_geom_type == GeometryType::INVALID;
431992
431993 // We cant specialize empty geometries, because we cant represent zero-vertex geometries in those layouts
431994 const auto has_empty = flags.HasEmptyGeometry() || flags.HasEmptyPart();
431995
431996 if (has_mixed_type || has_only_geometry_collection || has_only_invalid || has_empty) {
431997 // Cant specialize, keep column
431998 checkpoint_state->inner_column = base_column;
431999 checkpoint_state->inner_column_state =
432000 checkpoint_state->inner_column->Checkpoint(row_group, info, old_column_stats);
432001 checkpoint_state->global_stats = checkpoint_state->inner_column_state->GetStatistics();
432002 return std::move(checkpoint_state);
432003 }
432004
432005 auto new_type = Geometry::GetVectorizedType(new_geom_type, new_vert_type);
432006 auto new_storage_type = GetStorageType(new_geom_type, new_vert_type);
432007
432008 auto new_column = CreateColumn(block_manager, this->info, base_column->column_index, new_type, GetDataType(), this);
432009
432010 // Setup scan from the old column
432011 DataChunk scan_chunk;
432012 ColumnScanState scan_state(nullptr);
432013 scan_chunk.Initialize(Allocator::DefaultAllocator(), {base_column->type}, STANDARD_VECTOR_SIZE);
432014 InitializeScan(scan_state);
432015
432016 // Setup append to the new column
432017 DataChunk append_chunk;
432018 ColumnAppendState append_state;
432019 append_chunk.Initialize(Allocator::DefaultAllocator(), {new_column->type}, STANDARD_VECTOR_SIZE);
432020 new_column->InitializeAppend(append_state);
432021
432022 idx_t total_count = count.load();
432023 idx_t vector_index = 0;
432024
432025 auto dummy_stats = BaseStatistics::CreateEmpty(new_column->GetType());
432026
432027 for (idx_t scanned = 0; scanned < total_count; scanned += STANDARD_VECTOR_SIZE) {
432028 scan_chunk.Reset();
432029
432030 auto to_scan = MinValue(total_count - scanned, static_cast<idx_t>(STANDARD_VECTOR_SIZE));
432031 Scan(TransactionData::Committed(), vector_index++, scan_state, scan_chunk.data[0], to_scan);
432032
432033 // Verify the scan chunk
432034 scan_chunk.Verify();
432035
432036 append_chunk.Reset();
432037 append_chunk.SetCardinality(to_scan);
432038
432039 // Make the split
432040 Specialize(scan_chunk.data[0], append_chunk.data[0], to_scan, new_storage_type);
432041
432042 // Append into the new specialized column
432043 new_column->Append(dummy_stats, append_state, append_chunk.data[0], to_scan);
432044 }
432045
432046 // Merge the stats into the checkpoint state's global stats
432047 InterpretStats(dummy_stats, *checkpoint_state->global_stats, new_geom_type, new_vert_type);
432048
432049 // Move then new column into our checkpoint state
432050 auto empty_stats = BaseStatistics::CreateEmpty(new_column->GetType());
432051 checkpoint_state->inner_column = new_column;
432052 checkpoint_state->inner_column_state = checkpoint_state->inner_column->Checkpoint(row_group, info, empty_stats);
432053
432054 // Also set the shredding state
432055 checkpoint_state->storage_type = new_storage_type;
432056
432057 return std::move(checkpoint_state);
432058}
static BaseStatistics CreateEmpty(LogicalType type)
Definition duckdb.cpp:422871
DUCKDB_API void Verify()
Definition duckdb.cpp:117115
DUCKDB_API void Reset()
Definition duckdb.cpp:116840
bool HasAnyChanges() const override
Whether or not the column has ANY changes, including in child columns.
Definition duckdb.cpp:432064
void InitializeScan(ColumnScanState &state) override
Initialize a scan of the column.
Definition duckdb.cpp:431603
static LogicalType GetSpatialGeometryType()
Get legacy geometry type (pre v1.5).
Definition duckdb.cpp:120729
static DUCKDB_API LogicalType GetVectorizedType(GeometryStorageType type)
Get the vectorized logical type for a given geometry and vertex type.
Definition duckdb.cpp:120146
db
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static DUCKDB_API BaseStatistics CreateUnknown(LogicalType type)
Unknown statistics.
Definition duckdb.cpp:423480

◆ IsPersistent()

bool duckdb::GeoColumnData::IsPersistent ( )
overridevirtual

Reimplemented from duckdb::ColumnData.

432060 {
432061 return base_column->IsPersistent();
432062}

◆ HasAnyChanges()

bool duckdb::GeoColumnData::HasAnyChanges ( ) const
overridevirtual

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

Reimplemented from duckdb::ColumnData.

432064 {
432065 return base_column->HasAnyChanges();
432066}

◆ Serialize()

PersistentColumnData duckdb::GeoColumnData::Serialize ( )
overridevirtual

Reimplemented from duckdb::ColumnData.

432068 {
432069 // Serialize the inner column
432070 auto inner_data = base_column->Serialize();
432071
432072 // Always store the format, except for the old spatial format, to avoid breaking compatibility with older versions
432073 if (storage_type != GeometryStorageType::SPATIAL) {
432074 auto extra_data = make_uniq<GeometryPersistentColumnData>();
432075 extra_data->storage_type = storage_type;
432076 inner_data.extra_data = std::move(extra_data);
432077 }
432078
432079 return inner_data;
432080}

◆ InitializeColumn()

void duckdb::GeoColumnData::InitializeColumn ( PersistentColumnData & column_data,
BaseStatistics & target_stats )
overridevirtual

Reimplemented from duckdb::ColumnData.

432082 {
432083 if (!column_data.extra_data) {
432084 // Old geometry segment
432085 storage_type = GeometryStorageType::SPATIAL;
432086
432087 // No shredding, just initialize normally
432088 base_column->InitializeColumn(column_data, target_stats);
432089 count = base_column->count.load();
432090 return;
432091 }
432092
432093 auto &geom_data = column_data.extra_data->Cast<GeometryPersistentColumnData>();
432094
432095 if (geom_data.storage_type == GeometryStorageType::WKB) {
432096 // Standard WKB column, just initialize normally
432097 storage_type = geom_data.storage_type;
432098 base_column->InitializeColumn(column_data, target_stats);
432099 count = base_column->count.load();
432100 return;
432101 }
432102
432103 // Set the shredding state
432104 storage_type = geom_data.storage_type;
432105
432106 // Else, this is a shredded point
432107 const auto layout_type = Geometry::GetVectorizedType(storage_type);
432108 base_column = CreateColumn(block_manager, info, base_column->column_index, layout_type, GetDataType(), this);
432109 D_ASSERT(base_column != nullptr);
432110
432111 auto dummy_stats = BaseStatistics::CreateEmpty(layout_type);
432112 base_column->InitializeColumn(column_data, dummy_stats);
432113 count = base_column->count.load();
432114
432115 // Interpret the stats
432116 const auto types = Geometry::GetSpecializedType(storage_type);
432117 InterpretStats(dummy_stats, target_stats, types.first, types.second);
432118}

◆ GetColumnSegmentInfo()

void duckdb::GeoColumnData::GetColumnSegmentInfo ( const QueryContext & context,
idx_t row_group_index,
vector< idx_t > col_path,
vector< ColumnSegmentInfo > & result )
overridevirtual

Reimplemented from duckdb::ColumnData.

432129 {
432130 return base_column->GetColumnSegmentInfo(context, row_group_index, col_path, result);
432131}

◆ Verify()

void duckdb::GeoColumnData::Verify ( RowGroup & parent)
overridevirtual

Reimplemented from duckdb::ColumnData.

432133 {
432134 return base_column->Verify(parent);
432135}

◆ VisitBlockIds()

void duckdb::GeoColumnData::VisitBlockIds ( BlockIdVisitor & visitor) const
overridevirtual

Reimplemented from duckdb::ColumnData.

432137 {
432138 return base_column->VisitBlockIds(visitor);
432139}

◆ Specialize()

void duckdb::GeoColumnData::Specialize ( Vector & source,
Vector & target,
idx_t count,
GeometryStorageType storage_type )
staticprivate
432144 {
432145 Geometry::ToVectorizedFormat(source, target, count, type);
432146}
static DUCKDB_API void ToVectorizedFormat(Vector &source, Vector &target, idx_t count, GeometryType geom_type, VertexType vert_type)
Convert to vectorized format.
Definition duckdb.cpp:120003

◆ Reassemble()

void duckdb::GeoColumnData::Reassemble ( Vector & source,
Vector & target,
idx_t count,
GeometryStorageType storage_type,
idx_t offset )
staticprivate
432149 {
432150 Geometry::FromVectorizedFormat(source, target, count, type, result_offset);
432151}
static DUCKDB_API void FromVectorizedFormat(Vector &source, Vector &target, idx_t count, GeometryType geom_type, VertexType vert_type, idx_t result_offset)
Convert from vectorized format.
Definition duckdb.cpp:120050

◆ InterpretStats()

void duckdb::GeoColumnData::InterpretStats ( BaseStatistics & source,
BaseStatistics & target,
GeometryType geom_type,
VertexType vert_type )
staticprivate
432189 {
432190 // Copy base stats
432191 target.CopyBase(source);
432192
432193 // Extract vertex stats
432194 const auto vert_stats = GetVertexStats(source, geom_type);
432195 auto &extent = GeometryStats::GetExtent(target);
432196 extent.x_min = NumericStats::GetMin<double>(vert_stats[0]);
432197 extent.x_max = NumericStats::GetMax<double>(vert_stats[0]);
432198 extent.y_min = NumericStats::GetMin<double>(vert_stats[1]);
432199 extent.y_max = NumericStats::GetMax<double>(vert_stats[1]);
432200
432201 switch (vert_type) {
432202 case VertexType::XYZ:
432203 extent.z_min = NumericStats::GetMin<double>(vert_stats[2]);
432204 extent.z_max = NumericStats::GetMax<double>(vert_stats[2]);
432205 break;
432206 case VertexType::XYM:
432207 extent.m_min = NumericStats::GetMin<double>(vert_stats[2]);
432208 extent.m_max = NumericStats::GetMax<double>(vert_stats[2]);
432209 break;
432210 case VertexType::XYZM:
432211 extent.z_min = NumericStats::GetMin<double>(vert_stats[2]);
432212 extent.z_max = NumericStats::GetMax<double>(vert_stats[2]);
432213 extent.m_min = NumericStats::GetMin<double>(vert_stats[3]);
432214 extent.m_max = NumericStats::GetMax<double>(vert_stats[3]);
432215 break;
432216 default:
432217 // Nothing to do
432218 break;
432219 }
432220
432221 // Set types
432222 auto &types = GeometryStats::GetTypes(target);
432223 types.Clear();
432224 types.Add(geom_type, vert_type);
432225
432226 // Also set non-empty flag
432227 auto &geo_flags = GeometryStats::GetFlags(target);
432228 geo_flags.Clear();
432229 geo_flags.SetHasNonEmptyGeometry();
432230 geo_flags.SetHasNonEmptyPart();
432231}

Member Data Documentation

◆ base_column

shared_ptr<ColumnData> duckdb::GeoColumnData::base_column

The actual column data The "shape" of this might differ depending on if we "shred" this column or not.


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