Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
45
libs/indexer/caching_rank_table_loader.cpp
Normal file
45
libs/indexer/caching_rank_table_loader.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include "indexer/caching_rank_table_loader.hpp"
|
||||
|
||||
#include "search/dummy_rank_table.hpp"
|
||||
|
||||
#include "indexer/data_source.hpp"
|
||||
|
||||
CachingRankTableLoader::CachingRankTableLoader(DataSource const & dataSource, std::string const & sectionName)
|
||||
: m_dataSource(dataSource)
|
||||
, m_sectionName(sectionName)
|
||||
{}
|
||||
|
||||
uint8_t CachingRankTableLoader::Get(FeatureID const & featureId) const
|
||||
{
|
||||
auto const handle = m_dataSource.GetMwmHandleById(featureId.m_mwmId);
|
||||
|
||||
if (!handle.IsAlive())
|
||||
return search::RankTable::kNoRank;
|
||||
|
||||
auto it = m_deserializers.find(featureId.m_mwmId);
|
||||
|
||||
if (it == m_deserializers.end())
|
||||
{
|
||||
auto rankTable = search::RankTable::Load(handle.GetValue()->m_cont, m_sectionName);
|
||||
|
||||
if (!rankTable)
|
||||
rankTable = std::make_unique<search::DummyRankTable>();
|
||||
|
||||
auto const result = m_deserializers.emplace(featureId.m_mwmId, std::move(rankTable));
|
||||
it = result.first;
|
||||
}
|
||||
|
||||
return it->second->Get(featureId.m_index);
|
||||
}
|
||||
|
||||
void CachingRankTableLoader::OnMwmDeregistered(platform::LocalCountryFile const & localFile)
|
||||
{
|
||||
for (auto it = m_deserializers.begin(); it != m_deserializers.end(); ++it)
|
||||
{
|
||||
if (it->first.IsDeregistered(localFile))
|
||||
{
|
||||
m_deserializers.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue