MCPcopy Create free account
hub / github.com/apache/cloudberry / binaryheap_replace_first

Function binaryheap_replace_first

src/backend/lib/binaryheap.c:203–212  ·  view source on GitHub ↗

* binaryheap_replace_first * * Replace the topmost element of a non-empty heap, preserving the heap * property. O(1) in the best case, or O(log n) if it must fall back to * sifting the new node down. */

Source from the content-addressed store, hash-verified

201 * sifting the new node down.
202 */
203void
204binaryheap_replace_first(binaryheap *heap, Datum d)
205{
206 Assert(!binaryheap_empty(heap) && heap->bh_has_heap_property);
207
208 heap->bh_nodes[0] = d;
209
210 if (heap->bh_size > 1)
211 sift_down(heap, 0);
212}
213
214/*
215 * Swap the contents of two nodes.

Callers 6

ReorderBufferIterTXNNextFunction · 0.85
BufferSyncFunction · 0.85
execMotionSortedReceiverFunction · 0.85
ExecMergeAppendFunction · 0.85
gather_merge_getnextFunction · 0.85

Calls 1

sift_downFunction · 0.85

Tested by

no test coverage detected