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::BoundIndex Class Referenceabstract

The index is an abstract base class that serves as the basis for indexes. More...

#include <duckdb.hpp>

Inheritance diagram for duckdb::BoundIndex:
Collaboration diagram for duckdb::BoundIndex:

Public Member Functions

 BoundIndex (const string &name, const string &index_type, IndexConstraintType index_constraint_type, const vector< column_t > &column_ids, TableIOManager &table_io_manager, const vector< unique_ptr< Expression > > &unbound_expressions, 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.
void InitializeLock (IndexLock &state)
 Obtains a lock on the index.
virtual ErrorData Append (IndexLock &l, DataChunk &chunk, Vector &row_ids)=0
 Appends data to the locked index.
ErrorData Append (DataChunk &chunk, Vector &row_ids)
 Obtains a lock and calls Append while holding that lock.
virtual ErrorData Append (IndexLock &l, DataChunk &chunk, Vector &row_ids, IndexAppendInfo &info)
 Appends data to the locked index and verifies constraint violations.
ErrorData Append (DataChunk &chunk, Vector &row_ids, IndexAppendInfo &info)
 Obtains a lock and calls Append while holding that lock.
virtual void VerifyAppend (DataChunk &chunk, IndexAppendInfo &info, optional_ptr< ConflictManager > manager)
 Verify that data can be appended to the index without a constraint violation.
virtual void VerifyConstraint (DataChunk &chunk, IndexAppendInfo &info, ConflictManager &manager)
 Verifies the constraint for a chunk of data.
virtual void CommitDrop (IndexLock &index_lock)=0
 Deletes all data from the index. The lock obtained from InitializeLock must be held.
void CommitDrop () override
 Deletes all data from the index.
virtual idx_t TryDelete (IndexLock &state, DataChunk &entries, Vector &row_identifiers, optional_ptr< SelectionVector > deleted_sel=nullptr, optional_ptr< SelectionVector > non_deleted_sel=nullptr)
 Delete a chunk of entries from the index. The lock obtained from InitializeLock must be held. Returns the amount of rows successfully deleted from the index. If either deleted_sel or non_deleted_sel are provided the exact rows that were (not) deleted are written there.
idx_t TryDelete (DataChunk &entries, Vector &row_identifiers, optional_ptr< SelectionVector > deleted_sel=nullptr, optional_ptr< SelectionVector > non_deleted_sel=nullptr)
 Obtains a lock and calls TryDelete while holding that lock.
virtual void Delete (IndexLock &state, DataChunk &entries, Vector &row_identifiers)
 Delete a chunk of entries from the index. The lock obtained from InitializeLock must be held. Throws an error if not all rows are deleted.
void Delete (DataChunk &entries, Vector &row_identifiers)
 Obtains a lock and calls Delete while holding that lock.
virtual ErrorData Insert (IndexLock &l, DataChunk &chunk, Vector &row_ids)=0
 Insert a chunk.
virtual ErrorData Insert (IndexLock &l, DataChunk &chunk, Vector &row_ids, IndexAppendInfo &info)
 Insert a chunk and verifies constraint violations.
virtual bool MergeIndexes (IndexLock &state, BoundIndex &other_index)=0
 Merge another index into this index. The lock obtained from InitializeLock must be held, and the other index must also be locked during the merge.
bool MergeIndexes (BoundIndex &other_index)
 Obtains a lock and calls MergeIndexes while holding that lock.
virtual void Vacuum (IndexLock &l)=0
 Performs a full traversal of the ART while vacuuming the qualifying nodes. The lock obtained from InitializeLock must be held.
void Vacuum ()
 Obtains a lock and calls Vacuum while holding that lock.
virtual bool SupportsDeltaIndexes () const
 Whether or not the index supports the creation of delta indexes.
virtual unique_ptr< BoundIndex > CreateDeltaIndex (DeltaIndexType delta_index_type) const
 Creates a delta index - an empty copy of the index with the same schema, etc This will only be called if SupportsDeltaIndexes returns true.
virtual idx_t GetInMemorySize (IndexLock &state)=0
 Returns the in-memory usage of the index. The lock obtained from InitializeLock must be held.
idx_t GetInMemorySize ()
 Returns the in-memory usage of the index.
virtual void Verify (IndexLock &l)=0
 Returns the string representation of an index, or only traverses and verifies the index.
void Verify ()
 Obtains a lock and calls VerifyAndToString.
virtual string ToString (IndexLock &l, bool display_ascii=false)=0
 Returns the string representation of an index.
string ToString (bool display_ascii=false)
 Obtains a lock and calls ToString.
virtual void VerifyAllocations (IndexLock &l)=0
 Ensures that the node allocation counts match the node counts.
void VerifyAllocations ()
 Obtains a lock and calls VerifyAllocations.
virtual void VerifyBuffers (IndexLock &l)
 Verify the index buffers.
void VerifyBuffers ()
 Obtains a lock and calls VerifyBuffers.
bool IndexIsUpdated (const vector< PhysicalIndex > &column_ids) const
 Returns true if the index is affected by updates on the specified column IDs, and false otherwise.
virtual IndexStorageInfo SerializeToDisk (QueryContext context, const case_insensitive_map_t< Value > &options)
 Serializes index memory to disk and returns the index storage information.
virtual IndexStorageInfo SerializeToWAL (const case_insensitive_map_t< Value > &options)
 Serializes index memory to the WAL and returns the index storage information.
void ExecuteExpressions (DataChunk &input, DataChunk &result)
 Execute the index expressions on an input chunk.
virtual string GetConstraintViolationMessage (VerifyExistenceType verify_type, idx_t failed_index, DataChunk &input)=0
 Throw a constraint violation exception.
void ApplyBufferedReplays (const vector< LogicalType > &table_types, BufferedIndexReplays &buffered_replays, const vector< StorageIndex > &mapped_column_ids)
 Replay index insert and delete operations buffered during WAL replay. table_types has the physical types of the table in the order they appear, not logical (no generated columns). mapped_column_ids contains the sorted order of Indexed physical column ID's (see unbound_index.hpp comments).
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

Static Public Member Functions

static string AppendRowError (DataChunk &input, idx_t index)

Public Attributes

vector< PhysicalType > types
 The physical types stored in the index.
vector< LogicalType > logical_types
 The logical types of the expressions.
string name
 The name of the index.
string index_type
 The index type (ART, B+-tree, Skip-List, ...).
IndexConstraintType index_constraint_type
 The index constraint type.
vector< unique_ptr< Expression > > unbound_expressions
 The vector of unbound expressions, which are later turned into bound expressions. We need to store the unbound expressions, as we might not always have the context available to bind directly. The leaves of these unbound expressions are BoundColumnRefExpressions. These BoundColumnRefExpressions contain a binding (ColumnBinding), and that contains a table_index and a column_index. The table_index is a dummy placeholder. The column_index indexes the column_ids vector in the Index base class. Those column_ids store the physical table indexes of the Index, and we use them when binding the unbound expressions.
DeltaIndexType delta_index_type = DeltaIndexType::NONE
 Whether or not this is a delta index - and if it is, which type it is.
Public Attributes inherited from duckdb::Index
TableIOManager & table_io_manager
 Associated table io manager.
AttachedDatabase & db
 Attached database instance.

Protected Attributes

mutex lock
 Lock used for any changes to the index.
vector< unique_ptr< Expression > > bound_expressions
 The vector of bound expressions to generate the Index keys based on a data chunk. The leaves of the bound expressions are BoundReferenceExpressions. These BoundReferenceExpressions contain offsets into the DataChunk to retrieve the columns for the expression. With these offsets into the DataChunk, the expression executor can now evaluate the expression on incoming data chunks to generate the keys.
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.

Private Member Functions

unique_ptr< Expression > BindExpression (unique_ptr< Expression > expr)
 Bind the unbound expressions of the index.

Private Attributes

ExpressionExecutor executor
 Expression executor to execute the index expressions.

Additional Inherited Members

Protected Member Functions inherited from duckdb::Index
 Index (const vector< column_t > &column_ids, TableIOManager &table_io_manager, AttachedDatabase &db)

Detailed Description

The index is an abstract base class that serves as the basis for indexes.

Constructor & Destructor Documentation

◆ BoundIndex()

duckdb::BoundIndex::BoundIndex ( const string & name,
const string & index_type,
IndexConstraintType index_constraint_type,
const vector< column_t > & column_ids,
TableIOManager & table_io_manager,
const vector< unique_ptr< Expression > > & unbound_expressions,
AttachedDatabase & db )
155897 for (auto &expr : unbound_expressions_p) {
155898 types.push_back(expr->return_type.InternalType());
155899 logical_types.push_back(expr->return_type);
155900 unbound_expressions.emplace_back(expr->Copy());
155901 bound_expressions.push_back(BindExpression(expr->Copy()));
155902 executor.AddExpression(*bound_expressions.back());
155903 }
155904}
vector< PhysicalType > types
The physical types stored in the index.
Definition duckdb.hpp:50020
vector< LogicalType > logical_types
The logical types of the expressions.
Definition duckdb.hpp:50022
ExpressionExecutor executor
Expression executor to execute the index expressions.
Definition duckdb.hpp:50182
string name
The name of the index.
Definition duckdb.hpp:50025
IndexConstraintType index_constraint_type
The index constraint type.
Definition duckdb.hpp:50029
vector< unique_ptr< Expression > > bound_expressions
The vector of bound expressions to generate the Index keys based on a data chunk. The leaves of the b...
Definition duckdb.hpp:50178
vector< unique_ptr< Expression > > unbound_expressions
The vector of unbound expressions, which are later turned into bound expressions. We need to store th...
Definition duckdb.hpp:50041
unique_ptr< Expression > BindExpression(unique_ptr< Expression > expr)
Bind the unbound expressions of the index.
Definition duckdb.cpp:156021
string index_type
The index type (ART, B+-tree, Skip-List, ...).
Definition duckdb.hpp:50027
TableIOManager & table_io_manager
Associated table io manager.
Definition duckdb.hpp:49684
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
AttachedDatabase & db
Attached database instance.
Definition duckdb.hpp:49686

