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

Поиск
Список
Период
Сортировка
От Alexander Korotkov
Тема Re: [HACKERS] How to implement a SP-GiST index as a extension module?
Дата
Msg-id CAPpHfduoHUC7dWtOkpngUqf8H-tV6xeg29zxQ8WbQ3_3Ydw-Vw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] How to implement a SP-GiST index as a extension module?  (Connor Wolf <connorw@imaginaryindustries.com>)
Ответы Re: [HACKERS] How to implement a SP-GiST index as a extension module?
Список pgsql-hackers
On Fri, Nov 3, 2017 at 12:37 PM, Connor Wolf <connorw@imaginaryindustries.com> wrote:
EDIT: That's actually exactly how the example I'm working off of works. DERP. The SQL is 

CREATE TYPE vptree_area AS
(
    center _int4,
    distance float8
);

CREATE OR REPLACE FUNCTION vptree_area_match(_int4, vptree_area) RETURNS boolean AS
'MODULE_PATHNAME','vptree_area_match'
LANGUAGE C IMMUTABLE STRICT;

CREATE OPERATOR <@ (
LEFTARG = _int4,
RIGHTARG = vptree_area, 
PROCEDURE = vptree_area_match,
RESTRICT = contsel,
JOIN = contjoinsel);

so I just need to understand how to parse out the custom type in my index operator.

You can see the implementation of vptree_area_match function located in vptree.c.  It just calls GetAttributeByNum() function.

There is also alternative approach for that implemented in pg_trgm contrib module.  It has "text % text" operator which checks if two strings are similar enough.  The similarity threshold is defined by pg_trgm.similarity_threshold GUC.  Thus, you can also define GUC with threshold distance value.  However, it would place some limitations.  For instance, you wouldn't be able to use different distance threshold in the same query.

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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: Re: [HACKERS] WIP: long transactions on hot standby feedback replica/ proof of concept
Следующее
От: Nikita Glukhov
Дата:
Сообщение: Re: [HACKERS] SQL/JSON in PostgreSQL