MADARA  3.4.1
madara::knowledge::CheckpointReader Class Reference

Class for iterating binary checkpoint files. More...

#include <CheckpointPlayer.h>

Public Member Functions

 CheckpointReader (CheckpointSettings &in_checkpoint_settings)
 Construct using the given CheckpointSettings. More...
 
const CheckpointSettingsget_checkpoint_settings () const
 Returns CheckpointSettings this reader is using. More...
 
const FileHeaderget_file_header () const
 Get the file header information. More...
 
int64_t get_total_read () const
 Get total number of bytes read so far during iteration. More...
 
bool is_open () const
 Check if underlying file is open. More...
 
std::pair< std::string, KnowledgeRecordnext ()
 Get the next update from the checkpoint file. More...
 
void start ()
 Begin by reading any header information. More...
 

Private Attributes

utility::ScopedArray< char > buffer
 
int64_t buffer_remaining
 
transport::MessageHeader checkpoint_header
 
CheckpointSettingscheckpoint_settings
 
uint64_t checkpoint_size
 
size_t checkpoint_start
 
char * current
 
std::ifstream file
 
logger::Loggerlogger_
 
int64_t max_buffer
 
FileHeader meta
 
int stage = 0
 
uint64_t state
 
int64_t total_read = 0
 
uint64_t update
 

Detailed Description

Class for iterating binary checkpoint files.

Definition at line 29 of file CheckpointPlayer.h.

Constructor & Destructor Documentation

◆ CheckpointReader()

madara::knowledge::CheckpointReader::CheckpointReader ( CheckpointSettings in_checkpoint_settings)
inline

Construct using the given CheckpointSettings.

Ensure that the referenced object outlives this one.

Definition at line 36 of file CheckpointPlayer.h.

Member Function Documentation

◆ get_checkpoint_settings()

const CheckpointSettings& madara::knowledge::CheckpointReader::get_checkpoint_settings ( ) const
inline

Returns CheckpointSettings this reader is using.

Definition at line 90 of file CheckpointPlayer.h.

◆ get_file_header()

const FileHeader* madara::knowledge::CheckpointReader::get_file_header ( ) const
inline

Get the file header information.

Only valid after calling start(), or next(). If not valid, returns nullptr.

Definition at line 68 of file CheckpointPlayer.h.

◆ get_total_read()

int64_t madara::knowledge::CheckpointReader::get_total_read ( ) const
inline

Get total number of bytes read so far during iteration.

Definition at line 59 of file CheckpointPlayer.h.

◆ is_open()

bool madara::knowledge::CheckpointReader::is_open ( ) const
inline

Check if underlying file is open.

This does not imply there are more records left to read.

Definition at line 82 of file CheckpointPlayer.h.

◆ next()

std::pair< std::string, KnowledgeRecord > madara::knowledge::CheckpointReader::next ( )

Get the next update from the checkpoint file.

Returns an empty string and record if the end is reached.

What we read into the checkpoint_header will dictate our max_buffer. We want to make this checkpoint_header size into something reasonable.

Definition at line 165 of file CheckpointPlayer.cpp.

◆ start()

void madara::knowledge::CheckpointReader::start ( )

Begin by reading any header information.

Optional. Will be called automatically by next if need be. This opens the file specified in the settings based during construction. The file will be closed when this object is destructed.

check that there is more than one state and that the rest of the file is sufficient to at least be a message header (what we use as a checkpoint header

Definition at line 21 of file CheckpointPlayer.cpp.

Member Data Documentation

◆ buffer

utility::ScopedArray<char> madara::knowledge::CheckpointReader::buffer
private

Definition at line 105 of file CheckpointPlayer.h.

◆ buffer_remaining

int64_t madara::knowledge::CheckpointReader::buffer_remaining
private

Definition at line 104 of file CheckpointPlayer.h.

◆ checkpoint_header

transport::MessageHeader madara::knowledge::CheckpointReader::checkpoint_header
private

Definition at line 110 of file CheckpointPlayer.h.

◆ checkpoint_settings

CheckpointSettings& madara::knowledge::CheckpointReader::checkpoint_settings
private

Definition at line 96 of file CheckpointPlayer.h.

◆ checkpoint_size

uint64_t madara::knowledge::CheckpointReader::checkpoint_size
private

Definition at line 109 of file CheckpointPlayer.h.

◆ checkpoint_start

size_t madara::knowledge::CheckpointReader::checkpoint_start
private

Definition at line 107 of file CheckpointPlayer.h.

◆ current

char* madara::knowledge::CheckpointReader::current
private

Definition at line 106 of file CheckpointPlayer.h.

◆ file

std::ifstream madara::knowledge::CheckpointReader::file
private

Definition at line 100 of file CheckpointPlayer.h.

◆ logger_

logger::Logger* madara::knowledge::CheckpointReader::logger_
private

Definition at line 98 of file CheckpointPlayer.h.

◆ max_buffer

int64_t madara::knowledge::CheckpointReader::max_buffer
private

Definition at line 103 of file CheckpointPlayer.h.

◆ meta

FileHeader madara::knowledge::CheckpointReader::meta
private

Definition at line 102 of file CheckpointPlayer.h.

◆ stage

int madara::knowledge::CheckpointReader::stage = 0
private

Definition at line 99 of file CheckpointPlayer.h.

◆ state

uint64_t madara::knowledge::CheckpointReader::state
private

Definition at line 108 of file CheckpointPlayer.h.

◆ total_read

int64_t madara::knowledge::CheckpointReader::total_read = 0
private

Definition at line 101 of file CheckpointPlayer.h.

◆ update

uint64_t madara::knowledge::CheckpointReader::update
private

Definition at line 111 of file CheckpointPlayer.h.


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