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

Method toIntermediate

bolt/exec/GroupingSet.cpp:2067–2154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2065
2066namespace {
2067// Recursive resize all children.
2068
2069void recursiveResizeChildren(VectorPtr& vector, vector_size_t newSize) {
2070 BOLT_CHECK(vector.use_count() == 1);
2071 if (vector->typeKind() == TypeKind::ROW) {
2072 auto rowVector = vector->asUnchecked<RowVector>();
2073 for (auto& child : rowVector->children()) {
2074 recursiveResizeChildren(child, newSize);
2075 }
2076 }
2077 vector->resize(newSize);
2078}
2079
2080} // namespace
2081
2082void GroupingSet::toIntermediate(
2083 const RowVectorPtr& input,
2084 RowVectorPtr& result) {
2085 BOLT_CHECK(abandonedPartialAggregation_);
2086 BOLT_CHECK(result.use_count() == 1);
2087 if (!isRawInput_) {
2088 result = input;
2089 return;
2090 }
2091 auto numRows = input->size();
2092 activeRows_.resize(numRows);
2093 activeRows_.setAll();
2094 masks_.addInput(input, activeRows_);
2095
2096 result->resize(numRows);
2097 if (!allSupportToIntermediate_) {
2098 intermediateGroups_.resize(numRows);
2099 for (auto i = 0; i < numRows; ++i) {
2100 intermediateGroups_[i] = intermediateRows_->newRow();
2101 intermediateRows_->setAllNull(intermediateGroups_[i]);
2102 }
2103 intermediateRowNumbers_.resize(numRows);
2104 std::iota(
2105 intermediateRowNumbers_.begin(), intermediateRowNumbers_.end(), 0);
2106 }
2107
2108 for (auto i = 0; i < keyChannels_.size(); ++i) {
2109 result->childAt(i) = input->childAt(keyChannels_[i]);
2110 }
2111 // should update lazy info after children changes
2112 result->updateContainsLazyNotLoaded();
2113 for (auto i = 0; i < aggregates_.size(); ++i) {
2114 auto& function = aggregates_[i].function;
2115 auto& aggregateVector = result->childAt(i + keyChannels_.size());
2116 recursiveResizeChildren(aggregateVector, input->size());
2117 const auto& rows = getSelectivityVector(i);
2118
2119 if (function->supportsToIntermediate()) {
2120 populateTempVectors(i, input);
2121 BOLT_DCHECK(aggregateVector);
2122 function->toIntermediate(rows, tempVectors_, aggregateVector);
2123 continue;
2124 }

Callers 1

getOutputMethod · 0.45

Calls 15

recursiveResizeChildrenFunction · 0.85
setAllMethod · 0.80
childAtMethod · 0.80
hasSelectionsMethod · 0.80
eraseRowsSkippingKeysMethod · 0.80
checkFreeMethod · 0.80
checkEmptyMethod · 0.80
iotaFunction · 0.50
sizeMethod · 0.45
resizeMethod · 0.45
addInputMethod · 0.45

Tested by

no test coverage detected