You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Jason Michael <jm...@videoegg.com> on 2009/09/10 02:42:58 UTC

UDAF issue: "Cannot get typeName for class ..."

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

Re: UDAF issue: "Cannot get typeName for class ..."

Posted by Jason Michael <jm...@videoegg.com>.
Hey Zheng,

I copied the example over and registered it without any changes, but am getting the same sort of error message:

hive> select EXAMPLE_AVG(impressionrequesttime) from foo where day = '2009-08-31' and hour = 3;
FAILED: Unknown exception : Internal error: Cannot get typeName for class com.videoegg.vdat.hive.udf.UDAFExampleAvg$UDAFAvgState

Jason


On 9/9/09 6:06 PM, "Zheng Shao" <zs...@gmail.com> wrote:

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 <jm...@videoegg.com> 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



Re: UDAF issue: "Cannot get typeName for class ..."

Posted by Zheng Shao <zs...@gmail.com>.
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 <jm...@videoegg.com> 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