OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
foreign_storage::ArchiveWrapper Class Reference

#include <CsvReader.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 165 of file CsvReader.h.

Constructor & Destructor Documentation

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

Definition at line 167 of file CsvReader.h.

References resetArchive().

168  : current_block_(nullptr)
170  , current_entry_(-1)
171  , file_path_(file_path) {
172  resetArchive();
173  }

+ 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 182 of file CsvReader.cpp.

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

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

182  {
183  CHECK(size <= block_chars_remaining_);
184  block_chars_remaining_ -= size;
185  if (dest_buffer != nullptr) {
186  memcpy(dest_buffer, current_block_, size);
187  }
188  current_block_ = static_cast<const char*>(current_block_) + size;
189  if (block_chars_remaining_ == 0) {
190  fetchBlock();
191  }
192 }
#define CHECK(condition)
Definition: Logger.h:197

+ 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 185 of file CsvReader.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 183 of file CsvReader.h.

References block_chars_remaining_.

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

183 { return (block_chars_remaining_ == 0); }

+ Here is the caller graph for this function:

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

Definition at line 198 of file CsvReader.h.

References arch_.

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

198 { return arch_->entryName(); }
std::unique_ptr< Archive > arch_
Definition: CsvReader.h:206

+ 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 206 of file CsvReader.cpp.

References arch_, block_chars_remaining_, and current_block_.

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

206  {
207  int64_t offset;
208  auto ok =
209  arch_.get()->read_data_block(&current_block_, &block_chars_remaining_, &offset);
210  if (!ok) {
212  }
213 }
std::unique_ptr< Archive > arch_
Definition: CsvReader.h:206

+ Here is the caller graph for this function:

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

Definition at line 193 of file CsvReader.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 173 of file CsvReader.cpp.

References arch_, current_entry_, and fetchBlock().

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

173  {
174  bool success = arch_.get()->read_next_header();
175  if (success) {
176  current_entry_++;
177  fetchBlock();
178  }
179  return success;
180 }
std::unique_ptr< Archive > arch_
Definition: CsvReader.h:206

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

+ Here is the caller graph for this function:

void foreign_storage::ArchiveWrapper::resetArchive ( )

Definition at line 199 of file CsvReader.cpp.

References arch_, block_chars_remaining_, current_entry_, and file_path_.

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

199  {
200  arch_.reset(new PosixFileArchive(file_path_, false));
202  // We will increment to 0 when reading first entry
203  current_entry_ = -1;
204 }
std::unique_ptr< Archive > arch_
Definition: CsvReader.h:206

+ Here is the caller graph for this function:

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

Skip to entry in archive

Definition at line 158 of file CsvReader.cpp.

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

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

158  {
159  if (current_entry_ >= entry_number) {
160  resetArchive();
161  }
162  while (current_entry_ < entry_number) {
163  if (arch_.get()->read_next_header()) {
164  current_entry_++;
165  } else {
166  throw std::runtime_error{"Invalid archive entry"};
167  }
168  }
169  fetchBlock();
170 }
std::unique_ptr< Archive > arch_
Definition: CsvReader.h:206

+ 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 206 of file CsvReader.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 208 of file CsvReader.h.

Referenced by consumeDataFromCurrentEntry(), and fetchBlock().

int foreign_storage::ArchiveWrapper::current_entry_
private

Definition at line 212 of file CsvReader.h.

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

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

Definition at line 214 of file CsvReader.h.

Referenced by resetArchive().


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