Member Function Documentation

◆ IsBound()

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

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

Implements duckdb::Index.

50047 {
50048 return true;
50049 }

◆ GetIndexType()

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

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

Implements duckdb::Index.

50050 {
50051 return index_type;
50052 }

◆ GetIndexName()

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

The name of the index.

Implements duckdb::Index.

50053 {
50054 return name;
50055 }

◆ GetConstraintType()

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

The index constraint type.

Implements duckdb::Index.

50056 {
50057 return index_constraint_type;
50058 }

◆ InitializeLock()

void duckdb::BoundIndex::InitializeLock ( IndexLock & state)

Obtains a lock on the index.

155906 {
155907 state.index_lock = unique_lock<mutex>(lock);
155908}
mutex lock
Lock used for any changes to the index.
Definition duckdb.hpp:50170
Here is the caller graph for this function:

◆ Append() [1/4]

virtual ErrorData duckdb::BoundIndex::Append ( IndexLock & l,
DataChunk & chunk,
Vector & row_ids )
pure virtual

Appends data to the locked index.

Implemented in duckdb::ART.

Here is the caller graph for this function:

◆ Append() [2/4]

ErrorData duckdb::BoundIndex::Append ( DataChunk & chunk,
Vector & row_ids )

Obtains a lock and calls Append while holding that lock.

