MCPcopy Create free account
hub / github.com/bytedance/bolt / TableWriter

Method TableWriter

bolt/exec/TableWriter.cpp:37–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35namespace bytedance::bolt::exec {
36
37TableWriter::TableWriter(
38 int32_t operatorId,
39 DriverCtx* driverCtx,
40 const std::shared_ptr<const core::TableWriteNode>& tableWriteNode)
41 : Operator(
42 driverCtx,
43 tableWriteNode->outputType(),
44 operatorId,
45 tableWriteNode->id(),
46 "TableWrite",
47 tableWriteNode->canSpill(driverCtx->queryConfig())
48 ? driverCtx->makeSpillConfig(operatorId)
49 : std::nullopt),
50 driverCtx_(driverCtx),
51 connectorPool_(driverCtx_->task->addConnectorPoolLocked(
52 planNodeId(),
53 driverCtx_->pipelineId,
54 driverCtx_->driverId,
55 operatorType(),
56 tableWriteNode->insertTableHandle()->connectorId())),
57 insertTableHandle_(
58 tableWriteNode->insertTableHandle()->connectorInsertTableHandle()),
59 commitStrategy_(tableWriteNode->commitStrategy()) {
60 setConnectorMemoryReclaimer();
61 if (tableWriteNode->outputType()->size() == 1) {
62 BOLT_USER_CHECK_NULL(tableWriteNode->aggregationNode());
63 } else {
64 BOLT_USER_CHECK(tableWriteNode->outputType()->equivalent(
65 *(TableWriteTraits::outputType(tableWriteNode->aggregationNode()))));
66 }
67
68 if (tableWriteNode->aggregationNode() != nullptr) {
69 aggregation_ = std::make_unique<HashAggregation>(
70 operatorId, driverCtx, tableWriteNode->aggregationNode());
71 }
72 const auto& connectorId = tableWriteNode->insertTableHandle()->connectorId();
73 connector_ = connector::getConnector(connectorId);
74 connectorQueryCtx_ = operatorCtx_->createConnectorQueryCtx(
75 connectorId,
76 planNodeId(),
77 connectorPool_,
78 spillConfig_.has_value() ? &(spillConfig_.value()) : nullptr);
79
80 auto names = tableWriteNode->columnNames();
81 auto types = tableWriteNode->columns()->children();
82
83 const auto& inputType = tableWriteNode->sources()[0]->outputType();
84
85 inputMapping_.reserve(types.size());
86 for (const auto& name : tableWriteNode->columns()->names()) {
87 inputMapping_.emplace_back(inputType->getChildIdx(name));
88 }
89
90 mappedType_ = ROW(std::move(names), std::move(types));
91}
92
93void TableWriter::initialize() {
94 Operator::initialize();

Callers

nothing calls this directly

Calls 15

getConnectorFunction · 0.85
ROWFunction · 0.85
outputTypeMethod · 0.80
makeSpillConfigMethod · 0.80
connectorIdMethod · 0.80
has_valueMethod · 0.80
getChildIdxMethod · 0.80
idMethod · 0.45
canSpillMethod · 0.45
commitStrategyMethod · 0.45

Tested by

no test coverage detected