OmniSciDB
a5dc49c757
|
A container for relational algebra descriptors defining the execution order for a relational algebra query. Holds the relational algebra descriptors for executing a relational algebra query. Each descriptor holds both a top-level relational algebra node and a ResultSet ptr holding the results from the execution of the accompany node(s). The sequence can be generated on initialization or lazily with calls to the next() operator. More...
#include <RelAlgExecutionDescriptor.h>
Public Member Functions | |
RaExecutionSequence (const RelAlgNode *, Executor *, const bool build_sequence=true) | |
RaExecutionSequence (std::unique_ptr< RaExecutionDesc > exec_desc) | |
RaExecutionDesc * | next () |
RaExecutionDesc * | prev () |
std::optional< size_t > | nextStepId (const bool after_broadcast) const |
bool | executionFinished () const |
void | extractQueryStepSkippingInfo () |
void | skipQuerySteps () |
std::vector< Vertex > | mergeSortWithInput (const std::vector< Vertex > &vertices, const DAG &graph) |
const std::unordered_map< int, QueryPlanHash > | getSkippedQueryStepCacheKeys () const |
RaExecutionDesc * | getDescriptor (size_t idx) const |
RaExecutionDesc * | getDescriptorByBodyId (unsigned const body_id, size_t const start_idx) const |
size_t | size () const |
bool | empty () const |
size_t | totalDescriptorsCount () const |
const bool | hasQueryStepForUnion () const |
Private Member Functions | |
size_t | stepsToNextBroadcast () const |
Private Attributes | |
DAG | graph_ |
Executor * | executor_ |
std::unordered_set< Vertex > | joins_ |
std::vector< Vertex > | ordering_ |
size_t | current_vertex_ = 0 |
size_t | scan_count_ = 0 |
std::unordered_map< const RelAlgNode *, int > | node_ptr_to_vert_idx_ |
std::unordered_map< int, std::unordered_set< int > > | skippable_steps_ |
std::unordered_set< int > | cached_query_steps_ |
std::unordered_map< int, QueryPlanHash > | cached_resultset_keys_ |
bool | has_step_for_union_ {false} |
bool | has_limit_clause_ {false} |
std::vector< std::unique_ptr < RaExecutionDesc > > | descs_ |
A container for relational algebra descriptors defining the execution order for a relational algebra query. Holds the relational algebra descriptors for executing a relational algebra query. Each descriptor holds both a top-level relational algebra node and a ResultSet ptr holding the results from the execution of the accompany node(s). The sequence can be generated on initialization or lazily with calls to the next() operator.
Definition at line 133 of file RelAlgExecutionDescriptor.h.
RaExecutionSequence::RaExecutionSequence | ( | const RelAlgNode * | sink, |
Executor * | executor, | ||
const bool | build_sequence = true |
||
) |
Definition at line 209 of file RelAlgExecutionDescriptor.cpp.
References anonymous_namespace{RelAlgExecutionDescriptor.cpp}::build_dag(), CHECK, executor_, extractQueryStepSkippingInfo(), g_allow_query_step_skipping, g_cluster, g_enable_data_recycler, g_use_query_resultset_cache, anonymous_namespace{RelAlgExecutionDescriptor.cpp}::get_join_vertices(), graph_, has_step_for_union_, joins_, mergeSortWithInput(), next(), node_ptr_to_vert_idx_, ordering_, gpu_enabled::reverse(), and skipQuerySteps().
RaExecutionSequence::RaExecutionSequence | ( | std::unique_ptr< RaExecutionDesc > | exec_desc | ) |
Definition at line 238 of file RelAlgExecutionDescriptor.cpp.
References descs_.
|
inline |
Definition at line 189 of file RelAlgExecutionDescriptor.h.
References descs_.
Referenced by RelAlgExecutor::executeRelAlgSeq().
bool RaExecutionSequence::executionFinished | ( | ) | const |
Definition at line 437 of file RelAlgExecutionDescriptor.cpp.
References current_vertex_, nextStepId(), ordering_, and totalDescriptorsCount().
void RaExecutionSequence::extractQueryStepSkippingInfo | ( | ) |
Extracts a topological information of the query plan DAG about the relationship among query steps where a parent step and its child steps can be skipped if we have a cached resultset of the parent step
Definition at line 334 of file RelAlgExecutionDescriptor.cpp.
References CHECK, descs_, graph_, anonymous_namespace{RelAlgDag.cpp}::node_id(), node_ptr_to_vert_idx_, run_benchmark_import::res, and skippable_steps_.
Referenced by RaExecutionSequence().
|
inline |
Definition at line 180 of file RelAlgExecutionDescriptor.h.
References CHECK_LT, and descs_.
Referenced by RelAlgExecutor::executeRelAlgQuerySingleStep(), RelAlgExecutor::executeRelAlgSeq(), RelAlgExecutor::executeRelAlgStep(), and RelAlgExecutor::executeRelAlgSubSeq().
RaExecutionDesc * RaExecutionSequence::getDescriptorByBodyId | ( | unsigned const | body_id, |
size_t const | start_idx | ||
) | const |
Definition at line 462 of file RelAlgExecutionDescriptor.cpp.
References CHECK_LT, and descs_.
Referenced by RelAlgExecutor::executeRelAlgStep().
|
inline |
Definition at line 176 of file RelAlgExecutionDescriptor.h.
References cached_resultset_keys_.
Referenced by RelAlgExecutor::executeRelAlgSeq().
|
inline |
Definition at line 193 of file RelAlgExecutionDescriptor.h.
References has_step_for_union_.
Referenced by RelAlgExecutor::executeRelAlgSeq(), and RelAlgExecutor::executeRelAlgStep().
std::vector< Vertex > RaExecutionSequence::mergeSortWithInput | ( | const std::vector< Vertex > & | vertices, |
const DAG & | graph | ||
) |
Definition at line 288 of file RelAlgExecutionDescriptor.cpp.
References CHECK, has_limit_clause_, and gpu_enabled::sort().
Referenced by RaExecutionSequence().
RaExecutionDesc * RaExecutionSequence::next | ( | ) |
Return the next execution descriptor in the sequence. If no more execution descriptors exist, returns nullptr.
Definition at line 242 of file RelAlgExecutionDescriptor.cpp.
References QueryPlanDagExtractor::applyLimitClauseToCacheKey(), cached_query_steps_, cached_resultset_keys_, CHECK, CHECK_GE, SortInfo::createFromSortNode(), current_vertex_, descs_, EMPTY_QUERY_PLAN, executor_, QueryPlanDagExtractor::extractQueryPlanDag(), g_allow_query_step_skipping, RelAlgNode::getId(), RelAlgNode::getQueryPlanDagHash(), graph_, has_step_for_union_, joins_, ordering_, scan_count_, and RelAlgNode::setOutputMetainfo().
Referenced by RaExecutionSequence().
std::optional< size_t > RaExecutionSequence::nextStepId | ( | const bool | after_broadcast | ) | const |
Returns the index of the next execution descriptor in the graph. If after_broadcast is true, returns the index of the first execution descriptor after the next global broadcast. Returns std::nullopt if no execution descriptors remain in the graph.
Definition at line 424 of file RelAlgExecutionDescriptor.cpp.
References current_vertex_, descs_, ordering_, and stepsToNextBroadcast().
Referenced by executionFinished().
RaExecutionDesc * RaExecutionSequence::prev | ( | ) |
Return the previous execution descriptor in the sequence. If the sequence is made up of 0 or 1 descriptors, returns nullptr.
Definition at line 322 of file RelAlgExecutionDescriptor.cpp.
References CHECK_GE, and descs_.
|
inline |
Definition at line 188 of file RelAlgExecutionDescriptor.h.
References descs_.
Referenced by RelAlgExecutor::executeRelAlgQueryWithFilterPushDown(), and RelAlgExecutor::executeRelAlgSeq().
void RaExecutionSequence::skipQuerySteps | ( | ) |
Optimizes the query execution step based on the information extracted from the extractQueryStepSkippingInfo
function
Definition at line 379 of file RelAlgExecutionDescriptor.cpp.
References cached_query_steps_, cached_resultset_keys_, CHECK, CHECK_LE, descs_, skippable_steps_, gpu_enabled::swap(), and VLOG.
Referenced by RaExecutionSequence().
|
private |
Starting from the current vertex, iterate the graph counting the number of execution descriptors remaining before the next required broadcast step. The current vertex is counted as the first step before a broadcast is required; i.e. a return value of 0 indicates no additional steps in the graph can be executed without a global broadcast, and a return value of 2 indicates the current vertex and both subsequent vertices can be executed before a global broacast is needed.
Definition at line 490 of file RelAlgExecutionDescriptor.cpp.
References CHECK, CHECK_EQ, current_vertex_, graph_, joins_, ordering_, and gpu_enabled::sort().
Referenced by nextStepId().
size_t RaExecutionSequence::totalDescriptorsCount | ( | ) | const |
Definition at line 472 of file RelAlgExecutionDescriptor.cpp.
References CHECK, graph_, joins_, and ordering_.
Referenced by executionFinished().
|
private |
Definition at line 207 of file RelAlgExecutionDescriptor.h.
Referenced by next(), and skipQuerySteps().
|
private |
Definition at line 208 of file RelAlgExecutionDescriptor.h.
Referenced by getSkippedQueryStepCacheKeys(), next(), and skipQuerySteps().
|
private |
Definition at line 201 of file RelAlgExecutionDescriptor.h.
Referenced by executionFinished(), next(), nextStepId(), and stepsToNextBroadcast().
|
private |
Definition at line 225 of file RelAlgExecutionDescriptor.h.
Referenced by empty(), extractQueryStepSkippingInfo(), getDescriptor(), getDescriptorByBodyId(), next(), nextStepId(), prev(), RaExecutionSequence(), size(), and skipQuerySteps().
|
private |
Definition at line 197 of file RelAlgExecutionDescriptor.h.
Referenced by next(), and RaExecutionSequence().
|
private |
Definition at line 196 of file RelAlgExecutionDescriptor.h.
Referenced by extractQueryStepSkippingInfo(), next(), RaExecutionSequence(), stepsToNextBroadcast(), and totalDescriptorsCount().
|
private |
Definition at line 210 of file RelAlgExecutionDescriptor.h.
Referenced by mergeSortWithInput().
|
private |
Definition at line 209 of file RelAlgExecutionDescriptor.h.
Referenced by hasQueryStepForUnion(), next(), and RaExecutionSequence().
|
private |
Definition at line 199 of file RelAlgExecutionDescriptor.h.
Referenced by next(), RaExecutionSequence(), stepsToNextBroadcast(), and totalDescriptorsCount().
|
private |
Definition at line 204 of file RelAlgExecutionDescriptor.h.
Referenced by extractQueryStepSkippingInfo(), and RaExecutionSequence().
|
private |
Definition at line 200 of file RelAlgExecutionDescriptor.h.
Referenced by executionFinished(), next(), nextStepId(), RaExecutionSequence(), stepsToNextBroadcast(), and totalDescriptorsCount().
|
private |
Definition at line 202 of file RelAlgExecutionDescriptor.h.
Referenced by next().
|
private |
Definition at line 205 of file RelAlgExecutionDescriptor.h.
Referenced by extractQueryStepSkippingInfo(), and skipQuerySteps().