24.09., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit 59262a4f authored by Alessio Netti's avatar Alessio Netti

Analytics: using absolute query mode for some operator plugins

parent ccfea02a
......@@ -177,10 +177,12 @@ void ClusteringOperator::compute(U_Ptr unit) {
void ClusteringOperator::computeFeatureVector(U_Ptr unit, uint64_t offset) {
_currentfVector = cv::Mat(1, unit->getInputs().size(), CV_32F);
std::vector<ClusteringSBPtr>& inputs = unit->getInputs();
uint64_t endTs = getTimestamp() - offset;
uint64_t startTs = endTs - _aggregationWindow;
for(size_t idx=0; idx<inputs.size(); idx++) {
_mean=0;
_buffer.clear();
if(!_queryEngine.querySensor(inputs[idx]->getName(), _aggregationWindow - offset, offset, _buffer) || _buffer.empty())
if(!_queryEngine.querySensor(inputs[idx]->getName(), startTs, endTs, _buffer, false) || _buffer.empty())
throw std::runtime_error("Operator " + _name + ": cannot read from sensor " + inputs[idx]->getName() + "!");
// Computing MEAN
......
......@@ -187,11 +187,13 @@ void RegressorOperator::computeFeatureVector(U_Ptr unit) {
_currentfVector = new cv::Mat(1, unit->getInputs().size()*REG_NUMFEATURES, CV_32F);
int64_t val;
size_t qId, qMod, idx, fIdx;
uint64_t endTs = getTimestamp();
uint64_t startTs = endTs - _aggregationWindow;
std::vector<RegressorSBPtr>& inputs = unit->getInputs();
for(idx=0; idx<inputs.size(); idx++) {
_mean=0; _std=0; _diffsum=0; _qtl25=0; _qtl75=0;
_buffer.clear();
if(!_queryEngine.querySensor(inputs[idx]->getName(), _aggregationWindow, 0, _buffer) || _buffer.empty())
if(!_queryEngine.querySensor(inputs[idx]->getName(), startTs, endTs, _buffer, false) || _buffer.empty())
throw std::runtime_error("Operator " + _name + ": cannot read from sensor " + inputs[idx]->getName() + "!");
if (inputs[idx]->getTrainingTarget())
_currentTarget = (float)_buffer.back().value;
......
......@@ -47,10 +47,11 @@ void SmoothingOperator::compute(U_Ptr unit) {
// Clearing the buffer
_buffer.clear();
SmoothingSBPtr sIn=unit->getInputs()[0], sOut=unit->getOutputs()[0];
uint64_t startTs = sOut->getTimestamp() ? getTimestamp()-sOut->getTimestamp() : 0;
uint64_t endTs = getTimestamp();
uint64_t startTs = sOut->getTimestamp() ? sOut->getTimestamp() : endTs;
// Throwing an error does not make sense here - the query will often fail depending on insert batching
if(!_queryEngine.querySensor(sIn->getName(), startTs, 0, _buffer, true))
if(!_queryEngine.querySensor(sIn->getName(), startTs, endTs, _buffer, false))
return;
for(const auto& v : _buffer) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment