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

Method addInput

bolt/exec/SortWindowBuild.cpp:103–142  ·  view source on GitHub ↗

Handle top N

Source from the content-addressed store, hash-verified

101
102// Handle top N
103void SortWindowBuild::addInput(RowVectorPtr input) {
104 if (followedTopNum_ <= 0) {
105 return;
106 }
107
108 ensureInputFits(input);
109
110 const auto numInput = input->size();
111 vector_size_t rowCnt = 0;
112 if (table_) {
113 // keep rows in topN heap
114 SelectivityVector rows(numInput);
115 table_->prepareForGroupProbe(
116 *lookup_,
117 input,
118 rows,
119 false,
120 BaseHashTable::kNoSpillInputStartPartitionBit);
121 table_->groupProbe(*lookup_);
122
123 // Initialize new partitions.
124 initializeNewPartitions();
125
126 for (auto row = 0; row < numInput; ++row) {
127 // get partitionKeys and calc hashid
128 auto& partition = partitionAt(lookup_->hits[row]);
129 if (processInputRow(row, partition)) {
130 rowCnt++;
131 }
132 }
133 } else {
134 // no partition key
135 for (auto row = 0; row < numInput; ++row) {
136 if (processInputRow(row, *singlePartition_)) {
137 rowCnt++;
138 }
139 }
140 }
141 numRows_ += rowCnt;
142}
143
144void SortWindowBuild::ensureInputFits(const RowVectorPtr& input) {
145 if (spillConfig_ == nullptr) {

Callers

nothing calls this directly

Calls 3

prepareForGroupProbeMethod · 0.80
groupProbeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected