Lbug C++ API
Loading...
Searching...
No Matches
lbug::main::QueryResult Class Referenceabstract

QueryResult stores the result of a query execution. More...

#include <query_result.h>

Classes

class  QueryResultIterator

Public Member Functions

LBUG_API QueryResult ()
 Used to create a QueryResult object for the failing query.
 QueryResult (QueryResultType type)
 QueryResult (QueryResultType type, std::vector< std::string > columnNames, std::vector< common::LogicalType > columnTypes)
virtual LBUG_API ~QueryResult ()=0
 Deconstructs the QueryResult object.
LBUG_API bool isSuccess () const
LBUG_API std::string getErrorMessage () const
LBUG_API size_t getNumColumns () const
LBUG_API std::vector< std::string > getColumnNames () const
LBUG_API std::vector< common::LogicalTypegetColumnDataTypes () const
LBUG_API QuerySummarygetQuerySummary () const
QuerySummarygetQuerySummaryUnsafe ()
LBUG_API bool hasNextQueryResult () const
LBUG_API QueryResultgetNextQueryResult ()
virtual LBUG_API uint64_t getNumTuples () const =0
virtual LBUG_API bool hasNext () const =0
virtual LBUG_API std::shared_ptr< processor::FlatTuplegetNext ()=0
virtual LBUG_API void resetIterator ()=0
 Resets the result tuple iterator.
virtual LBUG_API std::string toString () const =0
LBUG_API std::unique_ptr< ArrowSchemagetArrowSchema () const
 Returns the arrow schema of the query result.
virtual LBUG_API bool hasNextArrowChunk ()=0
virtual LBUG_API std::unique_ptr< ArrowArraygetNextArrowChunk (int64_t chunkSize)=0
 Returns the next chunk of the query result as an arrow array.
QueryResultType getType () const
void setColumnNames (std::vector< std::string > columnNames)
void setColumnTypes (std::vector< common::LogicalType > columnTypes)
void addNextResult (std::unique_ptr< QueryResult > next_)
std::unique_ptr< QueryResultmoveNextResult ()
void setQuerySummary (std::unique_ptr< QuerySummary > summary)
void setDBLifeCycleManager (std::shared_ptr< common::DatabaseLifeCycleManager > dbLifeCycleManager)
template<class TARGET>
TARGET & cast ()
template<class TARGET>
const TARGET & constCast () const

Static Public Member Functions

static std::unique_ptr< QueryResultgetQueryResultWithError (const std::string &errorMessage)

Protected Member Functions

void validateQuerySucceed () const
void checkDatabaseClosedOrThrow () const

Protected Attributes

QueryResultType type
bool success = true
std::string errMsg
std::vector< std::string > columnNames
std::vector< common::LogicalTypecolumnTypes
std::shared_ptr< processor::FlatTupletuple
std::unique_ptr< QuerySummaryquerySummary
std::unique_ptr< QueryResultnextQueryResult
QueryResultIterator queryResultIterator
std::shared_ptr< common::DatabaseLifeCycleManagerdbLifeCycleManager

Detailed Description

QueryResult stores the result of a query execution.

Constructor & Destructor Documentation

◆ QueryResult() [1/3]

LBUG_API lbug::main::QueryResult::QueryResult ( )

Used to create a QueryResult object for the failing query.

◆ QueryResult() [2/3]

lbug::main::QueryResult::QueryResult ( QueryResultType type)
explicit

◆ QueryResult() [3/3]

lbug::main::QueryResult::QueryResult ( QueryResultType type,
std::vector< std::string > columnNames,
std::vector< common::LogicalType > columnTypes )

◆ ~QueryResult()

virtual LBUG_API lbug::main::QueryResult::~QueryResult ( )
pure virtual

Deconstructs the QueryResult object.

Member Function Documentation

◆ addNextResult()

void lbug::main::QueryResult::addNextResult ( std::unique_ptr< QueryResult > next_)

◆ cast()

template<class TARGET>
TARGET & lbug::main::QueryResult::cast ( )
inline

◆ checkDatabaseClosedOrThrow()

void lbug::main::QueryResult::checkDatabaseClosedOrThrow ( ) const
protected

◆ constCast()

template<class TARGET>
const TARGET & lbug::main::QueryResult::constCast ( ) const
inline

◆ getArrowSchema()

LBUG_API std::unique_ptr< ArrowSchema > lbug::main::QueryResult::getArrowSchema ( ) const

Returns the arrow schema of the query result.

Returns
datatypes of the columns as an arrow schema

It is the caller's responsibility to call the release function to release the underlying data If converting to another arrow type, this is usually handled automatically.

◆ getColumnDataTypes()

LBUG_API std::vector< common::LogicalType > lbug::main::QueryResult::getColumnDataTypes ( ) const
Returns
dataType of each column in the query result.

◆ getColumnNames()

LBUG_API std::vector< std::string > lbug::main::QueryResult::getColumnNames ( ) const
Returns
name of each column in the query result.

◆ getErrorMessage()

LBUG_API std::string lbug::main::QueryResult::getErrorMessage ( ) const
Returns
error message of the query execution if the query fails.

◆ getNext()

virtual LBUG_API std::shared_ptr< processor::FlatTuple > lbug::main::QueryResult::getNext ( )
pure virtual
Returns
next flat tuple in the query result. Note that to reduce resource allocation, all calls to getNext() reuse the same FlatTuple object. Since its contents will be overwritten, please complete processing a FlatTuple or make a copy of its data before calling getNext() again.

◆ getNextArrowChunk()

virtual LBUG_API std::unique_ptr< ArrowArray > lbug::main::QueryResult::getNextArrowChunk ( int64_t chunkSize)
pure virtual

Returns the next chunk of the query result as an arrow array.

Parameters
chunkSizenumber of tuples to return in the chunk.
Returns
An arrow array representation of the next chunkSize tuples of the query result.

The ArrowArray internally stores an arrow struct with fields for each of the columns. This can be converted to a RecordBatch with arrow's ImportRecordBatch function

It is the caller's responsibility to call the release function to release the underlying data If converting to another arrow type, this is usually handled automatically.

◆ getNextQueryResult()

LBUG_API QueryResult * lbug::main::QueryResult::getNextQueryResult ( )
Returns
get the next query result to read (for multiple query statements).

◆ getNumColumns()

LBUG_API size_t lbug::main::QueryResult::getNumColumns ( ) const
Returns
number of columns in query result.

◆ getNumTuples()

virtual LBUG_API uint64_t lbug::main::QueryResult::getNumTuples ( ) const
pure virtual
Returns
num of tuples in query result.

◆ getQueryResultWithError()

std::unique_ptr< QueryResult > lbug::main::QueryResult::getQueryResultWithError ( const std::string & errorMessage)
static

◆ getQuerySummary()

LBUG_API QuerySummary * lbug::main::QueryResult::getQuerySummary ( ) const
Returns
query summary which stores the execution time, compiling time, plan and query options.

◆ getQuerySummaryUnsafe()

QuerySummary * lbug::main::QueryResult::getQuerySummaryUnsafe ( )

◆ getType()

QueryResultType lbug::main::QueryResult::getType ( ) const
inline

◆ hasNext()

virtual LBUG_API bool lbug::main::QueryResult::hasNext ( ) const
pure virtual
Returns
whether there are more tuples to read.

◆ hasNextArrowChunk()

virtual LBUG_API bool lbug::main::QueryResult::hasNextArrowChunk ( )
pure virtual
Returns
whether there are more arrow chunk to read.

◆ hasNextQueryResult()

LBUG_API bool lbug::main::QueryResult::hasNextQueryResult ( ) const
Returns
whether there are more query results to read.

◆ isSuccess()

LBUG_API bool lbug::main::QueryResult::isSuccess ( ) const
Returns
if the query is executed successfully or not.

◆ moveNextResult()

std::unique_ptr< QueryResult > lbug::main::QueryResult::moveNextResult ( )

◆ resetIterator()

virtual LBUG_API void lbug::main::QueryResult::resetIterator ( )
pure virtual

Resets the result tuple iterator.

◆ setColumnNames()

void lbug::main::QueryResult::setColumnNames ( std::vector< std::string > columnNames)

◆ setColumnTypes()

void lbug::main::QueryResult::setColumnTypes ( std::vector< common::LogicalType > columnTypes)

◆ setDBLifeCycleManager()

void lbug::main::QueryResult::setDBLifeCycleManager ( std::shared_ptr< common::DatabaseLifeCycleManager > dbLifeCycleManager)

◆ setQuerySummary()

void lbug::main::QueryResult::setQuerySummary ( std::unique_ptr< QuerySummary > summary)

◆ toString()

virtual LBUG_API std::string lbug::main::QueryResult::toString ( ) const
pure virtual
Returns
string of first query result.

◆ validateQuerySucceed()

void lbug::main::QueryResult::validateQuerySucceed ( ) const
protected

Member Data Documentation

◆ columnNames

std::vector<std::string> lbug::main::QueryResult::columnNames
protected

◆ columnTypes

std::vector<common::LogicalType> lbug::main::QueryResult::columnTypes
protected

◆ dbLifeCycleManager

std::shared_ptr<common::DatabaseLifeCycleManager> lbug::main::QueryResult::dbLifeCycleManager
protected

◆ errMsg

std::string lbug::main::QueryResult::errMsg
protected

◆ nextQueryResult

std::unique_ptr<QueryResult> lbug::main::QueryResult::nextQueryResult
protected

◆ queryResultIterator

QueryResultIterator lbug::main::QueryResult::queryResultIterator
protected

◆ querySummary

std::unique_ptr<QuerySummary> lbug::main::QueryResult::querySummary
protected

◆ success

bool lbug::main::QueryResult::success = true
protected

◆ tuple

std::shared_ptr<processor::FlatTuple> lbug::main::QueryResult::tuple
protected

◆ type

QueryResultType lbug::main::QueryResult::type
protected

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