155910 {
155911 IndexLock l;
155912 InitializeLock(l);
155913 return Append(l, chunk, row_ids);
155914}
void InitializeLock(IndexLock &state)
Obtains a lock on the index.
Definition duckdb.cpp:155906
virtual ErrorData Append(IndexLock &l, DataChunk &chunk, Vector &row_ids)=0
Appends data to the locked index.
Here is the call graph for this function:

◆ Append() [3/4]

ErrorData duckdb::BoundIndex::Append ( IndexLock & l,
DataChunk & chunk,
Vector & row_ids,
IndexAppendInfo & info )
virtual

Appends data to the locked index and verifies constraint violations.

Reimplemented in duckdb::ART.

155916 {
155917 // Fallback to the old Append.
155918 return Append(l, chunk, row_ids);
155919}
Here is the call graph for this function:

◆ Append() [4/4]

ErrorData duckdb::BoundIndex::Append ( DataChunk & chunk,
Vector & row_ids,
IndexAppendInfo & info )

Obtains a lock and calls Append while holding that lock.

155921 {
155922 IndexLock l;
155923 InitializeLock(l);
155924 return Append(l, chunk, row_ids, info);
155925}
Here is the call graph for this function:

◆ VerifyAppend()

void duckdb::BoundIndex::VerifyAppend ( DataChunk & chunk,
IndexAppendInfo & info,
optional_ptr< ConflictManager > manager )
virtual

