Re: review: Built-in binning functions

Lists: pgsql-hackers
From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Petr Jelinek <petr(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: review: Built-in binning functions
Date: 2014-06-21 18:41:43
Message-ID: CAFj8pRDSonorPd-dYOe3C8sroeOKgXDo2A1E0QLM992et06Rfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

review: https://commitfest.postgresql.org/action/patch_view?id=1484

Hello

I did review of this patch, that add three functions varwidth_bucket for
types: anyelement, double and bigint

* This patch respects PostgreSQL coding rules
* it can applied without any issues
* there are no new compile warnings
* patch contains documentation and tests
* all tests was passed

* there was no any objection in related discussion. Functionality is clean
and based on current functionality of width_bucket.

My comments:

* I miss in documentation description of implementation - its is based on
binary searching, and when second parameter is unsorted array, then it
returns some nonsense without any warning.

* Description for anyelement is buggy twice times

"varwidth_bucket(5.35::numeric, ARRAY[1, 3, 4, 6]::numeric)"

probably should be "varwidth_bucket(5.35::numeric, ARRAY[1, 3, 4,
6]::numeric[])"

BUT it is converted to double precision, function with polymorphic
parameters is not used. So it not respects a widh_buckets model:

postgres=# \dfS width_bucket
List of functions
Schema │ Name │ Result data type │
Argument data types │ Type
────────────┼──────────────┼──────────────────┼───────────────────────────────────────────────────────────────┼────────
pg_catalog │ width_bucket │ integer │ double precision, double
precision, double precision, integer │ normal
pg_catalog │ width_bucket │ integer │ numeric, numeric, numeric,
integer │ normal
(2 rows)

There should be a interface for numeric type too. I am sure so important
part of code for polymorphic type can be shared.

Regards

Pavel


From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: review: Built-in binning functions
Date: 2014-06-22 11:02:53
Message-ID: 53A6B7DD.7050503@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

On 21/06/14 20:41, Pavel Stehule wrote:
> review: https://commitfest.postgresql.org/action/patch_view?id=1484
>

Thanks for review.

>
> My comments:
>
> * I miss in documentation description of implementation - its is based
> on binary searching, and when second parameter is unsorted array, then
> it returns some nonsense without any warning.
>

Right I did mean to mention that thresholds array must be sorted, but
forgot about it when submitting.

> * Description for anyelement is buggy twice times
>
> "varwidth_bucket(5.35::numeric, ARRAY[1, 3, 4, 6]::numeric)"
>
> probably should be "varwidth_bucket(5.35::numeric, ARRAY[1, 3, 4,
> 6]::numeric[])"
>
> BUT it is converted to double precision, function with polymorphic
> parameters is not used. So it not respects a widh_buckets model:
>
> postgres=# \dfS width_bucket
> List of functions
> Schema │ Name │ Result data type │
> Argument data types │ Type
> ────────────┼──────────────┼──────────────────┼───────────────────────────────────────────────────────────────┼────────
> pg_catalog │ width_bucket │ integer │ double precision,
> double precision, double precision, integer │ normal
> pg_catalog │ width_bucket │ integer │ numeric, numeric,
> numeric, integer │ normal
> (2 rows)
>
> There should be a interface for numeric type too. I am sure so important
> part of code for polymorphic type can be shared.
>

I wonder if it would be acceptable to just create pg_proc entry and
point it to generic implementation (that's what I originally had, then I
changed pg_proc entry to polymorphic types...)

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Petr Jelinek <petr(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: review: Built-in binning functions
Date: 2014-06-22 14:55:28
Message-ID: CAFj8pRBNC+=HzB7ErHYq1dkhos09oBe-=K-uobWNi_9q5Z=bqw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2014-06-22 13:02 GMT+02:00 Petr Jelinek <petr(at)2ndquadrant(dot)com>:

> Hi,
>
> On 21/06/14 20:41, Pavel Stehule wrote:
>
>> review: https://commitfest.postgresql.org/action/patch_view?id=1484
>>
>>
> Thanks for review.
>
>
>
>> My comments:
>>
>> * I miss in documentation description of implementation - its is based
>> on binary searching, and when second parameter is unsorted array, then
>> it returns some nonsense without any warning.
>>
>>
> Right I did mean to mention that thresholds array must be sorted, but
> forgot about it when submitting.
>
>
> * Description for anyelement is buggy twice times
>>
>> "varwidth_bucket(5.35::numeric, ARRAY[1, 3, 4, 6]::numeric)"
>>
>> probably should be "varwidth_bucket(5.35::numeric, ARRAY[1, 3, 4,
>> 6]::numeric[])"
>>
>> BUT it is converted to double precision, function with polymorphic
>> parameters is not used. So it not respects a widh_buckets model:
>>
>> postgres=# \dfS width_bucket
>> List of functions
>> Schema │ Name │ Result data type │
>> Argument data types │ Type
>> ────────────┼──────────────┼──────────────────┼─────────────
>> ──────────────────────────────────────────────────┼────────
>> pg_catalog │ width_bucket │ integer │ double precision,
>> double precision, double precision, integer │ normal
>> pg_catalog │ width_bucket │ integer │ numeric, numeric,
>> numeric, integer │ normal
>> (2 rows)
>>
>> There should be a interface for numeric type too. I am sure so important
>> part of code for polymorphic type can be shared.
>>
>>
> I wonder if it would be acceptable to just create pg_proc entry and point
> it to generic implementation (that's what I originally had, then I changed
> pg_proc entry to polymorphic types...)
>

probably not. But very simple wrapper is acceptable.

Pavel

>
> --
> Petr Jelinek http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: review: Built-in binning functions
Date: 2014-06-22 15:22:13
Message-ID: 20140622152213.GK30721@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

On 2014-06-21 20:41:43 +0200, Pavel Stehule wrote:
> review: https://commitfest.postgresql.org/action/patch_view?id=1484

Can you please not start new threads for reviews of smaller features?
Doing so makes following the discussion much harder. I'm fine with
changing the subject if the reply headers are left intact...

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: review: Built-in binning functions
Date: 2014-06-26 20:43:33
Message-ID: 53AC85F5.3090007@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Here is v2,

with fixed documentation and numeric version of the implementation.

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
binning-fns-v2.patch text/x-diff 25.5 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Petr Jelinek <petr(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: review: Built-in binning functions
Date: 2014-06-27 06:33:38
Message-ID: CAFj8pRDorixkA77EnWPUZoqcCE9vLoEMjdnXQyy7R3nAb6yeEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

I recheck this patch

1. applied cleanly and compilation was without warnings and errors
2. all tests was passed ok
3. documentation was rebuild without issues
4. I don't see any issue in code quality - it is well commented, well
formatted, with regress tests

It is ready for commit

Regards

Pavel

2014-06-26 22:43 GMT+02:00 Petr Jelinek <petr(at)2ndquadrant(dot)com>:

> Here is v2,
>
> with fixed documentation and numeric version of the implementation.
>
>
> --
> Petr Jelinek http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>