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::InMemoryLogStorage Class Reference

The InMemoryLogStorage implements a log storage that is backed by ColumnDataCollection's. It only support normalized mode and support a basic single-threaded scan. TODO: improve? More...

#include <duckdb.hpp>

Inheritance diagram for duckdb::InMemoryLogStorage:
Collaboration diagram for duckdb::InMemoryLogStorage:

Public Member Functions

 InMemoryLogStorage (DatabaseInstance &db)
const string GetStorageName () override
bool CanScan (LoggingTargetTable table) override
 Implement LogStorage Single-threaded scan interface.
unique_ptr< LogStorageScanState > CreateScanState (LoggingTargetTable table) const override
bool Scan (LogStorageScanState &state, DataChunk &result) const override
void InitializeScan (LogStorageScanState &state) const override
Public Member Functions inherited from duckdb::BufferingLogStorage
 BufferingLogStorage (DatabaseInstance &db_p, idx_t buffer_size, bool normalize)
void WriteLogEntry (timestamp_t timestamp, LogLevel level, const string &log_type, const string &log_message, const RegisteredLoggingContext &context) final
 (Partially) Implements LogStorage API
void WriteLogEntries (DataChunk &chunk, const RegisteredLoggingContext &context) final
 Write out the chunk to the buffers.
void FlushAll () final
 Flushes buffers for all tables.
void Flush (LoggingTargetTable table) final
 Flushes buffer for a specific table.
void Truncate () override
 Truncates log storage: both buffers and persistent storage (if applicable).
void UpdateConfig (DatabaseInstance &db, case_insensitive_map_t< Value > &config) override
 Apply a new log storage configuration.
bool IsEnabled (LoggingTargetTable table) override
 Returns whether the table is enabled for this storage.
Public Member Functions inherited from duckdb::LogStorage
virtual DUCKDB_API unique_ptr< TableRef > BindReplace (ClientContext &context, TableFunctionBindInput &input, LoggingTargetTable table)

Protected Member Functions

void FlushChunk (LoggingTargetTable table, DataChunk &chunk) override
 Implement BufferingLogStorage interface.
void ResetAllBuffers () override
 Resets the all ColumnDataCollection's.
Protected Member Functions inherited from duckdb::BufferingLogStorage
virtual void UpdateConfigInternal (DatabaseInstance &db, case_insensitive_map_t< Value > &config)
 This method is called in a chained way down the class hierarchy. This allows each class to interpret its own part of the config. Unhandled config values that are left over will result in an error.
void FlushAllInternal ()
 Helper methods.
void FlushInternal (LoggingTargetTable table)
 Flushes one of the tables.
bool IsEnabledInternal (LoggingTargetTable table)
 Whether a specific table is available in the log storage.
idx_t GetBufferLimit () const

Private Member Functions

ColumnDataCollection & GetBuffer (LoggingTargetTable table) const
 Helper function to get the buffer.

Private Attributes

map< LoggingTargetTable, unique_ptr< ColumnDataCollection > > log_storage_buffers

Additional Inherited Members

Static Public Member Functions inherited from duckdb::LogStorage
static vector< LogicalType > GetSchema (LoggingTargetTable table)
static vector< string > GetColumnNames (LoggingTargetTable table)
Protected Attributes inherited from duckdb::BufferingLogStorage
mutex lock
 lock to be used by this class and child classes to ensure thread safety TODO: maybe remove and delegate thread-safety to LogManager?
bool normalize_contexts = true
 Switches between using false = use LoggingTargetTable::ALL_LOGS, true = use LoggingTargetTable::LOG_ENTIRES + LoggingTargetTable::CONTEXTS.

Detailed Description

The InMemoryLogStorage implements a log storage that is backed by ColumnDataCollection's. It only support normalized mode and support a basic single-threaded scan. TODO: improve?

Constructor & Destructor Documentation

◆ InMemoryLogStorage()

duckdb::InMemoryLogStorage::InMemoryLogStorage ( DatabaseInstance & db)
explicit
260464 : BufferingLogStorage(db_p, STANDARD_VECTOR_SIZE, true) {
260465 log_storage_buffers[LoggingTargetTable::LOG_ENTRIES] =
260466 make_uniq<ColumnDataCollection>(Allocator::DefaultAllocator(), GetSchema(LoggingTargetTable::LOG_ENTRIES));
260467 log_storage_buffers[LoggingTargetTable::LOG_CONTEXTS] =
260468 make_uniq<ColumnDataCollection>(Allocator::DefaultAllocator(), GetSchema(LoggingTargetTable::LOG_CONTEXTS));
260469}