Verify that data can be appended to the index without a constraint violation.

Reimplemented in duckdb::ART.

155927 {
155928 throw NotImplementedException("this implementation of VerifyAppend does not exist.");
155929}

◆ VerifyConstraint()

void duckdb::BoundIndex::VerifyConstraint ( DataChunk & chunk,
IndexAppendInfo & info,
ConflictManager & manager )
virtual

Verifies the constraint for a chunk of data.

Reimplemented in duckdb::ART.

155931 {
155932 throw NotImplementedException("this implementation of VerifyConstraint does not exist.");
155933}
Here is the caller graph for this function:

◆ CommitDrop() [1/2]

virtual void duckdb::BoundIndex::CommitDrop ( IndexLock & index_lock)
pure virtual

Deletes all data from the index. The lock obtained from InitializeLock must be held.

Implemented in duckdb::ART.

Here is the caller graph for this function:

◆ CommitDrop() [2/2]

void duckdb::BoundIndex::CommitDrop ( )
overridevirtual

Deletes all data from the index.

Implements duckdb::Index.

155935 {
155936 IndexLock index_lock;
155937 InitializeLock(index_lock);
155938 CommitDrop(index_lock);
155939}
void CommitDrop() override
Deletes all data from the index.
Definition duckdb.cpp:155935
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryDelete() [1/2]

idx_t duckdb::BoundIndex::TryDelete ( IndexLock & state,
DataChunk & entries,
Vector & row_identifiers,
optional_ptr< SelectionVector > deleted_sel = nullptr,
optional_ptr< SelectionVector > non_deleted_sel = nullptr )
virtual

Delete a chunk of entries from the index. The lock obtained from InitializeLock must be held. Returns the amount of rows successfully deleted from the index. If either deleted_sel or non_deleted_sel are provided the exact rows that were (not) deleted are written there.

Reimplemented in duckdb::ART.

155949 {
155950 throw InternalException("TryDelete not implemented");
155951}
Here is the caller graph for this function:

◆ TryDelete() [2/2]

idx_t duckdb::BoundIndex::TryDelete ( DataChunk & entries,
Vector & row_identifiers,
optional_ptr< SelectionVector > deleted_sel = nullptr,
optional_ptr< SelectionVector > non_deleted_sel = nullptr )

Obtains a lock and calls TryDelete while holding that lock.

155942 {
155943 IndexLock state;
155944 InitializeLock(state);
155945 return TryDelete(state, entries, row_identifiers, deleted_sel, non_deleted_sel);
155946}
virtual idx_t TryDelete(IndexLock &state, DataChunk &entries, Vector &row_identifiers, optional_ptr< SelectionVector > deleted_sel=nullptr, optional_ptr< SelectionVector > non_deleted_sel=nullptr)
Delete a chunk of entries from the index. The lock obtained from InitializeLock must be held....
Definition duckdb.cpp:155948
Here is the call graph for this function:

◆ Delete() [1/2]

void duckdb::BoundIndex::Delete ( IndexLock & state,
DataChunk & entries,
Vector & row_identifiers )
virtual

Delete a chunk of entries from the index. The lock obtained from InitializeLock must be held. Throws an error if not all rows are deleted.

155959 {
155960 auto deleted_rows = TryDelete(state, entries, row_identifiers);
155961 if (deleted_rows != entries.size()) {
155962 throw InvalidInputException("Failed to delete all rows from index. Only deleted %d out of %d rows.\nChunk: %s",
155963 deleted_rows, entries.size(), entries.ToString());
155964 }
155965}
DUCKDB_API string ToString() const
Converts this DataChunk to a printable string representation.
Definition duckdb.cpp:117003
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Delete() [2/2]

void duckdb::BoundIndex::Delete ( DataChunk & entries,
Vector & row_identifiers )

Obtains a lock and calls Delete while holding that lock.

155953 {
155954 IndexLock state;
155955 InitializeLock(state);
155956 Delete(state, entries, row_identifiers);
155957}
virtual void Delete(IndexLock &state, DataChunk &entries, Vector &row_identifiers)
Delete a chunk of entries from the index. The lock obtained from InitializeLock must be held....
Definition duckdb.cpp:155959
Here is the call graph for this function:

◆ Insert() [1/2]

virtual ErrorData duckdb::BoundIndex::Insert ( IndexLock & l,
DataChunk & chunk,
Vector & row_ids )
pure virtual

Insert a chunk.

Implemented in duckdb::ART.

◆ Insert() [2/2]

ErrorData duckdb::BoundIndex::Insert ( IndexLock & l,
DataChunk & chunk,
Vector & row_ids,
IndexAppendInfo & info )
virtual

Insert a chunk and verifies constraint violations.

Reimplemented in duckdb::ART.

155967 {
155968 throw NotImplementedException("this implementation of Insert does not exist.");
155969}

◆ MergeIndexes() [1/2]

virtual bool duckdb::BoundIndex::MergeIndexes ( IndexLock & state,
BoundIndex & other_index )
pure virtual

Merge another index into this index. The lock obtained from InitializeLock must be held, and the other index must also be locked during the merge.

Implemented in duckdb::ART.

Here is the caller graph for this function:

◆ MergeIndexes() [2/2]

bool duckdb::BoundIndex::MergeIndexes ( BoundIndex & other_index)

Obtains a lock and calls MergeIndexes while holding that lock.

155971 {
155972 IndexLock state;
155973 InitializeLock(state);
155974 return MergeIndexes(state, other_index);
155975}
virtual bool MergeIndexes(IndexLock &state, BoundIndex &other_index)=0
Merge another index into this index. The lock obtained from InitializeLock must be held,...
Here is the call graph for this function:

◆ Vacuum() [1/2]

virtual void duckdb::BoundIndex::Vacuum ( IndexLock & l)
pure virtual

Performs a full traversal of the ART while vacuuming the qualifying nodes. The lock obtained from InitializeLock must be held.

Implemented in duckdb::ART.

◆ Vacuum() [2/2]

void duckdb::BoundIndex::Vacuum ( )

Obtains a lock and calls Vacuum while holding that lock.

156005 {
156006 IndexLock state;
156007 InitializeLock(state);
156008 Vacuum(state);
156009}
void Vacuum()
Obtains a lock and calls Vacuum while holding that lock.
Definition duckdb.cpp:156005
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SupportsDeltaIndexes()

bool duckdb::BoundIndex::SupportsDeltaIndexes ( ) const
virtual

Whether or not the index supports the creation of delta indexes.

Reimplemented in duckdb::ART.

156039 {
156040 return false;
156041}

◆ CreateDeltaIndex()

unique_ptr< BoundIndex > duckdb::BoundIndex::CreateDeltaIndex ( DeltaIndexType delta_index_type) const
virtual

Creates a delta index - an empty copy of the index with the same schema, etc This will only be called if SupportsDeltaIndexes returns true.

Reimplemented in duckdb::ART.

156043 {
156044 throw InternalException("BoundIndex::CreateDeltaIndex is not supported for this index type");
156045}

◆ GetInMemorySize() [1/2]

virtual idx_t duckdb::BoundIndex::GetInMemorySize ( IndexLock & state)
pure virtual

Returns the in-memory usage of the index. The lock obtained from InitializeLock must be held.

Implemented in duckdb::ART.

◆ GetInMemorySize() [2/2]

idx_t duckdb::BoundIndex::GetInMemorySize ( )

Returns the in-memory usage of the index.

156011 {
156012 IndexLock state;
156013 InitializeLock(state);
156014 return GetInMemorySize(state);
156015}
idx_t GetInMemorySize()
Returns the in-memory usage of the index.
Definition duckdb.cpp:156011
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Verify() [1/2]

virtual void duckdb::BoundIndex::Verify ( IndexLock & l)
pure virtual

Returns the string representation of an index, or only traverses and verifies the index.

Implemented in duckdb::ART.

◆ Verify() [2/2]

void duckdb::BoundIndex::Verify ( )

Obtains a lock and calls VerifyAndToString.

155977 {
155978 IndexLock l;
155979 InitializeLock(l);
155980 Verify(l);
155981}
void Verify()
Obtains a lock and calls VerifyAndToString.
Definition duckdb.cpp:155977
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToString() [1/2]

virtual string duckdb::BoundIndex::ToString ( IndexLock & l,
bool display_ascii = false )
pure virtual

Returns the string representation of an index.

