mini\Table\Wrappers\SortedTable::materializeWithBoundedHeap() Method

private

Signature

private function materializeWithBoundedHeap(array $additionalColumns, int $k, int $offset, ?int $limit): Traversable

Parameters

Name Type Default Description
$additionalColumns array required Documentation missing
$k int required Documentation missing
$offset int required Documentation missing
$limit ?int required Documentation missing

Returns

Traversable

Documentation

Materialize using a bounded heap for efficient top-k selection

Instead of sorting all n rows (O(n log n)), we maintain a heap of size k and process each row once (O(n log k)). This is much faster when k << n.

Source

src/Table/Wrappers/SortedTable.php:142-198