[
https://issues.apache.org/jira/browse/HIVE-894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12795725#action_12795725
]
Carl Steinbach commented on HIVE-894:
-------------------------------------
A couple suggestions:
Implementation:
* Use Collections.binarySearch() to implement binaryInsert
* Use Collections.sort() for sorting.
* Use Collections.reverseOrder() for sorting in descending order.
* Consider writing a SortedArrayList class that extends ArrayList instead of
providing a utility class.
* Refer to objects by their interfaces, e.g. "binaryInsert(List<? > list, ...)"
instead of "binaryInsert(ArrayList<Double> array, ...)"
* Simplify your merge logic by using a comparator. You should be able to
eliminate half of the code in sortedMerge().
* Make it generic, e.g. "static <T extends Comparable<? super T>> void
binaryInsert(List<T> list, ...)"
Semantics:
* The class is named SortedArrayUtils, but it operates exclusively on Lists?
SortedListUtils would be more accurate.
Optimizations:
* In sortedMerge(), if l1.max() < l2.min() or l2.max() < l l1.min(), merging
the two lists reduces to concatenating them.
Style:
* Variable names begin with a lowercase letter.
* Please follow the Sun Java Coding Conventions:
http://java.sun.com/docs/codeconv/
> 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, 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.