Implemented in duckdb::ART.

Here is the caller graph for this function:

◆ ToString() [2/2]

string duckdb::BoundIndex::ToString ( bool display_ascii = false)

Obtains a lock and calls ToString.

155983 {
155984 IndexLock l;
155985 InitializeLock(l);
155986 return ToString(l, display_ascii);
155987}
virtual string ToString(IndexLock &l, bool display_ascii=false)=0
Returns the string representation of an index.
Here is the call graph for this function:

◆ VerifyAllocations() [1/2]

virtual void duckdb::BoundIndex::VerifyAllocations ( IndexLock & l)
pure virtual

Ensures that the node allocation counts match the node counts.

Implemented in duckdb::ART.

◆ VerifyAllocations() [2/2]

void duckdb::BoundIndex::VerifyAllocations ( )

Obtains a lock and calls VerifyAllocations.

155989 {
155990 IndexLock l;
155991 InitializeLock(l);
155992 return VerifyAllocations(l);
155993}
void VerifyAllocations()
Obtains a lock and calls VerifyAllocations.
Definition duckdb.cpp:155989
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifyBuffers() [1/2]

void duckdb::BoundIndex::VerifyBuffers ( IndexLock & l)
virtual

Verify the index buffers.

Reimplemented in duckdb::ART.

155995 {
155996 throw NotImplementedException("this implementation of VerifyBuffers does not exist");
155997}

◆ VerifyBuffers() [2/2]

void duckdb::BoundIndex::VerifyBuffers ( )

Obtains a lock and calls VerifyBuffers.

155999 {
156000 IndexLock l;
156001 InitializeLock(l);
156002 return VerifyBuffers(l);
156003}
void VerifyBuffers()
Obtains a lock and calls VerifyBuffers.
Definition duckdb.cpp:155999
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IndexIsUpdated()

bool duckdb::BoundIndex::IndexIsUpdated ( const vector< PhysicalIndex > & column_ids) const

Returns true if the index is affected by updates on the specified column IDs, and false otherwise.

156030 {
156031 for (auto &column : column_ids_p) {
156032 if (column_id_set.find(column.index) != column_id_set.end()) {
156033 return true;
156034 }
156035 }
156036 return false;
156037}
unordered_set< column_t > column_id_set
Unordered set of column_ids used by the Index.
Definition duckdb.hpp:49680
Here is the caller graph for this function:

◆ SerializeToDisk()

IndexStorageInfo duckdb::BoundIndex::SerializeToDisk ( QueryContext context,
const case_insensitive_map_t< Value > & options )
virtual

Serializes index memory to disk and returns the index storage information.

Reimplemented in duckdb::ART.

156047 {
156048 throw NotImplementedException("The implementation of this index disk serialization does not exist.");
156049}

◆ SerializeToWAL()

IndexStorageInfo duckdb::BoundIndex::SerializeToWAL ( const case_insensitive_map_t< Value > & options)
virtual

Serializes index memory to the WAL and returns the index storage information.

Reimplemented in duckdb::ART.

156051 {
156052 throw NotImplementedException("The implementation of this index WAL serialization does not exist.");
156053}

◆ ExecuteExpressions()

void duckdb::BoundIndex::ExecuteExpressions ( DataChunk & input,
DataChunk & result )

Execute the index expressions on an input chunk.

156017 {
156018 executor.Execute(input, result);
156019}
Here is the caller graph for this function:

◆ AppendRowError()

string duckdb::BoundIndex::AppendRowError ( DataChunk & input,
idx_t index )
static
156055 {
156056 string error;
156057 for (idx_t c = 0; c < input.ColumnCount(); c++) {
156058 if (c > 0) {
156059 error += ", ";
156060 }
156061 error += input.GetValue(c, index).ToString();
156062 }
156063 return error;
156064}
DUCKDB_API string ToString() const
Convert this value to a string.
Definition duckdb.cpp:133318
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ GetConstraintViolationMessage()

virtual string duckdb::BoundIndex::GetConstraintViolationMessage ( VerifyExistenceType verify_type,
idx_t failed_index,
DataChunk & input )
pure virtual

Throw a constraint violation exception.

Implemented in duckdb::ART.

◆ ApplyBufferedReplays()

