4 #include "frame_on_disk.h"
8 FrameReader::~FrameReader()
15 string FrameReader::read_frame(FrameOnDisk frame)
17 if (int(frame.filename_idx) != last_filename_idx) {
19 close(fd); // Ignore errors.
24 lock_guard<mutex> lock(frame_mu);
25 filename = frame_filenames[frame.filename_idx];
28 fd = open(filename.c_str(), O_RDONLY);
30 perror(filename.c_str());
34 // We want readahead. (Ignore errors.)
35 posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
37 last_filename_idx = frame.filename_idx;
41 str.resize(frame.size);
43 while (offset < frame.size) {
44 int ret = pread(fd, &str[offset], frame.size - offset, frame.offset + offset);