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

Public Member Functions

 FixedBatchCopyGlobalState (ClientContext &context_p, idx_t minimum_memory_per_thread)
void Initialize (ClientContext &context, const PhysicalBatchCopyToFile &op)
void AddBatchData (idx_t batch_index, unique_ptr< PreparedBatchData > new_batch, idx_t memory_usage)
idx_t MaxThreads (idx_t source_max_threads) override
Public Member Functions inherited from duckdb::GlobalSinkState
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const
Public Member Functions inherited from duckdb::StateWithBlockableTasks
unique_lock< mutex > Lock ()
void PreventBlocking (const unique_lock< mutex > &guard)
bool BlockTask (const unique_lock< mutex > &guard, const InterruptState &interrupt_state)
 Add a task to 'blocked_tasks' before returning SourceResultType::BLOCKED (must hold the lock).
bool CanBlock (const unique_lock< mutex > &guard) const
bool UnblockTasks (const unique_lock< mutex > &guard)
 Unblock all tasks (must hold the lock).
SinkResultType BlockSink (const unique_lock< mutex > &guard, const InterruptState &interrupt_state)
SourceResultType BlockSource (const unique_lock< mutex > &guard, const InterruptState &interrupt_state)
void VerifyLock (const unique_lock< mutex > &guard) const

Public Attributes

BatchMemoryManager memory_manager
BatchTaskManager< BatchCopyTask > task_manager
mutex lock
mutex flush_lock
atomic< bool > initialized
 Whether or not the copy has been initialized.
atomic< idx_t > rows_copied
 The total number of rows copied to the file.
unique_ptr< GlobalFunctionData > global_state
 Global copy state.
idx_t batch_size
 The desired batch size (if any).
map< idx_t, unique_ptr< FixedRawBatchData > > raw_batches
 Unpartitioned batches.
map< idx_t, unique_ptr< FixedPreparedBatchData > > batch_data
 The prepared batch data by batch index - ready to flush.
atomic< idx_t > scheduled_batch_index
 The index of the latest batch index that has been scheduled.
atomic< idx_t > flushed_batch_index
 The index of the latest batch index that has been flushed.
atomic< bool > any_flushing
 Whether or not any thread is flushing.
atomic< bool > any_finished
 Whether or not any threads are finished.
idx_t minimum_memory_per_thread
 Minimum memory per thread.
unique_ptr< CopyToFileInfo > written_file_info
 Written file info (for RETURN_STATS).
Public Attributes inherited from duckdb::GlobalSinkState
SinkFinalizeType state

Static Public Attributes

static constexpr const idx_t MINIMUM_MEMORY_PER_COLUMN_PER_THREAD = 4ULL * 1024ULL * 1024ULL

Constructor & Destructor Documentation

◆ FixedBatchCopyGlobalState()

duckdb::FixedBatchCopyGlobalState::FixedBatchCopyGlobalState ( ClientContext & context_p,
idx_t minimum_memory_per_thread )
inlineexplicit
192067 : memory_manager(context_p, minimum_memory_per_thread), initialized(false), rows_copied(0), batch_size(0),
192070 }
atomic< bool > any_finished
Whether or not any threads are finished.
Definition duckdb.cpp:192095
idx_t minimum_memory_per_thread
Minimum memory per thread.
Definition duckdb.cpp:192097
atomic< idx_t > rows_copied
The total number of rows copied to the file.
Definition duckdb.cpp:192079
atomic< bool > any_flushing
Whether or not any thread is flushing.
Definition duckdb.cpp:192093
idx_t batch_size
The desired batch size (if any).
Definition duckdb.cpp:192083
atomic< idx_t > scheduled_batch_index
The index of the latest batch index that has been scheduled.
Definition duckdb.cpp:192089
atomic< bool > initialized
Whether or not the copy has been initialized.
Definition duckdb.cpp:192077
atomic< idx_t > flushed_batch_index
The index of the latest batch index that has been flushed.
Definition duckdb.cpp:192091

Member Function Documentation

◆ Initialize()

void duckdb::FixedBatchCopyGlobalState::Initialize ( ClientContext & context,
const PhysicalBatchCopyToFile & op )
inline
192101 {
192102 if (initialized) {
192103 return;
192104 }
192105 lock_guard<mutex> guard(lock);
192106 if (initialized) {
192107 return;
192108 }
192109 // initialize writing to the file
192110 global_state = op.function.copy_to_initialize_global(context, *op.bind_data, op.file_path);
192111 if (op.function.initialize_operator) {
192112 op.function.initialize_operator(*global_state, op);
192113 }
192114 if (op.return_type == CopyFunctionReturnType::WRITTEN_FILE_STATISTICS) {
192115 written_file_info = make_uniq<CopyToFileInfo>(op.file_path);
192116 written_file_info->file_stats = make_uniq<CopyFunctionFileStatistics>();
192117 op.function.copy_to_get_written_statistics(context, *op.bind_data, *global_state,
192118 *written_file_info->file_stats);
192119 }
192120 initialized = true;
192121 }
unique_ptr< CopyToFileInfo > written_file_info
Written file info (for RETURN_STATS).
Definition duckdb.cpp:192099
unique_ptr< GlobalFunctionData > global_state
Global copy state.
Definition duckdb.cpp:192081

◆ AddBatchData()

void duckdb::FixedBatchCopyGlobalState::AddBatchData ( idx_t batch_index,
unique_ptr< PreparedBatchData > new_batch,
idx_t memory_usage )
inline
192123 {
192124 // move the batch data to the set of prepared batch data
192125 lock_guard<mutex> l(lock);
192126 auto prepared_data = make_uniq<FixedPreparedBatchData>();
192127 prepared_data->prepared_data = std::move(new_batch);
192128 prepared_data->memory_usage = memory_usage;
192129 auto entry = batch_data.insert(make_pair(batch_index, std::move(prepared_data)));
192130 if (!entry.second) {
192131 throw InternalException("Duplicate batch index %llu encountered in PhysicalFixedBatchCopy", batch_index);
192132 }
192133 }
map< idx_t, unique_ptr< FixedPreparedBatchData > > batch_data
The prepared batch data by batch index - ready to flush.
Definition duckdb.cpp:192087

◆ MaxThreads()

idx_t duckdb::FixedBatchCopyGlobalState::MaxThreads ( idx_t source_max_threads)
inlineoverridevirtual

Reimplemented from duckdb::GlobalSinkState.

192135 {
192136 // try to request 4MB per column per thread
192137 memory_manager.SetMemorySize(source_max_threads * minimum_memory_per_thread);
192138 // cap the concurrent threads working on this task based on the amount of available memory
192139 return MinValue<idx_t>(source_max_threads, memory_manager.AvailableMemory() / minimum_memory_per_thread + 1);
192140 }

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