#include <timeseries.h>
Element of time series can be arbitrary type with declared TYPE_DESCRIPTOR and defined time_t time() method
Public Member Functions | |
| virtual void | process (T const &) |
| Virtual method for processing elements, Should be redefinedin derived class. | |
| void | add (oid_t oid, T const &data) |
| Add new element. | |
| void | select (oid_t oid, time_t from, time_t till) |
| Process elements in the block belonging to the specified range. | |
| time_t | getFirstTime (oid_t oid) |
| Get the time of the first element in time series. | |
| time_t | getLastTime (oid_t oid) |
| Get the time of the last element in time series. | |
| size_t | getNumberOfElements (oid_t oid) |
| Get number of elements in time series. | |
| size_t | getInterval (oid_t oid, time_t from, time_t till, T *buf, size_t bufSize) |
| Select elements belonging to the specified interval. | |
| bool | getElement (oid_t oid, T &elem, time_t t) |
| Get time series element with specified time. | |
| size_t | getFirstInterval (oid_t oid, time_t till, T *buf, size_t bufSize) |
| Select first N elements of times series with timestamp less than or equal to specified. | |
| size_t | getLastInterval (oid_t oid, time_t from, T *buf, size_t bufSize) |
| Select last N elements of times series with timestamp greater than or equal to specified. | |
| bool | hasElement (oid_t oid, time_t t) |
| Check if there is element for specified data in time series. | |
| dbTimeSeriesProcessor (dbDatabase &database, int minElementsInBlock=100, int maxElementsInBlock=100, time_t maxBlockTimeInterval=0) | |
| TimeSeries processor constructor. | |
| int | remove (oid_t oid, time_t from, time_t till) |
| Remove elements for the sepcified period. | |
| virtual | ~dbTimeSeriesProcessor () |
| int | _openIteratorCursor (dbCursor< dbTimeSeriesBlock< T > > &cursor, oid_t oid, time_t from, time_t till) |
| This method should be actually private but since there is no portable way of declaration of friend templates classes recognized by all C++ compiler, it is made public. | |
Private Member Functions | |
| db_int8 | generateBlockId (oid_t oid, time_t date) |
| void | addNewBlock (oid_t oid, T const &data) |
| void | insertInBlock (oid_t oid, dbCursor< dbTimeSeriesBlock< T > > &blocks, T const &data) |
Private Attributes | |
| dbDatabase & | db |
| int | maxElementsInBlock |
| int | minElementsInBlock |
| time_t | maxBlockTimeInterval |
| dbQuery | selectBlock |
| dbQuery | selectBlockReverse |
Classes | |
| struct | Interval |
| dbTimeSeriesProcessor | ( | dbDatabase & | database, | |
| int | minElementsInBlock = 100, |
|||
| int | maxElementsInBlock = 100, |
|||
| time_t | maxBlockTimeInterval = 0 | |||
| ) | [inline] |
TimeSeries processor constructor.
| database | reference to the database | |
| minElementsInBlock | preallocated number of the elements in the block: array with specified number of elements will be allocated for new block | |
| maxElementsInBlock | maximal number of the elements in the block: block will be splitten if it has maxElementsInBlock elements and new is added to the block | |
| maxBlockTimeInterval | maximal interval between first and last element in the block, new block will be created if adding new element to the block cause violation of this assumption. If maxBlockTimeInterval is 0, then it is assigned to doubled number of seconds in day multipied on maxElementsInBlock |
| virtual ~dbTimeSeriesProcessor | ( | ) | [inline] |
| virtual void process | ( | T const & | ) | [inline, virtual] |
Virtual method for processing elements, Should be redefinedin derived class.
| data | reference to the processed data element |
| void add | ( | oid_t | oid, | |
| T const & | data | |||
| ) | [inline] |
Add new element.
| oid | time series identifer (OID of the object associated with this time series) | |
| data | reference to the inserted element |
| void select | ( | oid_t | oid, | |
| time_t | from, | |||
| time_t | till | |||
| ) | [inline] |
Process elements in the block belonging to the specified range.
| oid | time series identifer (OID of the object associated with this time series) | |
| from | inclusive low bound for element timestamp (set 0 to disable this criteria) | |
| till | inclusive high bound for element timestamp (set INFINITE_TIME to disable this criteria) |
| time_t getFirstTime | ( | oid_t | oid | ) | [inline] |
Get the time of the first element in time series.
| oid | time series identifer (OID of the object associated with this time series) |
| time_t getLastTime | ( | oid_t | oid | ) | [inline] |
Get the time of the last element in time series.
| oid | time series identifer (OID of the object associated with this time series) |
| size_t getNumberOfElements | ( | oid_t | oid | ) | [inline] |
Get number of elements in time series.
| oid | time series identifer (OID of the object associated with this time series) |
| size_t getInterval | ( | oid_t | oid, | |
| time_t | from, | |||
| time_t | till, | |||
| T * | buf, | |||
| size_t | bufSize | |||
| ) | [inline] |
Select elements belonging to the specified interval.
| oid | time series identifer (OID of the object associated with this time series) | |
| from | inclusive low bound for element timestamp (set 0 to disable this criteria) | |
| till | inclusive high bound for element timestamp (set INFINITE_TIME to disable this criteria) | |
| buf | destination buffer for selected elements | |
| bufSize | size of buffer: up to bufSize elements will be placed in buffer |
| bool getElement | ( | oid_t | oid, | |
| T & | elem, | |||
| time_t | t | |||
| ) | [inline] |
Get time series element with specified time.
| oid | time series identifer (OID of the object associated with this time series) | |
| elem | reference to the extracted element | |
| t | timestamp of extracted element |
true if element with specifed times exists in time series | size_t getFirstInterval | ( | oid_t | oid, | |
| time_t | till, | |||
| T * | buf, | |||
| size_t | bufSize | |||
| ) | [inline] |
Select first N elements of times series with timestamp less than or equal to specified.
| oid | time series identifer (OID of the object associated with this time series) | |
| till | inclusive high bound for element timestamp (set INFINITE_TIME to disable this criteria) | |
| buf | destination buffer for selected elements | |
| bufSize | size of buffer: up to bufSize elements will be placed in buffer |
| size_t getLastInterval | ( | oid_t | oid, | |
| time_t | from, | |||
| T * | buf, | |||
| size_t | bufSize | |||
| ) | [inline] |
Select last N elements of times series with timestamp greater than or equal to specified.
| oid | time series identifer (OID of the object associated with this time series) | |
| from | inclusive low bound for element timestamp (set 0 to disable this criteria) | |
| buf | destination buffer for selected elements | |
| bufSize | size of buffer: up to bufSize elements will be placed in buffer |
| bool hasElement | ( | oid_t | oid, | |
| time_t | t | |||
| ) | [inline] |
Check if there is element for specified data in time series.
| oid | time series identifer (OID of the object associated with this time series) | |
| t | timestamp of checked element |
true if element with specifed times exists in time series | int remove | ( | oid_t | oid, | |
| time_t | from, | |||
| time_t | till | |||
| ) | [inline] |
Remove elements for the sepcified period.
| oid | time series identifer (OID of the object associated with this time series) | |
| from | inclusive low bound for element timestamp (set 0 to disable this criteria) | |
| till | inclusive high bound for element timestamp (set INFINITE_TIME to disable this criteria) |
| int _openIteratorCursor | ( | dbCursor< dbTimeSeriesBlock< T > > & | cursor, | |
| oid_t | oid, | |||
| time_t | from, | |||
| time_t | till | |||
| ) | [inline] |
This method should be actually private but since there is no portable way of declaration of friend templates classes recognized by all C++ compiler, it is made public.
Do not use this method yourself.
| void addNewBlock | ( | oid_t | oid, | |
| T const & | data | |||
| ) | [inline, private] |
| void insertInBlock | ( | oid_t | oid, | |
| dbCursor< dbTimeSeriesBlock< T > > & | blocks, | |||
| T const & | data | |||
| ) | [inline, private] |
dbDatabase& db [private] |
int maxElementsInBlock [private] |
int minElementsInBlock [private] |
time_t maxBlockTimeInterval [private] |
dbQuery selectBlock [private] |
dbQuery selectBlockReverse [private] |