dbTimeSeriesProcessor Class Template Reference

#include <timeseries.h>

List of all members.


Detailed Description

template<class T>
class dbTimeSeriesProcessor< T >

Time series processor.


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

dbDatabasedb
int maxElementsInBlock
int minElementsInBlock
time_t maxBlockTimeInterval
dbQuery selectBlock
dbQuery selectBlockReverse

Classes

struct  Interval


Constructor & Destructor Documentation

dbTimeSeriesProcessor ( dbDatabase database,
int  minElementsInBlock = 100,
int  maxElementsInBlock = 100,
time_t  maxBlockTimeInterval = 0 
) [inline]

TimeSeries processor constructor.

Parameters:
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]


Member Function Documentation

virtual void process ( T const &   )  [inline, virtual]

Virtual method for processing elements, Should be redefinedin derived class.

Parameters:
data reference to the processed data element

void add ( oid_t  oid,
T const &  data 
) [inline]

Add new element.

Parameters:
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.

Parameters:
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.

Parameters:
oid time series identifer (OID of the object associated with this time series)
Returns:
earliest time in times series or -1 if there are no elements in time series

time_t getLastTime ( oid_t  oid  )  [inline]

Get the time of the last element in time series.

Parameters:
oid time series identifer (OID of the object associated with this time series)
Returns:
latest time in times series or -1 if there are no elements in time series

size_t getNumberOfElements ( oid_t  oid  )  [inline]

Get number of elements in time series.

Parameters:
oid time series identifer (OID of the object associated with this time series)
Returns:
number of elements in 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.

Parameters:
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
Returns:
number of elements belonging to the specified interval (can be greater than bufSize)

bool getElement ( oid_t  oid,
T &  elem,
time_t  t 
) [inline]

Get time series element with specified time.

Parameters:
oid time series identifer (OID of the object associated with this time series)
elem reference to the extracted element
t timestamp of extracted element
Returns:
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.

Parameters:
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
Returns:
number of selected elements (can be less than bufSize if there are less elements in time series with timestamp less or equal than specified, but can not be greater than bufSize)

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.

Parameters:
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
Returns:
number of selected elements (can be less than bufSize if there are less elements in time series with timestamp greater or equal than specified, but can not be greater than bufSize)

bool hasElement ( oid_t  oid,
time_t  t 
) [inline]

Check if there is element for specified data in time series.

Parameters:
oid time series identifer (OID of the object associated with this time series)
t timestamp of checked element
Returns:
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.

Parameters:
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)
Returns:
number of removed elements

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.

db_int8 generateBlockId ( oid_t  oid,
time_t  date 
) [inline, private]

void addNewBlock ( oid_t  oid,
T const &  data 
) [inline, private]

void insertInBlock ( oid_t  oid,
dbCursor< dbTimeSeriesBlock< T > > &  blocks,
T const &  data 
) [inline, private]


Member Data Documentation

dbDatabase& db [private]

int maxElementsInBlock [private]

int minElementsInBlock [private]

time_t maxBlockTimeInterval [private]

dbQuery selectBlock [private]


Online Library Docs

sipXecs home page

Version 4.2.1-018930 2010-07-31T01:13:23 build16 abuild