Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::ImpalaServer::QueryExecState Class Reference

#include <query-exec-state.h>

Collaboration diagram for impala::ImpalaServer::QueryExecState:

Public Member Functions

 QueryExecState (const TQueryCtx &query_ctx, ExecEnv *exec_env, Frontend *frontend, ImpalaServer *server, boost::shared_ptr< ImpalaServer::SessionState > session)
 
 ~QueryExecState ()
 
Status Exec (TExecRequest *exec_request)
 
Status Exec (const TMetadataOpRequest &exec_request)
 
void Wait ()
 
void WaitAsync ()
 Calls Wait() asynchronously in a thread and returns immediately. More...
 
void BlockOnWait ()
 
Status FetchRows (const int32_t max_rows, QueryResultSet *fetched_rows)
 
Status RestartFetch ()
 
void UpdateQueryState (beeswax::QueryState::type query_state)
 
Status UpdateQueryStatus (const Status &status)
 
void Cancel (const Status *cause=NULL)
 
void Done ()
 
Status SetResultCache (QueryResultSet *cache, int64_t max_size)
 
ImpalaServer::SessionStatesession () const
 
const std::string & effective_user () const
 
const std::string & connected_user () const
 
const std::string & do_as_user () const
 
TSessionType::type session_type () const
 
const TUniqueId & session_id () const
 
const std::string & default_db () const
 
bool eos () const
 
Coordinator * coord () const
 
QueryScheduleschedule ()
 
int num_rows_fetched () const
 
void set_fetched_rows ()
 
bool fetched_rows () const
 
bool returns_result_set ()
 
const TResultSetMetadata * result_metadata ()
 
const TUniqueId & query_id () const
 
const TExecRequest & exec_request () const
 
TStmtType::type stmt_type () const
 
TCatalogOpType::type catalog_op_type () const
 
TDdlType::type ddl_type () const
 
boost::mutex * lock ()
 
boost::mutex * fetch_rows_lock ()
 
const beeswax::QueryState::type query_state () const
 
void set_query_state (beeswax::QueryState::type state)
 
const Statusquery_status () const
 
void set_result_metadata (const TResultSetMetadata &md)
 
const RuntimeProfileprofile () const
 
const RuntimeProfilesummary_profile () const
 
const TimestampValuestart_time () const
 
const TimestampValueend_time () const
 
const std::string & sql_stmt () const
 
const TQueryOptions & query_options () const
 
TUniqueId parent_query_id () const
 Returns 0:0 if this is a root query. More...
 
const std::vector< std::string > & GetAnalysisWarnings () const
 
int64_t last_active () const
 
bool is_active () const
 Returns true if Impala is actively processing this query. More...
 
RuntimeProfile::EventSequencequery_events () const
 
RuntimeProfilesummary_profile ()
 

Private Member Functions

Status ExecLocalCatalogOp (const TCatalogOpRequest &catalog_op)
 
void MarkInactive ()
 
void MarkActive ()
 
Status ExecQueryOrDmlRequest (const TQueryExecRequest &query_exec_request)
 
Status ExecDdlRequest ()
 
Status ExecLoadDataRequest ()
 Executes a LOAD DATA. More...
 
Status WaitInternal ()
 Core logic of Wait(). Does not update query_state_/status_. More...
 
Status FetchRowsInternal (const int32_t max_rows, QueryResultSet *fetched_rows)
 
Status FetchNextBatch ()
 
Status GetRowValue (TupleRow *row, std::vector< void * > *result, std::vector< int > *scales)
 
Status UpdateCatalog ()
 Gather and publish all required updates to the metastore. More...
 
void SetResultSet (const std::vector< std::string > &results)
 
void SetResultSet (const std::vector< std::string > &col1, const std::vector< std::string > &col2)
 
void SetResultSet (const std::vector< std::string > &col1, const std::vector< std::string > &col2, const std::vector< std::string > &col3, const std::vector< std::string > &col4)
 
void SetCreateTableAsSelectResultSet ()
 
Status UpdateTableAndColumnStats ()
 
void ExecChildQueriesAsync ()
 
void ExecChildQueries ()
 
Status WaitForChildQueries ()
 
void ClearResultCache ()
 

Private Attributes

const TQueryCtx query_ctx_
 
boost::mutex fetch_rows_lock_
 
boost::mutex expiration_data_lock_
 
int64_t last_active_time_
 
uint32_t ref_count_
 
boost::scoped_ptr< Threadwait_thread_
 Thread for asynchronously running Wait(). More...
 
boost::mutex lock_
 
ExecEnvexec_env_
 
boost::shared_ptr< SessionStatesession_
 Session that this query is from. More...
 
boost::scoped_ptr< QueryScheduleschedule_
 Resource assignment determined by scheduler. Owned by obj_pool_. More...
 
boost::scoped_ptr< Coordinator > coord_
 not set for ddl queries, or queries with "limit 0" More...
 
boost::scoped_ptr
< CatalogOpExecutor
catalog_op_executor_
 Runs statements that query or modify the catalog via the CatalogService. More...
 
boost::scoped_ptr< std::vector
< TResultRow > > 
request_result_set_
 
boost::scoped_ptr< QueryResultSetresult_cache_
 
int64_t result_cache_max_size_
 Max size of the result_cache_ in number of rows. A value <= 0 means no caching. More...
 
boost::scoped_ptr< RuntimeStatelocal_runtime_state_
 local runtime_state_ in case we don't have a coord_ More...
 
ObjectPool profile_pool_
 
RuntimeProfile profile_
 
RuntimeProfile server_profile_
 
RuntimeProfile summary_profile_
 
RuntimeProfile::Counterrow_materialization_timer_
 
RuntimeProfile::Counterclient_wait_timer_
 Tracks how long we are idle waiting for a client to fetch rows. More...
 
MonotonicStopWatch client_wait_sw_
 Timer to track idle time for the above counter. More...
 
RuntimeProfile::EventSequencequery_events_
 
std::vector< ExprContext * > output_expr_ctxs_
 
bool eos_
 
beeswax::QueryState::type query_state_
 
Status query_status_
 
TExecRequest exec_request_
 
TResultSetMetadata result_metadata_
 
RowBatchcurrent_batch_
 
int current_batch_row_
 
int num_rows_fetched_
 
bool fetched_rows_
 
Frontendfrontend_
 To get access to UpdateCatalog, LOAD, and DDL methods. Not owned. More...
 
ImpalaServerparent_server_
 
TimestampValue start_time_
 Start/end time of the query. More...
 
TimestampValue end_time_
 
std::vector< ChildQuerychild_queries_
 List of child queries to be executed on behalf of this query. More...
 
Status child_queries_status_
 
boost::scoped_ptr< Threadchild_queries_thread_
 

Detailed Description

Execution state of a query. This captures everything necessary to convert row batches received by the coordinator into results we can return to the client. It also captures all state required for servicing query-related requests from the client. Thread safety: this class is generally not thread-safe, callers need to synchronize access explicitly via lock(). To avoid deadlocks, the caller must not acquire query_exec_state_map_lock_ while holding the exec state's lock. TODO: Consider renaming to RequestExecState for consistency. TODO: Compute stats is the only stmt that requires child queries. Once the CatalogService performs background stats gathering the concept of child queries will likely become obsolete. Remove all child-query related code from this class.

Definition at line 55 of file query-exec-state.h.

Constructor & Destructor Documentation

impala::ImpalaServer::QueryExecState::~QueryExecState ( )

Definition at line 110 of file query-exec-state.cc.

Member Function Documentation

void impala::ImpalaServer::QueryExecState::BlockOnWait ( )

BlockOnWait() may be called after WaitAsync() has been called in order to wait for the asynchronous thread to complete. It is safe to call this multiple times (only the first call will block). Do not call while holding lock_.

Definition at line 531 of file query-exec-state.cc.

void impala::ImpalaServer::QueryExecState::Cancel ( const Status cause = NULL)

Cancels the child queries and the coordinator with the given cause. If cause is NULL, assume this was deliberately cancelled by the user. Otherwise, sets state to EXCEPTION. Caller needs to hold lock_. Does nothing if the query has reached EOS or already cancelled.

Definition at line 778 of file query-exec-state.cc.

References impala::ChildQuery::Cancel(), impala::RuntimeProfile::EventSequence::MarkEvent(), and impala::query_events_.

TCatalogOpType::type impala::ImpalaServer::QueryExecState::catalog_op_type ( ) const
inline

Definition at line 157 of file query-exec-state.h.

References exec_request_.

Referenced by impala::ImpalaServer::LogQueryEvents().

void impala::ImpalaServer::QueryExecState::ClearResultCache ( )
private

Sets result_cache_ to NULL and updates its associated metrics and mem consumption. This function is a no-op if the cache has already been cleared.

Definition at line 1013 of file query-exec-state.cc.

References impala::ImpaladMetrics::RESULTSET_CACHE_TOTAL_BYTES, and impala::ImpaladMetrics::RESULTSET_CACHE_TOTAL_NUM_ROWS.

const std::string& impala::ImpalaServer::QueryExecState::connected_user ( ) const
inline

Definition at line 141 of file query-exec-state.h.

References query_ctx_.

Referenced by effective_user(), impala::ImpalaServer::LogAuditRecord(), and QueryExecState().

Coordinator* impala::ImpalaServer::QueryExecState::coord ( ) const
inline

Definition at line 147 of file query-exec-state.h.

References coord_.

Referenced by impala::ImpalaServer::ArchiveQuery().

TDdlType::type impala::ImpalaServer::QueryExecState::ddl_type ( ) const
inline

Definition at line 160 of file query-exec-state.h.

References exec_request_.

const std::string& impala::ImpalaServer::QueryExecState::default_db ( ) const
inline

Definition at line 145 of file query-exec-state.h.

References query_ctx_.

Referenced by QueryExecState().

const std::string& impala::ImpalaServer::QueryExecState::do_as_user ( ) const
inline

Definition at line 142 of file query-exec-state.h.

References session_.

Referenced by effective_user(), impala::ImpalaServer::LogAuditRecord(), and QueryExecState().

void impala::ImpalaServer::QueryExecState::Done ( )
const std::string& impala::ImpalaServer::QueryExecState::effective_user ( ) const
inline

Queries are run and authorized on behalf of the effective_user. When a do_as_user is specified (is not empty), the effective_user is set to the do_as_user. This is because the connected_user is acting as a "proxy user" for the do_as_user. When do_as_user is empty, the effective_user is always set to the connected_user.

Definition at line 138 of file query-exec-state.h.

References connected_user(), and do_as_user().

Referenced by impala::ImpalaServer::LogAuditRecord(), and QueryExecState().

const TimestampValue& impala::ImpalaServer::QueryExecState::end_time ( ) const
inline

Definition at line 172 of file query-exec-state.h.

References end_time_.

bool impala::ImpalaServer::QueryExecState::eos ( ) const
inline

Definition at line 146 of file query-exec-state.h.

References eos_.

Status impala::ImpalaServer::QueryExecState::Exec ( TExecRequest *  exec_request)

Initiates execution of a exec_request. Non-blocking. Must not be called with lock_ held.

Definition at line 128 of file query-exec-state.cc.

References impala::ImpalaServer::exec_env_, impala::Status::OK, impala::PrintQueryState(), impala::PrintTStmtType(), RETURN_IF_ERROR, impala::SetQueryOption(), and impala::TQueryOptionsToMap().

Status impala::ImpalaServer::QueryExecState::Exec ( const TMetadataOpRequest &  exec_request)

Execute a HiveServer2 metadata operation TODO: This is likely a superset of GetTableNames/GetDbNames. Coalesce these different code paths.

Definition at line 514 of file query-exec-state.cc.

References impala::Status::OK, impala::PrintQueryState(), impala::PrintTStmtType(), and RETURN_IF_ERROR.

const TExecRequest& impala::ImpalaServer::QueryExecState::exec_request ( ) const
inline

Definition at line 155 of file query-exec-state.h.

References exec_request_.

Referenced by impala::ImpalaServer::LogQueryEvents().

void impala::ImpalaServer::QueryExecState::ExecChildQueries ( )
private

Serially executes the queries in child_queries_ by calling the child query's ExecAndWait(). This function is blocking and is intended to be run in a separate thread to ensure that Exec() remains non-blocking. Sets child_queries_status_. Must not be called while holding lock_.

Definition at line 994 of file query-exec-state.cc.

Referenced by ExecChildQueriesAsync().

void impala::ImpalaServer::QueryExecState::ExecChildQueriesAsync ( )
private

Asynchronously executes all child_queries_ one by one. Calls ExecChildQueries() in a new child_queries_thread_.

Definition at line 988 of file query-exec-state.cc.

References ExecChildQueries().

Status impala::ImpalaServer::QueryExecState::ExecDdlRequest ( )
private

Core logic of executing a ddl statement. May internally initiate execution of queries (e.g., compute stats) or dml (e.g., create table as select)

Definition at line 424 of file query-exec-state.cc.

References impala::ImpalaServer::ChildQuery, impala::ImpalaServer::exec_env_, impala::lock_, impala::Status::OK, impala::PrintTCatalogOpType(), impala::PrintTDdlType(), and RETURN_IF_ERROR.

Status impala::ImpalaServer::QueryExecState::ExecLoadDataRequest ( )
private

Executes a LOAD DATA.

