From: | Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com> |
---|---|
To: | Chengjie Qin <cqin3(at)ucmerced(dot)edu> |
Cc: | pgsql-in-general(at)postgresql(dot)org |
Subject: | Re: Initialize the User-defined Aggregate in ECPG |
Date: | 2012-03-20 04:06:13 |
Message-ID: | CAFjFpRekTBeQLYdJGabBxhxNKiMORtf19coXRxZy4FxuuqR58Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-in-general |
On Tue, Mar 20, 2012 at 5:37 AM, Chengjie Qin <cqin3(at)ucmerced(dot)edu> wrote:
> Hi all,
>
> I'm using the embedded SQL in C to create the User-Defined Aggregate(UDA).
> The command is :
> CREATE AGGREGATE aggname( sfunc=kmeans,
> stype=double precision[],
> finalfunc=kmeansfinal,
> INITCOND='{1,2,3}');
>
> Since I need to do the aggregation in multiple rounds. I need to initialize
> the INITCOND using the execution result of last execution (aggregation.)
> Any one can tell me how can I initialize the INITCOND using host variables
> instead of hard code the INITCOND?
>
There is no straight forward way to have 'variable' initial condition.
According to
http://www.postgresql.org/docs/9.1/static/sql-createaggregate.html, initial
condition can be a constant string acceptable by state_data_type's in
function. You might be able to achieve what you want by changing sfunc().
Set initial condition as null, and inside sfunc(), i.e. state transition
function, if you see NULL initial condition, pull the initial condition
from the database appropriately. But, this is the last resort. Why do you
need to have variable initial condition? Can you please elaborate the
problem you are solving, there might be simpler ways to handle this.
--
Best Wishes,
Ashutosh Bapat
EntepriseDB Corporation
The Enterprise Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | Pavan Deolasee | 2012-03-20 08:13:51 | Re: Initialize the User-defined Aggregate in ECPG |
Previous Message | Chengjie Qin | 2012-03-20 00:07:53 | Initialize the User-defined Aggregate in ECPG |