Skip to content

Commit

Permalink
Throw an exception if a shared region is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase committed Apr 23, 2018
1 parent 8de1285 commit e637d69
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions include/storage/shared_data_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,39 @@ class SharedDataIndex

template <typename T> auto GetBlockPtr(const std::string &name) const
{
const auto index_iter = block_to_region.find(name);
const auto &region = regions[index_iter->second];
const auto &region = GetBlockRegion(name);
return region.layout.GetBlockPtr<T>(region.memory_ptr, name);
}

template <typename T> auto GetBlockPtr(const std::string &name)
{
const auto index_iter = block_to_region.find(name);
const auto &region = regions[index_iter->second];
const auto &region = GetBlockRegion(name);
return region.layout.GetBlockPtr<T>(region.memory_ptr, name);
}

std::size_t GetBlockEntries(const std::string &name) const
{
const auto index_iter = block_to_region.find(name);
const auto &region = regions[index_iter->second];
const auto &region = 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 &region = regions[index_iter->second];
const auto &region = 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<AllocatedRegion> regions;
std::unordered_map<std::string, std::uint32_t> block_to_region;
};
Expand Down

0 comments on commit e637d69

Please sign in to comment.