| 111 | } |
| 112 | |
| 113 | void DictionaryReader::readKeys(const IColumn & keys, Block & out_block, ColumnVector<UInt8>::Container & found, |
| 114 | std::vector<size_t> & positions) const |
| 115 | { |
| 116 | auto working_block = sample_block.getColumnsWithTypeAndName(); |
| 117 | size_t has_position = key_position + 1; |
| 118 | size_t size = keys.size(); |
| 119 | |
| 120 | /// set keys for dictHas() |
| 121 | ColumnWithTypeAndName & key_column = working_block[key_position]; |
| 122 | key_column.column = keys.cloneResized(size); /// just a copy we cannot avoid |
| 123 | |
| 124 | /// calculate and extract dictHas() |
| 125 | function_has->execute(working_block, size); |
| 126 | ColumnWithTypeAndName & has_column = working_block[has_position]; |
| 127 | auto mutable_has = IColumn::mutate(std::move(has_column.column)); |
| 128 | found.swap(typeid_cast<ColumnVector<UInt8> &>(*mutable_has).getData()); |
| 129 | has_column.column = nullptr; |
| 130 | |
| 131 | /// set mapping form source keys to resulting rows in output block |
| 132 | positions.clear(); |
| 133 | positions.resize(size, 0); |
| 134 | size_t pos = 0; |
| 135 | for (size_t i = 0; i < size; ++i) |
| 136 | if (found[i]) |
| 137 | positions[i] = pos++; |
| 138 | |
| 139 | /// set keys for dictGet(): remove not found keys |
| 140 | key_column.column = key_column.column->filter(found, -1); |
| 141 | size_t rows = key_column.column->size(); |
| 142 | |
| 143 | /// calculate dictGet() |
| 144 | for (const auto & func : functions_get) |
| 145 | func.execute(working_block, rows); |
| 146 | |
| 147 | /// make result: copy header block with correct names and move data columns |
| 148 | out_block = result_header.cloneEmpty(); |
| 149 | size_t first_get_position = has_position + 1; |
| 150 | for (size_t i = 0; i < out_block.columns(); ++i) |
| 151 | { |
| 152 | auto & src_column = working_block[first_get_position + i]; |
| 153 | auto & dst_column = out_block.getByPosition(i); |
| 154 | dst_column.column = src_column.column; |
| 155 | src_column.column = nullptr; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | Block DictionaryReader::makeResultBlock(const NamesAndTypesList & names) |
| 160 | { |
no test coverage detected