nidas v1.2.3
Public Types | Public Member Functions | Public Attributes | List of all members
nidas::dynld::BlockStats Struct Reference

Keep track of statistics for a contiguous block of good or bad samples in a stream. More...

#include <SampleInputStream.h>

Public Types

typedef nidas::core::dsm_time_t dsm_time_t
 

Public Member Functions

 BlockStats (bool goodblock=true, size_t startblock=0)
 Initialize a block as good or bad and give it an offset.
 
bool addGoodSample (nidas::core::Sample *samp, long long offset)
 On a good sample, reset this block to a good block if not already, and update the last good sample and the size of the block.
 
void addBadSample (long long offset, unsigned int nbadbytes)
 An alternative to calling startBadBlock()/endBadBlock(), it adds nbadbytes to a bad block, resetting the block from good to bad if necessary.
 
void startBadBlock (long long offset)
 Start a bad block.
 
void endBadBlock (nidas::core::Sample *samp, long long offset)
 Mark the end of a bad block by assigning the end_time and setting nbytes according to the current offset.
 
size_t blockEnd () const
 

Public Attributes

dsm_time_t start_time
 Sample times bounding this block.
 
dsm_time_t end_time
 
bool good
 True if this is a block of good samples.
 
size_t nsamples
 Number of good samples in a row.
 
size_t block_start
 
size_t nbytes
 Size in bytes of this block.
 
unsigned int last_good_sample_size
 Size of the last good sample in a good sample block.
 

Detailed Description

Keep track of statistics for a contiguous block of good or bad samples in a stream.

Member Typedef Documentation

◆ dsm_time_t

Constructor & Destructor Documentation

◆ BlockStats()

BlockStats::BlockStats ( bool goodblock = true,
size_t startblock = 0 )

Initialize a block as good or bad and give it an offset.

Blocks default to being good but empty.

Referenced by addGoodSample(), and startBadBlock().

Member Function Documentation

◆ addBadSample()

void BlockStats::addBadSample ( long long offset,
unsigned int nbadbytes )

An alternative to calling startBadBlock()/endBadBlock(), it adds nbadbytes to a bad block, resetting the block from good to bad if necessary.

It is analogous to the addGoodSample() method. Use startBadBlock() and endBadBlock() to avoid calling addGoodSample() on every single bad byte. When a bad block is started from a good block, it copies the end_time from the good block into the start_time of the new bad block.

References good, nbytes, and startBadBlock().

◆ addGoodSample()

bool BlockStats::addGoodSample ( nidas::core::Sample * samp,
long long offset )

On a good sample, reset this block to a good block if not already, and update the last good sample and the size of the block.

Call this method on each good sample so that when a bad header appears, all the stats in this block are already correct. Return true if this is the start of a new good block.

References BlockStats(), end_time, nidas::core::getSample(), good, last_good_sample_size, nbytes, nsamples, and start_time.

Referenced by nidas::dynld::SampleInputStream::sampleFromHeader().

◆ blockEnd()

size_t nidas::dynld::BlockStats::blockEnd ( ) const
inline

References block_start, and nbytes.

◆ endBadBlock()

void BlockStats::endBadBlock ( nidas::core::Sample * samp,
long long offset )

Mark the end of a bad block by assigning the end_time and setting nbytes according to the current offset.

If the block ends without a good sample, then pass samp as NULL, in which case the end_time will remain at the default of LONG_LONG_MAX.

References block_start, end_time, and nbytes.

Referenced by nidas::dynld::SampleInputStream::sampleFromHeader().

◆ startBadBlock()

void BlockStats::startBadBlock ( long long offset)

Start a bad block.

The size (nbytes) will not be correct until endBadBlock() is called.

References BlockStats(), end_time, nidas::core::getSample(), nbytes, and start_time.

Referenced by addBadSample(), and nidas::dynld::SampleInputStream::sampleFromHeader().

Member Data Documentation

◆ block_start

size_t nidas::dynld::BlockStats::block_start

◆ end_time

dsm_time_t nidas::dynld::BlockStats::end_time

◆ good

bool nidas::dynld::BlockStats::good

True if this is a block of good samples.

Referenced by addBadSample(), addGoodSample(), and nidas::dynld::SampleInputStream::sampleFromHeader().

◆ last_good_sample_size

unsigned int nidas::dynld::BlockStats::last_good_sample_size

Size of the last good sample in a good sample block.

It is zero in a bad block.

Referenced by addGoodSample().

◆ nbytes

size_t nidas::dynld::BlockStats::nbytes

◆ nsamples

size_t nidas::dynld::BlockStats::nsamples

Number of good samples in a row.

Zero in a bad block.

Referenced by addGoodSample().

◆ start_time

dsm_time_t nidas::dynld::BlockStats::start_time

Sample times bounding this block.

For good blocks, these are the sample times for the first and last samples in the block. For bad blocks, they are the sample times of the last good sample before the block and the first good sample after the block. If unset, start_time is LONG_LONG_MIN and end_time is LONG_LONG_MAX.

Referenced by addGoodSample(), nidas::dynld::SampleInputStream::sampleFromHeader(), and startBadBlock().


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