@Override
  public boolean next() throws IOException {
    //add the previous nextKVReader back to queue
    if(nextKVReader != null){
      addToQueue(nextKVReader);
    }

    //get the new nextKVReader with lowest key
    nextKVReader = pQueue.poll();
    if (nextKVReader == null)
      return false;

    if (nextKVReader != prevKVReader) {
      prevKVReader = nextKVReader;
      // update path in IOContext
      ioCxt.setInputPath(kvReaderPathMap.get(nextKVReader));
    }
    return true;
  }
@return true if there are more key-values and advances to next key-values
@throws IOException
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/tools/KeyValueInputMerger.java