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

Public Member Functions

 CheckpointReader (Catalog &catalog)

Protected Member Functions

virtual void LoadCheckpoint (CatalogTransaction transaction, MetadataReader &reader)
virtual void ReadEntry (CatalogTransaction transaction, Deserializer &deserializer)
virtual void ReadSchema (CatalogTransaction transaction, Deserializer &deserializer)
virtual void ReadTable (CatalogTransaction transaction, Deserializer &deserializer)
virtual void ReadView (CatalogTransaction transaction, Deserializer &deserializer)
virtual void ReadSequence (CatalogTransaction transaction, Deserializer &deserializer)
virtual void ReadMacro (CatalogTransaction transaction, Deserializer &deserializer)
virtual void ReadTableMacro (CatalogTransaction transaction, Deserializer &deserializer)
virtual void ReadIndex (CatalogTransaction transaction, Deserializer &deserializer)
virtual void ReadType (CatalogTransaction transaction, Deserializer &deserializer)
virtual void ReadTableData (CatalogTransaction transaction, Deserializer &deserializer, BoundCreateTableInfo &bound_info)

Protected Attributes

Catalog & catalog

Constructor & Destructor Documentation

◆ CheckpointReader()

duckdb::CheckpointReader::CheckpointReader ( Catalog & catalog)
inlineexplicit
388910 : catalog(catalog) {
388911 }

◆ ~CheckpointReader()

virtual duckdb::CheckpointReader::~CheckpointReader ( )
inlinevirtual
388912 {
388913 }

Member Function Documentation

◆ LoadCheckpoint()

void duckdb::CheckpointReader::LoadCheckpoint ( CatalogTransaction transaction,
MetadataReader & reader )
protectedvirtual
390008 {
390009 BinaryDeserializer deserializer(reader);
390010 deserializer.Set<Catalog &>(catalog);
390011 deserializer.Begin();
390012 deserializer.ReadList(100, "catalog_entries", [&](Deserializer::List &list, idx_t i) {
390013 return list.ReadObject([&](Deserializer &obj) { ReadEntry(transaction, obj); });
390014 });
390015 deserializer.End();
390016 deserializer.Unset<Catalog>();
390017}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ ReadEntry()

void duckdb::CheckpointReader::ReadEntry ( CatalogTransaction transaction,
Deserializer & deserializer )
protectedvirtual
390101 {
390102 auto type = deserializer.ReadProperty<CatalogType>(99, "type");
390103
390104 switch (type) {
390105 case CatalogType::SCHEMA_ENTRY: {
390106 ReadSchema(transaction, deserializer);
390107 break;
390108 }
390109 case CatalogType::TYPE_ENTRY: {
390110 ReadType(transaction, deserializer);
390111 break;
390112 }
390113 case CatalogType::SEQUENCE_ENTRY: {
390114 ReadSequence(transaction, deserializer);
390115 break;
390116 }
390117 case CatalogType::TABLE_ENTRY: {
390118 ReadTable(transaction, deserializer);
390119 break;
390120 }
390121 case CatalogType::VIEW_ENTRY: {
390122 ReadView(transaction, deserializer);
390123 break;
390124 }
390125 case CatalogType::MACRO_ENTRY: {
390126 ReadMacro(transaction, deserializer);
390127 break;
390128 }
390129 case CatalogType::TABLE_MACRO_ENTRY: {
390130 ReadTableMacro(transaction, deserializer);
390131 break;
390132 }
390133 case CatalogType::INDEX_ENTRY: {
390134 ReadIndex(transaction, deserializer);
390135 break;
390136 }
390137 default:
390138 throw InternalException("Unrecognized catalog type in CheckpointWriter::WriteEntry");
390139 }
390140}

◆ ReadSchema()

void duckdb::CheckpointReader::ReadSchema ( CatalogTransaction transaction,
Deserializer & deserializer )
protectedvirtual
390142 {
390143 // Read the schema and create it in the catalog
390144 auto info = deserializer.ReadProperty<unique_ptr<CreateInfo>>(100, "schema");
390145 auto &schema_info = info->Cast<CreateSchemaInfo>();
390146
390147 // we set create conflict to IGNORE_ON_CONFLICT, so that we can ignore a failure when recreating the main schema
390148 schema_info.on_conflict = OnCreateConflict::IGNORE_ON_CONFLICT;
390149 catalog.CreateSchema(transaction, schema_info);
390150}

◆ ReadTable()

void duckdb::CheckpointReader::ReadTable ( CatalogTransaction transaction,
Deserializer & deserializer )
protectedvirtual
390301 {
390302 // deserialize the table meta data
390303 auto info = deserializer.ReadProperty<unique_ptr<CreateInfo>>(100, "table");
390304 auto &schema = catalog.GetSchema(transaction, info->schema);
390305 auto bound_info = Binder::BindCreateTableCheckpoint(std::move(info), schema);
390306
390307 for (auto &dep : bound_info->Base().dependencies.Set()) {
390308 bound_info->dependencies.AddDependency(dep);
390309 }
390310
390311 // now read the actual table data and place it into the CreateTableInfo
390312 ReadTableData(transaction, deserializer, *bound_info);
390313
390314 // finally create the table in the catalog
390315 catalog.CreateTable(transaction, *bound_info);
390316}

◆ ReadView()

void duckdb::CheckpointReader::ReadView ( CatalogTransaction transaction,
Deserializer & deserializer )
protectedvirtual
390159 {
390160 auto info = deserializer.ReadProperty<unique_ptr<CreateInfo>>(100, "view");
390161 auto &view_info = info->Cast<CreateViewInfo>();
390162 catalog.CreateView(transaction, view_info);
390163}

◆ ReadSequence()

void duckdb::CheckpointReader::ReadSequence ( CatalogTransaction transaction,
Deserializer & deserializer )
protectedvirtual
390172 {
390173 auto info = deserializer.ReadProperty<unique_ptr<CreateInfo>>(100, "sequence");
390174 auto &sequence_info = info->Cast<CreateSequenceInfo>();
390175 catalog.CreateSequence(transaction, sequence_info);
390176}

◆ ReadMacro()

void duckdb::CheckpointReader::ReadMacro ( CatalogTransaction transaction,
Deserializer & deserializer )
protectedvirtual
390261 {
390262 auto info = deserializer.ReadProperty<unique_ptr<CreateInfo>>(100, "macro");
390263 auto &macro_info = info->Cast<CreateMacroInfo>();
390264 catalog.CreateFunction(transaction, macro_info);
390265}

◆ ReadTableMacro()

void duckdb::CheckpointReader::ReadTableMacro ( CatalogTransaction transaction,
Deserializer & deserializer )
protectedvirtual
390271 {
390272 auto info = deserializer.ReadProperty<unique_ptr<CreateInfo>>(100, "table_macro");
390273 auto &macro_info = info->Cast<CreateMacroInfo>();
390274 catalog.CreateFunction(transaction, macro_info);
390275}

◆ ReadIndex()

void duckdb::CheckpointReader::ReadIndex ( CatalogTransaction transaction,
Deserializer & deserializer )
protectedvirtual
390189 {
390190 // we need to keep the tag "index", even though it is slightly misleading.
390191 auto create_info = deserializer.ReadProperty<unique_ptr<CreateInfo>>(100, "index");
390192 auto &info = create_info->Cast<CreateIndexInfo>();
390193
390194 // also, we have to read the root_block_pointer, which will not be valid for newer storage versions.
390195 // This leads to different code paths in this function.
390196 auto root_block_pointer =
390197 deserializer.ReadPropertyWithExplicitDefault<BlockPointer>(101, "root_block_pointer", BlockPointer());
390198
390199 // create the index in the catalog
390200
390201 // look for the table in the catalog
390202 auto &schema = catalog.GetSchema(transaction, create_info->schema);
390203 auto catalog_table = schema.GetEntry(transaction, CatalogType::TABLE_ENTRY, info.table);
390204 if (!catalog_table) {
390205 // See internal issue 3663.
390206 throw IOException("corrupt database file - index entry without table entry");
390207 }
390208 auto &table = catalog_table->Cast<DuckTableEntry>();
390209
390210 // we also need to make sure the index type is loaded
390211 // backwards compatibility:
390212 // if the index type is not specified, we default to ART
390213 if (info.index_type.empty()) {
390214 info.index_type = ART::TYPE_NAME;
390215 }
390216
390217 // now we can look for the index in the catalog and assign the table info
390218 auto &index = schema.CreateIndex(transaction, info, table)->Cast<DuckIndexEntry>();
390219 auto &data_table = table.GetStorage();
390220 auto &table_info = data_table.GetDataTableInfo();
390221
390222 IndexStorageInfo index_storage_info;
390223 if (root_block_pointer.IsValid()) {
390224 // Read older duckdb files.
390225 index_storage_info.name = index.name;
390226 index_storage_info.root_block_ptr = root_block_pointer;
390227 } else {
390228 // Extract the matching index storage info (moves it out of the stored collection).
390229 index_storage_info = table_info->ExtractIndexStorageInfo(index.name);
390230 }
390231
390232 D_ASSERT(index_storage_info.IsValid());
390233 D_ASSERT(!index_storage_info.name.empty());
390234
390235 // Create an unbound index and add it to the table.
390236 auto unbound_index = make_uniq<UnboundIndex>(std::move(create_info), std::move(index_storage_info),
390237 TableIOManager::Get(data_table), data_table.db);
390238 table_info->GetIndexes().AddIndex(std::move(unbound_index));
390239}
static constexpr const char * TYPE_NAME
Index type name for the ART.
Definition duckdb.cpp:12136
static TableIOManager & Get(DataTable &table)
Obtains a reference to the TableIOManager of a specific table.
Definition duckdb.cpp:411568
index

◆ ReadType()

void duckdb::CheckpointReader::ReadType ( CatalogTransaction transaction,
Deserializer & deserializer )
protectedvirtual
390248 {
390249 auto info = deserializer.ReadProperty<unique_ptr<CreateInfo>>(100, "type");
390250 auto &type_info = info->Cast<CreateTypeInfo>();
390251 catalog.CreateType(transaction, type_info);
390252}

◆ ReadTableData()

void duckdb::CheckpointReader::ReadTableData ( CatalogTransaction transaction,
Deserializer & deserializer,
BoundCreateTableInfo & bound_info )
protectedvirtual
390319 {
390320 // written in "SingleFileTableDataWriter::FinalizeTable"
390321 auto table_pointer = deserializer.ReadProperty<MetaBlockPointer>(101, "table_pointer");
390322 auto total_rows = deserializer.ReadProperty<idx_t>(102, "total_rows");
390323
390324 // Cover reading old storage files.
390325 auto index_pointers = deserializer.ReadPropertyWithExplicitDefault<vector<BlockPointer>>(103, "index_pointers", {});
390326 // Cover reading new storage files.
390327 auto index_storage_infos =
390328 deserializer.ReadPropertyWithExplicitDefault<vector<IndexStorageInfo>>(104, "index_storage_infos", {});
390329
390330 if (!index_storage_infos.empty()) {
390331 bound_info.indexes = std::move(index_storage_infos);
390332
390333 } else {
390334 // This is an old duckdb file containing index pointers and deprecated storage.
390335 for (idx_t i = 0; i < index_pointers.size(); i++) {
390336 // Deprecated storage is always true for old duckdb files.
390337 IndexStorageInfo index_storage_info;
390338 index_storage_info.root_block_ptr = index_pointers[i];
390339 bound_info.indexes.push_back(std::move(index_storage_info));
390340 }
390341 }
390342
390343 // FIXME: icky downcast to get the underlying MetadataReader
390344 auto &binary_deserializer = dynamic_cast<BinaryDeserializer &>(deserializer);
390345 auto &reader = dynamic_cast<MetadataReader &>(binary_deserializer.GetStream());
390346
390347 vector<MetaBlockPointer> read_pointers;
390348 MetadataReader table_data_reader(reader.GetMetadataManager(), table_pointer, read_pointers);
390349 TableDataReader data_reader(table_data_reader, bound_info, table_pointer);
390350 data_reader.ReadTableData();
390351
390352 bound_info.data->total_rows = total_rows;
390353 bound_info.data->read_metadata_pointers = read_pointers;
390354}

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