RDM::TIME_SERIES::split< NEXT_1, NEXT_2 > Class Template Reference

Template Class for doing a split. More...

#include "rdm_time_series_split.h"

Public Member Functions

uint8_t * serialize (uint8_t *buffer)
uint8_t * unserialize (uint8_t *buffer)
RDM_RETCODE init (RDM_DB p_db)
Initialize this object. More...
void reset (void)
Reset this object. More...
RDM_RETCODE flush_value (uint32_t threshold=1, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Flush this object. More...
RDM_RETCODE flush_stats (uint32_t threshold=1, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Flush this object. More...
RDM_RETCODE flush_range (uint32_t threshold=1, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Flush this object. More...
template<class SOURCE_VALUE_T >
RDM_RETCODE put_value (SOURCE_VALUE_T *source_value, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Template method for receiving a data value. More...
template<class SOURCE_STATS_T >
RDM_RETCODE put_stats (SOURCE_STATS_T *source_stats, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Template method for receiving statistics. More...
template<class SOURCE_RANGE_T >
RDM_RETCODE put_range (SOURCE_RANGE_T *source_range, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Template method for receiving ranges. More...

Static Public Member Functions

constexpr static int get_serialize_size (void)
Get the size of a buffer for serialization to hold its state. More...

Data Fields

NEXT_1 next_1
NEXT_2 next_2

Friends

template<class ANY_NEXT >
class RDM::DB::transaction
template<class ANY_NEXT_1 , class ANY_NEXT_2 >
class split
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_NEXT >
class collect
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_INDATA_T , class ANY_NEXT >
class fft
template<uint32_t ANY_N, class ANY_AGGREGATE_T , class ANY_AGG_ELEMENT_T , class ANY_NEXT >
class mean
template<class ANY_RATIO , class ANY_NEXT >
class scale
template<uint32_t ANY_N, class ANY_STATS_T , class ANY_NEXT >
class stats
template<uint32_t ANY_N, class ANY_NEXT >
class downsample
template<class ANY_NEXT >
class custom

Detailed Description

template<class NEXT_1, class NEXT_2>
class RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >

Template Class for doing a split.

Template class for 2-way split of data values, ranges, or statistics. What is received by this class will be forwarded to both classes in the split.

Template Parameters
NEXT_1 The first class in the chain of classes for the split to receive data, ranges, or statistics.
NEXT_2 The second class in the chain of classes for the split to receive data, ranges, or statistics.
Examples
cpp70Example_main.cpp, time_series_fft.cpp, and time_series_restore_aggregate.cpp.

Member Function Documentation

flush_range()

template<class NEXT_1 , class NEXT_2 >
RDM_RETCODE RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::flush_range ( uint32_t threshold = 1,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Flush this object.

Call this method to flush ranges that have been collected so far. A threshold can also be provided. All the data collected for those ranges will be kept as is. The same is the case where the threshold has not been reached.

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
threshold [IN] Only flush objects where at least this many elements have been collected
transactional [IN] Is the flush required to be transactional
354 {
355RDM_RETCODE rc = sOKAY;
356RDM_TRANS trans{};
357
358if (transactional == RDM::DB::TRANSACTIONAL)
359 {
360 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
361 }
362if (rc == sOKAY)
363 {
364 rc = next_1.flush_stats (threshold, RDM::DB::NOT_TRANSACTIONAL);
365if (rc == sOKAY)
366 {
367 rc = next_2.flush_stats (threshold, RDM::DB::NOT_TRANSACTIONAL);
368if (rc != sOKAY)
369 {
370next_1.unflush ();
371 }
372 }
373if (transactional == RDM::DB::TRANSACTIONAL)
374 {
375if (rc == sOKAY)
376 {
377 rc = rdm_transEnd (trans);
378 }
379else
380 {
382 }
383 }
384 }
385
386return rc;
387 }

flush_stats()

template<class NEXT_1 , class NEXT_2 >
RDM_RETCODE RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::flush_stats ( uint32_t threshold = 1,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Flush this object.

Call this method to flush statistics that have been collected so far. A threshold can also be provided. All the data collected for those statistics will be kept as is. The same is the case where the threshold has not been reached.

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
threshold [IN] Only flush objects where at least this many elements have been collected
transactional [IN] Is the flush required to be transactional
290 {
291RDM_RETCODE rc = sOKAY;
292RDM_TRANS trans{};
293
294if (transactional == RDM::DB::TRANSACTIONAL)
295 {
296 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
297 }
298if (rc == sOKAY)
299 {
300 rc = next_1.flush_stats (threshold, RDM::DB::NOT_TRANSACTIONAL);
301if (rc == sOKAY)
302 {
303 rc = next_2.flush_stats (threshold, RDM::DB::NOT_TRANSACTIONAL);
304if (rc != sOKAY)
305 {
306next_1.unflush ();
307 }
308 }
309if (transactional == RDM::DB::TRANSACTIONAL)
310 {
311if (rc == sOKAY)
312 {
313 rc = rdm_transEnd (trans);
314 }
315else
316 {
318 }
319 }
320 }
321
322return rc;
323 }

flush_value()

template<class NEXT_1 , class NEXT_2 >
RDM_RETCODE RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::flush_value ( uint32_t threshold = 1,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Flush this object.

Call this method to flush values that have been collected so far. A threshold can also be provided. All the data collected for those values will be kept as is. The same is the case where the threshold has not been reached.

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
threshold [IN] Only flush objects where at least this many elements have been collected
transactional [IN] Is the flush required to be transactional
226 {
227RDM_RETCODE rc = sOKAY;
228RDM_TRANS trans{nullptr};
229
230if (transactional == RDM::DB::TRANSACTIONAL)
231 {
232 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
233 }
234if (rc == sOKAY)
235 {
236 rc = next_1.flush_value (threshold, RDM::DB::NOT_TRANSACTIONAL);
237if (rc == sOKAY)
238 {
239 rc = next_2.flush_value (threshold, RDM::DB::NOT_TRANSACTIONAL);
240if (rc != sOKAY)
241 {
242next_1.unflush ();
243 }
244 }
245if (transactional == RDM::DB::TRANSACTIONAL)
246 {
247if (rc == sOKAY)
248 {
249 rc = rdm_transEnd (trans);
250 }
251else
252 {
254 }
255 }
256 }
257
258return rc;
259 }

get_serialize_size()

template<class NEXT_1 , class NEXT_2 >
constexpr static int RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::get_serialize_size ( void )
inlinestaticconstexpr

Get the size of a buffer for serialization to hold its state.

Get the size needed for a buffer to hold the state of this object.

52 {
53return NEXT_1::get_serialize_size () + NEXT_2::get_serialize_size ();
54 }

init()

template<class NEXT_1 , class NEXT_2 >
RDM_RETCODE RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::init ( RDM_DB p_db )
inline

Initialize this object.

Call this method before sending it any data values, ranges, or statistics.

Return values
sOKAY Normal, successful return.
eINVARG Invalid argument.
eDBNOTOPEN Database not open.
eCURSORDB Cursor is associated with a different database.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
Parameters
p_db [IN] Use this database for chained classes that need to insert rows
169 {
170RDM_RETCODE rc = next_1.init (p_db);
171
172if (rc == sOKAY)
173 {
174 rc = next_2.init (p_db);
175 }
176
177if (rc == sOKAY)
178 {
179 split::db = p_db;
180 }
181
182return rc;
183 }

put_range()

template<class NEXT_1 , class NEXT_2 >
template<class SOURCE_RANGE_T >
RDM_RETCODE RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::put_range ( SOURCE_RANGE_T * source_range,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Template method for receiving ranges.

Receive one range and process it accordingly.

The type for the value provided is required to have columns for 'time_stamp_first', 'time_stamp_last', and 'value_range' with appropriate types. The column 'value_range' must be an array that is able to hold a static number of elements. Such a type can be generated using rdm-compile with a schema including a table similar to this:

CREATE TABLE range
(
value_range DOUBLE ARRAY [32] NOT NULL,
time_stamp_first UINT64 NOT NULL,
time_stamp_last UINT64 PRIMARY KEY
);
Template Parameters
SOURCE_RANGE_T The actual type of the range received.

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
[in] source_range The source range sent to this class
transactional [IN] Is the put required to be transactional
593 {
594RDM_RETCODE rc = sOKAY;
595RDM_TRANS trans{};
596
597if (transactional == RDM::DB::TRANSACTIONAL)
598 {
599 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
600 }
601
602if (rc == sOKAY)
603 {
604 rc = next_1.put_range (source_range, RDM::DB::NOT_TRANSACTIONAL);
605if (rc == sOKAY)
606 {
607 rc = next_2.put_range (source_range, RDM::DB::NOT_TRANSACTIONAL);
608if (rc != sOKAY)
609 {
610next_1.unput ();
611 }
612 }
613if (transactional == RDM::DB::TRANSACTIONAL)
614 {
615if (rc == sOKAY)
616 {
617 rc = rdm_transEnd (trans);
618 }
619else
620 {
622 }
623 }
624 }
625
626return rc;
627 }

put_stats()

template<class NEXT_1 , class NEXT_2 >
template<class SOURCE_STATS_T >
RDM_RETCODE RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::put_stats ( SOURCE_STATS_T * source_stats,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Template method for receiving statistics.

Receive one statistic and process it accordingly.

The type for the value provided is required to have columns for 'time_stamp_first', 'time_stamp_last', 'n', 'value_sum', and 'value_sum2' with appropriate types. Such a type can be generated using rdm-compile with a schema including a table similar to this:

CREATE TABLE stats
(
time_stamp_first UINT64 NOT NULL,
time_stamp_last UINT64 PRIMARY KEY,
n UINT64 NOT NULL,
value_sum DOUBLE NOT NULL,
value_sum2 DOUBLE NOT NULL
);

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Template Parameters
SOURCE_STATS_T The actual type of the statistic received.
Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
[in] source_stats The source statistics sent to this class
transactional [IN] Is the put required to be transactional
512 {
513RDM_RETCODE rc = sOKAY;
514RDM_TRANS trans{};
515
516if (transactional == RDM::DB::TRANSACTIONAL)
517 {
518 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
519 }
520
521if (rc == sOKAY)
522 {
523 rc = next_1.put_stats (source_stats, RDM::DB::NOT_TRANSACTIONAL);
524if (rc == sOKAY)
525 {
526 rc = next_2.put_stats (source_stats, RDM::DB::NOT_TRANSACTIONAL);
527if (rc != sOKAY)
528 {
529next_1.unput ();
530 }
531 }
532if (transactional == RDM::DB::TRANSACTIONAL)
533 {
534if (rc == sOKAY)
535 {
536 rc = rdm_transEnd (trans);
537 }
538else
539 {
541 }
542 }
543 }
544
545return rc;
546 }

put_value()

template<class NEXT_1 , class NEXT_2 >
template<class SOURCE_VALUE_T >
RDM_RETCODE RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::put_value ( SOURCE_VALUE_T * source_value,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Template method for receiving a data value.

Receive one data value and process it accordingly.

The type for the value provided is required to have columns for 'time_stamp_current' and 'value_current' with appropriate types. Such a type can be generated using rdm-compile with a schema including a table similar to this:

CREATE TABLE measurement
(
time_stamp_current UINT64 PRIMARY KEY,
value_current DOUBLE NOT NULL
);

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Template Parameters
SOURCE_VALUE_T The actual type of the source values received
Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
[in] source_value The source value sent to this class
transactional [IN] Is the put required to be transactional
431 {
432RDM_RETCODE rc = sOKAY;
433RDM_TRANS trans{};
434
435if (transactional == RDM::DB::TRANSACTIONAL)
436 {
437 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
438 }
439
440if (rc == sOKAY)
441 {
442 rc = next_1.put_value (source_value, RDM::DB::NOT_TRANSACTIONAL);
443if (rc == sOKAY)
444 {
445 rc = next_2.put_value (source_value, RDM::DB::NOT_TRANSACTIONAL);
446if (rc != sOKAY)
447 {
448next_1.unput ();
449 }
450 }
451if (transactional == RDM::DB::TRANSACTIONAL)
452 {
453if (rc == sOKAY)
454 {
455 rc = rdm_transEnd (trans);
456 }
457else
458 {
460 }
461 }
462 }
463
464return rc;
465 }

reset()

template<class NEXT_1 , class NEXT_2 >
void RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::reset ( void )
inline

Reset this object.

Call this method to discard all internally kept data values, ranges, and statistics that have not yet been persisted and start over from scratch.

192 {
193next_1.reset ();
194next_2.reset ();
195 }

serialize()

template<class NEXT_1 , class NEXT_2 >
uint8_t* RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::serialize ( uint8_t * buffer )
inline
63 {
64 buffer = next_1.serialize (buffer);
65return next_2.serialize (buffer);
66 }

unserialize()

template<class NEXT_1 , class NEXT_2 >
uint8_t* RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::unserialize ( uint8_t * buffer )
inline
75 {
76 buffer = next_1.unserialize (buffer);
77return next_2.unserialize (buffer);
78 }

Friends And Related Function Documentation

collect

template<class NEXT_1 , class NEXT_2 >
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_NEXT >
friend class collect
friend

custom

template<class NEXT_1 , class NEXT_2 >
template<class ANY_NEXT >
friend class custom
friend

downsample

template<class NEXT_1 , class NEXT_2 >
template<uint32_t ANY_N, class ANY_NEXT >
friend class downsample
friend

fft

template<class NEXT_1 , class NEXT_2 >
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_INDATA_T , class ANY_NEXT >
friend class fft
friend

mean

template<class NEXT_1 , class NEXT_2 >
template<uint32_t ANY_N, class ANY_AGGREGATE_T , class ANY_AGG_ELEMENT_T , class ANY_NEXT >
friend class mean
friend

RDM::DB::transaction

template<class NEXT_1 , class NEXT_2 >
template<class ANY_NEXT >
friend class RDM::DB::transaction
friend

scale

template<class NEXT_1 , class NEXT_2 >
template<class ANY_RATIO , class ANY_NEXT >
friend class scale
friend

split

template<class NEXT_1 , class NEXT_2 >
template<class ANY_NEXT_1 , class ANY_NEXT_2 >
friend class split
friend

stats

template<class NEXT_1 , class NEXT_2 >
template<uint32_t ANY_N, class ANY_STATS_T , class ANY_NEXT >
friend class stats
friend

Field Documentation

next_1

next_2


The documentation for this class was generated from the following files:
RDM_RETCODE rdm_transEnd(RDM_TRANS trans)
End a transactional operation.
@ NOT_TRANSACTIONAL
Definition: rdm_db_transaction.h:36
RDM_RETCODE rdm_transEndRollback(RDM_TRANS trans)
End a transactional operation with a rollback.
@ sOKAY
Definition: rdmretcodetypes.h:100
struct RDM_TRANS_S * RDM_TRANS
Definition: rdmtypes.h:328
enum RDM_RETCODE_E RDM_RETCODE
RaimaDB status and error return codes.
NEXT_2 next_2
Definition: rdm_time_series_split.h:45
NEXT_1 next_1
Definition: rdm_time_series_split.h:44
RDM_RETCODE rdm_dbStartUpdate(RDM_DB db, const RDM_TABLE_ID *writeTableIds, uint32_t numWriteTableIds, const RDM_TABLE_ID *readTableIds, uint32_t numReadTableIds, RDM_TRANS *pTrans)
Get write locks.
@ TRANSACTIONAL
Definition: rdm_db_transaction.h:35