MODE as User Defined Aggregate Function in Vertica?


I've already asked this once on Stack Overflow but currently without no luck, so I will try it here. http://stackoverflow.com/questions/22411761/mode-as-user-defined-aggregate-function-in-vertica

Is there a way how to implement a MODE (http://en.wikipedia.org/wiki/Mode_%28statistics%29) function in Vertica as User Defined Aggregate Function (UDAF)? The implementation would be pretty straightforward - just go through list of values and use some dictionary to count them. And even more simple if the list is ordered.

I looked into SDK documentation and on examples provided by HP - there is function void Vertica::AggregateFunction::aggregate(ServerInterface &srvInterface, BlockReader &arg_reader, IntermediateAggs &aggs) which may be called several times, each call processes part of data and saves intermediate result in aggs, and these results are finally combined together. I suppose this is because of parallel processing on several nodes and so on.

And this is the problem as I did not find any way how pass some larger structure in aggs or how to force whole data to be processed in one call of aggregate. Does anybody find any solution for this?

Thanks, Karel

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file