27 #ifndef NIDAS_CORE_SAMPLESORTER_H
28 #define NIDAS_CORE_SAMPLESORTER_H
34 namespace nidas {
namespace core {
158 void flush() throw();
280 int run() throw(nidas::util::Exception);
384 SampleSorter& operator=(const SampleSorter&);
void setKeepStats(bool val)
Definition: SampleSourceSupport.h:154
size_t getNumEarlySamples() const
Number of early samples, which may not be sorted.
Definition: SampleSorter.h:234
SampleT< char > _dummy
Definition: SampleSorter.h:363
unsigned int _earlySamples
Samples which are earlier than the current latest sample in the sorter minus the sorter length...
Definition: SampleSorter.h:347
void setLateSampleCacheSize(unsigned int val)
When aging-off samples, cache this number of samples with the latest time tags.
Definition: SampleSorter.h:263
bool _flushed
Definition: SampleSorter.h:361
int _earlyWarningCount
How often to log warnings about early samples.
Definition: SampleSorter.h:357
bool _heapBlock
_heapBlock controls what happens when the number of bytes in _samples exceeds _heapMax.
Definition: SampleSorter.h:322
Interface for a Thread for buffering samples.
Definition: SampleThread.h:52
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleSorter.h:81
unsigned int _lateSampleCacheSize
Definition: SampleSorter.h:374
size_t _heapSize
Current heap size, in bytes.
Definition: SampleSorter.h:309
void setRealTime(bool val)
Is this sorter running in real-time? If so then we can screen for bad time-tags by checking against t...
Definition: SampleSorter.h:243
const SampleStats & getSampleStats() const
Definition: SampleSorter.h:148
std::list< const SampleTag * > getSampleTags() const
Implementation of SampleSource::getSampleTags().
Definition: SampleSorter.h:103
void removeSampleTag(const SampleTag *tag)
Definition: SampleSourceSupport.cc:67
SampleTagIterator getSampleTagIterator() const
Implementation of SampleSource::getSampleTagIterator().
Definition: SampleSorter.h:111
size_t getNumFutureSamples() const
Number of samples discarded because their timetags were in the future.
Definition: SampleSorter.h:226
SortedSampleSet _samples
Definition: SampleSorter.h:287
virtual ~SampleSorter()
Definition: SampleSorter.cc:106
unsigned int _realTimeFutureSamples
Number of samples discarded because getRealTime() is true and the samples have timetags later than th...
Definition: SampleSorter.h:338
Pure virtual interface for a source of Samples.
Definition: SampleSource.h:48
SampleTagIterator getSampleTagIterator() const
Definition: SampleSourceSupport.cc:75
size_t getHeapSize() const
Get the current amount of heap being used for sorting.
Definition: SampleSorter.h:200
void interrupt()
Interrupt sorting thread.
Definition: SampleSorter.cc:367
SampleSorter(const std::string &name, bool raw)
Constructor.
Definition: SampleSorter.cc:82
void removeSampleTag(const SampleTag *tag)
Definition: SampleSorter.h:95
nidas::util::Cond _flushCond
Definition: SampleSorter.h:298
A source of samples.
Definition: SampleSourceSupport.h:47
unsigned int _discardedSamples
Number of samples discarded because of _heapSize > _heapMax and heapBlock == true.
Definition: SampleSorter.h:332
void removeSampleClient(SampleClient *c)
Remove a SampleClient from this SampleSource This will also remove a SampleClient if it has been adde...
Definition: SampleSourceSupport.cc:88
bool getKeepStats() const
Definition: SampleSorter.h:71
bool getKeepStats() const
Definition: SampleSourceSupport.h:159
bool _heapExceeded
Definition: SampleSorter.h:326
void addSampleTag(const SampleTag *tag)
How to tell this SampleSorter what sample tags it will be sorting.
Definition: SampleSorter.h:90
void removeSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition: SampleSourceSupport.cc:121
std::multiset< const Sample *, SampleTimetagComparator > SortedSampleSet
A multiset for storing samples sorted by timetag.
Definition: SortedSampleSet.h:107
void addSampleClient(SampleClient *c)
Add a SampleClient to this SampleSource.
Definition: SampleSourceSupport.cc:80
Pure virtual interface of a client of Samples.
Definition: SampleClient.h:38
A SampleClient that sorts its received samples, using an STL multiset, and then sends the sorted samp...
Definition: SampleSorter.h:51
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleSorter.h:76
bool getRealTime() const
Definition: SampleSorter.h:248
void setHeapBlock(bool val)
Definition: SampleSorter.h:209
unsigned int _sorterLengthUsec
Length of SampleSorter, in micro-seconds.
Definition: SampleSorter.h:285
const SampleStats & getSampleStats() const
Definition: SampleSourceSupport.h:149
int _discardWarningCount
How often to log warnings about discardedSamples.
Definition: SampleSorter.h:352
int getClientCount() const
How many SampleClients are currently in my list.
Definition: SampleSorter.h:143
void setKeepStats(bool val)
Definition: SampleSorter.h:66
long long _maxSorterLengthUsec
Definition: SampleSorter.h:372
void heapDecrement(size_t bytes)
Utility function to decrement the heap size after writing one or more samples.
Definition: SampleSorter.cc:406
A typed Sample, with data of type DataT.
Definition: Sample.h:393
Interface to a data sample.
Definition: Sample.h:189
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleSourceSupport.h:60
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition: NidsIterators.h:217
void setHeapMax(size_t val)
Set the maximum amount of heap memory to use for sorting samples.
Definition: SampleSorter.h:193
bool receive(const Sample *s)
Implementation of SampleClient::receive().
Definition: SampleSorter.cc:496
Class describing a group of variables that are sampled and handled together.
Definition: SampleTag.h:87
void addSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition: SampleSourceSupport.cc:101
void removeSampleClientForTag(SampleClient *client, const SampleTag *tag)
Remove a SampleClient for a given SampleTag from this SampleSource.
Definition: SampleSorter.h:138
void removeSampleClient(SampleClient *client)
Remove a SampleClient from this SampleSource.
Definition: SampleSorter.h:124
void setLengthSecs(float val)
Definition: SampleSorter.h:179
A source of samples.
Definition: SampleStats.h:41
#define USECS_PER_SEC
Definition: ublox.cc:59
void addSampleClient(SampleClient *client)
Implementation of SampleSource::addSampleClient().
Definition: SampleSorter.h:119
unsigned int getLateSampleCacheSize() const
Definition: SampleSorter.h:268
bool _doFlush
Definition: SampleSorter.h:359
size_t size() const
Current number of samples in the sorter.
Definition: SampleSorter.h:177
bool _realTime
Is this sorter running in real-time? If so then we can screen for bad time-tags by checking against t...
Definition: SampleSorter.h:370
SampleSourceSupport _source
Definition: SampleSorter.h:275
float getLengthSecs() const
Definition: SampleSorter.h:184
int getClientCount() const
How many SampleClients are currently in my list.
Definition: SampleSourceSupport.cc:136
size_t getNumDiscardedSamples() const
Number of samples discarded because of _heapSize > _heapMax and heapBlock == true.
Definition: SampleSorter.h:217
void flush()
Implementation of SampleSource::flush().
Definition: SampleSorter.cc:434
std::list< const SampleTag * > getSampleTags() const
What SampleTags am I a SampleSource for?
Definition: SampleSourceSupport.cc:54
size_t getHeapMax() const
Definition: SampleSorter.h:195
bool getHeapBlock() const
Definition: SampleSorter.h:211
size_t _heapMax
Limit on the maximum size of memory to use while buffering samples.
Definition: SampleSorter.h:304
nidas::util::Cond _sampleSetCond
Definition: SampleSorter.h:296
int run()
Thread run function.
Definition: SampleSorter.cc:144
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleSourceSupport.h:66
nidas::util::Cond _heapCond
Definition: SampleSorter.h:324
void addSampleClientForTag(SampleClient *client, const SampleTag *tag)
Add a Client for a given SampleTag.
Definition: SampleSorter.h:133
void addSampleTag(const SampleTag *tag)
Add a SampleTag to this SampleSource.
Definition: SampleSourceSupport.cc:60