Skip to content

Optionally run Plugin parsers after DB indexing #753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions parser/include/parser/abstractparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ class AbstractParser
* @return Returns true if the parse succeeded, false otherwise.
*/
virtual bool parse() = 0;
/**
* Returns true in case database indices are required for the parser, due to performance reasons.
*
* Should return the same value on each call for the same object.
* @return Returns true if the database indexing has to be performed before the parser is executed.
*/
virtual bool isDatabaseIndexRequired() const
{
return false;
}

protected:
ParserContext& _ctx;
Expand Down
19 changes: 17 additions & 2 deletions parser/src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,18 +411,33 @@ int main(int argc, char* argv[])
incrementalCleanup(ctx);
}

std::vector<std::string> afterIndexingPlugins;

// TODO: Handle errors returned by parse().
for (const std::string& pluginName : pluginNames)
{
LOG(info) << "[" << pluginName << "] parse started!";
pHandler.getParser(pluginName)->parse();
auto plugin = pHandler.getParser(pluginName);
if (!plugin->isDatabaseIndexRequired())
{
LOG(info) << "[" << pluginName << "] parse started!";
plugin->parse();
}
else {
afterIndexingPlugins.push_back(pluginName);
}
}

//--- Add indexes to the database ---//

if (vm.count("force") || isNewDb)
cc::util::createIndexes(db, SQL_DIR);

for (const std::string& pluginName : afterIndexingPlugins)
{
LOG(info) << "[" << pluginName << "] parse started!";
pHandler.getParser(pluginName)->parse();
}

//--- Create project config file ---//

boost::property_tree::ptree pt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class CppMetricsParser : public AbstractParser
virtual bool cleanupDatabase() override;
virtual bool parse() override;

virtual bool isDatabaseIndexRequired() const override
{
return true;
}

private:
// Calculate the count of parameters for every function.
void functionParameters();
Expand Down
Loading