presto-main/src/main/java/io/prestosql/operator/TopNRowNumberOperator.java/TopNRowNumberOperator/isFinished
class TopNRowNumberOperator:    @Override
    public boolean isFinished()
    {
        // has no more input, has finished flushing, and has no unfinished work
        return finishing && outputIterator != null && !outputIterator.hasNext() && unfinishedWork == null;
    }