◆ ~InMemoryLogStorage()

duckdb::InMemoryLogStorage::~InMemoryLogStorage ( )
override
260487 {
260488}

Member Function Documentation

◆ GetStorageName()

const string duckdb::InMemoryLogStorage::GetStorageName ( )
inlineoverridevirtual

Implements duckdb::LogStorage.

39772 {
39773 return "InMemoryLogStorage";
39774 }

◆ CanScan()

bool duckdb::InMemoryLogStorage::CanScan ( LoggingTargetTable table)
overridevirtual

Implement LogStorage Single-threaded scan interface.

Reimplemented from duckdb::LogStorage.

260652 {
260653 unique_lock<mutex> lck(lock);
260654 return IsEnabledInternal(table);
260655}
mutex lock
lock to be used by this class and child classes to ensure thread safety TODO: maybe remove and delega...
Definition duckdb.hpp:39592
bool IsEnabledInternal(LoggingTargetTable table)
Whether a specific table is available in the log storage.
Definition duckdb.cpp:260018
Here is the call graph for this function:

◆ CreateScanState()

unique_ptr< LogStorageScanState > duckdb::InMemoryLogStorage::CreateScanState ( LoggingTargetTable table) const
overridevirtual

Reimplemented from duckdb::LogStorage.

260657 {
260658 return make_uniq<InMemoryLogStorageScanState>(table);
260659}

◆ Scan()

bool duckdb::InMemoryLogStorage::Scan ( LogStorageScanState & state,
DataChunk & result ) const
overridevirtual

Reimplemented from duckdb::LogStorage.

260661 {
260662 unique_lock<mutex> lck(lock);
260663 auto &in_mem_scan_state = state.Cast<InMemoryLogStorageScanState>();
260664 return GetBuffer(in_mem_scan_state.table).Scan(in_mem_scan_state.scan_state, result);
260665}
DUCKDB_API bool Scan(ColumnDataScanState &state, DataChunk &result) const
Scans a DataChunk from the ColumnDataCollection.
Definition duckdb.cpp:115583
ColumnDataCollection & GetBuffer(LoggingTargetTable table) const
Helper function to get the buffer.
Definition duckdb.cpp:260479

◆ InitializeScan()

void duckdb::InMemoryLogStorage::InitializeScan ( LogStorageScanState & state) const
overridevirtual

Reimplemented from duckdb::LogStorage.

260667 {
260668 unique_lock<mutex> lck(lock);
260669 auto &in_mem_scan_state = state.Cast<InMemoryLogStorageScanState>();
260670 GetBuffer(in_mem_scan_state.table)
260671 .InitializeScan(in_mem_scan_state.scan_state, ColumnDataScanProperties::DISALLOW_ZERO_COPY);
260672}
DUCKDB_API void InitializeScan(ColumnDataScanState &state, ColumnDataScanProperties properties=ColumnDataScanProperties::ALLOW_ZERO_COPY) const
Initializes a Scan state for scanning all columns.
Definition duckdb.cpp:115453
@ DISALLOW_ZERO_COPY
Definition duckdb.hpp:18814

◆ FlushChunk()

void duckdb::InMemoryLogStorage::FlushChunk ( LoggingTargetTable table,
DataChunk & chunk )
overrideprotectedvirtual

Implement BufferingLogStorage interface.

Flushes a chunk to the corresponding ColumnDataCollection

Implements duckdb::BufferingLogStorage.

260611 {
260612 D_ASSERT(table == LoggingTargetTable::LOG_ENTRIES || table == LoggingTargetTable::LOG_CONTEXTS);
260613 log_storage_buffers[table]->Append(chunk);
260614}

◆ ResetAllBuffers()

void duckdb::InMemoryLogStorage::ResetAllBuffers ( )
overrideprotectedvirtual

Resets the all ColumnDataCollection's.

Reimplemented from duckdb::BufferingLogStorage.

260471 {
260473
260474 for (const auto &buffer : log_storage_buffers) {
260475 buffer.second->Reset();
260476 }
260477}
virtual void ResetAllBuffers()
ResetAllBuffers will clear all buffered data. To be overridden by child classes to ensure their buffe...
Definition duckdb.cpp:260455
Here is the call graph for this function:

◆ GetBuffer()

ColumnDataCollection & duckdb::InMemoryLogStorage::GetBuffer ( LoggingTargetTable table) const
private

Helper function to get the buffer.

260479 {
260480 auto res = log_storage_buffers.find(table);
260481 if (res == log_storage_buffers.end()) {
260482 throw InternalException("Failed to find table");
260483 }
260484 return *res->second;
260485}

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