mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:10:05 +00:00
Optimization of object listing by date
This commit is contained in:
parent
f452d3f15d
commit
da835d7226
4 changed files with 29 additions and 12 deletions
|
|
@ -683,9 +683,15 @@ RadarProductManager::GetActiveVolumeTimes(
|
|||
{
|
||||
std::unordered_set<std::shared_ptr<provider::NexradDataProvider>>
|
||||
providers {};
|
||||
std::set<std::chrono::system_clock::time_point> volumeTimes;
|
||||
std::set<std::chrono::system_clock::time_point> volumeTimes {};
|
||||
std::mutex volumeTimesMutex {};
|
||||
|
||||
// Return a default set of volume times if the default time point is given
|
||||
if (time == std::chrono::system_clock::time_point {})
|
||||
{
|
||||
return volumeTimes;
|
||||
}
|
||||
|
||||
// Lock the refresh map
|
||||
std::shared_lock refreshLock {p->refreshMapMutex_};
|
||||
|
||||
|
|
@ -717,6 +723,12 @@ RadarProductManager::GetActiveVolumeTimes(
|
|||
dates.end(),
|
||||
[&](const auto& date)
|
||||
{
|
||||
// Don't query for a time point in the future
|
||||
if (date > std::chrono::system_clock::now())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Query the provider for volume time points
|
||||
auto timePoints = provider->GetTimePointsByDate(date);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
std::string FindLatestKey() override;
|
||||
std::vector<std::chrono::system_clock::time_point>
|
||||
GetTimePointsByDate(std::chrono::system_clock::time_point date) override;
|
||||
std::pair<size_t, size_t>
|
||||
std::tuple<bool, size_t, size_t>
|
||||
ListObjects(std::chrono::system_clock::time_point date) override;
|
||||
std::shared_ptr<wsr88d::NexradFile>
|
||||
LoadObjectByKey(const std::string& key) override;
|
||||
|
|
|
|||
|
|
@ -64,10 +64,11 @@ public:
|
|||
*
|
||||
* @param date Date for which to list objects
|
||||
*
|
||||
* @return - New objects found for the given date
|
||||
* @return - Whether query was successful
|
||||
* - New objects found for the given date
|
||||
* - Total objects found for the given date
|
||||
*/
|
||||
virtual std::pair<size_t, size_t>
|
||||
virtual std::tuple<bool, size_t, size_t>
|
||||
ListObjects(std::chrono::system_clock::time_point date) = 0;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ AwsNexradDataProvider::GetTimePointsByDate(
|
|||
|
||||
std::vector<std::chrono::system_clock::time_point> timePoints {};
|
||||
|
||||
logger_->debug("GetTimePointsByDate: {}", day);
|
||||
logger_->debug("GetTimePointsByDate: {}", util::TimeString(date));
|
||||
|
||||
std::shared_lock lock(p->objectsMutex_);
|
||||
|
||||
|
|
@ -177,7 +177,11 @@ AwsNexradDataProvider::GetTimePointsByDate(
|
|||
lock.unlock();
|
||||
|
||||
// List objects, since the date is not present in the date list
|
||||
ListObjects(date);
|
||||
auto [success, newObjects, totalObjects] = ListObjects(date);
|
||||
if (success)
|
||||
{
|
||||
p->UpdateObjectDates(date);
|
||||
}
|
||||
|
||||
// Re-lock mutex
|
||||
lock.lock();
|
||||
|
|
@ -196,7 +200,7 @@ AwsNexradDataProvider::GetTimePointsByDate(
|
|||
return timePoints;
|
||||
}
|
||||
|
||||
std::pair<size_t, size_t>
|
||||
std::tuple<bool, size_t, size_t>
|
||||
AwsNexradDataProvider::ListObjects(std::chrono::system_clock::time_point date)
|
||||
{
|
||||
const std::string prefix {GetPrefix(date)};
|
||||
|
|
@ -262,7 +266,7 @@ AwsNexradDataProvider::ListObjects(std::chrono::system_clock::time_point date)
|
|||
outcome.GetError().GetMessage());
|
||||
}
|
||||
|
||||
return std::make_pair(newObjects, totalObjects);
|
||||
return {outcome.IsSuccess(), newObjects, totalObjects};
|
||||
}
|
||||
|
||||
std::shared_ptr<wsr88d::NexradFile>
|
||||
|
|
@ -309,16 +313,16 @@ std::pair<size_t, size_t> AwsNexradDataProvider::Refresh()
|
|||
// yesterday, to ensure we haven't missed any objects near midnight
|
||||
if (p->refreshDate_ < today)
|
||||
{
|
||||
auto [newObjects, totalObjects] = ListObjects(yesterday);
|
||||
allNewObjects = newObjects;
|
||||
allTotalObjects = totalObjects;
|
||||
auto [success, newObjects, totalObjects] = ListObjects(yesterday);
|
||||
allNewObjects = newObjects;
|
||||
allTotalObjects = totalObjects;
|
||||
if (totalObjects > 0)
|
||||
{
|
||||
p->refreshDate_ = yesterday;
|
||||
}
|
||||
}
|
||||
|
||||
auto [newObjects, totalObjects] = ListObjects(today);
|
||||
auto [success, newObjects, totalObjects] = ListObjects(today);
|
||||
allNewObjects += newObjects;
|
||||
allTotalObjects += totalObjects;
|
||||
if (totalObjects > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue