MCPcopy Create free account
hub / github.com/ByConity/ByConity / execute

Method execute

src/DataStreams/TTLColumnAlgorithm.cpp:29–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void TTLColumnAlgorithm::execute(Block & block)
30{
31 if (!block)
32 return;
33
34 /// If we read not all table columns. E.g. while mutation.
35 if (!block.has(column_name))
36 return;
37
38 /// Nothing to do
39 if (!isMinTTLExpired())
40 return;
41
42 /// Later drop full column
43 if (isMaxTTLExpired())
44 return;
45
46 auto default_column = executeExpressionAndGetColumn(default_expression, block, default_column_name);
47 if (default_column)
48 default_column = default_column->convertToFullColumnIfConst();
49
50 auto ttl_column = executeExpressionAndGetColumn(description.expression, block, description.result_column);
51
52 auto & column_with_type = block.getByName(column_name);
53 const IColumn * values_column = column_with_type.column.get();
54 MutableColumnPtr result_column = values_column->cloneEmpty();
55 result_column->reserve(block.rows());
56
57 for (size_t i = 0; i < block.rows(); ++i)
58 {
59 UInt32 cur_ttl = getTimestampByIndex(ttl_column.get(), i);
60 if (isTTLExpired(cur_ttl))
61 {
62 if (default_column)
63 result_column->insertFrom(*default_column, i);
64 else
65 result_column->insertDefault();
66 }
67 else
68 {
69 new_ttl_info.update(cur_ttl);
70 is_fully_empty = false;
71 result_column->insertFrom(*values_column, i);
72 }
73 }
74
75 column_with_type.column = std::move(result_column);
76}
77
78void TTLColumnAlgorithm::finalize(const MutableDataPartPtr & data_part) const
79{

Callers 15

writeMethod · 0.45
processMethod · 0.45
writeMethod · 0.45
readImplMethod · 0.45
writeMethod · 0.45
getTotalsMethod · 0.45
readImplMethod · 0.45
writeMethod · 0.45
createTableFromASTFunction · 0.45

Calls 10

getByNameMethod · 0.80
hasMethod · 0.45
getMethod · 0.45
cloneEmptyMethod · 0.45
reserveMethod · 0.45
rowsMethod · 0.45
insertFromMethod · 0.45
insertDefaultMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected