From 64d757eeae79ca3dcc14c9f611bca7ae0cb974e5 2017-06-30 08:45:34 From: mperrinel Date: 2017-06-30 08:45:34 Subject: [PATCH] Add method to display cache. Fix bug in a cache detection when interval was include in a part of the cache intervals --- diff --git a/core/include/Variable/VariableCacheController.h b/core/include/Variable/VariableCacheController.h index 2fd48b2..dd7b988 100644 --- a/core/include/Variable/VariableCacheController.h +++ b/core/include/Variable/VariableCacheController.h @@ -5,10 +5,15 @@ #include +#include + #include class Variable; +Q_DECLARE_LOGGING_CATEGORY(LOG_VariableCacheController) + + /// This class aims to store in the cache all of the dateTime already requested to the variable. class VariableCacheController : public QObject { Q_OBJECT @@ -25,6 +30,8 @@ public: QVector dateCacheList(std::shared_ptr variable) const noexcept; + void displayCache(std::shared_ptr variable); + private: class VariableCacheControllerPrivate; spimpl::unique_impl_ptr impl; diff --git a/core/src/Variable/VariableCacheController.cpp b/core/src/Variable/VariableCacheController.cpp index 34cb514..f151b4d 100644 --- a/core/src/Variable/VariableCacheController.cpp +++ b/core/src/Variable/VariableCacheController.cpp @@ -3,6 +3,8 @@ #include "Variable/Variable.h" #include +Q_LOGGING_CATEGORY(LOG_VariableCacheController, "VariableCacheController") + struct VariableCacheController::VariableCacheControllerPrivate { std::unordered_map, QVector > @@ -156,15 +158,26 @@ void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataBySt // ts localised between to interval: let's localized te addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndex, currentTStart); } - else if (dateTime.m_TStart < currentDateTimeI.m_TEnd) { - // ts not localised before the current interval: we need to look at the next interval - // We can assume now current tstart is the last interval tend, because data between them are - // in the cache - addInCacheDataByStart(dateTime, dateTimeList, notInCache, ++cacheIndex, - currentDateTimeI.m_TEnd); + else if (currentTStart < currentDateTimeI.m_TEnd) { + if (dateTime.m_TEnd > currentDateTimeI.m_TEnd) { + // ts not localised before the current interval: we need to look at the next interval + // We can assume now current tstart is the last interval tend, because data between them + // are + // in the cache + addInCacheDataByStart(dateTime, dateTimeList, notInCache, ++cacheIndex, + currentDateTimeI.m_TEnd); + } } else { // ts not localised before the current interval: we need to look at the next interval addInCacheDataByStart(dateTime, dateTimeList, notInCache, ++cacheIndex, currentTStart); } } + + +void VariableCacheController::displayCache(std::shared_ptr variable) +{ + auto variableDateTimeList = impl->m_VariableToSqpDateTimeListMap.at(variable); + qCInfo(LOG_VariableCacheController()) << tr("VariableCacheController::displayCache") + << variableDateTimeList; +}