From: | Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru> |
---|---|
To: | Connor Wolf <connorw(at)imaginaryindustries(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: How to implement a SP-GiST index as a extension module? |
Date: | 2017-11-13 10:09:46 |
Message-ID: | CAPpHfdtpOjDrQJfvGfBedzzWW60o9QCnALzxZEoAXKXqvzHTVw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi!
On Mon, Nov 13, 2017 at 6:47 AM, Connor Wolf <connorw(at)imaginaryindustries(dot)
com> wrote:
> Ok, I've managed to get my custom index working.
>
Good!
It's all on github here: https://github.com/fake-name/pg-spgist_hamming, if
> anyone else needs a fuzzy-image searching system
> that can integrate into postgresql..
>
> It should be a pretty good basis for anyone else to use if they want to
> implement a SP-GiST index too.
>
I took a look at the code, and I feel myself a bit confused :)
It appears that you're indexing int8 values. That seems like unrealistic
short representation for image signature.
Also, name of repository make me think that hamming distance would be used
to compare signatures. But after look at the code, I see that plain
absolute value of difference is used for that purpose.
static double
getDistance(Datum v1, Datum v2)
{
int64_t a1 = DatumGetInt64(v1);
int64_t a2 = DatumGetInt64(v2);
int64_t diff = Abs(a1 - a2);
fprintf_to_ereport("getDistance %ld <-> %ld : %ld", a1, a2, diff);
return diff;
}
For such notion of distance, you don't need a VP-tree or another complex
indexing. B-tree is quite enough in this case. Alternatively, distance
function is not what it meant to be.
It would be useful if you provide complete usage example of this extension:
from image to signature conversion to search queries.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Korotkov | 2017-11-13 10:13:23 | Re: Fix bloom WAL tap test |
Previous Message | Anthony Bykov | 2017-11-13 10:00:28 | Re: Jsonb transform for pl/python |