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

Method copyKeyAndInitGroup

bolt/exec/GroupingSet.cpp:1266–1319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1264 if (spillConfig_->rowBasedSpillMode == common::RowBasedSpillMode::DISABLE) {
1265 if (isDistinct()) {
1266 return mergeNextWithoutAggregates(maxOutputRows, result);
1267 } else {
1268 return mergeNextWithAggregates(maxOutputRows, maxOutputBytes, result);
1269 }
1270 } else {
1271 if (supportRowBasedOutput_) {
1272 bool ret = mergeNextWithRowBasedSpillInRowFormat(
1273 maxOutputRows, maxOutputBytes, result);
1274 return ret;
1275 } else {
1276 return mergeNextWithRowBasedSpill(maxOutputRows, maxOutputBytes, result);
1277 }
1278 }
1279}
1280
1281void GroupingSet::copyKeyAndInitGroup(
1282 std::vector<char*>& distinctRows,
1283 std::vector<char*>& groups,
1284 size_t& initGroupCount,
1285 const RowContainer* container,
1286 const RowVectorPtr& result,
1287 const vector_size_t resultOffset) {
1288 NanosecondTimer aggTimer(&stats_.aggOutputUpdateTimeNs);
1289 auto numNewGroups = distinctRows.size() - initGroupCount;
1290 // has new groups to handle
1291 if (numNewGroups) {
1292 // for RowBased output, do not resize!!!
1293 if (!supportRowBasedOutput_) {
1294 result->resize(distinctRows.size());
1295 }
1296 // key direct copy into result vector
1297 for (auto i = 0; i < keyChannels_.size(); ++i) {
1298 rowToColumnVector(
1299 distinctRows.data() + initGroupCount,
1300 distinctRows.size() - initGroupCount,
1301 container->columns().at(i),
1302 resultOffset,
1303 result->childAt(i));
1304 }
1305 if (!isDistinct()) {
1306 BOLT_CHECK_EQ(distinctRows.size(), groups.size());
1307 // init from initGroupCount to groups.size()
1308 ensureGroupIndices(groups.size());
1309
1310 if (supportRowBasedOutput_) {
1311 // need to store keys in columnar format
1312 SelectivityVector selectivity(result->size(), true);
1313
1314 for (auto row = 0; row < numNewGroups; ++row) {
1315 for (auto i = 0; i < keyChannels_.size(); ++i) {
1316 DecodedVector decoded(*result->childAt(i), selectivity);
1317 char* group = groups[groupIndicesOfRows_[initGroupCount + row]];
1318 mergeRows_->store(decoded, resultOffset + row, group, i);
1319 }
1320 }
1321 }
1322

Callers

nothing calls this directly

Calls 9

rowToColumnVectorFunction · 0.85
childAtMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
atMethod · 0.45
storeMethod · 0.45
emptyMethod · 0.45
initializeNewGroupsMethod · 0.45

Tested by

no test coverage detected