#include <timeseries.h>
Public Member Functions | |
virtual void | process (T const &data) |
void | add (oid_t oid, T const &data) |
void | select (oid_t oid, time_t from, time_t till) |
time_t | getFirstTime (oid_t oid) |
time_t | getLastTime (oid_t oid) |
size_t | getNumberOfElements (oid_t oid) |
size_t | getInterval (oid_t oid, time_t from, time_t till, T *buf, size_t bufSize) |
bool | getElement (oid_t oid, T &elem, time_t t) |
size_t | getFirstInterval (oid_t oid, time_t till, T *buf, size_t bufSize) |
size_t | getLastInterval (oid_t oid, time_t from, T *buf, size_t bufSize) |
bool | hasElement (oid_t oid, time_t t) |
dbTimeSeriesProcessor (dbDatabase &database, int minElementsInBlock=100, int maxElementsInBlock=100, time_t maxBlockTimeInterval=0) | |
int | remove (oid_t oid, time_t from, time_t till) |
int | _openIteratorCursor (dbCursor< dbTimeSeriesBlock< T > > &cursor, oid_t oid, time_t from, time_t till) |
Time series processor.
Element of time series can be arbitrary type with declared TYPE_DESCRIPTOR and defined time_t time()
method
dbTimeSeriesProcessor< T >::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 |
int dbTimeSeriesProcessor< T >::_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.
Referenced by dbTimeSeriesReverseIterator< T >::start(), and dbTimeSeriesIterator< T >::start().
void dbTimeSeriesProcessor< T >::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 |
bool dbTimeSeriesProcessor< T >::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 References dbTimeSeriesProcessor< T >::getInterval().
Referenced by dbTimeSeriesProcessor< T >::hasElement().
size_t dbTimeSeriesProcessor< 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 |
References dbCursor< T >::get(), dbCursor< T >::next(), and dbAnyCursor::select().
time_t dbTimeSeriesProcessor< 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) |
References dbAnyCursor::select(), and dbAnyCursor::setSelectionLimit().
size_t dbTimeSeriesProcessor< 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 |
References dbCursor< T >::get(), dbCursor< T >::next(), and dbAnyCursor::select().
Referenced by dbTimeSeriesProcessor< T >::getElement().
size_t dbTimeSeriesProcessor< 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 |
References dbCursor< T >::get(), dbCursor< T >::last(), dbCursor< T >::prev(), and dbAnyCursor::select().
time_t dbTimeSeriesProcessor< 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) |
References dbAnyCursor::select(), and dbAnyCursor::setSelectionLimit().
size_t dbTimeSeriesProcessor< 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) |
References dbCursor< T >::next(), and dbAnyCursor::select().
bool dbTimeSeriesProcessor< T >::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 References dbTimeSeriesProcessor< T >::getElement().
virtual void dbTimeSeriesProcessor< T >::process | ( | T const & | data | ) | [inline, virtual] |
Virtual method for processing elements, Should be redefinedin derived class.
data | reference to the processed data element |
Referenced by dbTimeSeriesProcessor< T >::select().
int dbTimeSeriesProcessor< T >::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) |
References dbCursor< T >::get(), dbCursor< T >::next(), dbAnyCursor::remove(), dbAnyCursor::select(), and dbAnyCursor::update().
void dbTimeSeriesProcessor< T >::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) |
References dbCursor< T >::get(), dbCursor< T >::next(), dbTimeSeriesProcessor< T >::process(), and dbAnyCursor::select().