Main Page | Class Hierarchy | Class List | File List | Class Members

dbTimeSeriesBlock< T > Class Template Reference

#include <timeseries.h>

List of all members.

Public Member Functions

 TYPE_DESCRIPTOR ((KEY(blockId, INDEXED), FIELD(used), FIELD(elements)))

Public Attributes

db_int8 blockId
db_int4 used
dbArray< T > elements


Detailed Description

template<class T>
class dbTimeSeriesBlock< T >

Time series block contaning array of elements. Grouping several elements in one block (record) reduce space overhead and increase processing speed.
Attention! This class is not serialized, so it is can be accessed only by one thread

You are defining your own time series class, for example:

class Stock { public: char const* name; TYPE_DESCRIPTOR((KEY(name, INDEXED))); };

class Quote { public: int4 tickerDate; real4 bid; int4 bidSize; real4 ask; int4 askSize;

time_t time() const { return tickerDate; } // this method should be defined

TYPE_DESCRIPTOR((FIELD(tickerDate), FIELD(bid), FIELD(bidSize), FIELD(ask), FIELD(askSize))); }; typedef dbTimeSeriesBlock<Daily> DailyBlock; REGISTER(DailyBlock);
Now you can work with time series objects in the followin way:
dbDatabase db; if (db.open("mydatabase.dbs")) { dbTimeSeriesProcessor<Quote> proc(db, MIN_ELEMENTS_IN_BLOCK,MAX_ELEMENTS_IN_BLOCK); Quote quote; // initialize quote Stock stock; stock.name = "AAD"; oid_t stockId = insert(oid).getOid(); proc.add(stockId, quote); // add new element in time series

Quote quoteBuf[MAX_QUOTES]; // select quotes for the specified interval int n = proc.getInterval(stockId, fromDate, tillDate, quoteBuf, MAX_QUOTES); for (int i = 0; i < n; i++) { printf("bid=d ask=%d\n", quoteBuf[i].bid, quoteBuf[i].ask); } }


The documentation for this class was generated from the following file:
Generated on Thu Feb 12 18:46:28 2004 for GigaBASE by doxygen 1.3.5