data: Fixes in indexing
* Show status update for every indexed translation unit and only once * Save nodes in same order they were indexed
This commit is contained in:
@@ -33,7 +33,7 @@ void InterprocessIndexer::work()
|
||||
LOG_INFO_STREAM(<< m_processId << " Indexing " << indexerCommand->getSourceFilePath().str());
|
||||
LOG_INFO_STREAM(<< m_processId << " Commands left: " << (m_interprocessIndexerCommandManager.indexerCommandCount() + 1));
|
||||
|
||||
m_interprocessIndexingStatusManager.setCurrentlyIndexedSourceFilePath(indexerCommand->getSourceFilePath());
|
||||
m_interprocessIndexingStatusManager.startIndexingSourceFile(indexerCommand->getSourceFilePath());
|
||||
|
||||
FileRegisterStateData data;
|
||||
data.setIndexedFiles(m_interprocessIndexingStatusManager.getIndexedFiles());
|
||||
@@ -48,7 +48,7 @@ void InterprocessIndexer::work()
|
||||
|
||||
m_interprocessIntermediateStorageManager.pushIntermediateStorage(result);
|
||||
|
||||
m_interprocessIndexingStatusManager.clearCurrentlyIndexedSourceFilePath();
|
||||
m_interprocessIndexingStatusManager.finishIndexingSourceFile();
|
||||
}
|
||||
}
|
||||
catch (boost::interprocess::interprocess_exception& e)
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
|
||||
const char* InterprocessIndexingStatusManager::s_sharedMemoryNamePrefix = "ists_";
|
||||
|
||||
const char* InterprocessIndexingStatusManager::s_lastFileKeyName = "last_file";
|
||||
const char* InterprocessIndexingStatusManager::s_indexingFilesKeyName = "indexing_files";
|
||||
const char* InterprocessIndexingStatusManager::s_currentFilesKeyName = "current_files";
|
||||
const char* InterprocessIndexingStatusManager::s_crashedFilesKeyName = "crashed_files";
|
||||
const char* InterprocessIndexingStatusManager::s_indexedFilesKeyName = "indexed_files";
|
||||
const char* InterprocessIndexingStatusManager::s_finishedProcessIdsKeyName = "finished_process_ids";
|
||||
|
||||
InterprocessIndexingStatusManager::InterprocessIndexingStatusManager(const std::string& instanceUuid, Id processId, bool isOwner)
|
||||
: BaseInterprocessDataManager(s_sharedMemoryNamePrefix + instanceUuid, 1048576 /* 1 MB */, instanceUuid, processId, isOwner)
|
||||
@@ -18,14 +19,17 @@ InterprocessIndexingStatusManager::~InterprocessIndexingStatusManager()
|
||||
{
|
||||
}
|
||||
|
||||
void InterprocessIndexingStatusManager::setCurrentlyIndexedSourceFilePath(const FilePath& filePath)
|
||||
void InterprocessIndexingStatusManager::startIndexingSourceFile(const FilePath& filePath)
|
||||
{
|
||||
SharedMemory::ScopedAccess access(&m_sharedMemory);
|
||||
|
||||
SharedMemory::String* strPtr = access.accessValueWithAllocator<SharedMemory::String>(s_lastFileKeyName);
|
||||
if (strPtr)
|
||||
SharedMemory::Queue<SharedMemory::String>* indexingFilesPtr =
|
||||
access.accessValueWithAllocator<SharedMemory::Queue<SharedMemory::String>>(s_indexingFilesKeyName);
|
||||
if (indexingFilesPtr)
|
||||
{
|
||||
*strPtr = filePath.str().c_str();
|
||||
SharedMemory::String fileStr(access.getAllocator());
|
||||
fileStr = filePath.str().c_str();
|
||||
indexingFilesPtr->push_back(fileStr);
|
||||
}
|
||||
|
||||
SharedMemory::Map<Id, SharedMemory::String>* currentFilesPtr =
|
||||
@@ -52,7 +56,7 @@ void InterprocessIndexingStatusManager::setCurrentlyIndexedSourceFilePath(const
|
||||
}
|
||||
}
|
||||
|
||||
void InterprocessIndexingStatusManager::clearCurrentlyIndexedSourceFilePath()
|
||||
void InterprocessIndexingStatusManager::finishIndexingSourceFile()
|
||||
{
|
||||
SharedMemory::ScopedAccess access(&m_sharedMemory);
|
||||
|
||||
@@ -62,19 +66,49 @@ void InterprocessIndexingStatusManager::clearCurrentlyIndexedSourceFilePath()
|
||||
{
|
||||
currentFilesPtr->erase(currentFilesPtr->find(getProcessId()), currentFilesPtr->end());
|
||||
}
|
||||
|
||||
SharedMemory::Queue<Id>* finishedProcessIdsPtr =
|
||||
access.accessValueWithAllocator<SharedMemory::Queue<Id>>(s_finishedProcessIdsKeyName);
|
||||
if (finishedProcessIdsPtr)
|
||||
{
|
||||
finishedProcessIdsPtr->push_back(m_processId);
|
||||
}
|
||||
}
|
||||
|
||||
FilePath InterprocessIndexingStatusManager::getCurrentlyIndexedSourceFilePath()
|
||||
Id InterprocessIndexingStatusManager::getNextFinishedProcessId()
|
||||
{
|
||||
SharedMemory::ScopedAccess access(&m_sharedMemory);
|
||||
|
||||
SharedMemory::String* strPtr = access.accessValueWithAllocator<SharedMemory::String>(s_lastFileKeyName);
|
||||
if (strPtr)
|
||||
SharedMemory::Queue<Id>* finishedProcessIdsPtr =
|
||||
access.accessValueWithAllocator<SharedMemory::Queue<Id>>(s_finishedProcessIdsKeyName);
|
||||
if (finishedProcessIdsPtr && finishedProcessIdsPtr->size())
|
||||
{
|
||||
return FilePath(strPtr->c_str());
|
||||
Id processId = finishedProcessIdsPtr->front();
|
||||
finishedProcessIdsPtr->pop_front();
|
||||
return processId;
|
||||
}
|
||||
|
||||
return FilePath();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<FilePath> InterprocessIndexingStatusManager::getCurrentlyIndexedSourceFilePaths()
|
||||
{
|
||||
SharedMemory::ScopedAccess access(&m_sharedMemory);
|
||||
|
||||
std::vector<FilePath> indexingFiles;
|
||||
|
||||
SharedMemory::Queue<SharedMemory::String>* indexingFilesPtr =
|
||||
access.accessValueWithAllocator<SharedMemory::Queue<SharedMemory::String>>(s_indexingFilesKeyName);
|
||||
if (indexingFilesPtr)
|
||||
{
|
||||
while (indexingFilesPtr->size())
|
||||
{
|
||||
indexingFiles.push_back(FilePath(indexingFilesPtr->front().c_str()));
|
||||
indexingFilesPtr->pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
return indexingFiles;
|
||||
}
|
||||
|
||||
std::vector<FilePath> InterprocessIndexingStatusManager::getCrashedSourceFilePaths()
|
||||
|
||||
@@ -13,10 +13,12 @@ public:
|
||||
InterprocessIndexingStatusManager(const std::string& instanceUuid, Id processId, bool isOwner);
|
||||
virtual ~InterprocessIndexingStatusManager();
|
||||
|
||||
void setCurrentlyIndexedSourceFilePath(const FilePath& filePath);
|
||||
void clearCurrentlyIndexedSourceFilePath();
|
||||
FilePath getCurrentlyIndexedSourceFilePath();
|
||||
void startIndexingSourceFile(const FilePath& filePath);
|
||||
void finishIndexingSourceFile();
|
||||
|
||||
Id getNextFinishedProcessId();
|
||||
|
||||
std::vector<FilePath> getCurrentlyIndexedSourceFilePaths();
|
||||
std::vector<FilePath> getCrashedSourceFilePaths();
|
||||
|
||||
std::set<FilePath> getIndexedFiles();
|
||||
@@ -25,10 +27,11 @@ public:
|
||||
private:
|
||||
static const char* s_sharedMemoryNamePrefix;
|
||||
|
||||
static const char* s_lastFileKeyName;
|
||||
static const char* s_indexingFilesKeyName;
|
||||
static const char* s_currentFilesKeyName;
|
||||
static const char* s_crashedFilesKeyName;
|
||||
static const char* s_indexedFilesKeyName;
|
||||
static const char* s_finishedProcessIdsKeyName;
|
||||
};
|
||||
|
||||
#endif // INTERPROCESS_INDEXING_STATUS_MANAGER_H
|
||||
|
||||
Reference in New Issue
Block a user