Skip to content

Commit

Permalink
Extended MetricsParser to handle incremental parsing #10
Browse files Browse the repository at this point in the history
  • Loading branch information
intjftw committed Jul 12, 2018
1 parent 8f85585 commit 7affe06
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MetricsParser : public AbstractParser
MetricsParser(ParserContext& ctx_);
virtual std::vector<std::string> getDependentParsers() const override;
virtual bool parse() override;
virtual void preparse() override;

private:
util::DirIterCallback getParserCallback();
Expand Down
20 changes: 20 additions & 0 deletions plugins/metrics/parser/src/metricsparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ std::vector<std::string> MetricsParser::getDependentParsers() const
return std::vector<std::string>{};
}

void MetricsParser::preparse()
{
if(!_fileIdCache.empty())
{
(util::OdbTransaction(_ctx.db))([this] {
for(const model::File& file
: _ctx.db->query<model::File>(
odb::query<model::File>::id.in_range(_fileIdCache.begin(), _fileIdCache.end())))
{
if(_ctx.fileStatus[file.path] == cc::parser::IncrementalStatus::DELETED ||
_ctx.fileStatus[file.path] == cc::parser::IncrementalStatus::MODIFIED)
{
_ctx.db->erase_query<model::Metrics>(odb::query<model::Metrics>::file == file.id);
_fileIdCache.erase(file.id);
}
}
});
}
}

bool MetricsParser::parse()
{
for(std::string path : _ctx.options["input"].as<std::vector<std::string>>())
Expand Down

0 comments on commit 7affe06

Please sign in to comment.