copy dummy cache over implement retrievePackedPathFromSearchSpace calculate packed_path_from_source_to_middle debugging the retrievePackedPathFromSearchSpace function implementation adding in packed_path_from_source_to_middle cache is partway working unpack path and get duration that way the computeDurationForEdge method comment out cache clean up the code move vector creation and allocation to outside of loop hack to not return vectors on facade.GetUncompressedForwardDurations and facade.GetUncompressedReverseDurations clean up hack add exclude_index to cache key clearing cache with timestamp rebase against vectors->range pr swapped out unordered_map cache with a boost_lru implementation calculation for cache size cleaned up comment about cache size calculations unit tests cache uses unsigned char for exclude index clean up cache and unit tests
112 lines
3.5 KiB
C++
112 lines
3.5 KiB
C++
#ifndef OSRM_ENGINE_DATAFACADE_PROVIDER_HPP
|
|
#define OSRM_ENGINE_DATAFACADE_PROVIDER_HPP
|
|
|
|
#include "engine/data_watchdog.hpp"
|
|
#include "engine/datafacade.hpp"
|
|
#include "engine/datafacade/contiguous_internalmem_datafacade.hpp"
|
|
#include "engine/datafacade/mmap_memory_allocator.hpp"
|
|
#include "engine/datafacade/process_memory_allocator.hpp"
|
|
#include "engine/datafacade_factory.hpp"
|
|
|
|
namespace osrm
|
|
{
|
|
namespace engine
|
|
{
|
|
namespace detail
|
|
{
|
|
|
|
template <typename AlgorithmT, template <typename A> class FacadeT> class DataFacadeProvider
|
|
{
|
|
public:
|
|
using Facade = FacadeT<AlgorithmT>;
|
|
|
|
virtual ~DataFacadeProvider() = default;
|
|
|
|
virtual std::shared_ptr<const Facade> Get(const api::BaseParameters &) const = 0;
|
|
virtual std::shared_ptr<const Facade> Get(const api::TileParameters &) const = 0;
|
|
};
|
|
|
|
template <typename AlgorithmT, template <typename A> class FacadeT>
|
|
class ExternalProvider final : public DataFacadeProvider<AlgorithmT, FacadeT>
|
|
{
|
|
public:
|
|
using Facade = typename DataFacadeProvider<AlgorithmT, FacadeT>::Facade;
|
|
|
|
ExternalProvider(const storage::StorageConfig &config,
|
|
const boost::filesystem::path &memory_file)
|
|
: facade_factory(std::make_shared<datafacade::MMapMemoryAllocator>(config, memory_file),
|
|
0) // is it ok to add timestamp as zero here?
|
|
{
|
|
}
|
|
|
|
std::shared_ptr<const Facade> Get(const api::TileParameters ¶ms) const override final
|
|
{
|
|
return facade_factory.Get(params);
|
|
}
|
|
std::shared_ptr<const Facade> Get(const api::BaseParameters ¶ms) const override final
|
|
{
|
|
return facade_factory.Get(params);
|
|
}
|
|
|
|
private:
|
|
DataFacadeFactory<FacadeT, AlgorithmT> facade_factory;
|
|
};
|
|
|
|
template <typename AlgorithmT, template <typename A> class FacadeT>
|
|
class ImmutableProvider final : public DataFacadeProvider<AlgorithmT, FacadeT>
|
|
{
|
|
public:
|
|
using Facade = typename DataFacadeProvider<AlgorithmT, FacadeT>::Facade;
|
|
|
|
ImmutableProvider(const storage::StorageConfig &config)
|
|
: facade_factory(std::make_shared<datafacade::ProcessMemoryAllocator>(config), 0)
|
|
{
|
|
}
|
|
|
|
std::shared_ptr<const Facade> Get(const api::TileParameters ¶ms) const override final
|
|
{
|
|
return facade_factory.Get(params);
|
|
}
|
|
std::shared_ptr<const Facade> Get(const api::BaseParameters ¶ms) const override final
|
|
{
|
|
return facade_factory.Get(params);
|
|
}
|
|
|
|
private:
|
|
DataFacadeFactory<FacadeT, AlgorithmT> facade_factory;
|
|
};
|
|
|
|
template <typename AlgorithmT, template <typename A> class FacadeT>
|
|
class WatchingProvider : public DataFacadeProvider<AlgorithmT, FacadeT>
|
|
{
|
|
DataWatchdog<AlgorithmT, FacadeT> watchdog;
|
|
|
|
public:
|
|
using Facade = typename DataFacadeProvider<AlgorithmT, FacadeT>::Facade;
|
|
|
|
WatchingProvider(const std::string &dataset_name) : watchdog(dataset_name) {}
|
|
|
|
std::shared_ptr<const Facade> Get(const api::TileParameters ¶ms) const override final
|
|
{
|
|
return watchdog.Get(params);
|
|
}
|
|
std::shared_ptr<const Facade> Get(const api::BaseParameters ¶ms) const override final
|
|
{
|
|
return watchdog.Get(params);
|
|
}
|
|
};
|
|
}
|
|
|
|
template <typename AlgorithmT>
|
|
using DataFacadeProvider = detail::DataFacadeProvider<AlgorithmT, DataFacade>;
|
|
template <typename AlgorithmT>
|
|
using WatchingProvider = detail::WatchingProvider<AlgorithmT, DataFacade>;
|
|
template <typename AlgorithmT>
|
|
using ImmutableProvider = detail::ImmutableProvider<AlgorithmT, DataFacade>;
|
|
template <typename AlgorithmT>
|
|
using ExternalProvider = detail::ExternalProvider<AlgorithmT, DataFacade>;
|
|
}
|
|
}
|
|
|
|
#endif
|