}
public GroupbyItem[] getPairSortedDetail(int saverecords) {
long t1=System.currentTimeMillis();
int sz=countsDetail.size();
final MergerDetailSelectDetailRowCompare cmp=this.createMergerDetailCmp();
if(sz<=(saverecords*2))
{
SelectDetailRow[] arr = new SelectDetailRow[sz];
int index=0;
for(SelectDetailRow f:countsDetail)
{
arr[index]=f;
index++;
}
Arrays.sort(arr, cmp);
long t2=System.currentTimeMillis();
LOG.info("####merger sort#### by array sort size="+sz+",timetaken="+(t2-t1));
return arr;
}
PriorityQueue<SelectDetailRow> res = new PriorityQueue<SelectDetailRow>(saverecords, Collections.reverseOrder(cmp));
for(SelectDetailRow f:countsDetail)
{
SelectDetailRow mrow=f;
if (res.size() < saverecords) {
res.add(mrow);
} else if (cmp.compare(res.peek(), mrow) > 0) {
res.add(mrow);
res.poll();
}
}