MCPcopy Create free account
hub / github.com/apache/arrow / InitLocalStateIfNeeded

Method InitLocalStateIfNeeded

cpp/src/arrow/acero/groupby_aggregate_node.cc:419–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417}
418
419Status GroupByNode::InitLocalStateIfNeeded(ThreadLocalState* state) {
420 // Get input schema
421 auto input_schema = inputs_[0]->output_schema();
422
423 if (state->grouper != nullptr) return Status::OK();
424
425 // Build vector of key field data types
426 std::vector<TypeHolder> key_types(key_field_ids_.size());
427 for (size_t i = 0; i < key_field_ids_.size(); ++i) {
428 auto key_field_id = key_field_ids_[i];
429 key_types[i] = input_schema->field(key_field_id)->type().get();
430 }
431
432 // Construct grouper
433 ARROW_ASSIGN_OR_RAISE(state->grouper,
434 Grouper::Make(key_types, plan_->query_context()->exec_context()));
435
436 // Build vector of aggregate source field data types
437 std::vector<std::vector<TypeHolder>> agg_src_types(agg_kernels_.size());
438 for (size_t i = 0; i < agg_kernels_.size(); ++i) {
439 for (const auto& field_id : agg_src_fieldsets_[i]) {
440 agg_src_types[i].emplace_back(input_schema->field(field_id)->type().get());
441 }
442 }
443
444 ARROW_ASSIGN_OR_RAISE(state->agg_states,
445 InitKernels(agg_kernels_, plan_->query_context()->exec_context(),
446 aggs_, agg_src_types));
447
448 return Status::OK();
449}
450
451} // namespace aggregate
452} // namespace acero

Callers

nothing calls this directly

Calls 11

InitKernelsFunction · 0.85
exec_contextMethod · 0.80
query_contextMethod · 0.80
emplace_backMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.70
OKFunction · 0.50
MakeFunction · 0.50
sizeMethod · 0.45
getMethod · 0.45
typeMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected