diff --git a/include/storage/shared_data_index.hpp b/include/storage/shared_data_index.hpp index 0c6bd7942..94f78182a 100644 --- a/include/storage/shared_data_index.hpp +++ b/include/storage/shared_data_index.hpp @@ -46,33 +46,39 @@ class SharedDataIndex template auto GetBlockPtr(const std::string &name) const { - const auto index_iter = block_to_region.find(name); - const auto ®ion = regions[index_iter->second]; + const auto ®ion = GetBlockRegion(name); return region.layout.GetBlockPtr(region.memory_ptr, name); } template auto GetBlockPtr(const std::string &name) { - const auto index_iter = block_to_region.find(name); - const auto ®ion = regions[index_iter->second]; + const auto ®ion = GetBlockRegion(name); return region.layout.GetBlockPtr(region.memory_ptr, name); } std::size_t GetBlockEntries(const std::string &name) const { - const auto index_iter = block_to_region.find(name); - const auto ®ion = regions[index_iter->second]; + const auto ®ion = GetBlockRegion(name); return region.layout.GetBlockEntries(name); } std::size_t GetBlockSize(const std::string &name) const { - const auto index_iter = block_to_region.find(name); - const auto ®ion = regions[index_iter->second]; + const auto ®ion = GetBlockRegion(name); return region.layout.GetBlockSize(name); } private: + const AllocatedRegion &GetBlockRegion(const std::string &name) const + { + const auto index_iter = block_to_region.find(name); + if (index_iter == block_to_region.end()) + { + throw util::exception("data block " + name + " not found " + SOURCE_REF); + } + return regions[index_iter->second]; + } + std::vector regions; std::unordered_map block_to_region; };