MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / sortBlock

Function sortBlock

src/Interpreters/sortBlock.cpp:351–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351void sortBlock(Block & block, const SortDescription & description, UInt64 limit, IColumn::PermutationSortStability stability)
352{
353 IColumn::Permutation permutation;
354
355#ifndef NDEBUG
356 block.checkNumberOfRows();
357#endif
358 getBlockSortPermutationImpl(block, description, stability, limit, permutation);
359
360#ifndef NDEBUG
361 checkSortedWithPermutation(block, description, limit, permutation);
362#endif
363
364 if (permutation.empty())
365 return;
366
367 bool is_identity_permutation = isIdentityPermutation(permutation, limit);
368 if (is_identity_permutation && limit == 0)
369 return;
370
371 size_t output_rows = limit ? std::min(static_cast<size_t>(limit), permutation.size()) : permutation.size();
372 Columns columns = block.getColumns();
373 transformColumnsWithSharedIndex(
374 columns,
375 [&](const ColumnPtr & col) { return is_identity_permutation ? col->cut(0, output_rows) : col->permute(permutation, limit); });
376 block.setColumns(columns);
377}
378
379void stableGetPermutation(const Block & block, const SortDescription & description, IColumn::Permutation & out_permutation)
380{

Callers 8

transformMethod · 0.85
transformMethod · 0.85
generateMethod · 0.85
onLogDataMethod · 0.85
MergeTreeSetIndexMethod · 0.85
addBlockToJoinMethod · 0.85
joinBlockMethod · 0.85

Calls 12

isIdentityPermutationFunction · 0.85
checkNumberOfRowsMethod · 0.80
minFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
getColumnsMethod · 0.45
cutMethod · 0.45
permuteMethod · 0.45
setColumnsMethod · 0.45

Tested by

no test coverage detected