OmniSciDB
a5dc49c757
|
#include <FileReader.h>
Public Member Functions | |
CompressedFileReader (const std::string &file_path, const import_export::CopyParams ©_params) | |
CompressedFileReader (const std::string &file_path, const import_export::CopyParams ©_params, const rapidjson::Value &value) | |
size_t | read (void *buffer, size_t max_size) override |
size_t | readRegion (void *buffer, size_t offset, size_t size) override |
bool | isScanFinished () const override |
bool | isRemainingSizeKnown () override |
size_t | getRemainingSize () override |
void | serialize (rapidjson::Value &value, rapidjson::Document::AllocatorType &allocator) const override |
Public Member Functions inherited from foreign_storage::SingleFileReader | |
SingleFileReader (const std::string &file_path, const import_export::CopyParams ©_params) | |
~SingleFileReader () override=default | |
FirstLineByFilePath | getFirstLineForEachFile () const override |
bool | isEndOfLastFile () override |
std::string | getCurrentFilePath () const override |
Public Member Functions inherited from foreign_storage::FileReader | |
FileReader (const std::string &file_path, const import_export::CopyParams ©_params) | |
virtual | ~FileReader ()=default |
Private Member Functions | |
void | resetArchive () |
void | checkForMoreRows (size_t file_offset, const shared::FilePathOptions &options, const ForeignServer *server_options, const UserMapping *user_mapping) override |
void | nextEntry () |
void | skipHeader () override |
void | skipBytes (size_t n_bytes) |
size_t | readInternal (void *buffer, size_t read_size, size_t buffer_size) |
std::string | getFirstLine () const override |
void | consumeFirstLine (std::optional< std::string > &dest_str) |
Private Attributes | |
ArchiveWrapper | archive_ |
bool | initial_scan_ |
bool | scan_finished_ |
size_t | current_offset_ |
int | current_index_ |
std::vector< size_t > | cumulative_sizes_ |
std::vector< std::string > | sourcenames_ |
std::vector< int > | archive_entry_index_ |
Additional Inherited Members | |
Protected Attributes inherited from foreign_storage::FileReader | |
import_export::CopyParams | copy_params_ |
std::string | file_path_ |
Static Protected Attributes inherited from foreign_storage::SingleFileReader | |
static constexpr size_t | DEFAULT_HEADER_READ_SIZE {1024} |
Definition at line 269 of file FileReader.h.
foreign_storage::CompressedFileReader::CompressedFileReader | ( | const std::string & | file_path, |
const import_export::CopyParams & | copy_params | ||
) |
Definition at line 249 of file FileReader.cpp.
References nextEntry().
foreign_storage::CompressedFileReader::CompressedFileReader | ( | const std::string & | file_path, |
const import_export::CopyParams & | copy_params, | ||
const rapidjson::Value & | value | ||
) |
Definition at line 261 of file FileReader.cpp.
References archive_entry_index_, cumulative_sizes_, json_utils::get_value_from_object(), initial_scan_, scan_finished_, and sourcenames_.
|
overrideprivatevirtual |
Rescan the target files Throws an exception if the rescan fails (ie files are not in a valid appended state or not supported)
file_offset | - where to resume the scan from (end of the last row) as not all of the bytes may have been consumed by the upstream compoennet |
server_options | - only needed for S3 backed files |
user_mapping | - only needed for S3 backed files |
Reimplemented from foreign_storage::FileReader.
Definition at line 422 of file FileReader.cpp.
References archive_, archive_entry_index_, CHECK, cumulative_sizes_, current_index_, current_offset_, foreign_storage::ArchiveWrapper::currentEntryDataAvailable(), foreign_storage::ArchiveWrapper::currentEntryFinished(), foreign_storage::ArchiveWrapper::entryName(), foreign_storage::FileReader::file_path_, initial_scan_, foreign_storage::ArchiveWrapper::nextEntry(), nextEntry(), foreign_storage::ArchiveWrapper::resetArchive(), scan_finished_, skipBytes(), skipHeader(), foreign_storage::ArchiveWrapper::skipToEntry(), and sourcenames_.
|
private |
Definition at line 384 of file FileReader.cpp.
References archive_, foreign_storage::ArchiveWrapper::consumeDataFromCurrentEntry(), foreign_storage::FileReader::copy_params_, foreign_storage::ArchiveWrapper::currentEntryFinished(), import_export::CopyParams::line_delim, and foreign_storage::ArchiveWrapper::peekNextChar().
Referenced by skipHeader().
|
overrideprivatevirtual |
Implements foreign_storage::SingleFileReader.
Definition at line 376 of file FileReader.cpp.
References foreign_storage::FileReader::copy_params_, foreign_storage::SingleFileReader::DEFAULT_HEADER_READ_SIZE, and foreign_storage::FileReader::file_path_.
|
inlineoverridevirtual |
Implements foreign_storage::FileReader.
Definition at line 283 of file FileReader.h.
|
inlineoverridevirtual |
Implements foreign_storage::FileReader.
Definition at line 282 of file FileReader.h.
|
inlineoverridevirtual |
Implements foreign_storage::FileReader.
Definition at line 280 of file FileReader.h.
References scan_finished_.
Referenced by readRegion().
|
private |
Go to next archive entry/header with valid data
Definition at line 333 of file FileReader.cpp.
References archive_, archive_entry_index_, CHECK, cumulative_sizes_, current_index_, current_offset_, foreign_storage::ArchiveWrapper::currentEntryFinished(), foreign_storage::ArchiveWrapper::entryName(), foreign_storage::ArchiveWrapper::getCurrentEntryIndex(), initial_scan_, foreign_storage::ArchiveWrapper::nextEntry(), scan_finished_, skipHeader(), foreign_storage::ArchiveWrapper::skipToEntry(), and sourcenames_.
Referenced by checkForMoreRows(), CompressedFileReader(), and readInternal().
|
overridevirtual |
Read up to max_size bytes from archive into buffer starting starting from the end of the last read
buffer | - buffer to load into |
max_size | - maximum number of bytes to read into the buffer |
Implements foreign_storage::FileReader.
Definition at line 301 of file FileReader.cpp.
References readInternal().
|
private |
Definition at line 275 of file FileReader.cpp.
References foreign_storage::anonymous_namespace{FileReader.cpp}::adjust_eof(), archive_, foreign_storage::ArchiveWrapper::consumeDataFromCurrentEntry(), foreign_storage::FileReader::copy_params_, current_offset_, foreign_storage::ArchiveWrapper::currentEntryDataAvailable(), foreign_storage::ArchiveWrapper::currentEntryFinished(), run_benchmark_import::dest, import_export::CopyParams::line_delim, and nextEntry().
Referenced by read(), and readRegion().
|
overridevirtual |
Read up to max_size bytes from archive, starting at given offset isScanFinished() must return true to use readRegion
buffer | - buffer to load into |
offset | - starting point into the archive to read |
size | - maximum number of bytes to read into the buffer |
Implements foreign_storage::FileReader.
Definition at line 307 of file FileReader.cpp.
References archive_, archive_entry_index_, CHECK, cumulative_sizes_, current_index_, current_offset_, foreign_storage::ArchiveWrapper::getCurrentEntryIndex(), isScanFinished(), foreign_storage::anonymous_namespace{FileReader.cpp}::offset_to_index(), readInternal(), skipBytes(), skipHeader(), and foreign_storage::ArchiveWrapper::skipToEntry().
|
private |
Reopen file and reset back to the beginning
|
overridevirtual |
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
value | - json object to store needed state to this function can store any needed data or none |
allocator | - allocator to use for json contruction |
Implements foreign_storage::FileReader.
Definition at line 516 of file FileReader.cpp.
References json_utils::add_value_to_object(), archive_entry_index_, CHECK, cumulative_sizes_, initial_scan_, scan_finished_, and sourcenames_.
|
private |
Skip forward N bytes in current entry without reading the data
n_bytes | - number of bytes to skip |
Skip forward N bytes without reading the data in current entry
n_bytes | - number of bytes to skip |
Definition at line 404 of file FileReader.cpp.
References archive_, foreign_storage::ArchiveWrapper::consumeDataFromCurrentEntry(), current_offset_, and foreign_storage::ArchiveWrapper::currentEntryDataAvailable().
Referenced by checkForMoreRows(), and readRegion().
|
overrideprivatevirtual |
Skip Header of file
Skip file header
Implements foreign_storage::SingleFileReader.
Definition at line 369 of file FileReader.cpp.
References consumeFirstLine(), foreign_storage::FileReader::copy_params_, import_export::CopyParams::has_header, and import_export::kNoHeader.
Referenced by checkForMoreRows(), nextEntry(), and readRegion().
|
private |
Definition at line 322 of file FileReader.h.
Referenced by checkForMoreRows(), consumeFirstLine(), nextEntry(), readInternal(), readRegion(), and skipBytes().
|
private |
Definition at line 342 of file FileReader.h.
Referenced by checkForMoreRows(), CompressedFileReader(), nextEntry(), readRegion(), and serialize().
|
private |
Definition at line 337 of file FileReader.h.
Referenced by checkForMoreRows(), CompressedFileReader(), nextEntry(), readRegion(), and serialize().
|
private |
Definition at line 334 of file FileReader.h.
Referenced by checkForMoreRows(), nextEntry(), and readRegion().
|
private |
Definition at line 330 of file FileReader.h.
Referenced by checkForMoreRows(), nextEntry(), readInternal(), readRegion(), and skipBytes().
|
private |
Definition at line 325 of file FileReader.h.
Referenced by checkForMoreRows(), CompressedFileReader(), nextEntry(), and serialize().
|
private |
Definition at line 327 of file FileReader.h.
Referenced by checkForMoreRows(), CompressedFileReader(), isScanFinished(), nextEntry(), and serialize().
|
private |
Definition at line 339 of file FileReader.h.
Referenced by checkForMoreRows(), CompressedFileReader(), nextEntry(), and serialize().