Re: Cube extension kNN support

Lists: pgsql-hackers
From: Stas Kelvich <stas(dot)kelvich(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cube extension kNN support
Date: 2015-02-07 09:45:47
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi!

I had updated old patch with kNN operators for cube data structures. Copying description from old message:

Following distance operators introduced:

<#> taxicab distance
<-> euclidean distance
<=> chebyshev distance

For example:
SELECT * FROM objects ORDER BY objects.coord <-> '(137,42,314)'::cube LIMIT 10;

Also there is operator "->" for selecting ordered rows directly from index.
This request selects rows ordered ascending by 3rd coordinate:

SELECT * FROM objects ORDER BY objects.coord->3 LIMIT 10;

For descendent ordering suggested syntax with minus before coordinate.
This request selects rows ordered descending by 4th coordinate:

SELECT * FROM objects ORDER BY objects.coord->-4 LIMIT 10;

Stas Kelvich.

Attachment Content-Type Size
distances2.patch application/octet-stream 47.7 KB

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Stas Kelvich <stas(dot)kelvich(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cube extension kNN support
Date: 2015-02-07 21:32:58
Message-ID: CAPpHfdugQB1iiLCO+=BRhP5R5-DhumsZaZwKRtYNcq58UKTVpA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi!

On Sat, Feb 7, 2015 at 12:45 PM, Stas Kelvich <stas(dot)kelvich(at)gmail(dot)com>
wrote:

> I had updated old patch with kNN operators for cube data structures.
> Copying description from old message:
>
> Following distance operators introduced:
>
> <#> taxicab distance
> <-> euclidean distance
> <=> chebyshev distance
>
> For example:
> SELECT * FROM objects ORDER BY objects.coord <-> '(137,42,314)'::cube
> LIMIT 10;
>
> Also there is operator "->" for selecting ordered rows directly from index.
> This request selects rows ordered ascending by 3rd coordinate:
>
> SELECT * FROM objects ORDER BY objects.coord->3 LIMIT 10;
>
> For descendent ordering suggested syntax with minus before coordinate.
> This request selects rows ordered descending by 4th coordinate:
>
> SELECT * FROM objects ORDER BY objects.coord->-4 LIMIT 10;
>

I've checked the patch. The first notes are so:
1) Check coding style, in particular braces. Postgres coding style require
using it for multiline statements.
2) Update documentation according to new features.

------
With best regards,
Alexander Korotkov.


From: Stas Kelvich <stas(dot)kelvich(at)gmail(dot)com>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cube extension kNN support
Date: 2015-03-12 17:43:07
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Documentation along with style fix.

Attachment Content-Type Size
distances2r3.patch application/octet-stream 51.1 KB
unknown_filename text/plain 1.2 KB

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Stas Kelvich <stas(dot)kelvich(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cube extension kNN support
Date: 2015-04-03 12:23:51
Message-ID: CAPpHfdvQuyELW-6NapnvUwhbbQF3877ai6De6gepm8GoBVfffA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Mar 12, 2015 at 8:43 PM, Stas Kelvich <stas(dot)kelvich(at)gmail(dot)com>
wrote:

> Documentation along with style fix.
>

Since we change the interface of extension we have to change it version and
create a migration script.
E.g. you have to rename cube--1.0.sql to cube--1.1.sql and create
cube--1.0--1.1.sql to migrate the old version.

+ -- Alias for backword compatibility
CREATE FUNCTION cube_distance(cube, cube)
RETURNS float8
+ AS 'MODULE_PATHNAME', 'distance_euclid'
+ LANGUAGE C IMMUTABLE STRICT;

For backward compatibility it would be better to keep the old name of
cube_distance so that extension with old definition could work with new
binary.

------
With best regards,
Alexander Korotkov.