bool operator () (TimeSeriesValue const& value) const { if (query.lowerbound <= value.get_timestamp() && query.upperbound >= value.get_timestamp()) { if (query.param_pred(value.get_paramid()) == SearchQuery::MATCH) { return true; } } return false; }
std::tuple<int, int> Sequencer::add(TimeSeriesValue const& value) { // FIXME: max_cache_size_ is not used int status = 0; int lock = 0; tie(status, lock) = check_timestamp_(value.get_timestamp()); if (status != AKU_SUCCESS) { return make_tuple(status, lock); } key_->pop_back(); key_->push_back(value); Lock guard(runs_resize_lock_); space_estimate_ += SPACE_PER_ELEMENT; auto begin = runs_.begin(); auto end = runs_.end(); auto insert_it = lower_bound(begin, end, key_, top_element_more<PSortedRun>); int run_ix = distance(begin, insert_it); bool new_run_needed = insert_it == runs_.end(); SortedRun* run = nullptr; if (!new_run_needed) { run = insert_it->get(); } guard.unlock(); if (!new_run_needed) { auto ix = run_ix & RUN_LOCK_FLAGS_MASK; auto& rwlock = run_locks_.at(ix); rwlock.wrlock(); run->push_back(value); rwlock.unlock(); } else { guard.lock(); PSortedRun new_pile(new SortedRun()); new_pile->push_back(value); runs_.push_back(move(new_pile)); guard.unlock(); } return make_tuple(AKU_SUCCESS, lock); }