Re: How to implement a SP-GiST index as a extension module?

From: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
To: Oleg Bartunov <obartunov(at)gmail(dot)com>
Cc: Connor Wolf <wolf(at)imaginaryindustries(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: How to implement a SP-GiST index as a extension module?
Date: 2017-10-30 11:52:45
Message-ID: CAPpHfduKvJxzEdZCbQy3-6YJMmrGQa9QzL0=YPiMtqsqopb-Rw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 30, 2017 at 2:07 PM, Oleg Bartunov <obartunov(at)gmail(dot)com> wrote:

> On Mon, Oct 30, 2017 at 12:05 PM, Oleg Bartunov <obartunov(at)gmail(dot)com>
> wrote:
> > On Sun, Oct 29, 2017 at 10:07 AM, Connor Wolf
> > <wolf(at)imaginaryindustries(dot)com> wrote:
> >> Hi there!
> >>
> >> I'm looking at implementing a custom indexing scheme, and I've been
> having
> >> trouble understanding the proper approach.
> >>
> >> Basically, I need a BK tree, which is a tree-structure useful for
> indexing
> >> arbitrary discrete metric-spaces (in my case, I'm interested in indexing
> >> across the hamming edit-distance of perceptual hashes, for fuzzy image
> >> searching). I'm pretty sure a SP-GiST index is the correct index type,
> as my
> >> tree is intrinsically unbalanced.
> >>
> >> I have a functional stand-alone implementation of a BK-Tree, and it
> works
> >> very well, but the complexity of managing what is basically a external
> index
> >> for my database has reached the point where it's significantly
> problematic,
> >> and it seems to be it should be moved into the database.
> >>
> >> Anyways, looking at the contents of postgres/src/backend/access/spgist,
> it
> >> looks pretty straightforward in terms of the actual C implementation,
> but
> >> I'm stuck understanding how to "install" a custom SP-GiST
> implementation.
> >> There are several GiST indexing implementations in the contrib
> directory,
> >> but no examples for how I'd go about implementing a loadable SP-GiST
> index.
> >>
> >> Basically, my questions are:
> >>
> >> Is it possible to implement a SP-GiST indexing scheme as a loadable
> module?
> >>
> >> If so, how?
> >> And is there an example I can base my implementation off of?
> >
> > Look on RUM access method ( https://github.com/postgrespro/rum ) we
> > developed using
> > api available since 9.6.
>
> or even simple, there is contrib/bloom access method, which illustrates
> developing access method as an extension.

I think Connor struggles to implement just an operator class. Advising him
to implement an index access method is a good way to get him away of
PostgreSQL hacking for a long time :)

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Raúl Marín Rodríguez 2017-10-30 11:56:22 Re: pow support for pgbench
Previous Message Alexander Korotkov 2017-10-30 11:50:13 Re: How to implement a SP-GiST index as a extension module?