Skip to content

Commit

Permalink
Add comments for SortHelper
Browse files Browse the repository at this point in the history
Signed-off-by: Heng Qian <qianheng@amazon.com>
  • Loading branch information
qianheng-aws committed Aug 2, 2024
1 parent 4b25b72 commit cf2bc7a
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@

public interface SortHelper {

/**
* Construct an expr comparator for sorting on ExprValue.
* @param sortList list of sort fields and their related sort options.
* @return A comparator for ExprValue
*/
static Comparator<ExprValue> constructExprComparator(
List<Pair<SortOption, Expression>> sortList) {
return (o1, o2) -> compareWithExpressions(o1, o2, constructComparator(sortList));
}

/**
* Construct an expr ordering for efficiently taking the top-k elements on ExprValue.
* @param sortList list of sort fields and their related sort options.
* @return An guava ordering for ExprValue
*/
static Ordering<ExprValue> constructExprOrdering(List<Pair<SortOption, Expression>> sortList) {
return Ordering.from(constructExprComparator(sortList));
}
Expand Down

0 comments on commit cf2bc7a

Please sign in to comment.