use of org.apache.carbondata.processing.newflow.sort.unsafe.holder.UnsafeCarbonRowForMerge in project carbondata by apache.
the class UnsafeInMemoryIntermediateDataMerger method getSortedRecordFromMemory.
/**
* This method will be used to get the sorted record from file
*
* @return sorted record sorted record
* @throws CarbonSortKeyAndGroupByException
*/
private UnsafeCarbonRowForMerge getSortedRecordFromMemory() throws CarbonSortKeyAndGroupByException {
UnsafeCarbonRowForMerge row = null;
// poll the top object from heap
// heap maintains binary tree which is based on heap condition that will
// be based on comparator we are passing the heap
// when will call poll it will always delete root of the tree and then
// it does trickel down operation complexity is log(n)
UnsafeInmemoryMergeHolder poll = this.recordHolderHeap.poll();
// get the row from chunk
row = poll.getRow();
// check if there no entry present
if (!poll.hasNext()) {
// change the file counter
--this.holderCounter;
// reaturn row
return row;
}
// read new row
poll.readRow();
// add to heap
this.recordHolderHeap.add(poll);
// return row
return row;
}
Aggregations