logic: Cache graph and stats of overview in StorageCache

This commit is contained in:
Eberhard Graether
2016-08-10 13:15:45 +02:00
parent d0cf500c8e
commit 2800c072ff
6 changed files with 30 additions and 25 deletions
+5 -4
View File
@@ -359,9 +359,12 @@ void PersistentStorage::logStats() const
ss << "\t" << stats.fileCount << " Files\n";
ss << "\t" << stats.fileLOCCount << " Lines of Code\n";
ErrorCountInfo errorCount = getErrorCount();
ss << "\nErrors:\n";
ss << "\t" << stats.errorCount.total << " Errors\n";
ss << "\t" << stats.errorCount.fatal << " Fatal Errors\n";
ss << "\t" << errorCount.total << " Errors\n";
ss << "\t" << errorCount.fatal << " Fatal Errors\n";
LOG_INFO(ss.str());
}
@@ -1108,8 +1111,6 @@ StorageStats PersistentStorage::getStorageStats() const
stats.fileCount = m_sqliteStorage.getFileCount();
stats.fileLOCCount = m_sqliteStorage.getFileLOCCount();
stats.errorCount = getErrorCount();
return stats;
}
+15 -10
View File
@@ -2,22 +2,27 @@
void StorageCache::clear()
{
m_queryToTokenIds.clear();
m_graphForAll.reset();
m_storageStats = StorageStats();
}
std::vector<Id> StorageCache::getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const
std::shared_ptr<Graph> StorageCache::getGraphForAll() const
{
std::string query = SearchMatch::searchMatchesToString(matches);
std::map<std::string, std::vector<Id>>::const_iterator it = m_queryToTokenIds.find(query);
if (it != m_queryToTokenIds.end())
if (!m_graphForAll)
{
return it->second;
m_graphForAll = StorageAccessProxy::getGraphForAll();
}
std::vector<Id> ids = StorageAccessProxy::getTokenIdsForMatches(matches);
return m_graphForAll;
}
m_queryToTokenIds.emplace(query, ids);
StorageStats StorageCache::getStorageStats() const
{
if (!m_storageStats.nodeCount)
{
m_storageStats = StorageAccessProxy::getStorageStats();
}
return ids;
return m_storageStats;
}
+5 -2
View File
@@ -11,10 +11,13 @@ class StorageCache
public:
void clear();
virtual std::vector<Id> getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const;
virtual std::shared_ptr<Graph> getGraphForAll() const;
virtual StorageStats getStorageStats() const;
private:
mutable std::map<std::string, std::vector<Id>> m_queryToTokenIds;
mutable std::shared_ptr<Graph> m_graphForAll;
mutable StorageStats m_storageStats;
};
#endif // STORAGE_CACHE_H
-5
View File
@@ -1,8 +1,6 @@
#ifndef STORAGE_STATS_H
#define STORAGE_STATS_H
#include "data/ErrorCountInfo.h"
struct StorageStats
{
StorageStats()
@@ -10,7 +8,6 @@ struct StorageStats
, edgeCount(0)
, fileCount(0)
, fileLOCCount(0)
, errorCount(ErrorCountInfo())
{}
size_t nodeCount;
@@ -18,8 +15,6 @@ struct StorageStats
size_t fileCount;
size_t fileLOCCount;
ErrorCountInfo errorCount;
};
#endif // STORAGE_STATS_H