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

Method markDistinctBlock

src/Interpreters/Set.cpp:276–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276ColumnUInt8::MutablePtr Set::markDistinctBlock(const Block & block)
277{
278 std::unique_lock lock(rwlock);
279
280 if (data.empty())
281 throw Exception("Method Set::setHeader must be called before Set::insertFromBlock", ErrorCodes::LOGICAL_ERROR);
282
283 ColumnRawPtrs key_columns;
284 key_columns.reserve(keys_size);
285
286 /// The constant columns to the right of IN are not supported directly. For this, they first materialize.
287 Columns materialized_columns;
288
289 /// Remember the columns we will work with
290 for (size_t i = 0; i < keys_size; ++i)
291 {
292 materialized_columns.emplace_back(block.safeGetByPosition(i).column->convertToFullColumnIfConst()->convertToFullColumnIfLowCardinality());
293 key_columns.emplace_back(materialized_columns.back().get());
294 }
295
296 size_t rows = block.rows();
297
298 /// We will insert to the Set only keys, where all components are not NULL.
299 ConstNullMapPtr null_map{};
300 ColumnPtr null_map_holder;
301 if (!transform_null_in)
302 null_map_holder = extractNestedColumnsAndNullMap(key_columns, null_map);
303
304 /// Filter to extract distinct values from the block.
305 ColumnUInt8::MutablePtr filter;
306 if (fill_set_elements)
307 filter = ColumnUInt8::create(block.rows());
308
309 switch (data.type)
310 {
311 case SetVariants::Type::EMPTY:
312 break;
313 case SetVariants::Type::bitmap64:
314 {
315 if (key_columns.size() == 1)
316 {
317 if (const auto * bitmap_column = dynamic_cast<const ColumnBitMap64 *>(key_columns[0]);
318 bitmap_column)
319 {
320 for (size_t i = 0; i < bitmap_column->size(); ++i)
321 {
322 bitmap_set |= bitmap_column->getBitMapAt(i);
323 }
324 }
325 else
326 throw Exception("Not found ColumnBitMap64 when using IN bitmap", ErrorCodes::LOGICAL_ERROR);
327 }
328 else
329 throw Exception("Column size of Set(BitMap64) should be only one when using IN operator", ErrorCodes::LOGICAL_ERROR);
330 break;
331 }
332#define M(NAME) \
333 case SetVariants::Type::NAME: \

Callers 1

transformMethod · 0.80

Calls 11

ExceptionClass · 0.70
createFunction · 0.50
emptyMethod · 0.45
reserveMethod · 0.45
emplace_backMethod · 0.45
getMethod · 0.45
rowsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected