16 #ifndef IMPALA_RUNTIME_RUNTIME_STATE_H
17 #define IMPALA_RUNTIME_RUNTIME_STATE_H
22 #include <boost/scoped_ptr.hpp>
23 #include <boost/shared_ptr.hpp>
35 #include "gen-cpp/PlanNodes_types.h"
36 #include "gen-cpp/Types_types.h"
37 #include "gen-cpp/ImpalaInternalService_types.h"
43 class BufferedBlockMgr;
71 RuntimeState(
const TPlanFragmentInstanceCtx& fragment_instance_ctx,
87 int64_t query_bytes_limit, int64_t query_rm_reservation_limit_bytes = -1);
100 return query_ctx().request.query_options.abort_on_error;
103 return query_ctx().request.query_options.abort_on_default_limit_exceeded;
109 if (
query_ctx().session.__isset.delegated_user &&
110 !query_ctx().session.delegated_user.empty()) {
117 return query_ctx().session.connected_user;
122 const std::vector<std::pair<std::string, int> >&
file_errors()
const {
148 DCHECK_EQ(
root_node_id_, -1) <<
"Should not set this twice.";
262 int64_t failed_allocation_size = 0);
303 boost::scoped_ptr<TimestampValue>
now_;
384 #define RETURN_IF_CANCELLED(state) \
386 if (UNLIKELY((state)->is_cancelled())) return Status::CANCELLED; \
boost::shared_ptr< MemTracker > query_mem_tracker_
PartitionStatusMap per_partition_status_
Records summary statistics for the results of inserts into Hdfs partitions.
void set_fragment_root_id(PlanNodeId id)
uint32_t slot_filter_bitmap_size() const
QueryResourceMgr * query_resource_mgr_
boost::shared_ptr< BufferedBlockMgr > block_mgr_
RuntimeProfile::Counter * total_storage_wait_timer_
Total time waiting in storage (across all threads)
const TUniqueId & query_id() const
bool codegen_created() const
CatalogServiceClientCache * catalogd_client_cache()
BufferedBlockMgr * block_mgr()
std::string ErrorLog()
Returns the error log lines as a string joined with ' '.
FileMoveMap * hdfs_files_to_move()
void InitMemTrackers(const TUniqueId &query_id, const std::string *request_pool, int64_t query_bytes_limit, int64_t query_rm_reservation_limit_bytes=-1)
boost::scoped_ptr< ObjectPool > obj_pool_
RuntimeProfile * runtime_profile()
Returns runtime state profile.
void GetUnreportedErrors(ErrorLogMap *new_errors)
void set_desc_tbl(DescriptorTbl *desc_tbl)
SpinLock query_status_lock_
std::map< std::string, TInsertStats > PartitionInsertStats
Stats per partition for insert queries. They key is the same as for PartitionRowCount.
bool LogHasSpace()
Returns true if the error log has not reached max_errors_.
MemTracker * query_mem_tracker()
PartitionStatusMap * per_partition_status()
Status Init(ExecEnv *exec_env)
Set per-fragment state.
const std::string & cgroup() const
HBaseTableFactory * htable_factory()
const std::string & do_as_user() const
HBaseTableFactory * htable_factory()
SpinLock error_log_lock_
Lock protecting error_log_ and unreported_error_idx_.
void set_query_status(const std::string &err_msg)
Sets query_status_ with err_msg if no error has been set yet.
const ErrorLogMap & error_log() const
void AddBitmapFilter(SlotId slot, Bitmap *bitmap, bool *acquired_ownership)
boost::scoped_ptr< LlvmCodeGen > codegen_
std::vector< std::pair< std::string, int > > file_errors_
Stores the number of parse errors per file.
SpinLock bitmap_lock_
Lock protecting slot_bitmap_filters_.
LLVM code generator. This is the top level object to generate jitted code.
RuntimeProfile::Counter * total_network_receive_timer()
RuntimeProfile::Counter * total_network_send_timer()
QueryResourceMgr * query_resource_mgr() const
FileMoveMap hdfs_files_to_move_
boost::unordered_map< SlotId, Bitmap * > slot_bitmap_filters_
bool LogError(const ErrorMsg &msg)
const TQueryOptions & query_options() const
const Bitmap * GetBitmapFilter(SlotId slot)
std::map< std::string, std::string > FileMoveMap
void ReportFileErrors(const std::string &file_name, int num_errors)
Report that num_errors occurred while parsing file_name.
const std::string & connected_user() const
CatalogServiceClientCache * catalogd_client_cache()
ObjectPool * obj_pool() const
std::map< std::string, TInsertPartitionStatus > PartitionStatusMap
void ClearFileErrors()
Clear the file errors.
const std::vector< std::pair< std::string, int > > & file_errors() const
boost::scoped_ptr< MemTracker > instance_mem_tracker_
Memory usage of this fragment instance.
~RuntimeState()
Empty d'tor to avoid issues with scoped_ptr.
RuntimeProfile::Counter * total_cpu_timer_
Total CPU time (across all threads), including all wait times.
uint32_t fragment_hash_seed() const
const TUniqueId & fragment_instance_id() const
std::string FileErrors()
Returns a string representation of the file_errors_.
void set_is_cancelled(bool v)
const DescriptorTbl & desc_tbl() const
This class is thread-safe.
RuntimeState(const TPlanFragmentInstanceCtx &fragment_instance_ctx, const std::string &cgroup, ExecEnv *exec_env)
SpinLock file_errors_lock_
Lock protecting file_errors_.
const std::string & effective_user() const
bool is_cancelled() const
MemTracker * instance_mem_tracker()
Status SetMemLimitExceeded(MemTracker *tracker=NULL, int64_t failed_allocation_size=0)
static const int DEFAULT_BATCH_SIZE
DataStreamMgr * stream_mgr()
ImpalaInternalServiceClientCache * impalad_client_cache()
const TQueryCtx & query_ctx() const
bool codegen_enabled() const
Returns true if codegen is enabled for this query.
bool ErrorLogIsEmpty()
Return true if error log is empty.
Status CreateBlockMgr()
Gets/Creates the query wide block mgr.
std::vector< DiskIoMgr::RequestContext * > * reader_contexts()
DiskIoMgr * disk_io_mgr()
RuntimeProfile::Counter * total_network_send_timer_
Total time spent sending over the network (across all threads)
void set_now(const TimestampValue *now)
bool is_cancelled_
if true, execution should stop with a CANCELLED status
Status GetCodegen(LlvmCodeGen **codegen, bool initialize=true)
DataStreamMgr * stream_mgr()
ErrorLogMap error_log_
Logs error messages.
DescriptorTbl * desc_tbl_
const TimestampValue * now() const
ThreadResourceMgr::ResourcePool * resource_pool_
bool abort_on_error() const
Only CPU-heavy threads need be managed using this class.
RuntimeProfile::Counter * total_storage_wait_timer()
ThreadResourceMgr::ResourcePool * resource_pool()
const TPlanFragmentInstanceCtx & fragment_ctx() const
RuntimeProfile::Counter * total_cpu_timer()
std::map< TErrorCode::type, TErrorLogEntry > ErrorLogMap
Tracks log messages per error code.
TPlanFragmentInstanceCtx fragment_instance_ctx_
RuntimeProfile::Counter * total_network_receive_timer_
Total time spent receiving over the network (across all threads)
bool abort_on_default_limit_exceeded() const
std::vector< DiskIoMgr::RequestContext * > reader_contexts_
Reader contexts that need to be closed when the fragment is closed.
ImpalaInternalServiceClientCache * impalad_client_cache()
void SetQueryResourceMgr(QueryResourceMgr *res_mgr)
boost::scoped_ptr< TimestampValue > now_