Skip to content

Commit

Permalink
planner_multi: get random_access index based on resource type
Browse files Browse the repository at this point in the history
  • Loading branch information
milroy committed Jun 16, 2024
1 parent 245f610 commit ceaf635
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions resource/planner/c++/planner_multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ const char *planner_multi::get_resource_type_at (size_t i) const
return m_types_totals_planners.at (i).resource_type.c_str ();
}

size_t planner_multi::get_resource_type_idx (const char *type) const
{
std::string rtype = std::string (type);
auto by_res = m_types_totals_planners.get<res_type> ().find (rtype);
auto curr_idx = m_types_totals_planners.get<idx> ().iterator_to (*by_res);
return curr_idx - m_types_totals_planners.begin ();
}

struct request_multi &planner_multi::get_iter ()
{
return m_iter;
Expand Down
1 change: 1 addition & 0 deletions resource/planner/c++/planner_multi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class planner_multi {
int64_t get_resource_total_at (size_t i) const;
int64_t get_resource_total_at (const char *type) const;
const char *get_resource_type_at (size_t i) const;
size_t get_resource_type_idx (const char *type) const;
struct request_multi &get_iter ();
// Span lookup functions
std::map<uint64_t, std::vector<int64_t>> &get_span_lookup ();
Expand Down

0 comments on commit ceaf635

Please sign in to comment.