public boolean initializeBuffer(JobConf job, RecordReader recordreader,
      int footerCount, WritableComparable key, Writable value) throws IOException {

    // Fill the buffer with key value pairs.
    this.buffer = new ArrayList<>();
    while (buffer.size() < footerCount) {
      boolean notEOF = recordreader.next(key, value);
      if (!notEOF) {
        return false;
      }

      WritableComparable left = ReflectionUtils.copy(job, key, null);
      Writable right = ReflectionUtils.copy(job, value, null);
      Pair<WritableComparable, Writable> tem = Pair.of(left, right);
      buffer.add(tem);
    }
    this.cur = 0;
    return true;
  }
Initialize footer buffer in order to keep footer records at the end of file.

@param job
         Current job configuration.

@param recordreader
         Record reader.

@param footerCount
         Footer line number of the table files.

@param key
         Key of current reading record.

@param value
         Value of current reading record.

@return Return true if there are 0 or more records left in the file
        after initializing the footer buffer, otherwise return false.
ql/src/java/org/apache/hadoop/hive/ql/exec/FooterBuffer.java