The first problem is:

                private Integer key;
                private Integer attribute;
                private Integer count;

Java Integer objects are non-modifiable, which means we have to create
a new object per row (which in turn makes the code really
inefficient).

You can change it to "private int" to make it efficient (and also
works for Hive).


Second, can you post your Hive query? It seems your code does not do
what you want. You might want to take a look at
http://issues.apache.org/jira/browse/HIVE-894 for the UDAF max_n and
see how that works for Hive.

Zheng

On Sun, Jan 31, 2010 at 9:38 PM, Sonal Goyal <[email protected]> wrote:
> Hi,
>
> I am writing a UDAF which returns the top x results per key. Lets say my
> input is
>
> key attribute count
> 1      1            6
> 1      2            5
> 1      3            4
> 2      1            8
> 2      2            4
> 2      3            1
>
> I want the top 2 results per key. Which will be:
>
> key attribute count
> 1      1            6
> 1      2            5
> 2      1            8
> 2      2            4
>
> I have written a UDAF for this in the attached file. However, when I run the
> code, I get the exception:
> FAILED: Unknown exception :
> org.apache.hadoop.hive.serde2.objectinspector.primitive.JavaIntObjectInspector
> cannot be cast to
> org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableIntObjectInspector
>
>
> Can anyone please let me know what I could be doing wrong?
> Thanks and Regards,
> Sonal
>



-- 
Yours,
Zheng

Reply via email to