How to implement AVG and COUNT of GroupAggregate?

81 views
Skip to first unread message

kerne...@gmail.com

unread,
Apr 2, 2014, 5:20:01 AM4/2/14
to supersonic-...@googlegroups.com
Hi,
    I want to implement AVG and COUNT of GroupAggregate,but i found there is no AggregationOperator about them.So what should I do ? Thank you very much!

Piotr Tabor

unread,
Apr 2, 2014, 5:33:06 AM4/2/14
to kerne...@gmail.com, supersonic-...@googlegroups.com
There is SUM and COUNT. Search for SUM here to get an example: https://code.google.com/p/supersonic/source/browse/supersonic/cursor/core/aggregate_clusters_test.cc

If you want to compute AVG you need to do SUM(x)/COUNT(x)... It's more efficient that way. 


On Wed, Apr 2, 2014 at 11:20 AM, <kerne...@gmail.com> wrote:
Hi,
    I want to implement AVG and COUNT of GroupAggregate,but i found there is no AggregationOperator about them.So what should I do ? Thank you very much!

--
You received this message because you are subscribed to the Google Groups "Supersonic Query Engine Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supersonic-query-...@googlegroups.com.
To post to this group, send email to supersonic-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kerne...@gmail.com

unread,
Apr 2, 2014, 7:12:54 AM4/2/14
to supersonic-...@googlegroups.com
Yes,I know the example of the SUM,but I don`t know how to implement the SUM(x)/COUNT(x).like this?

 specification-> AddAggregation(SUM/COUNT, "L_QUANTITY", "avg_qty");

and when I use the COUNT,

 specification-> AddAggregation(COUNT, "L_QUANTITY", "sum_qty");

there is a error:

'COUNT' was not declared in this scope.

and I can`t find the COUNT in aggregation_operators.h which I can find SUM in it.Thank you !


在 2014年4月2日星期三UTC+8下午5时20分01秒,kerne...@gmail.com写道:
Message has been deleted

kerne...@gmail.com

unread,
Apr 2, 2014, 7:37:27 AM4/2/14
to supersonic-...@googlegroups.com
sorry,the COUNT`s problem i have sovled,it is because of the namespace,but the SUM(x)/COUNT(x) I still don`t know how to implement.Thank you for helping!

在 2014年4月2日星期三UTC+8下午5时20分01秒,kerne...@gmail.com写道:

Milosz Tanski

unread,
Apr 2, 2014, 9:08:06 AM4/2/14
to kerne...@gmail.com, supersonic-...@googlegroups.com
Just add a compute operation at the end of the Operation chain. Feed it an expression that will project all Attributes (eg... COUNT and SUM) and add another expression that will do a division of Attribute 1 (sum) by Attribute 0 (count). This should give you a result of (COUNT, SUM, AVG).


--
You received this message because you are subscribed to the Google Groups "Supersonic Query Engine Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supersonic-query-...@googlegroups.com.
To post to this group, send email to supersonic-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Milosz Tanski
CTO
10 East 53rd Street, 37th floor
New York, NY 10022

p: 646-253-9055
e: mil...@adfin.com
Reply all
Reply to author
Forward
0 new messages