Re: [PATCH] binary heap implementation

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] binary heap implementation
Date: 2012-11-27 16:56:41
Message-ID: CA+TgmobFnb9z-=9d0aNvzqJCJdzZDAosC8kwFj-a+zSVVvgGfQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

[ Sorry for the slow response on this, Thanksgiving interfered. ]

On Wed, Nov 21, 2012 at 3:41 PM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> One very minor nitpick I unfortunately just found now, not sure when
> that changed:
> binaryheap_replace_first() hardcodes the indices for the left/right node
> of the root node. I would rather have it use (left|right)_offset(0).

Hmm, yeah... but come to think of it, why do we need that special case
at all? Why not just call sift_down on the root node and call it
good? See the attached version, which simplifies the code
considerably and also makes some comment adjustments per Abhijit's
comments.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment Content-Type Size
binaryheap-rmh4.patch application/octet-stream 16.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-11-27 17:02:09 Re: Re: Problem Observed in behavior of Create Index Concurrently and Hot Update
Previous Message Pavel Stehule 2012-11-27 16:52:48 Re: MySQL search query is not executing in Postgres DB