Status impala::ImpalaServer::QueryExecState::ExecLocalCatalogOp ( const TCatalogOpRequest &  catalog_op)
private

Executes a local catalog operation (an operation that does not need to execute against the catalog service). Includes USE, SHOW, DESCRIBE, and EXPLAIN statements.

Definition at line 206 of file query-exec-state.cc.

References impala::ImpalaServer::exec_env_, impala::Status::OK, impala::query_ctx_, and RETURN_IF_ERROR.

Status impala::ImpalaServer::QueryExecState::ExecQueryOrDmlRequest ( const TQueryExecRequest &  query_exec_request)
private

Core logic of initiating a query or dml execution request. Initiates execution of plan fragments, if there are any, and sets up the output exprs for subsequent calls to FetchRows(). Also sets up profile and pre-execution counters. Non-blocking.

Definition at line 340 of file query-exec-state.cc.

References impala::ImpalaServer::exec_env_, impala::lock_, impala::RuntimeProfile::EventSequence::MarkEvent(), impala::Status::OK, impala::Status::ok(), impala::PER_HOST_MEM_KEY, impala::PER_HOST_VCORES_KEY, impala::query_events_, impala::query_id(), impala::ExecEnv::resource_broker(), RETURN_IF_ERROR, impala::Scheduler::Schedule(), impala::ExecEnv::scheduler(), and impala::TABLES_MISSING_STATS_KEY.

boost::mutex* impala::ImpalaServer::QueryExecState::fetch_rows_lock ( )
inline

Definition at line 164 of file query-exec-state.h.

References fetch_rows_lock_.

bool impala::ImpalaServer::QueryExecState::fetched_rows ( ) const
inline

Definition at line 151 of file query-exec-state.h.

References fetched_rows_.

Referenced by impala::ImpalaServer::LogQueryEvents().

Status impala::ImpalaServer::QueryExecState::FetchNextBatch ( )
private

Fetch the next row batch and store the results in current_batch_. Only called for non-DDL / DML queries. current_batch_ is set to NULL if execution is complete or the query was cancelled. Caller needs to hold fetch_rows_lock_ and lock_. Blocks, during which time lock_ is released.

Definition at line 847 of file query-exec-state.cc.

References impala::lock_, impala::Status::OK, impala::Status::ok(), and impala::query_status_.

Status impala::ImpalaServer::QueryExecState::FetchRows ( const int32_t  max_rows,
QueryResultSet fetched_rows 
)

Return at most max_rows from the current batch. If the entire current batch has been returned, fetch another batch first. Caller needs to hold fetch_rows_lock_ and lock_. Caller should verify that EOS has not be reached before calling. Must be preceeded by call to Wait() (or WaitAsync()/BlockOnWait()). Also updates query_state_/status_ in case of error.

Definition at line 589 of file query-exec-state.cc.

References impala::query_status_.

const std::vector<std::string>& impala::ImpalaServer::QueryExecState::GetAnalysisWarnings ( ) const
inline

Definition at line 178 of file query-exec-state.h.

References exec_request_.

Status impala::ImpalaServer::QueryExecState::GetRowValue ( TupleRow row,
std::vector< void * > *  result,
std::vector< int > *  scales 
)
private

Evaluates 'output_expr_ctxs_' against 'row' and output the evaluated row in 'result'. The values' scales (# of digits after decimal) are stored in 'scales'. result and scales must have been resized to the number of columns before call.

Definition at line 768 of file query-exec-state.cc.

References impala::Status::OK.

bool impala::ImpalaServer::QueryExecState::is_active ( ) const
inline

Returns true if Impala is actively processing this query.

Definition at line 188 of file query-exec-state.h.

References expiration_data_lock_, and ref_count_.

int64_t impala::ImpalaServer::QueryExecState::last_active ( ) const
inline

Definition at line 182 of file query-exec-state.h.

References expiration_data_lock_, and last_active_time_.

boost::mutex* impala::ImpalaServer::QueryExecState::lock ( )
inline

Definition at line 163 of file query-exec-state.h.

References lock_.

void impala::ImpalaServer::QueryExecState::MarkActive ( )
private

Updates last_active_time_ and ref_count_ to reflect that query is currently being actively processed. Takes expiration_data_lock_.

Definition at line 937 of file query-exec-state.cc.

References impala::UnixMillis().

void impala::ImpalaServer::QueryExecState::MarkInactive ( )
private

Updates last_active_time_ and ref_count_ to reflect that query is currently not doing any work. Takes expiration_data_lock_.

Definition at line 929 of file query-exec-state.cc.

References impala::UnixMillis().

int impala::ImpalaServer::QueryExecState::num_rows_fetched ( ) const
inline

Definition at line 149 of file query-exec-state.h.

References num_rows_fetched_.

TUniqueId impala::ImpalaServer::QueryExecState::parent_query_id ( ) const
inline

Returns 0:0 if this is a root query.

Definition at line 176 of file query-exec-state.h.

References query_ctx_.

const RuntimeProfile& impala::ImpalaServer::QueryExecState::profile ( ) const
inline

Definition at line 169 of file query-exec-state.h.

References profile_.

Referenced by impala::ImpalaServer::ArchiveQuery().

RuntimeProfile::EventSequence* impala::ImpalaServer::QueryExecState::query_events ( ) const
inline

Definition at line 193 of file query-exec-state.h.

References query_events_.

const TUniqueId& impala::ImpalaServer::QueryExecState::query_id ( ) const
inline
const TQueryOptions& impala::ImpalaServer::QueryExecState::query_options ( ) const
inline

Definition at line 174 of file query-exec-state.h.

References query_ctx_.

const beeswax::QueryState::type impala::ImpalaServer::QueryExecState::query_state ( ) const
inline

Definition at line 165 of file query-exec-state.h.

References query_state_.

const Status& impala::ImpalaServer::QueryExecState::query_status ( ) const
inline
Status impala::ImpalaServer::QueryExecState::RestartFetch ( )

Resets the state of this query such that the next fetch() returns results from the beginning of the query result set (by using the using result_cache_). It is valid to call this function for any type of statement that returns a result set, including queries, show stmts, compute stats, etc. Returns a recoverable error status if the restart is not possible, ok() otherwise. The error is recoverable to allow clients to resume fetching. The caller must hold fetch_rows_lock_ and lock_.

Definition at line 601 of file query-exec-state.cc.

References impala::Status::OK.

const TResultSetMetadata* impala::ImpalaServer::QueryExecState::result_metadata ( )
inline

Definition at line 153 of file query-exec-state.h.

References result_metadata_.

bool impala::ImpalaServer::QueryExecState::returns_result_set ( )
inline

Definition at line 152 of file query-exec-state.h.

References result_metadata_.

QuerySchedule* impala::ImpalaServer::QueryExecState::schedule ( )
inline

Definition at line 148 of file query-exec-state.h.

References schedule_.

ImpalaServer::SessionState* impala::ImpalaServer::QueryExecState::session ( ) const
inline

Definition at line 132 of file query-exec-state.h.

References session_.

Referenced by impala::ImpalaServer::LogAuditRecord().

const TUniqueId& impala::ImpalaServer::QueryExecState::session_id ( ) const
inline

Definition at line 144 of file query-exec-state.h.

References query_ctx_.

Referenced by impala::ImpalaServer::LogAuditRecord(), and QueryExecState().

TSessionType::type impala::ImpalaServer::QueryExecState::session_type ( ) const
inline

Definition at line 143 of file query-exec-state.h.

References query_ctx_.

Referenced by QueryExecState().

void impala::ImpalaServer::QueryExecState::set_fetched_rows ( )
inline

Definition at line 150 of file query-exec-state.h.

References fetched_rows_.

void impala::ImpalaServer::QueryExecState::set_query_state ( beeswax::QueryState::type  state)
inline

Definition at line 166 of file query-exec-state.h.

References query_state_.

void impala::ImpalaServer::QueryExecState::set_result_metadata ( const TResultSetMetadata &  md)
inline

Definition at line 168 of file query-exec-state.h.

References result_metadata_.

void impala::ImpalaServer::QueryExecState::SetCreateTableAsSelectResultSet ( )
private

Sets the result set for a CREATE TABLE AS SELECT statement. The results will not be ready until all BEs complete execution. This can be called as part of Wait(), at which point results will be avilable.

Definition at line 911 of file query-exec-state.cc.

References VLOG_QUERY.

Status impala::ImpalaServer::QueryExecState::SetResultCache ( QueryResultSet cache,
int64_t  max_size 
)

Sets the API-specific (Beeswax, HS2) result cache and its size bound. The given cache is owned by this query exec state, even if an error is returned. Returns a non-ok status if max_size exceeds the per-impalad allowed maximum.

Definition at line 114 of file query-exec-state.cc.

References impala::lock_, and impala::Status::OK.

void impala::ImpalaServer::QueryExecState::SetResultSet ( const std::vector< std::string > &  results)
private

Copies results into request_result_set_ TODO: Have the FE return list<Data.TResultRow> so that this isn't necessary

void impala::ImpalaServer::QueryExecState::SetResultSet ( const std::vector< std::string > &  col1,
const std::vector< std::string > &  col2 
)
private
void impala::ImpalaServer::QueryExecState::SetResultSet ( const std::vector< std::string > &  col1,
const std::vector< std::string > &  col2,
const std::vector< std::string > &  col3,
const std::vector< std::string > &  col4 
)
private
const std::string& impala::ImpalaServer::QueryExecState::sql_stmt ( ) const
inline

Definition at line 173 of file query-exec-state.h.

References query_ctx_.

Referenced by impala::ImpalaServer::LogAuditRecord().

const TimestampValue& impala::ImpalaServer::QueryExecState::start_time ( ) const
inline

Definition at line 171 of file query-exec-state.h.

References start_time_.

Referenced by impala::ImpalaServer::LogAuditRecord(), and QueryExecState().

TStmtType::type impala::ImpalaServer::QueryExecState::stmt_type ( ) const
inline

Definition at line 156 of file query-exec-state.h.

References exec_request_.

Referenced by impala::ImpalaServer::LogQueryEvents().

const RuntimeProfile& impala::ImpalaServer::QueryExecState::summary_profile ( ) const
inline

Definition at line 170 of file query-exec-state.h.

References summary_profile_.

RuntimeProfile* impala::ImpalaServer::QueryExecState::summary_profile ( )
inline

Definition at line 194 of file query-exec-state.h.

References summary_profile_.

void impala::ImpalaServer::QueryExecState::UpdateQueryState ( beeswax::QueryState::type  query_state)

Update query state if the requested state isn't already obsolete. Takes lock_.

Definition at line 620 of file query-exec-state.cc.

References impala::lock_.

Status impala::ImpalaServer::QueryExecState::UpdateQueryStatus ( const Status status)

