MCPcopy Create free account
hub / github.com/apache/impala / Prepare

Method Prepare

be/src/runtime/fragment-instance-state.cc:162–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162Status FragmentInstanceState::Prepare() {
163 DCHECK_EQ(current_state_.Load(), FInstanceExecStatePB::WAITING_FOR_EXEC);
164 VLOG(2) << "fragment_instance_ctx:\n" << ThriftDebugString(instance_ctx_);
165
166 // Do not call RETURN_IF_ERROR or explicitly return before this line,
167 // runtime_state_ != nullptr is a postcondition of this function.
168 runtime_state_ = obj_pool()->Add(new RuntimeState(query_state_, fragment_,
169 instance_ctx_, fragment_ctx_, instance_ctx_pb_, ExecEnv::GetInstance()));
170
171 // total_time_counter() is in the runtime_state_ so start it up now.
172 SCOPED_TIMER(profile()->total_time_counter());
173 timings_profile_ = RuntimeProfile::Create(
174 obj_pool(), RuntimeProfile::FRAGMENT_INSTANCE_LIFECYCLE_TIMINGS, false);
175 profile()->AddChild(timings_profile_);
176 SCOPED_TIMER(ADD_TIMER(timings_profile_, PREPARE_TIMER_NAME));
177
178 // Events that are tracked in a separate timeline for each fragment instance, relative
179 // to the startup of the query state.
180 event_sequence_ =
181 profile()->AddEventSequence("Fragment Instance Lifecycle Event Timeline");
182 event_sequence_->Start(query_state_->fragment_events_start_time());
183 UpdateState(StateEvent::PREPARE_START);
184
185 // Reserve one main thread from the pool
186 runtime_state_->resource_pool()->AcquireThreadToken();
187
188 // Exercise debug actions at the first point where errors are possible in Prepare().
189 RETURN_IF_ERROR(DebugAction(query_state_->query_options(), "FIS_IN_PREPARE"));
190
191 avg_thread_tokens_ = profile()->AddSamplingCounter("AverageThreadTokens",
192 bind<int64_t>(mem_fn(&ThreadResourcePool::num_threads),
193 runtime_state_->resource_pool()));
194 mem_usage_sampled_counter_ = profile()->AddSamplingTimeSeriesCounter("MemoryUsage",
195 TUnit::BYTES,
196 bind<int64_t>(mem_fn(&MemTracker::consumption),
197 runtime_state_->instance_mem_tracker()));
198 thread_usage_sampled_counter_ = profile()->AddSamplingTimeSeriesCounter("ThreadUsage",
199 TUnit::UNIT,
200 bind<int64_t>(mem_fn(&ThreadResourcePool::num_threads),
201 runtime_state_->resource_pool()));
202
203 // Create the exec tree.
204 const PlanNode* plan_tree = fragment_state_->plan_tree();
205 DCHECK(plan_tree != nullptr);
206 RETURN_IF_ERROR(ExecNode::CreateTree(
207 runtime_state_, *plan_tree, query_state_->desc_tbl(), &exec_tree_));
208 runtime_state_->set_fragment_root_id(exec_tree_->id());
209 if (instance_ctx_.__isset.debug_options) {
210 ExecNode::SetDebugOptions(instance_ctx_.debug_options, exec_tree_);
211 }
212 std::function<void(ExecNode*)> build_node_map = [&](ExecNode* node) {
213 exec_node_map_[node->id()] = node;
214 for (int i = 0; i < node->num_children(); ++i) {
215 build_node_map(node->child(i));
216 }
217 };
218 build_node_map(exec_tree_);
219

Callers

nothing calls this directly

Calls 15

ThriftDebugStringFunction · 0.85
CreateClass · 0.85
DebugActionFunction · 0.85
OKFunction · 0.85
total_time_counterMethod · 0.80
AddChildMethod · 0.80
AddEventSequenceMethod · 0.80
AcquireThreadTokenMethod · 0.80
resource_poolMethod · 0.80
AddSamplingCounterMethod · 0.80

Tested by

no test coverage detected