| 15 | } |
| 16 | |
| 17 | void TTLDeleteAlgorithm::execute(Block & block) |
| 18 | { |
| 19 | if (!block || !isMinTTLExpired()) |
| 20 | return; |
| 21 | |
| 22 | auto ttl_column = executeExpressionAndGetColumn(description.expression, block, description.result_column); |
| 23 | auto where_column = executeExpressionAndGetColumn(description.where_expression, block, description.where_result_column); |
| 24 | |
| 25 | MutableColumns result_columns; |
| 26 | const auto & column_names = block.getNames(); |
| 27 | |
| 28 | result_columns.reserve(column_names.size()); |
| 29 | for (auto it = column_names.begin(); it != column_names.end(); ++it) |
| 30 | { |
| 31 | const IColumn * values_column = block.getByName(*it).column.get(); |
| 32 | MutableColumnPtr result_column = values_column->cloneEmpty(); |
| 33 | result_column->reserve(block.rows()); |
| 34 | |
| 35 | for (size_t i = 0; i < block.rows(); ++i) |
| 36 | { |
| 37 | UInt32 cur_ttl = getTimestampByIndex(ttl_column.get(), i); |
| 38 | bool where_filter_passed = !where_column || where_column->getBool(i); |
| 39 | |
| 40 | if (!isTTLExpired(cur_ttl) || !where_filter_passed) |
| 41 | { |
| 42 | new_ttl_info.update(cur_ttl); |
| 43 | result_column->insertFrom(*values_column, i); |
| 44 | } |
| 45 | else if (it == column_names.begin()) |
| 46 | ++rows_removed; |
| 47 | } |
| 48 | |
| 49 | result_columns.emplace_back(std::move(result_column)); |
| 50 | } |
| 51 | |
| 52 | block = block.cloneWithColumns(std::move(result_columns)); |
| 53 | } |
| 54 | |
| 55 | void TTLDeleteAlgorithm::finalize(const MutableDataPartPtr & data_part) const |
| 56 | { |
nothing calls this directly
no test coverage detected