LogReader Class
(LogManager::LogReader)The LogReader interface is used to read data from a datastore. More...
Header: | #include <LogManager/LogReader.h> |
Public Functions
virtual | ~LogReader() |
virtual void | Close() = 0 |
virtual int64_t | CountEvents(const EventQuery &query = {}) |
virtual NodeInfoList | GetNodeInfo() = 0 |
virtual std::string | GetVersion() const = 0 |
virtual void | Interrupt() = 0 |
virtual KeyframeList | Read(IDList const &nodeIDList, unsigned int resolution, double xAxisBegin, double xAxisEnd, unsigned int limit = 0) = 0 |
virtual KeyframeList | Read(NameList const &nodeNames, unsigned int resolution, double xAxisBegin, double xAxisEnd, unsigned int limit = 0) = 0 |
virtual EventSenderTags | ReadEventSenderTags() |
virtual std::vector<Event> | ReadEvents(const EventQuery &query) |
virtual std::pair<double, double> | ReadXAxisSpan() = 0 |
Detailed Description
The LogReader interface is used to read data from a datastore.
Functions throw std::exception to indicate failure.
Member Function Documentation
[virtual]
LogReader::~LogReader()
Destroys the instance of LogReader. The destructor is virtual.
[pure virtual]
void LogReader::Close()
Closes the connection. Happens automatically during destruction.
[virtual]
int64_t LogReader::CountEvents(const EventQuery &query = {})
Counts the number of rows that would be returned by ReadEvents with the given EventQuery. Note, the limit argument is not applied to the count (same as in SQL queries).
[pure virtual]
NodeInfoList LogReader::GetNodeInfo()
Returns a list of node names and IDs.
Element's ID will be equal to the element's position in the list (list[i].id == i
). This can be used to convert IDs into names (std::string name = list[id].name
).
[pure virtual]
std::string LogReader::GetVersion() const
Returns the datastore version.
[pure virtual]
void LogReader::Interrupt()
This function causes any pending database operation to abort and return at its earliest opportunity.
It is safe to call this routine from a thread different from the thread that is currently running the database operation.
[pure virtual]
KeyframeList LogReader::Read(IDList const &nodeIDList, unsigned int resolution, double xAxisBegin, double xAxisEnd, unsigned int limit = 0)
Reads data from given range.
Parameters:
- nodeIDList - nodes to include in the result. Use node IDs returned by GetNodeInfo().
- resolution - requested amount of rows in the result. The min and max value of each sample is preserved. When 0, full resolution data is returned for the given range. Implementation is allowed to return a higher than requested resolution.
- xAxisBegin and xAxisEnd - the beginning and the end of the range to read. Full log range can be queried using ReadXAxisSpan method.
- limit - returns the first 'n' rows of the query result. Useful for querying high resolution data in small chunks. Use 0 for no limit.
Returns a table of data in row-major order. Each sample contains the min, max and last value of the range (calculated based on the resolution parameter). The timestamp in the sample marks the end of the range.
[pure virtual]
KeyframeList LogReader::Read(NameList const &nodeNames, unsigned int resolution, double xAxisBegin, double xAxisEnd, unsigned int limit = 0)
Reads data from given range.
Parameters:
- nodeNames - nodes to include in the result. Use node names returned by GetNodeInfo().
- resolution - requested amount of rows in the result. The min and max value of each sample is preserved. When 0, full resolution data is returned for the given range. Implementation is allowed to return a higher than requested resolution.
- xAxisBegin and xAxisEnd - the beginning and the end of the range to read. Full log range can be queried using ReadXAxisSpan method.
- limit - returns the first 'n' rows of the query result. Useful for querying high resolution data in small chunks. Use 0 for no limit.
Returns a table of data in row-major order. Each sample contains the min, max and last value of the range (calculated based on the resolution parameter). The timestamp in the sample marks the end of the range.
[virtual]
EventSenderTags LogReader::ReadEventSenderTags()
Returns a map where key is the event sender and the value is tags map.
[virtual]
std::vector<Event> LogReader::ReadEvents(const EventQuery &query)
Returns a list of logged events matching the given EventQuery.
[pure virtual]
std::pair<double, double> LogReader::ReadXAxisSpan()
Returns a pair of min and max value of xAxis (they are Unix timestamps describing log range) for logged values. The xAxis can be passed as a parameter to the Read method.
Note, if the event log range is needed, use something like:
std::pair<double, double> ReadEventLogSpan(LogReader* logReader) { auto first = logReader->ReadEvents(EventQuery().SetLimit(1)); auto last = logReader->ReadEvents(EventQuery().SetLimit(1).AddFlag(EventQuery::NewestFirst)); if (first.empty() || last.empty()) return {0, 0}; return {first.front().timestampSec, last.back().timestampSec}; // Or use logstampSec }
For events, the event timestampSec (time event generated) and logstampSec (time event logged) match the xAxis in the value log.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.