Class foreign_storage::MultiFileReader

class MultiFileReader : public foreign_storage::FileReader

Subclassed by foreign_storage::LocalMultiFileReader

Public Functions

MultiFileReader(const std::string &file_path, const import_export::CopyParams &copy_params)
MultiFileReader(const std::string &file_path, const import_export::CopyParams &copy_params, const rapidjson::Value &value)
size_t getRemainingSize()

Return

size of the remaining content to be read

bool isRemainingSizeKnown()

Return

if remaining size is known

size_t read(void *buffer, size_t max_size)

Read up to max_size bytes from archive into buffer starting starting from the end of the last read

Return

number of bytes actually read

Parameters
  • buffer: - buffer to load into

  • max_size: - maximum number of bytes to read into the buffer

size_t readRegion(void *buffer, size_t offset, size_t size)

Read up to max_size bytes from archive, starting at given offset isScanFinished() must return true to use readRegion

Return

number of bytes actually read

Parameters
  • buffer: - buffer to load into

  • offset: - starting point into the archive to read

  • size: - maximum number of bytes to read into the buffer

bool isScanFinished()

Return

true if the entire file has been read

void serialize(rapidjson::Value &value, rapidjson::Document::AllocatorType &allocator) const

Serialize internal state to given json object This Json will later be used to restore the reader state through a constructor must be called when isScanFinished() is true

Parameters
  • value: - json object to store needed state to this function can store any needed data or none

  • allocator: - allocator to use for json contruction

FirstLineByFilePath getFirstLineForEachFile() const

Returns a map containing the first line for each file that will be read.

bool isEndOfLastFile()

Returns a boolean indicating whether the reader is at the end of the last file that was read.

Protected Attributes

std::vector<std::unique_ptr<FileReader>> files_
std::vector<std::string> file_locations_
std::vector<size_t> cumulative_sizes_
size_t current_index_
size_t current_offset_
bool is_end_of_last_file_