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

Method mergeDataVectors

bolt/exec/NestedLoopJoinBuild.cpp:91–118  ·  view source on GitHub ↗

Merge adjacent vectors to larger vectors as long as the result do not exceed the size limit. This is important for performance because each small vector here would be duplicated by the number of rows on probe side, result in huge number of small vectors in the output.

Source from the content-addressed store, hash-verified

89// here would be duplicated by the number of rows on probe side, result in huge
90// number of small vectors in the output.
91std::vector<RowVectorPtr> NestedLoopJoinBuild::mergeDataVectors() const {
92 const auto maxBatchRows =
93 operatorCtx_->task()->queryCtx()->queryConfig().maxOutputBatchRows();
94 std::vector<RowVectorPtr> merged;
95 for (int i = 0; i < dataVectors_.size();) {
96 // convert int32_t to int64_t to avoid sum overflow
97 int64_t batchSize = dataVectors_[i]->size();
98 auto j = i + 1;
99 while (j < dataVectors_.size() &&
100 batchSize + dataVectors_[j]->size() <= maxBatchRows) {
101 batchSize += dataVectors_[j++]->size();
102 }
103 if (j == i + 1) {
104 merged.push_back(dataVectors_[i++]);
105 } else {
106 auto batch = BaseVector::create<RowVector>(
107 dataVectors_[i]->type(), batchSize, pool());
108 batchSize = 0;
109 while (i < j) {
110 auto* source = dataVectors_[i++].get();
111 batch->copy(source, batchSize, 0, source->size());
112 batchSize += source->size();
113 }
114 merged.push_back(std::move(batch));
115 }
116 }
117 return merged;
118}
119
120void NestedLoopJoinBuild::noMoreInput() {
121 Operator::noMoreInput();

Callers 1

TEST_FFunction · 0.80

Calls 9

maxOutputBatchRowsMethod · 0.80
queryCtxMethod · 0.80
taskMethod · 0.80
poolFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
typeMethod · 0.45
getMethod · 0.45
copyMethod · 0.45

Tested by 1

TEST_FFunction · 0.64