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
@@ -37,6 +37,7 @@ void CodeController::handleMessage(MessageActivateAll* message)
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
StorageStats stats = m_storageAccess->getStorageStats();
ErrorCountInfo errorCount = m_storageAccess->getErrorCount();
CodeSnippetParams statsSnippet;
statsSnippet.startLineNumber = 1;
@@ -69,10 +70,10 @@ void CodeController::handleMessage(MessageActivateAll* message)
ss << "\t" + std::to_string(stats.nodeCount) + " symbols\n";
ss << "\t" + std::to_string(stats.edgeCount) + " relations\n";
ss << "\n";
ss << "\t" + std::to_string(stats.errorCount.total) + " errors (" + std::to_string(stats.errorCount.fatal) + " fatal)\n";
ss << "\t" + std::to_string(errorCount.total) + " errors (" + std::to_string(errorCount.fatal) + " fatal)\n";
ss << "\n";
if (stats.errorCount.total > 0)
if (errorCount.total > 0)
{
ss << "\tWarning: Indexing may be incomplete as long as it yields fatal errors.\n";
ss << "\tTry resolving them and refresh the project.\n";
@@ -1,11 +1,11 @@
#include <src/lib/utility/file/FileSystem.h>
#include <src/lib/settings/ApplicationSettings.h>
#include "IDECommunicationController.h"
#include "data/access/StorageAccess.h"
#include "data/location/TokenLocationFile.h"
#include "data/location/TokenLocation.h"
#include "settings/ApplicationSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/messaging/type/MessageActivateTokenLocations.h"
#include "utility/messaging/type/MessageActivateWindow.h"
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
+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