void duckdb::BoundIndex::ApplyBufferedReplays ( const vector< LogicalType > & table_types,
BufferedIndexReplays & buffered_replays,
const vector< StorageIndex > & mapped_column_ids )

Replay index insert and delete operations buffered during WAL replay. table_types has the physical types of the table in the order they appear, not logical (no generated columns). mapped_column_ids contains the sorted order of Indexed physical column ID's (see unbound_index.hpp comments).

156077 {
156078 if (!buffered_replays.HasBufferedReplays()) {
156079 return;
156080 }
156081
156082 // We have two replay states: one for inserts and one for deletes. These are indexed into using the
156083 // replay_type. Both scans are interleaved, so the state maintains the position of each scan.
156084 array<BufferedReplayState, 2> replay_states;
156085 DataChunk table_chunk;
156086 table_chunk.InitializeEmpty(table_types);
156087
156088 for (const auto &replay_range : buffered_replays.ranges) {
156089 const auto type_idx = static_cast<idx_t>(replay_range.type);
156090 auto &state = replay_states[type_idx];
156091
156092 // Initialize the scan state if necessary. Take ownership of buffered operations, since we won't need
156093 // them after replaying anyways.
156094 if (!state.scan_initialized) {
156095 state.buffer = buffered_replays.GetBuffer(replay_range.type);
156096 state.buffer->InitializeScan(state.scan_state);
156097 state.buffer->InitializeScanChunk(state.current_chunk);
156098 state.scan_initialized = true;
156099 }
156100
156101 idx_t current_row = replay_range.start;
156102 while (current_row < replay_range.end) {
156103 // Scan the next DataChunk from the ColumnDataCollection buffer if the current row is on or after
156104 // that chunk's starting row index.
156105 if (current_row >= state.scan_state.next_row_index) {
156106 if (!state.buffer->Scan(state.scan_state, state.current_chunk)) {
156107 throw InternalException("Buffered index data exhausted during replay");
156108 }
156109 }
156110
156111 // We need to process the remaining rows in the current chunk, which is the minimum of the available
156112 // rows in the chunk and the remaining rows in the current range.
156113 const auto offset_in_chunk = current_row - state.scan_state.current_row_index;
156114 const auto available_in_chunk = state.current_chunk.size() - offset_in_chunk;
156115 // [start, end) in ReplayRange is [inclusive, exclusive).
156116 const auto range_remaining = replay_range.end - current_row;
156117 const auto rows_to_process = MinValue<idx_t>(available_in_chunk, range_remaining);
156118
156119 SelectionVector sel(offset_in_chunk, rows_to_process);
156120
156121 for (idx_t col_idx = 0; col_idx < state.current_chunk.ColumnCount() - 1; col_idx++) {
156122 const auto col_id = mapped_column_ids[col_idx].GetPrimaryIndex();
156123 table_chunk.data[col_id].Reference(state.current_chunk.data[col_idx]);
156124 table_chunk.data[col_id].Slice(sel, rows_to_process);
156125 }
156126 table_chunk.SetCardinality(rows_to_process);
156127 Vector row_ids(state.current_chunk.data.back(), sel, rows_to_process);
156128
156129 if (replay_range.type == BufferedIndexReplay::INSERT_ENTRY) {
156130 IndexAppendInfo append_info(IndexAppendMode::INSERT_DUPLICATES, nullptr);
156131 const auto error = Append(table_chunk, row_ids, append_info);
156132 if (error.HasError()) {
156133 throw InternalException("error while applying buffered appends: " + error.Message());
156134 }
156135 current_row += rows_to_process;
156136 continue;
156137 }
156138 Delete(table_chunk, row_ids);
156139 current_row += rows_to_process;
156140 }
156141 }
156142}
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
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
Here is the call graph for this function:

◆ BindExpression()

unique_ptr< Expression > duckdb::BoundIndex::BindExpression ( unique_ptr< Expression > expr)
private

Bind the unbound expressions of the index.

156021 {
156022 ExpressionIterator::VisitExpressionMutable<BoundColumnRefExpression>(
156023 root_expr, [&](BoundColumnRefExpression &bound_colref, unique_ptr<Expression> &expr) {
156024 expr =
156025 make_uniq<BoundReferenceExpression>(expr->return_type, column_ids[bound_colref.binding.column_index]);
156026 });
156027 return root_expr;
156028}

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