Hi Jason,

Can you copy
contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleAvg.java
and start from there?

I didn't see any problems from your code snip, but starting from that
example will give you an easy to debug what actually went wrong.

Let me know if that works.

Zheng

On Wed, Sep 9, 2009 at 5:42 PM, Jason Michael <[email protected]> wrote:

>  Hey all,
>
> I’m trying to write a UDAF as follows, borrowing heavily from the UDAF
> example on slide 84 from this deck:
> http://www.slideshare.net/ragho/hive-user-meeting-august-2009-facebook
>
> <snip>
> public class UDAFPercentUnderThreshold extends UDAF {
>
>     public static class State {
>         private LongWritable totalCount;
>         private LongWritable underCount;
>     }
>
>     public static class Evaluator implements UDAFEvaluator {
>         State s;
>         public void init() {
>             s.totalCount = new LongWritable(0);
>             s.underCount = new LongWritable(0);
>         }
>
>         public boolean iterate(LongWritable start, LongWritable end,
> IntWritable threshold) {
>             ...
>         }
>
>         public State terminatePartial() {
>             ...
>         }
>
>         public boolean merge(State o) {
>             ...
>         }
>
>         public Double terminate() {
>             ...
>         }
>     }
> }
> </snip>
>
> I then register the UDAF but when I try to use it, I get the following
> error:
> hive> select PERCENT_UNDER_THRESHOLD(impressionrequesttime, coreloadtime,
> 2000) from foo where day = '2009-08-31' and hour = 3;
> FAILED: Unknown exception : Internal error: Cannot get typeName for class
> foo.udf.UDAFPercentUnderThreshold$State
>
> I’m using a trunk build.  I looked through the code and found where the
> exception gets thrown, but I can’t figure out what exactly it is trying to
> do.  Any help would be much appreciated!
>
> Jason
>



-- 
Yours,
Zheng

Reply via email to