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

Public Member Functions

DUCKDB_API PendingQueryResult (shared_ptr< ClientContext > context, PreparedStatementData &statement, vector< LogicalType > types, bool allow_stream_result)
DUCKDB_API PendingQueryResult (ErrorData error_message)
 PendingQueryResult (const PendingQueryResult &)=delete
DUCKDB_API bool AllowStreamResult () const
PendingQueryResult & operator= (const PendingQueryResult &)=delete
DUCKDB_API PendingExecutionResult ExecuteTask ()
DUCKDB_API PendingExecutionResult CheckPulse ()
void WaitForTask ()
 Halt execution of the thread until a Task is ready to be executed (use with caution).
DUCKDB_API unique_ptr< QueryResult > Execute ()
DUCKDB_API void Close ()
Public Member Functions inherited from duckdb::BaseQueryResult
DUCKDB_API BaseQueryResult (QueryResultType type, StatementType statement_type, StatementProperties properties, vector< LogicalType > types, vector< string > names)
 Creates a successful query result with the specified names and types.
DUCKDB_API BaseQueryResult (QueryResultType type, ErrorData error)
 Creates an unsuccessful query result with error condition.
DUCKDB_API void ThrowError (const string &prepended_message="") const
DUCKDB_API void SetError (ErrorData error)
DUCKDB_API bool HasError () const
DUCKDB_API const ExceptionType & GetErrorType () const
DUCKDB_API const std::string & GetError () const
DUCKDB_API ErrorData & GetErrorObject ()
DUCKDB_API idx_t ColumnCount ()

Static Public Member Functions

static DUCKDB_API bool IsResultReady (PendingExecutionResult result)
 Function to determine whether execution is considered finished.
static DUCKDB_API bool IsExecutionFinished (PendingExecutionResult result)

Static Public Attributes

static constexpr const QueryResultType TYPE = QueryResultType::PENDING_RESULT

Private Member Functions

void CheckExecutableInternal (ClientContextLock &lock)
PendingExecutionResult ExecuteTaskInternal (ClientContextLock &lock)
unique_ptr< QueryResult > ExecuteInternal (ClientContextLock &lock)
unique_ptr< ClientContextLock > LockContext ()

Private Attributes

shared_ptr< ClientContext > context
bool allow_stream_result

Friends

class ClientContext

Additional Inherited Members

Public Attributes inherited from duckdb::BaseQueryResult
QueryResultType type
 The type of the result (MATERIALIZED or STREAMING).
StatementType statement_type
 The type of the statement that created this result.
StatementProperties properties
 Properties of the statement.
vector< LogicalType > types
 The SQL types of the result.
vector< string > names
 The names of the result.
Protected Attributes inherited from duckdb::BaseQueryResult
bool success
 Whether or not execution was successful.
ErrorData error
 The error (in case execution was not successful).

Constructor & Destructor Documentation

◆ PendingQueryResult() [1/2]

duckdb::PendingQueryResult::PendingQueryResult ( shared_ptr< ClientContext > context,
PreparedStatementData & statement,
vector< LogicalType > types,
bool allow_stream_result )
294251 : BaseQueryResult(QueryResultType::PENDING_RESULT, statement.statement_type, statement.properties,
294252 std::move(types_p), statement.names),
294253 context(std::move(context_p)), allow_stream_result(allow_stream_result) {
294254}
DUCKDB_API BaseQueryResult(QueryResultType type, StatementType statement_type, StatementProperties properties, vector< LogicalType > types, vector< string > names)
Creates a successful query result with the specified names and types.
Definition duckdb.cpp:296000

◆ PendingQueryResult() [2/2]

duckdb::PendingQueryResult::PendingQueryResult ( ErrorData error_message)
explicit
294257 : BaseQueryResult(QueryResultType::PENDING_RESULT, std::move(error)) {
294258}
ErrorData error
The error (in case execution was not successful).
Definition duckdb.hpp:19539

◆ ~PendingQueryResult()

duckdb::PendingQueryResult::~PendingQueryResult ( )
override
294260 {
294261}

Member Function Documentation

◆ AllowStreamResult()

bool duckdb::PendingQueryResult::AllowStreamResult ( ) const
294304 {
294305 return allow_stream_result;
294306}

◆ ExecuteTask()

PendingExecutionResult duckdb::PendingQueryResult::ExecuteTask ( )

Executes a single task within the query, returning whether or not the query is ready. If this returns RESULT_READY, the Execute function can be called to obtain a pointer to the result. If this returns RESULT_NOT_READY, the ExecuteTask function should be called again. If this returns EXECUTION_ERROR, an error occurred during execution. If this returns NO_TASKS_AVAILABLE, this means currently no meaningful work can be done by the current executor, but tasks may become available in the future. The error message can be obtained by calling GetError() on the PendingQueryResult.

294293 {
294294 auto lock = LockContext();
294295 return ExecuteTaskInternal(*lock);
294296}

◆ CheckPulse()

PendingExecutionResult duckdb::PendingQueryResult::CheckPulse ( )
294298 {
294299 auto lock = LockContext();
294300 CheckExecutableInternal(*lock);
294301 return context->ExecuteTaskInternal(*lock, *this, true);
294302}

◆ WaitForTask()

Halt execution of the thread until a Task is ready to be executed (use with caution).

294288 {
294289 auto lock = LockContext();
294290 context->WaitForTask(*lock, *this);
294291}

◆ Execute()

Returns the result of the query as an actual query result. This returns (mostly) instantly if ExecuteTask has been called until RESULT_READY was returned.

294335 {
294336 auto lock = LockContext();
294337 return ExecuteInternal(*lock);
294338}

◆ Close()

void duckdb::PendingQueryResult::Close ( )
294340 {
294341 context.reset();
294342}

◆ IsResultReady()

bool duckdb::PendingQueryResult::IsResultReady ( PendingExecutionResult result)
static

Function to determine whether execution is considered finished.

294344 {
294345 return (IsExecutionFinished(result) || result == PendingExecutionResult::RESULT_READY);
294346}
Here is the caller graph for this function:

◆ IsExecutionFinished()

bool duckdb::PendingQueryResult::IsExecutionFinished ( PendingExecutionResult result)
static
294348 {
294349 return (result == PendingExecutionResult::EXECUTION_FINISHED || result == PendingExecutionResult::EXECUTION_ERROR);
294350}

◆ CheckExecutableInternal()

void duckdb::PendingQueryResult::CheckExecutableInternal ( ClientContextLock & lock)
private
294274 {
294275 bool invalidated = HasError() || !context;
294276 if (!invalidated) {
294277 invalidated = !context->IsActiveResult(lock, *this);
294278 }
294279 if (invalidated) {
294280 if (HasError()) {
294281 throw InvalidInputException(
294282 "Attempting to execute an unsuccessful or closed pending query result\nError: %s", GetError());
294283 }
294284 throw InvalidInputException("Attempting to execute an unsuccessful or closed pending query result");
294285 }
294286}

◆ ExecuteTaskInternal()

PendingExecutionResult duckdb::PendingQueryResult::ExecuteTaskInternal ( ClientContextLock & lock)
private
294308 {
294309 CheckExecutableInternal(lock);
294310 return context->ExecuteTaskInternal(lock, *this, false);
294311}

◆ ExecuteInternal()

unique_ptr< QueryResult > duckdb::PendingQueryResult::ExecuteInternal ( ClientContextLock & lock)
private
294313 {
294314 CheckExecutableInternal(lock);
294315
294316 PendingExecutionResult execution_result;
294317 while (!IsResultReady(execution_result = ExecuteTaskInternal(lock))) {
294318 if (execution_result == PendingExecutionResult::BLOCKED) {
294319 CheckExecutableInternal(lock);
294320 context->WaitForTask(lock, *this);
294321 }
294322 }
294323 if (HasError()) {
294324 if (allow_stream_result) {
294325 return make_uniq<StreamQueryResult>(error);
294326 } else {
294327 return make_uniq<MaterializedQueryResult>(error);
294328 }
294329 }
294330 auto result = context->FetchResultInternal(lock, *this);
294331 Close();
294332 return result;
294333}
static DUCKDB_API bool IsResultReady(PendingExecutionResult result)
Function to determine whether execution is considered finished.
Definition duckdb.cpp:294344

◆ LockContext()

unique_ptr< ClientContextLock > duckdb::PendingQueryResult::LockContext ( )
private
294263 {
294264 if (!context) {
294265 if (HasError()) {
294266 throw InvalidInputException(
294267 "Attempting to execute an unsuccessful or closed pending query result\nError: %s", GetError());
294268 }
294269 throw InvalidInputException("Attempting to execute an unsuccessful or closed pending query result");
294270 }
294271 return context->LockContext();
294272}

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