protected boolean checkSortKeyInBufferRange ( BaseRow sortKey , TopNBuffer buffer ) { Comparator < BaseRow > comparator = buffer . getSortKeyComparator ( ) ; Map . Entry < BaseRow , Collection < BaseRow > > worstEntry = buffer . lastEntry ( ) ; if ( worstEntry == null ) { // return true if the buffer is empty. return true ; } else { BaseRow worstKey = worstEntry . getKey ( ) ; int compare = comparator . compare ( sortKey , worstKey ) ; if ( compare < 0 ) { return true ; } else { return buffer . getCurrentTopNum ( ) < getDefaultTopNSize ( ) ; } } }
Checks whether the record should be put into the buffer .