[ 
https://issues.apache.org/jira/browse/HIVE-894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12795651#action_12795651
 ] 

Zheng Shao commented on HIVE-894:
---------------------------------

The standard apache header should be there in any *.java file. I guess we also 
miss the header in UDAFExampleAvg.java. Can you add that as well?


For sharing the code, I think we should extract 2 utility functions from each 
to be static function:

// insert a number and keep the array sorted (let's put the trim code outside 
of this function)
static void binaryInsert(ArrayList<Double> array, Double value, boolean 
ascending)
// merge 2 sorted array and keep at most N numbers.
static ArrayList<Double> sortedMerge(ArrayList<Double> a1, ArrayList<Double> 
a2, boolean ascending, int N)

We can add a SortedArrayUtils.java to hold these 2 static functions.


Just add two lines in each of the .q files that you added: "describe max_n; 
describe extended max_n;".
Note that these lines should be after "add jar ...". Rerun "ant test .. 
-Doverwrite=true".



> add udaf max_n, min_n to contrib
> --------------------------------
>
>                 Key: HIVE-894
>                 URL: https://issues.apache.org/jira/browse/HIVE-894
>             Project: Hadoop Hive
>          Issue Type: New Feature
>            Reporter: Zheng Shao
>            Assignee: Bill Jia
>         Attachments: HIVE-894.1.patch
>
>
> These 2 UDAFs should return the max n numbers, min n numbers in order.
> {code}
> SELECT max_n(userid, 3) FROM src;
> [999,997,996]
> SELECT max_n(userid, 3)[1] FROM src;
> 997
> SELECT min_n(userid, 3) FROM src;
> [0, 3, 8]
> SELECT min_n(userid, 3)[2] FROM src;
> 8
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to