Handle top N
| 101 | |
| 102 | // Handle top N |
| 103 | void 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 | |
| 144 | void SortWindowBuild::ensureInputFits(const RowVectorPtr& input) { |
| 145 | if (spillConfig_ == nullptr) { |
nothing calls this directly
no test coverage detected