Re: aggregate function for median calculation

Поиск
Список
Период
Сортировка
От Alex Pilosov
Тема Re: aggregate function for median calculation
Дата
Msg-id Pine.BSO.4.10.10106181823320.1010-100000@spider.pilosoft.com
обсуждение исходный текст
Ответ на aggregate function for median calculation  ("Thalis A. Kalfigopoulos" <thalis@cs.pitt.edu>)
Ответы Re: aggregate function for median calculation  (Philip Hallstrom <philip@adhesivemedia.com>)
Re: aggregate function for median calculation  ("Thalis A. Kalfigopoulos" <thalis@cs.pitt.edu>)
Список pgsql-general
On Mon, 18 Jun 2001, Thalis A. Kalfigopoulos wrote:

> 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
> aggregate function. I thought of creating an aggregate function and
> have the state_function() gather all the values of a group in an array
> and the final_function() to do the actuall median calculation on this
> array. But the intermmediate state cannot hold multiple values in an
> array (can it?)  Any ideas on how to go with this?

With current architecture, its kinda painful to implement such a function.
Your 'state' function should allocate (palloc) memory for each element
processed and then pfree it when you are done.

-alex



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

Предыдущее
От: John Holland
Дата:
Сообщение: Re: General Security-Question
Следующее
От: Adam Haberlach
Дата:
Сообщение: Web site gripes