OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::ArchiveWrapper Class Reference

#include <FileReader.h>

+ Collaboration diagram for foreign_storage::ArchiveWrapper:

Public Member Functions

 ArchiveWrapper (const std::string &file_path)
 
void skipToEntry (int entry_number)
 
bool nextEntry ()
 
bool currentEntryFinished () const
 
size_t currentEntryDataAvailable () const
 
void consumeDataFromCurrentEntry (size_t size, char *dest_buffer=nullptr)
 
char peekNextChar ()
 
int getCurrentEntryIndex () const
 
void resetArchive ()
 
std::string entryName ()
 

Private Member Functions

void fetchBlock ()
 

Private Attributes

std::unique_ptr< Archivearch_
 
const void * current_block_
 
size_t block_chars_remaining_
 
int current_entry_
 
std::string file_path_
 

Detailed Description

Definition at line 216 of file FileReader.h.

Constructor & Destructor Documentation

foreign_storage::ArchiveWrapper::ArchiveWrapper ( const std::string &  file_path)
inline

Definition at line 218 of file FileReader.h.

References resetArchive().

219  : current_block_(nullptr)
221  , current_entry_(-1)
222  , file_path_(file_path) {
223  resetArchive();
224  }

+ Here is the call graph for this function:

Member Function Documentation

void foreign_storage::ArchiveWrapper::consumeDataFromCurrentEntry ( size_t  size,
char *  dest_buffer = nullptr 
)

Definition at line 216 of file FileReader.cpp.

References block_chars_remaining_, CHECK, current_block_, and fetchBlock().

Referenced by foreign_storage::CompressedFileReader::consumeFirstLine(), foreign_storage::CompressedFileReader::readInternal(), and foreign_storage::CompressedFileReader::skipBytes().

216  {
217  CHECK(size <= block_chars_remaining_);
218  block_chars_remaining_ -= size;
219  if (dest_buffer != nullptr) {
220  memcpy(dest_buffer, current_block_, size);
221  }
222  current_block_ = static_cast<const char*>(current_block_) + size;
223  if (block_chars_remaining_ == 0) {
224  fetchBlock();
225  }
226 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t foreign_storage::ArchiveWrapper::currentEntryDataAvailable ( ) const
inline

Definition at line 236 of file FileReader.h.

References block_chars_remaining_.

Referenced by foreign_storage::CompressedFileReader::checkForMoreRows(), foreign_storage::CompressedFileReader::readInternal(), and foreign_storage::CompressedFileReader::skipBytes().

+ Here is the caller graph for this function:

bool foreign_storage::ArchiveWrapper::currentEntryFinished ( ) const
inline

Definition at line 234 of file FileReader.h.

References block_chars_remaining_.

Referenced by foreign_storage::CompressedFileReader::checkForMoreRows(), foreign_storage::CompressedFileReader::consumeFirstLine(), foreign_storage::CompressedFileReader::nextEntry(), and foreign_storage::CompressedFileReader::readInternal().

234 { return (block_chars_remaining_ == 0); }

+ Here is the caller graph for this function:

std::string foreign_storage::ArchiveWrapper::entryName ( )
inline

Definition at line 249 of file FileReader.h.

References arch_.

Referenced by foreign_storage::CompressedFileReader::checkForMoreRows(), and foreign_storage::CompressedFileReader::nextEntry().

249 { return arch_->entryName(); }
std::unique_ptr< Archive > arch_
Definition: FileReader.h:257

+ Here is the caller graph for this function:

void foreign_storage::ArchiveWrapper::fetchBlock ( )
private

Get the next block from the current archive file

Definition at line 240 of file FileReader.cpp.

References arch_, block_chars_remaining_, and current_block_.

Referenced by consumeDataFromCurrentEntry(), nextEntry(), and skipToEntry().

240  {
241  int64_t offset;
242  auto ok =
243  arch_.get()->read_data_block(&current_block_, &block_chars_remaining_, &offset);
244  if (!ok) {
246  }
247 }
std::unique_ptr< Archive > arch_
Definition: FileReader.h:257

+ Here is the caller graph for this function:

int foreign_storage::ArchiveWrapper::getCurrentEntryIndex ( ) const
inline

Definition at line 244 of file FileReader.h.

References current_entry_.

Referenced by foreign_storage::CompressedFileReader::nextEntry(), and foreign_storage::CompressedFileReader::readRegion().

+ Here is the caller graph for this function:

bool foreign_storage::ArchiveWrapper::nextEntry ( )

Definition at line 207 of file FileReader.cpp.

References arch_, current_entry_, and fetchBlock().

Referenced by foreign_storage::CompressedFileReader::checkForMoreRows(), and foreign_storage::CompressedFileReader::nextEntry().

207  {
208  bool success = arch_.get()->read_next_header();
209  if (success) {
210  current_entry_++;
211  fetchBlock();
212  }
213  return success;
214 }
std::unique_ptr< Archive > arch_
Definition: FileReader.h:257

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char foreign_storage::ArchiveWrapper::peekNextChar ( )

Referenced by foreign_storage::CompressedFileReader::consumeFirstLine().

+ Here is the caller graph for this function:

void foreign_storage::ArchiveWrapper::resetArchive ( )

Definition at line 233 of file FileReader.cpp.

References arch_, block_chars_remaining_, current_entry_, and file_path_.

Referenced by ArchiveWrapper(), foreign_storage::CompressedFileReader::checkForMoreRows(), and skipToEntry().

233  {
234  arch_.reset(new PosixFileArchive(file_path_, false));
236  // We will increment to 0 when reading first entry
237  current_entry_ = -1;
238 }
std::unique_ptr< Archive > arch_
Definition: FileReader.h:257

+ Here is the caller graph for this function:

void foreign_storage::ArchiveWrapper::skipToEntry ( int  entry_number)

Skip to entry in archive

Definition at line 192 of file FileReader.cpp.

References arch_, current_entry_, fetchBlock(), and resetArchive().

Referenced by foreign_storage::CompressedFileReader::checkForMoreRows(), foreign_storage::CompressedFileReader::nextEntry(), and foreign_storage::CompressedFileReader::readRegion().

192  {
193  if (current_entry_ >= entry_number) {
194  resetArchive();
195  }
196  while (current_entry_ < entry_number) {
197  if (arch_.get()->read_next_header()) {
198  current_entry_++;
199  } else {
200  throw std::runtime_error{"Invalid archive entry"};
201  }
202  }
203  fetchBlock();
204 }
std::unique_ptr< Archive > arch_
Definition: FileReader.h:257

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::unique_ptr<Archive> foreign_storage::ArchiveWrapper::arch_
private

Definition at line 257 of file FileReader.h.

Referenced by entryName(), fetchBlock(), nextEntry(), resetArchive(), and skipToEntry().

size_t foreign_storage::ArchiveWrapper::block_chars_remaining_
private
const void* foreign_storage::ArchiveWrapper::current_block_
private

Definition at line 259 of file FileReader.h.

Referenced by consumeDataFromCurrentEntry(), and fetchBlock().

int foreign_storage::ArchiveWrapper::current_entry_
private

Definition at line 263 of file FileReader.h.

Referenced by getCurrentEntryIndex(), nextEntry(), resetArchive(), and skipToEntry().

std::string foreign_storage::ArchiveWrapper::file_path_
private

Definition at line 265 of file FileReader.h.

Referenced by resetArchive().


The documentation for this class was generated from the following files: