roo_monitoring
API Documentation for roo_monitoring
Loading...
Searching...
No Matches
roo_monitoring::VaultFileReader Class Reference

Sequential reader for a single vault file. More...

#include <vault.h>

Public Member Functions

 VaultFileReader (const Collection *collection)
 Creates a reader bound to the specified collection.
 
bool open (const VaultFileRef &ref, int index, int64_t offset)
 Opens the file and seeks to the specified index and byte offset.
 
bool is_open () const
 Returns true if a file is currently open.
 
void close ()
 Closes the reader.
 
void seekForward (int64_t timestamp)
 Advances the cursor to the first entry at or after the timestamp.
 
bool next (std::vector< Sample > *sample)
 Reads the next entry and fills the sample vector.
 
int index () const
 Returns the current entry index.
 
bool past_eof () const
 Returns true if the reader has passed the end of file.
 
bool ok () const
 Returns true if the file is either good or does not exist.
 
roo_io::Status status () const
 Returns the current reader status.
 
const VaultFileRefvault_ref () const
 Returns the vault file reference for this reader.
 
LogCursor tell ()
 Returns the current log cursor.
 
 ~VaultFileReader ()
 

Detailed Description

Sequential reader for a single vault file.

A single vault file has the following format:

header: major version (uint8): currently always 1 minor version (uint8): currently always 1 entry[]: sample count (varint) sample[]: stream ID (varint) avg (uint16) min (uint16) max (uint16) fill (uint16)

The file name of the vault file implies the start timestamp. The level implies the time resolution. The finished vault always has 256 entries.

Definition at line 106 of file vault.h.

Constructor & Destructor Documentation

◆ VaultFileReader()

roo_monitoring::VaultFileReader::VaultFileReader ( const Collection collection)

Creates a reader bound to the specified collection.

Definition at line 69 of file vault.cpp.

◆ ~VaultFileReader()

roo_monitoring::VaultFileReader::~VaultFileReader ( )

Definition at line 124 of file vault.cpp.

Member Function Documentation

◆ close()

void roo_monitoring::VaultFileReader::close ( )
inline

Closes the reader.

Definition at line 120 of file vault.h.

◆ index()

int roo_monitoring::VaultFileReader::index ( ) const
inline

Returns the current entry index.

Definition at line 127 of file vault.h.

Referenced by roo_monitoring::VaultIterator::cursor(), and open().

◆ is_open()

bool roo_monitoring::VaultFileReader::is_open ( ) const
inline

Returns true if a file is currently open.

Definition at line 117 of file vault.h.

◆ next()

bool roo_monitoring::VaultFileReader::next ( std::vector< Sample > *  sample)

Reads the next entry and fills the sample vector.

Definition at line 145 of file vault.cpp.

References roo_monitoring::kResolution_65536_ms, past_eof(), and roo_monitoring::VaultFileRef::resolution().

Referenced by roo_monitoring::VaultIterator::next(), and seekForward().

◆ ok()

bool roo_monitoring::VaultFileReader::ok ( ) const
inline

Returns true if the file is either good or does not exist.

If open fails for any reason other than not found, or if read fails, this returns false.

Definition at line 135 of file vault.h.

◆ open()

bool roo_monitoring::VaultFileReader::open ( const VaultFileRef ref,
int  index,
int64_t  offset 
)

Opens the file and seeks to the specified index and byte offset.

Definition at line 77 of file vault.cpp.

References roo_monitoring::Collection::fs(), roo_monitoring::Collection::getVaultFilePath(), index(), and vault_ref().

Referenced by roo_monitoring::VaultIterator::next(), and roo_monitoring::VaultIterator::VaultIterator().

◆ past_eof()

bool roo_monitoring::VaultFileReader::past_eof ( ) const

Returns true if the reader has passed the end of file.

Definition at line 201 of file vault.cpp.

References roo_monitoring::kRangeElementCount.

Referenced by roo_monitoring::VaultIterator::next(), next(), seekForward(), and tell().

◆ seekForward()

void roo_monitoring::VaultFileReader::seekForward ( int64_t  timestamp)

Advances the cursor to the first entry at or after the timestamp.

Definition at line 181 of file vault.cpp.

References roo_monitoring::kRangeElementCount, next(), past_eof(), roo_monitoring::VaultFileRef::resolution(), and roo_monitoring::VaultFileRef::timestamp().

Referenced by roo_monitoring::VaultIterator::VaultIterator().

◆ status()

roo_io::Status roo_monitoring::VaultFileReader::status ( ) const
inline

Returns the current reader status.

Definition at line 141 of file vault.h.

◆ tell()

LogCursor roo_monitoring::VaultFileReader::tell ( )

Returns the current log cursor.

Definition at line 126 of file vault.cpp.

References past_eof(), and roo_monitoring::VaultFileRef::timestamp().

◆ vault_ref()

const VaultFileRef & roo_monitoring::VaultFileReader::vault_ref ( ) const
inline

Returns the vault file reference for this reader.

Definition at line 144 of file vault.h.

Referenced by open().


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