Template Class for doing an arithmetic mean. More...
#include "rdm_time_series_mean.h"
|
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
|
|
template<uint32_t N, class AGGREGATE_T, class AGG_ELEMENT_T, class NEXT>
class RDM::TIME_SERIES::mean< N, AGGREGATE_T, AGG_ELEMENT_T, NEXT >
Template Class for doing an arithmetic mean.
Template class for taking the arithmetic means of data values or ranges. What is received will be collected and used for taking arithmetic means. The result of those arithmetic means will be forwarded to the next class in the chain.
This class is incomplete as it does not have the code for doing the actual FFT computation. Use one of the following derived classes:
- Template Parameters
-
N |
The number of receved RANGE calculations for each arithmetic mean. |
AGGREGATE_T |
The aggregate range or stats class for which objects will be passed to the next class. |
AGG_ELEMENT_T |
The type for the elements that must be aggregated to compute the mean. |
NEXT |
The class in the chain to receive arithmetic means. |
flush_range()
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
Flush this object.
Call this method to flush what has 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 |
356if (n >= threshold && n > 0)
358 AGGREGATE_T scaled_aggregate = aggregate;
360for (uint32_t i = 0; i <
RDM_LEN(aggregate.value_range); i++)
362 agg_scale (n, scaled_aggregate.value_range[i]);
377 n_just_before_last_flush = n;
405 n_just_before_last_flush = 0;
407 rc = next.flush_range (threshold, transactional);
References RDM::DB::NOT_TRANSACTIONAL, rdm_dbStartUpdate(), RDM_LEN, rdm_transEnd(), rdm_transEndRollback(), sOKAY, and RDM::DB::TRANSACTIONAL.
flush_value()
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
Flush this object.
Call this method to flush what has 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 |
271if (n >= threshold && n > 0)
273 AGGREGATE_T scaled_aggregate = aggregate;
275 agg_scale (n, scaled_aggregate.value_range[0]);
289 n_just_before_last_flush = n;
317 n_just_before_last_flush = 0;
319 rc = next.flush_range (threshold, transactional);
References RDM::DB::NOT_TRANSACTIONAL, rdm_dbStartUpdate(), rdm_transEnd(), rdm_transEndRollback(), sOKAY, and RDM::DB::TRANSACTIONAL.
get_serialize_size()
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
constexpr static int RDM::TIME_SERIES::mean< N, AGGREGATE_T, AGG_ELEMENT_T, NEXT >::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.
163return sizeof(prev_aggregate) +
sizeof(aggregate) +
sizeof(n) +
sizeof(n_just_before_last_put) +
sizeof(n_just_before_last_flush) + NEXT::get_serialize_size ();
init()
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
Initialize this object.
Call this method before sending it any 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 |
put_range()
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<class SOURCE_AGGREGATE_T >
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
);
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_AGGREGATE_T |
The actual type of the range 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_range |
The source range sent to this class |
|
transactional |
[IN] Is the put required to be transactional |
546 prev_aggregate = aggregate;
550 aggregate.time_stamp_first =
551 source_range->time_stamp_first;
552for (uint32_t i = 0; i <
RDM_LEN(aggregate.value_range); i++)
554 agg_set (source_range->value_range[i], aggregate.value_range[i]);
559for (uint32_t i = 0; i <
RDM_LEN(aggregate.value_range); i++)
561 agg_add (source_range->value_range[i], aggregate.value_range[i]);
564 aggregate.time_stamp_last =
565 source_range->time_stamp_last;
569 AGGREGATE_T scaled_aggregate = aggregate;
571for (uint32_t i = 0; i <
RDM_LEN(aggregate.value_range); i++)
573 agg_scale (N, scaled_aggregate.value_range[i]);
576 rc = next.put_range (&scaled_aggregate, transactional);
579 n_just_before_last_put = n;
584 aggregate = prev_aggregate;
References RDM_LEN, and sOKAY.
put_value()
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<class SOURCE_VALUE_T >
Template method for receiving a data values.
Receive one data value and return an error.
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 |
458 prev_aggregate = aggregate;
462 aggregate.time_stamp_first =
463 source_value->time_stamp_current;
464 agg_set (source_value->value_current, aggregate.value_range[0]);
468 agg_add (source_value->value_current, aggregate.value_range[0]);
470 aggregate.time_stamp_last =
471 source_value->time_stamp_current;
475 AGGREGATE_T scaled_aggregate = aggregate;
477 agg_scale (N, scaled_aggregate.value_range[0]);
479 rc = next.put_range (&scaled_aggregate, transactional);
482 n_just_before_last_put = n;
487 aggregate = prev_aggregate;
References sOKAY.
reset()
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
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.
serialize()
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
174 memcpy (buffer, &prev_aggregate,
sizeof (prev_aggregate));
175 buffer +=
sizeof (prev_aggregate);
176 memcpy (buffer, &aggregate,
sizeof (aggregate));
177 buffer +=
sizeof (aggregate);
178 memcpy (buffer, &n,
sizeof (n));
179 buffer +=
sizeof (n);
180 memcpy (buffer, &n_just_before_last_put,
sizeof (n_just_before_last_put));
181 buffer +=
sizeof (n_just_before_last_put);
182 memcpy (buffer, &n_just_before_last_flush,
sizeof (n_just_before_last_flush));
183 buffer +=
sizeof (n_just_before_last_flush);
184return next.serialize (buffer);
unserialize()
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
195 memcpy (&prev_aggregate, buffer,
sizeof (prev_aggregate));
196 buffer +=
sizeof (prev_aggregate);
197 memcpy (&aggregate, buffer,
sizeof (aggregate));
198 buffer +=
sizeof (aggregate);
199 memcpy (&n, buffer,
sizeof (n));
200 buffer +=
sizeof (n);
201 memcpy (&n_just_before_last_put, buffer,
sizeof (n_just_before_last_put));
202 buffer +=
sizeof (n_just_before_last_put);
203 memcpy (&n_just_before_last_flush, buffer,
sizeof (n_just_before_last_flush));
204 buffer +=
sizeof (n_just_before_last_flush);
205return next.unserialize (buffer);
collect
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_NEXT >
custom
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<class ANY_NEXT >
downsample
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<uint32_t ANY_N, class ANY_NEXT >
fft
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_INDATA_T , class ANY_NEXT >
mean
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<uint32_t ANY_N, class ANY_AGGREGATE_T , class ANY_AGG_ELEMENT_T , class ANY_NEXT >
RDM::DB::transaction
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<class ANY_NEXT >
scale
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<class ANY_RATIO , class ANY_NEXT >
split
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<class ANY_NEXT_1 , class ANY_NEXT_2 >
stats
template<uint32_t N, class AGGREGATE_T , class AGG_ELEMENT_T , class NEXT >
template<uint32_t ANY_N, class ANY_STATS_T , class ANY_NEXT >
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:349
enum RDM_RETCODE_E RDM_RETCODE
RaimaDB status and error return codes.
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.
#define RDM_LEN(x)
Definition: psptypes.h:106
@ TRANSACTIONAL
Definition: rdm_db_transaction.h:35