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

Method write

src/DataStreams/CheckConstraintsFilterBlockOutputStream.cpp:41–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40
41void CheckConstraintsFilterBlockOutputStream::write(const Block & block)
42{
43 written_block = block;
44 if (block.rows() > 0)
45 {
46 for (size_t expr_i = 0; expr_i < expressions.size(); ++expr_i)
47 {
48 Block block_to_calculate = written_block;
49 auto constraint_expr = expressions[expr_i];
50 constraint_expr->execute(block_to_calculate);
51
52 auto * constraint_ptr = constraints.constraints[expr_i]->as<ASTConstraintDeclaration>();
53
54 ColumnWithTypeAndName res_column = block_to_calculate.getByName(constraint_ptr->expr->getColumnName());
55
56 auto result_type = removeNullable(removeLowCardinality(res_column.type));
57
58 if (!isUInt8(result_type))
59 throw Exception(ErrorCodes::UNSUPPORTED_METHOD, "Constraint {} does not return a value of type UInt8",
60 backQuote(constraint_ptr->name));
61
62 auto result_column = res_column.column->convertToFullColumnIfConst()->convertToFullColumnIfLowCardinality();
63
64 FilterDescription filter_and_holder(*result_column);
65
66 size_t filtered_rows = countBytesInFilter(*filter_and_holder.data);
67 /// If the current block is completely filtered out, let's move on to the next one.
68 if (filtered_rows == 0)
69 {
70 return;
71 }
72
73 /// If all the rows pass through the filter.
74 if (filtered_rows == filter_and_holder.data->size())
75 {
76 continue;
77 }
78 else
79 {
80 /// Filter columns.
81 for (size_t i = 0; i < written_block.columns(); ++i)
82 {
83 ColumnWithTypeAndName &current_column = written_block.safeGetByPosition(i);
84
85 if (isColumnConst(*current_column.column))
86 current_column.column = current_column.column->cut(0, filtered_rows);
87 else
88 current_column.column = current_column.column->filter(*filter_and_holder.data, -1);
89 }
90 }
91 }
92 }
93
94 output->write(written_block);
95}
96
97void CheckConstraintsFilterBlockOutputStream::flush()
98{

Callers

nothing calls this directly

Calls 15

removeNullableFunction · 0.85
removeLowCardinalityFunction · 0.85
isUInt8Function · 0.85
backQuoteFunction · 0.85
countBytesInFilterFunction · 0.85
isColumnConstFunction · 0.85
getByNameMethod · 0.80
columnsMethod · 0.80
ExceptionClass · 0.50
rowsMethod · 0.45
sizeMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected