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

Public Member Functions

 UnboundIndex (unique_ptr< CreateInfo > create_info, IndexStorageInfo storage_info, TableIOManager &table_io_manager, AttachedDatabase &db)
bool IsBound () const override
 Returns true if the index is a bound index, and false otherwise.
const string & GetIndexType () const override
 The index type (ART, B+-tree, Skip-List, ...).
const string & GetIndexName () const override
 The name of the index.
IndexConstraintType GetConstraintType () const override
 The index constraint type.
const CreateIndexInfo & GetCreateInfo () const
const IndexStorageInfo & GetStorageInfo () const
const vector< unique_ptr< ParsedExpression > > & GetParsedExpressions () const
const string & GetTableName () const
void CommitDrop () override
void BufferChunk (DataChunk &index_column_chunk, Vector &row_ids, const vector< StorageIndex > &mapped_column_ids_p, BufferedIndexReplay replay_type)
 Buffer Index delete or insert (replay_type) data chunk. See note above on mapped_column_ids, this function assumes that index_column_chunk maps into mapped_column_ids_p to get the physical column index for each Indexed column in the chunk.
bool HasBufferedReplays () const
BufferedIndexReplays & GetBufferedReplays ()
const vector< StorageIndex > & GetMappedColumnIds () const
Public Member Functions inherited from duckdb::Index
bool IsUnique () const
 Returns unique flag.
bool IsPrimary () const
 Returns primary key flag.
bool IsForeign () const
 Returns foreign key flag.
const vector< column_t > & GetColumnIds () const
const unordered_set< column_t > & GetColumnIdSet () const
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Private Attributes

unique_ptr< CreateInfo > create_info
 The CreateInfo of the index.
IndexStorageInfo storage_info
 The serialized storage information of the index.
BufferedIndexReplays buffered_replays
 Buffered for index operations during WAL replay. They are replayed upon index binding.
vector< StorageIndex > mapped_column_ids
 Maps the column IDs in the buffered replays to a physical table offset. For example, column [i] in a buffered ColumnDataCollection is the data for an Indexed column with physical table index mapped_column_ids[i]. This is in sorted order of physical column IDs.

Additional Inherited Members

Public Attributes inherited from duckdb::Index
TableIOManager & table_io_manager
 Associated table io manager.
AttachedDatabase & db
 Attached database instance.
Protected Member Functions inherited from duckdb::Index
 Index (const vector< column_t > &column_ids, TableIOManager &table_io_manager, AttachedDatabase &db)
Protected Attributes inherited from duckdb::Index
vector< column_t > column_ids
 The physical column ids of the indexed columns. For example, given a table with the following columns: (a INT, gen AS (2 * a), b INT, c VARCHAR), an index on columns (a,c) would have physical column_ids [0,2] (since the virtual column is skipped in the physical representation). Also see comments in bound_index.hpp to see how these column IDs are used in the context of bound/unbound expressions. Note that these are the columns for this Index, not all Indexes on the table.
unordered_set< column_t > column_id_set
 Unordered set of column_ids used by the Index.

Constructor & Destructor Documentation

◆ UnboundIndex()

duckdb::UnboundIndex::UnboundIndex ( unique_ptr< CreateInfo > create_info,
IndexStorageInfo storage_info,
TableIOManager & table_io_manager,
AttachedDatabase & db )
156837 : Index(create_info->Cast<CreateIndexInfo>().column_ids, table_io_manager, db), create_info(std::move(create_info)),
156838 storage_info(std::move(storage_info_p)) {
156839 // Memory safety check.
156840 for (idx_t info_idx = 0; info_idx < storage_info.allocator_infos.size(); info_idx++) {
156841 auto &info = storage_info.allocator_infos[info_idx];
156842 for (idx_t buffer_idx = 0; buffer_idx < info.buffer_ids.size(); buffer_idx++) {
156843 if (info.buffer_ids[buffer_idx] > idx_t(MAX_ROW_ID)) {
156844 throw InternalException("found invalid buffer ID in UnboundIndex constructor");
156845 }
156846 }
156847 }
156848}
TableIOManager & table_io_manager
Associated table io manager.
Definition duckdb.hpp:49684
AttachedDatabase & db
Attached database instance.
Definition duckdb.hpp:49686
unique_ptr< CreateInfo > create_info
The CreateInfo of the index.
Definition duckdb.hpp:49900
IndexStorageInfo storage_info
The serialized storage information of the index.
Definition duckdb.hpp:49902
const row_t MAX_ROW_ID
The maximum row identifier used in tables.
Definition duckdb.cpp:50301
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

Member Function Documentation

◆ IsBound()

bool duckdb::UnboundIndex::IsBound ( ) const
inlineoverridevirtual

Returns true if the index is a bound index, and false otherwise.

Implements duckdb::Index.

49918 {
49919 return false;
49920 }

◆ GetIndexType()

const string & duckdb::UnboundIndex::GetIndexType ( ) const
inlineoverridevirtual

The index type (ART, B+-tree, Skip-List, ...).

Implements duckdb::Index.

49921 {
49922 return GetCreateInfo().index_type;
49923 }

◆ GetIndexName()

const string & duckdb::UnboundIndex::GetIndexName ( ) const
inlineoverridevirtual

The name of the index.

Implements duckdb::Index.

49924 {
49925 return GetCreateInfo().index_name;
49926 }

◆ GetConstraintType()

IndexConstraintType duckdb::UnboundIndex::GetConstraintType ( ) const
inlineoverridevirtual

The index constraint type.

Implements duckdb::Index.

49927 {
49928 return GetCreateInfo().constraint_type;
49929 }

◆ GetCreateInfo()

const CreateIndexInfo & duckdb::UnboundIndex::GetCreateInfo ( ) const
inline
49930 {
49931 return create_info->Cast<CreateIndexInfo>();
49932 }

◆ GetStorageInfo()

const IndexStorageInfo & duckdb::UnboundIndex::GetStorageInfo ( ) const
inline
49933 {
49934 return storage_info;
49935 }

◆ GetParsedExpressions()

const vector< unique_ptr< ParsedExpression > > & duckdb::UnboundIndex::GetParsedExpressions ( ) const
inline
49936 {
49937 return GetCreateInfo().parsed_expressions;
49938 }

◆ GetTableName()

const string & duckdb::UnboundIndex::GetTableName ( ) const
inline
49939 {
49940 return GetCreateInfo().table;
49941 }

◆ CommitDrop()

void duckdb::UnboundIndex::CommitDrop ( )
overridevirtual

Implements duckdb::Index.

156850 {
156851 auto &block_manager = table_io_manager.GetIndexBlockManager();
156852 for (auto &info : storage_info.allocator_infos) {
156853 for (auto &block : info.block_pointers) {
156854 if (block.IsValid()) {
156855 block_manager.MarkBlockAsModified(block.block_id);
156856 }
156857 }
156858 }
156859}

◆ BufferChunk()

void duckdb::UnboundIndex::BufferChunk ( DataChunk & index_column_chunk,
Vector & row_ids,
const vector< StorageIndex > & mapped_column_ids_p,
BufferedIndexReplay replay_type )

Buffer Index delete or insert (replay_type) data chunk. See note above on mapped_column_ids, this function assumes that index_column_chunk maps into mapped_column_ids_p to get the physical column index for each Indexed column in the chunk.

First time we are buffering data, canonical column_id mapping is stored. This should be a sorted list of all the physical offsets of Indexed columns on this table.

156862 {
156863 D_ASSERT(!column_ids.empty());
156864 auto types = index_column_chunk.GetTypes(); // column types
156865 types.push_back(LogicalType::ROW_TYPE);
156866
156867 auto &allocator = Allocator::Get(db);
156868
156871 if (mapped_column_ids.empty()) {
156872 mapped_column_ids = mapped_column_ids_p;
156873 }
156874 D_ASSERT(mapped_column_ids == mapped_column_ids_p);
156875
156876 // combined_chunk has all the indexed columns according to mapped_column_ids ordering, as well as a rowid column.
156877 DataChunk combined_chunk;
156878 combined_chunk.InitializeEmpty(types);
156879 for (idx_t i = 0; i < index_column_chunk.ColumnCount(); i++) {
156880 combined_chunk.data[i].Reference(index_column_chunk.data[i]);
156881 }
156882 combined_chunk.data.back().Reference(row_ids);
156883 combined_chunk.SetCardinality(index_column_chunk.size());
156884
156885 auto &buffer = buffered_replays.GetBuffer(replay_type);
156886 if (buffer == nullptr) {
156887 buffer = make_uniq<ColumnDataCollection>(allocator, types);
156888 }
156889 // The starting index of the buffer range is the size of the buffer.
156890 const idx_t start = buffer->Count();
156891 const idx_t end = start + combined_chunk.size();
156892 auto &ranges = buffered_replays.ranges;
156893
156894 if (ranges.empty() || ranges.back().type != replay_type) {
156895 // If there are no buffered ranges, or the replay types don't match, append a new range.
156896 ranges.emplace_back(replay_type, start, end);
156897 buffer->Append(combined_chunk);
156898 return;
156899 }
156900 // Otherwise merge the range with the previous one.
156901 ranges.back().end = end;
156902 buffer->Append(combined_chunk);
156903}
DUCKDB_API void InitializeEmpty(const vector< LogicalType > &types)
Initializes a DataChunk with the given types and without any vector data allocation.
Definition duckdb.cpp:116783
DUCKDB_API vector< LogicalType > GetTypes() const
Returns a list of types of the vectors of this data chunk.
Definition duckdb.cpp:116995
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
vector< column_t > column_ids
The physical column ids of the indexed columns. For example, given a table with the following columns...
Definition duckdb.hpp:49678
vector< StorageIndex > mapped_column_ids
Maps the column IDs in the buffered replays to a physical table offset. For example,...
Definition duckdb.hpp:49911
BufferedIndexReplays buffered_replays
Buffered for index operations during WAL replay. They are replayed upon index binding.
Definition duckdb.hpp:49905
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasBufferedReplays()

bool duckdb::UnboundIndex::HasBufferedReplays ( ) const
inline
49950 {
49951 return buffered_replays.HasBufferedReplays();
49952 }

◆ GetBufferedReplays()

BufferedIndexReplays & duckdb::UnboundIndex::GetBufferedReplays ( )
inline
49954 {
49955 return buffered_replays;
49956 }

◆ GetMappedColumnIds()

const vector< StorageIndex > & duckdb::UnboundIndex::GetMappedColumnIds ( ) const
inline
49958 {
49959 return mapped_column_ids;
49960 }

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