Update the query status and the "Query Status" summary profile string. If current status is already != ok, no update is made (we preserve the first error) If called with a non-ok argument, the expectation is that the query will be aborted quickly. Returns the status argument (so we can write RETURN_IF_ERROR(UpdateQueryStatus(SomeOperation())). Does not take lock_, but requires it: caller must ensure lock_ is taken before calling UpdateQueryStatus

Definition at line 625 of file query-exec-state.cc.

References impala::Status::GetDetail(), impala::Status::ok(), and impala::query_status_.

Status impala::ImpalaServer::QueryExecState::UpdateTableAndColumnStats ( )
private

Updates the metastore's table and column statistics based on the child-query results of a compute stats command. TODO: Unify the various ways that the Metastore is updated for DDL/DML. For example, INSERT queries update partition metadata in UpdateCatalog() using a TUpdateCatalogRequest, whereas our DDL uses a TCatalogOpRequest for very similar purposes. Perhaps INSERT should use a TCatalogOpRequest as well.

Definition at line 946 of file query-exec-state.cc.

References impala::ImpalaServer::exec_env_, impala::lock_, impala::RuntimeProfile::EventSequence::MarkEvent(), impala::Status::OK, impala::query_events_, and RETURN_IF_ERROR.

void impala::ImpalaServer::QueryExecState::Wait ( )

Call this to ensure that rows are ready when calling FetchRows(). Updates the query_status_, and advances query_state_ to FINISHED or EXCEPTION. Must be preceded by call to Exec(). Waits for all child queries to complete. Takes lock_.

Definition at line 538 of file query-exec-state.cc.

References impala::lock_, and impala::Status::ok().

Referenced by WaitAsync().

void impala::ImpalaServer::QueryExecState::WaitAsync ( )

Calls Wait() asynchronously in a thread and returns immediately.

Definition at line 526 of file query-exec-state.cc.

References Wait().

Status impala::ImpalaServer::QueryExecState::WaitForChildQueries ( )
private

Waits for all child queries to complete successfully or with an error, by joining child_queries_thread_. Returns a non-OK status if a child query fails or if the parent query is cancelled (subsequent children will not be executed). Returns OK if child_queries_thread_ is not set or if all child queries finished successfully.

Definition at line 1001 of file query-exec-state.cc.

References impala::lock_, impala::RuntimeProfile::EventSequence::MarkEvent(), impala::Status::OK, impala::query_events_, impala::query_status_, and RETURN_IF_ERROR.

Status impala::ImpalaServer::QueryExecState::WaitInternal ( )
private

Core logic of Wait(). Does not update query_state_/status_.

Definition at line 555 of file query-exec-state.cc.

References impala::Status::OK, impala::Expr::Open(), and RETURN_IF_ERROR.

Member Data Documentation

boost::scoped_ptr<CatalogOpExecutor> impala::ImpalaServer::QueryExecState::catalog_op_executor_
private

Runs statements that query or modify the catalog via the CatalogService.

Definition at line 232 of file query-exec-state.h.

std::vector<ChildQuery> impala::ImpalaServer::QueryExecState::child_queries_
private

List of child queries to be executed on behalf of this query.

Definition at line 301 of file query-exec-state.h.

Status impala::ImpalaServer::QueryExecState::child_queries_status_
private

Thread to execute child_queries_ in and the resulting status. The status is OK iff all child queries complete successfully. Otherwise, status contains the error of the first child query that failed (child queries are executed serially and abort on the first error).

Definition at line 307 of file query-exec-state.h.

boost::scoped_ptr<Thread> impala::ImpalaServer::QueryExecState::child_queries_thread_
private

Definition at line 308 of file query-exec-state.h.

MonotonicStopWatch impala::ImpalaServer::QueryExecState::client_wait_sw_
private

Timer to track idle time for the above counter.

Definition at line 272 of file query-exec-state.h.

RuntimeProfile::Counter* impala::ImpalaServer::QueryExecState::client_wait_timer_
private

Tracks how long we are idle waiting for a client to fetch rows.

Definition at line 270 of file query-exec-state.h.

Referenced by QueryExecState().

boost::scoped_ptr<Coordinator> impala::ImpalaServer::QueryExecState::coord_
private

not set for ddl queries, or queries with "limit 0"

Definition at line 229 of file query-exec-state.h.

Referenced by coord().

RowBatch* impala::ImpalaServer::QueryExecState::current_batch_
private

Definition at line 282 of file query-exec-state.h.

int impala::ImpalaServer::QueryExecState::current_batch_row_
private

Definition at line 283 of file query-exec-state.h.

TimestampValue impala::ImpalaServer::QueryExecState::end_time_
private

Definition at line 298 of file query-exec-state.h.

Referenced by end_time().

bool impala::ImpalaServer::QueryExecState::eos_
private

Definition at line 276 of file query-exec-state.h.

Referenced by eos().

ExecEnv* impala::ImpalaServer::QueryExecState::exec_env_
private

Definition at line 220 of file query-exec-state.h.

TExecRequest impala::ImpalaServer::QueryExecState::exec_request_
private
boost::mutex impala::ImpalaServer::QueryExecState::expiration_data_lock_
mutableprivate

Protects last_active_time_ and ref_count_. Must always be taken as the last lock, that is no other locks may be taken while holding this lock.

Definition at line 208 of file query-exec-state.h.

Referenced by is_active(), and last_active().

boost::mutex impala::ImpalaServer::QueryExecState::fetch_rows_lock_
private

Ensures single-threaded execution of FetchRows(). Callers of FetchRows() are responsible for acquiring this lock. To avoid deadlocks, callers must not hold lock_ while acquiring this lock (since FetchRows() will release and re-acquire lock_ during its execution).

Definition at line 203 of file query-exec-state.h.

Referenced by fetch_rows_lock().

bool impala::ImpalaServer::QueryExecState::fetched_rows_
private

True if a fetch was attempted by a client, regardless of whether a result set (or error) was returned to the client.

Definition at line 288 of file query-exec-state.h.

Referenced by fetched_rows(), and set_fetched_rows().

Frontend* impala::ImpalaServer::QueryExecState::frontend_
private

To get access to UpdateCatalog, LOAD, and DDL methods. Not owned.

Definition at line 291 of file query-exec-state.h.

int64_t impala::ImpalaServer::QueryExecState::last_active_time_
private

Definition at line 209 of file query-exec-state.h.

Referenced by last_active().

boost::scoped_ptr<RuntimeState> impala::ImpalaServer::QueryExecState::local_runtime_state_
private

local runtime_state_ in case we don't have a coord_

Definition at line 249 of file query-exec-state.h.

boost::mutex impala::ImpalaServer::QueryExecState::lock_
private

Definition at line 219 of file query-exec-state.h.

Referenced by lock().

int impala::ImpalaServer::QueryExecState::num_rows_fetched_
private

Definition at line 284 of file query-exec-state.h.

Referenced by num_rows_fetched().

std::vector<ExprContext*> impala::ImpalaServer::QueryExecState::output_expr_ctxs_
private

Definition at line 275 of file query-exec-state.h.

ImpalaServer* impala::ImpalaServer::QueryExecState::parent_server_
private

The parent ImpalaServer; called to wait until the the impalad has processed a catalog update request. Not owned.

Definition at line 295 of file query-exec-state.h.

RuntimeProfile impala::ImpalaServer::QueryExecState::profile_
private

The QueryExecState builds three separate profiles.

  • profile_ is the top-level profile which houses the other profiles, plus the query timeline
  • summary_profile_ contains mostly static information about the query, including the query statement, the plan and the user who submitted it.
  • server_profile_ tracks time spent inside the ImpalaServer, but not inside fragment execution, i.e. the time taken to register and set-up the query and for rows to be fetched. There's a fourth profile which is not built here (but is a child of profile_); the execution profile which tracks the actual fragment execution.

Definition at line 264 of file query-exec-state.h.

Referenced by profile(), and QueryExecState().

ObjectPool impala::ImpalaServer::QueryExecState::profile_pool_
private

Definition at line 250 of file query-exec-state.h.

const TQueryCtx impala::ImpalaServer::QueryExecState::query_ctx_
private
RuntimeProfile::EventSequence* impala::ImpalaServer::QueryExecState::query_events_
private

Definition at line 274 of file query-exec-state.h.

Referenced by query_events(), and QueryExecState().

beeswax::QueryState::type impala::ImpalaServer::QueryExecState::query_state_
private

Definition at line 277 of file query-exec-state.h.

Referenced by query_state(), QueryExecState(), and set_query_state().

Status impala::ImpalaServer::QueryExecState::query_status_
private

Definition at line 278 of file query-exec-state.h.

Referenced by query_status().

uint32_t impala::ImpalaServer::QueryExecState::ref_count_
private

ref_count_ > 0 if Impala is currently performing work on this query's behalf. Every time a client instructs Impala to do work on behalf of this query, the ref count is increased, and decreased once that work is completed.

Definition at line 214 of file query-exec-state.h.

Referenced by is_active().

boost::scoped_ptr<std::vector<TResultRow> > impala::ImpalaServer::QueryExecState::request_result_set_
private

Result set used for requests that return results and are not QUERY statements. For example, EXPLAIN, LOAD, and SHOW use this.

Definition at line 236 of file query-exec-state.h.

boost::scoped_ptr<QueryResultSet> impala::ImpalaServer::QueryExecState::result_cache_
private

Cache of the first result_cache_max_size_ query results to allow clients to restart fetching from the beginning of the result set. This cache is appended to in FetchInternal(), and set to NULL if its bound is exceeded. If the bound is exceeded, then clients cannot restart fetching because some results have been lost since the last fetch. Only set if result_cache_max_size_ > 0.

Definition at line 243 of file query-exec-state.h.

int64_t impala::ImpalaServer::QueryExecState::result_cache_max_size_
private

Max size of the result_cache_ in number of rows. A value <= 0 means no caching.

Definition at line 246 of file query-exec-state.h.

TResultSetMetadata impala::ImpalaServer::QueryExecState::result_metadata_
private

Definition at line 281 of file query-exec-state.h.

Referenced by result_metadata(), returns_result_set(), and set_result_metadata().

RuntimeProfile::Counter* impala::ImpalaServer::QueryExecState::row_materialization_timer_
private

Definition at line 267 of file query-exec-state.h.

Referenced by QueryExecState().

boost::scoped_ptr<QuerySchedule> impala::ImpalaServer::QueryExecState::schedule_
private

Resource assignment determined by scheduler. Owned by obj_pool_.

Definition at line 226 of file query-exec-state.h.

Referenced by schedule().

RuntimeProfile impala::ImpalaServer::QueryExecState::server_profile_
private

Definition at line 265 of file query-exec-state.h.

Referenced by QueryExecState().

boost::shared_ptr<SessionState> impala::ImpalaServer::QueryExecState::session_
private

Session that this query is from.

Definition at line 223 of file query-exec-state.h.

Referenced by do_as_user(), QueryExecState(), and session().

TimestampValue impala::ImpalaServer::QueryExecState::start_time_
private

Start/end time of the query.

Definition at line 298 of file query-exec-state.h.

Referenced by start_time().

RuntimeProfile impala::ImpalaServer::QueryExecState::summary_profile_
private

Definition at line 266 of file query-exec-state.h.

Referenced by QueryExecState(), and summary_profile().

boost::scoped_ptr<Thread> impala::ImpalaServer::QueryExecState::wait_thread_
private

Thread for asynchronously running Wait().

Definition at line 217 of file query-exec-state.h.


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