OmniSciDB  6686921089
 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 202 of file FileReader.h.

Constructor & Destructor Documentation

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

Definition at line 204 of file FileReader.h.

References resetArchive().

205  : current_block_(nullptr)
207  , current_entry_(-1)
208  , file_path_(file_path) {
209  resetArchive();
210  }

+ 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 206 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().

206  {
207  CHECK(size <= block_chars_remaining_);
208  block_chars_remaining_ -= size;
209  if (dest_buffer != nullptr) {
210  memcpy(dest_buffer, current_block_, size);
211  }
212  current_block_ = static_cast<const char*>(current_block_) + size;
213  if (block_chars_remaining_ == 0) {
214  fetchBlock();
215  }
216 }
#define CHECK(condition)
Definition: Logger.h:209

+ 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 222 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 220 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().

220 { return (block_chars_remaining_ == 0); }

+ Here is the caller graph for this function:

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

Definition at line 235 of file FileReader.h.

References arch_.

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

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

+ 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 230 of file FileReader.cpp.

References arch_, block_chars_remaining_, and current_block_.

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

230  {
231  int64_t offset;
232  auto ok =
233  arch_.get()->read_data_block(&current_block_, &block_chars_remaining_, &offset);
234  if (!ok) {
236  }
237 }
std::unique_ptr< Archive > arch_
Definition: FileReader.h:243

+ Here is the caller graph for this function:

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

Definition at line 230 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 197 of file FileReader.cpp.

References arch_, current_entry_, and fetchBlock().

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

197  {
198  bool success = arch_.get()->read_next_header();
199  if (success) {
200  current_entry_++;
201  fetchBlock();
202  }
203  return success;
204 }
std::unique_ptr< Archive > arch_
Definition: FileReader.h:243

+ 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 223 of file FileReader.cpp.

References arch_, block_chars_remaining_, current_entry_, and file_path_.

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

223  {
224  arch_.reset(new PosixFileArchive(file_path_, false));
226  // We will increment to 0 when reading first entry
227  current_entry_ = -1;
228 }
std::unique_ptr< Archive > arch_
Definition: FileReader.h:243

+ Here is the caller graph for this function:

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

Skip to entry in archive

Definition at line 182 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().

182  {
183  if (current_entry_ >= entry_number) {
184  resetArchive();
185  }
186  while (current_entry_ < entry_number) {
187  if (arch_.get()->read_next_header()) {
188  current_entry_++;
189  } else {
190  throw std::runtime_error{"Invalid archive entry"};
191  }
192  }
193  fetchBlock();
194 }
std::unique_ptr< Archive > arch_
Definition: FileReader.h:243

+ 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 243 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 245 of file FileReader.h.

Referenced by consumeDataFromCurrentEntry(), and fetchBlock().

int foreign_storage::ArchiveWrapper::current_entry_
private

Definition at line 249 of file FileReader.h.

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

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

Definition at line 251 of file FileReader.h.

Referenced by resetArchive().


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