Re: Red-black tree for GIN - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Red-black tree for GIN
Date
Msg-id 407d949e1001101854o55464134u7092db9a8a5a3e82@mail.gmail.com
Whole thread Raw
In response to Re: Red-black tree for GIN  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Mon, Jan 11, 2010 at 2:42 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> The coding pattern that this patch uses also merits some discussion.
> Basically, rbtree.c is a generic implementation of red-black trees -
> from a textbook - which ginbulk.c then uses for GIN.  One possible
> advantage of this implementation is that it might make it possible for
> us to use the rbtree.c logic in other places, if we have other data
> structures that need similar treatment.  But I'm not sure if that's
> the way we want to go.  The other alternative is to drop the
> generalized implementation and incorporate the logic directly into
> ginbulk.c.  I really don't know which is better, but I'd like to hear
> some other opinions...
>

So, code reuse is not the only advantage of abstraction. It's also
just plain easier to understand and test code written with clear
abstract interfaces. The way you describe it someone with no knowledge
could look at rbtree.c and see if it's done correctly and maybe
improve it. And someone reading ginbulk only has to understand the
operations red-black trees support and no understand how they're
implemented to follow the code.

Is there any advantage of integrating the code with ginbulk.c? Does it
let us get away with finer grained locks or do any tricks doing
gin-specific changes while we're in the middle of rebalancing or
anything like that?

--
greg


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Red-black tree for GIN
Next
From: Stephen Frost
Date:
Subject: Re: RADIUS authentication