|
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 STATS_T, class NEXT>
class RDM::TIME_SERIES::stats< N, STATS_T, NEXT >
Template Class for doing statistics.
Template class for doing statistics of data values or aggregating statistics. It is an error for this class to receive ranges. The sum of the data values (sum), the sum of the squared data values (sum2), and the total number of data values (n) will be computed or aggregated. The result of this will be forwarded to the next class in the chain.
We collect these values for easy calculation of the mean value and the standard deviation. These can be calculated as follows (we included the Bessel's correction here):
- Mean value: sum / n
- Standard deviation: sqrt ((sum2 - sum * sum / n) / (n - 1))
Upon destruction of this class, there might be incomplete aggregations that have not yet been passed to the next class in the chain. flush() can be called to force those incomplete aggregations to be sent to the next class. This approach may not always be desirable. Another approach is to restore the state of this class the next time this class is instantiated. See restore_aggregate for details.
- Template Parameters
-
N |
The number of receved elements to average. |
STATS_T |
The aggregate statistics class for which objects will be passed to the next class. |
NEXT |
The class in the chain to receive statistics. |
- Examples
- cpp70Example_main.cpp, time_series_custom.cpp, time_series_restore_aggregate.cpp, and time_series_stats.cpp.
template<uint32_t N, class STATS_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 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 |
351if (n >= threshold && n > 0)
362 rc = next.put_stats (&aggregate_stats, transactional);
365 n_just_before_last_flush = n;
366 rc = next.flush_stats (threshold, transactional);
393 n_just_before_last_flush = 0;
395 rc = next.flush_stats (threshold, transactional);
References rdm_dbStartUpdate(), rdm_transEnd(), rdm_transEndRollback(), sOKAY, and RDM::DB::TRANSACTIONAL.
template<uint32_t N, class STATS_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 |
269if (n >= threshold && n > 0)
284 n_just_before_last_flush = n;
312 n_just_before_last_flush = 0;
314 rc = next.flush_stats (threshold, transactional);
References RDM::DB::NOT_TRANSACTIONAL, rdm_dbStartUpdate(), rdm_transEnd(), rdm_transEndRollback(), sOKAY, and RDM::DB::TRANSACTIONAL.
template<uint32_t N, class STATS_T , class NEXT >
template<class SOURCE_STATS_T >
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 |
538 prev_aggregate_stats = aggregate_stats;
542 aggregate_stats.time_stamp_first =
543 source_stats->time_stamp_first;
544 aggregate_stats.n = source_stats->n;
545 aggregate_stats.value_sum = source_stats->value_sum;
546 aggregate_stats.value_sum2 = source_stats->value_sum2;
550 aggregate_stats.n += source_stats->n;
551 aggregate_stats.value_sum = aggregate_stats.value_sum + source_stats->value_sum;
552 aggregate_stats.value_sum2 = aggregate_stats.value_sum2 + source_stats->value_sum2;
554 aggregate_stats.time_stamp_last =
555 source_stats->time_stamp_last;
559 rc = next.put_stats (&aggregate_stats, transactional);
562 n_just_before_last_put = n;
567 aggregate_stats = prev_aggregate_stats;
References sOKAY.
template<uint32_t N, class STATS_T , class NEXT >
template<class SOURCE_VALUE_T >
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 |
446 prev_aggregate_stats = aggregate_stats;
450 aggregate_stats.time_stamp_first =
451 source_value->time_stamp_current;
452 aggregate_stats.n = 1;
453 aggregate_stats.value_sum = source_value->value_current;
454 aggregate_stats.value_sum2 = source_value->value_current *
455 source_value->value_current;
460 aggregate_stats.value_sum = aggregate_stats.value_sum + source_value->value_current;
461 aggregate_stats.value_sum2 = aggregate_stats.value_sum2 + source_value->value_current *
462 source_value->value_current;
465 aggregate_stats.time_stamp_last =
466 source_value->time_stamp_current;
470 rc = next.put_stats (&aggregate_stats, transactional);
473 n_just_before_last_put = n;
478 aggregate_stats = prev_aggregate_stats;
References sOKAY.