Re: [GENERAL] aggregate function for median calculation

2001-06-21 Thread Tom Lane
"Thalis A. Kalfigopoulos" <[EMAIL PROTECTED]> writes: > I worked on it so the struct state now has 3 fields: int length, int > elem_count, int *elements. Now the issue is that the transition > function, which I declare as strict, has a different input and state > type (int4 and text respectively),

Re: [GENERAL] aggregate function for median calculation

2001-06-21 Thread Thalis A. Kalfigopoulos
On Thu, 21 Jun 2001, Tom Lane wrote: > "Thalis A. Kalfigopoulos" <[EMAIL PROTECTED]> writes: > > I'm still a bit confused about how to declare the type of the transition state. > > I have a structure that will hold the current state: > > struct state { > > int elem_count; //how many numbers h

Re: [GENERAL] aggregate function for median calculation

2001-06-20 Thread Tom Lane
"Thalis A. Kalfigopoulos" <[EMAIL PROTECTED]> writes: > I'm still a bit confused about how to declare the type of the transition state. > I have a structure that will hold the current state: > struct state { > int elem_count; //how many numbers have been assigned so far > int *elem_are

Re: [GENERAL] aggregate function for median calculation

2001-06-20 Thread Thalis A. Kalfigopoulos
On Tue, 19 Jun 2001, Tom Lane wrote: > Peter Eisentraut <[EMAIL PROTECTED]> writes: > > Sure, you create a (static) global variable and reallocate memory for it > > in each call and free it by the finalizer function. > > A static would be a bad idea (consider a query with multiple instances > of

Re: [GENERAL] aggregate function for median calculation

2001-06-18 Thread Tom Lane
"Thalis A. Kalfigopoulos" <[EMAIL PROTECTED]> writes: > But the intermmediate state cannot hold multiple values in an array > (can it?) Sure, why not? Might not scale too well to lots of values, however. regards, tom lane ---(end of broadcast)---

[GENERAL] aggregate function for median calculation

2001-06-18 Thread Thalis A. Kalfigopoulos
Hippl, I'm interested in calculating the median of a set of numbers. The algorithm requires that all values are known in advance (ie stored in an array). So the question is: how can I store everything first in an array so I can later process it given that I'd like this to be an aggregat