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

RDM_RETCODE init (RDM_DB 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...

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
320 {
321RDM_RETCODE rc = sOKAY;
322RDM_TRANS trans;
323
324if (transactional == RDM::DB::TRANSACTIONAL)
325 {
326 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
327 }
328if (rc == sOKAY)
329 {
330 rc = next_1.flush_stats (threshold, RDM::DB::NOT_TRANSACTIONAL);
331if (rc == sOKAY)
332 {
333 rc = next_2.flush_stats (threshold, RDM::DB::NOT_TRANSACTIONAL);
334if (rc != sOKAY)
335 {
336next_1.unflush ();
337 }
338 }
339if (transactional == RDM::DB::TRANSACTIONAL)
340 {
341if (rc == sOKAY)
342 {
343 rc = rdm_transEnd (trans);
344 }
345else
346 {
348 }
349 }
350 }
351
352return rc;
353 }

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
256 {
257RDM_RETCODE rc = sOKAY;
258RDM_TRANS trans;
259
260if (transactional == RDM::DB::TRANSACTIONAL)
261 {
262 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
263 }
264if (rc == sOKAY)
265 {
266 rc = next_1.flush_stats (threshold, RDM::DB::NOT_TRANSACTIONAL);
267if (rc == sOKAY)
268 {
269 rc = next_2.flush_stats (threshold, RDM::DB::NOT_TRANSACTIONAL);
270if (rc != sOKAY)
271 {
272next_1.unflush ();
273 }
274 }
275if (transactional == RDM::DB::TRANSACTIONAL)
276 {
277if (rc == sOKAY)
278 {
279 rc = rdm_transEnd (trans);
280 }
281else
282 {
284 }
285 }
286 }
287
288return rc;
289 }

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
192 {
193RDM_RETCODE rc = sOKAY;
194RDM_TRANS trans;
195
196if (transactional == RDM::DB::TRANSACTIONAL)
197 {
198 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
199 }
200if (rc == sOKAY)
201 {
202 rc = next_1.flush_value (threshold, RDM::DB::NOT_TRANSACTIONAL);
203if (rc == sOKAY)
204 {
205 rc = next_2.flush_value (threshold, RDM::DB::NOT_TRANSACTIONAL);
206if (rc != sOKAY)
207 {
208next_1.unflush ();
209 }
210 }
211if (transactional == RDM::DB::TRANSACTIONAL)
212 {
213if (rc == sOKAY)
214 {
215 rc = rdm_transEnd (trans);
216 }
217else
218 {
220 }
221 }
222 }
223
224return rc;
225 }

init()

template<class NEXT_1 , class NEXT_2 >
RDM_RETCODE RDM::TIME_SERIES::split< NEXT_1, NEXT_2 >::init ( RDM_DB 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
db [IN] Use this database for chained classes that need to insert rows
135 {
136RDM_RETCODE rc = next_1.init (db);
137
138if (rc == sOKAY)
139 {
140 rc = next_2.init (db);
141 }
142
143if (rc == sOKAY)
144 {
145 split::db = db;
146 }
147
148return rc;
149 }

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
559 {
560RDM_RETCODE rc = sOKAY;
561RDM_TRANS trans;
562
563if (transactional == RDM::DB::TRANSACTIONAL)
564 {
565 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
566 }
567
568if (rc == sOKAY)
569 {
570 rc = next_1.put_range (source_range, RDM::DB::NOT_TRANSACTIONAL);
571if (rc == sOKAY)
572 {
573 rc = next_2.put_range (source_range, RDM::DB::NOT_TRANSACTIONAL);
574if (rc != sOKAY)
575 {
576next_1.unput ();
577 }
578 }
579if (transactional == RDM::DB::TRANSACTIONAL)
580 {
581if (rc == sOKAY)
582 {
583 rc = rdm_transEnd (trans);
584 }
585else
586 {
588 }
589 }
590 }
591
592return rc;
593 }

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
478 {
479RDM_RETCODE rc = sOKAY;
480RDM_TRANS trans;
481
482if (transactional == RDM::DB::TRANSACTIONAL)
483 {
484 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
485 }
486
487if (rc == sOKAY)
488 {
489 rc = next_1.put_stats (source_stats, RDM::DB::NOT_TRANSACTIONAL);
490if (rc == sOKAY)
491 {
492 rc = next_2.put_stats (source_stats, RDM::DB::NOT_TRANSACTIONAL);
493if (rc != sOKAY)
494 {
495next_1.unput ();
496 }
497 }
498if (transactional == RDM::DB::TRANSACTIONAL)
499 {
500if (rc == sOKAY)
501 {
502 rc = rdm_transEnd (trans);
503 }
504else
505 {
507 }
508 }
509 }
510
511return rc;
512 }

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
397 {
398RDM_RETCODE rc = sOKAY;
399RDM_TRANS trans;
400
401if (transactional == RDM::DB::TRANSACTIONAL)
402 {
403 rc = rdm_dbStartUpdate (db, NULL, 0, NULL, 0, &trans);
404 }
405
406if (rc == sOKAY)
407 {
408 rc = next_1.put_value (source_value, RDM::DB::NOT_TRANSACTIONAL);
409if (rc == sOKAY)
410 {
411 rc = next_2.put_value (source_value, RDM::DB::NOT_TRANSACTIONAL);
412if (rc != sOKAY)
413 {
414next_1.unput ();
415 }
416 }
417if (transactional == RDM::DB::TRANSACTIONAL)
418 {
419if (rc == sOKAY)
420 {
421 rc = rdm_transEnd (trans);
422 }
423else
424 {
426 }
427 }
428 }
429
430return rc;
431 }

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.

158 {
159next_1.reset ();
160next_2.reset ();
161 }

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:97
struct RDM_TRANS_S * RDM_TRANS
Definition: rdmtypes.h:307
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
RDM_RETCODE
RDM status and error return codes.
Definition: rdmretcodetypes.h:43