From fd24111b1708bfc25c5619458e5cdf84cbf05b00 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 21 Nov 2025 09:46:11 -0600 Subject: [PATCH 1/8] Rename level_id to data_cell_id --- phlex/core/cached_product_stores.hpp | 8 +-- phlex/core/declared_fold.hpp | 4 +- phlex/core/declared_observer.cpp | 2 +- phlex/core/declared_observer.hpp | 4 +- phlex/core/declared_predicate.hpp | 4 +- phlex/core/declared_transform.hpp | 4 +- phlex/core/declared_unfold.hpp | 10 +-- phlex/core/end_of_message.cpp | 6 +- phlex/core/end_of_message.hpp | 8 +-- phlex/core/message.cpp | 2 +- phlex/core/message_sender.hpp | 2 +- phlex/core/multiplexer.hpp | 2 +- phlex/core/store_counters.cpp | 8 +-- phlex/core/store_counters.hpp | 17 ++--- phlex/model/CMakeLists.txt | 2 +- .../model/{level_id.cpp => data_cell_id.cpp} | 64 +++++++++--------- phlex/model/data_cell_id.hpp | 65 +++++++++++++++++++ phlex/model/fwd.hpp | 4 +- phlex/model/handle.hpp | 12 ++-- phlex/model/level_counter.cpp | 6 +- phlex/model/level_counter.hpp | 18 ++--- phlex/model/level_hierarchy.cpp | 4 +- phlex/model/level_hierarchy.hpp | 4 +- phlex/model/level_id.hpp | 65 ------------------- phlex/model/product_store.cpp | 8 +-- phlex/model/product_store.hpp | 8 +-- test/CMakeLists.txt | 2 +- test/allowed_families.cpp | 10 +-- test/benchmarks/accept_even_ids.cpp | 4 +- test/benchmarks/last_index.cpp | 4 +- test/benchmarks/read_id.cpp | 4 +- test/benchmarks/read_index.cpp | 2 +- test/cached_product_stores.cpp | 6 +- test/{level_id.cpp => data_cell_id.cpp} | 6 +- test/demo-giantdata/unfold_transform_fold.cpp | 18 ++--- test/fold.cpp | 2 +- test/hierarchical_nodes.cpp | 4 +- test/level_counting.cpp | 2 +- test/mock-workflow/MC_truth_algorithm.cpp | 2 +- test/mock-workflow/three_tuple_algorithm.cpp | 2 +- test/product_handle.cpp | 30 ++++----- test/unfold.cpp | 8 +-- test/yielding_driver.cpp | 12 ++-- 43 files changed, 233 insertions(+), 226 deletions(-) rename phlex/model/{level_id.cpp => data_cell_id.cpp} (57%) create mode 100644 phlex/model/data_cell_id.hpp delete mode 100644 phlex/model/level_id.hpp rename test/{level_id.cpp => data_cell_id.cpp} (88%) diff --git a/phlex/core/cached_product_stores.hpp b/phlex/core/cached_product_stores.hpp index d7a27dd05..641f37231 100644 --- a/phlex/core/cached_product_stores.hpp +++ b/phlex/core/cached_product_stores.hpp @@ -4,21 +4,21 @@ // FIXME: only intended to be used in a single-threaded context as std::map is not // thread-safe. +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/fwd.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/product_store.hpp" namespace phlex::experimental { class cached_product_stores { public: - product_store_ptr get_store(level_id_ptr id = level_id::base_ptr()) + product_store_ptr get_store(data_cell_id_ptr id = data_cell_id::base_ptr()) { auto it = product_stores_.find(id->hash()); if (it != cend(product_stores_)) { return it->second; } - if (id == level_id::base_ptr()) { + if (id == data_cell_id::base_ptr()) { return new_store(product_store::base()); } return new_store( @@ -33,7 +33,7 @@ namespace phlex::experimental { } std::string const source_name_{"Source"}; - std::map product_stores_{}; + std::map product_stores_{}; }; } diff --git a/phlex/core/declared_fold.hpp b/phlex/core/declared_fold.hpp index 9461f2ca2..cc398c0f8 100644 --- a/phlex/core/declared_fold.hpp +++ b/phlex/core/declared_fold.hpp @@ -11,8 +11,8 @@ #include "phlex/core/products_consumer.hpp" #include "phlex/core/store_counters.hpp" #include "phlex/model/algorithm_name.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/handle.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/product_specification.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/simple_ptr_map.hpp" @@ -179,7 +179,7 @@ namespace phlex::experimental { std::string partition_; join_or_none_t join_; tbb::flow::multifunction_node, messages_t<1>> fold_; - tbb::concurrent_unordered_map> results_; + tbb::concurrent_unordered_map> results_; std::atomic calls_; std::atomic product_count_; }; diff --git a/phlex/core/declared_observer.cpp b/phlex/core/declared_observer.cpp index 47076705b..d13cb470d 100644 --- a/phlex/core/declared_observer.cpp +++ b/phlex/core/declared_observer.cpp @@ -14,7 +14,7 @@ namespace phlex::experimental { declared_observer::~declared_observer() = default; void declared_observer::report_cached_hashes( - tbb::concurrent_hash_map const& hashes) const + tbb::concurrent_hash_map const& hashes) const { if (hashes.size() > 0ull) { spdlog::warn("Monitor {} has {} cached hashes.", full_name(), hashes.size()); diff --git a/phlex/core/declared_observer.hpp b/phlex/core/declared_observer.hpp index ad6581267..b38325d54 100644 --- a/phlex/core/declared_observer.hpp +++ b/phlex/core/declared_observer.hpp @@ -10,8 +10,8 @@ #include "phlex/core/store_counters.hpp" #include "phlex/metaprogramming/type_deduction.hpp" #include "phlex/model/algorithm_name.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/handle.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/product_specification.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/simple_ptr_map.hpp" @@ -38,7 +38,7 @@ namespace phlex::experimental { virtual ~declared_observer(); protected: - using hashes_t = tbb::concurrent_hash_map; + using hashes_t = tbb::concurrent_hash_map; using accessor = hashes_t::accessor; void report_cached_hashes(hashes_t const& hashes) const; diff --git a/phlex/core/declared_predicate.hpp b/phlex/core/declared_predicate.hpp index ce43277c6..193aee20c 100644 --- a/phlex/core/declared_predicate.hpp +++ b/phlex/core/declared_predicate.hpp @@ -11,8 +11,8 @@ #include "phlex/core/store_counters.hpp" #include "phlex/metaprogramming/type_deduction.hpp" #include "phlex/model/algorithm_name.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/handle.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/simple_ptr_map.hpp" @@ -43,7 +43,7 @@ namespace phlex::experimental { virtual tbb::flow::sender& sender() = 0; protected: - using results_t = tbb::concurrent_hash_map; + using results_t = tbb::concurrent_hash_map; using accessor = results_t::accessor; using const_accessor = results_t::const_accessor; diff --git a/phlex/core/declared_transform.hpp b/phlex/core/declared_transform.hpp index 2f3ed8b53..3d1d7fb5e 100644 --- a/phlex/core/declared_transform.hpp +++ b/phlex/core/declared_transform.hpp @@ -13,8 +13,8 @@ #include "phlex/core/store_counters.hpp" #include "phlex/metaprogramming/type_deduction.hpp" #include "phlex/model/algorithm_name.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/handle.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/product_specification.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/simple_ptr_map.hpp" @@ -50,7 +50,7 @@ namespace phlex::experimental { virtual std::size_t product_count() const = 0; protected: - using stores_t = tbb::concurrent_hash_map; + using stores_t = tbb::concurrent_hash_map; using accessor = stores_t::accessor; using const_accessor = stores_t::const_accessor; diff --git a/phlex/core/declared_unfold.hpp b/phlex/core/declared_unfold.hpp index 4d40b4ec6..e59cf030b 100644 --- a/phlex/core/declared_unfold.hpp +++ b/phlex/core/declared_unfold.hpp @@ -9,8 +9,8 @@ #include "phlex/core/products_consumer.hpp" #include "phlex/core/store_counters.hpp" #include "phlex/model/algorithm_name.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/handle.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/product_specification.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/simple_ptr_map.hpp" @@ -50,7 +50,7 @@ namespace phlex::experimental { product_store_ptr parent_; std::string node_name_; std::string const& new_level_name_; - std::map child_counts_; + std::map child_counts_; }; class declared_unfold : public products_consumer { @@ -66,7 +66,7 @@ namespace phlex::experimental { virtual std::size_t product_count() const = 0; protected: - using stores_t = tbb::concurrent_hash_map; + using stores_t = tbb::concurrent_hash_map; using accessor = stores_t::accessor; using const_accessor = stores_t::const_accessor; @@ -144,7 +144,7 @@ namespace phlex::experimental { template void call(Predicate const& predicate, Unfold const& unfold, - level_id_ptr const& unfolded_id, + data_cell_id_ptr const& unfolded_id, generator& g, end_of_message_ptr const& eom, messages_t const& messages, @@ -181,7 +181,7 @@ namespace phlex::experimental { std::string new_level_name_; join_or_none_t join_; tbb::flow::multifunction_node, messages_t<1u>> unfold_; - tbb::concurrent_hash_map stores_; + tbb::concurrent_hash_map stores_; std::atomic msg_counter_{}; // Is this sufficient? Probably not. std::atomic calls_{}; std::atomic product_count_{}; diff --git a/phlex/core/end_of_message.cpp b/phlex/core/end_of_message.cpp index 89a1ec73d..4cdea422d 100644 --- a/phlex/core/end_of_message.cpp +++ b/phlex/core/end_of_message.cpp @@ -5,17 +5,17 @@ namespace phlex::experimental { end_of_message::end_of_message(end_of_message_ptr parent, level_hierarchy* hierarchy, - level_id_ptr id) : + data_cell_id_ptr id) : parent_{parent}, hierarchy_{hierarchy}, id_{id} { } - end_of_message_ptr end_of_message::make_base(level_hierarchy* hierarchy, level_id_ptr id) + end_of_message_ptr end_of_message::make_base(level_hierarchy* hierarchy, data_cell_id_ptr id) { return end_of_message_ptr{new end_of_message{nullptr, hierarchy, id}}; } - end_of_message_ptr end_of_message::make_child(level_id_ptr id) + end_of_message_ptr end_of_message::make_child(data_cell_id_ptr id) { return end_of_message_ptr{new end_of_message{shared_from_this(), hierarchy_, id}}; } diff --git a/phlex/core/end_of_message.hpp b/phlex/core/end_of_message.hpp index 9082c6217..9ae1dc6cb 100644 --- a/phlex/core/end_of_message.hpp +++ b/phlex/core/end_of_message.hpp @@ -10,16 +10,16 @@ namespace phlex::experimental { class end_of_message : public std::enable_shared_from_this { public: - static end_of_message_ptr make_base(level_hierarchy* hierarchy, level_id_ptr id); - end_of_message_ptr make_child(level_id_ptr id); + static end_of_message_ptr make_base(level_hierarchy* hierarchy, data_cell_id_ptr id); + end_of_message_ptr make_child(data_cell_id_ptr id); ~end_of_message(); private: - end_of_message(end_of_message_ptr parent, level_hierarchy* hierarchy, level_id_ptr id); + end_of_message(end_of_message_ptr parent, level_hierarchy* hierarchy, data_cell_id_ptr id); end_of_message_ptr parent_; level_hierarchy* hierarchy_; - level_id_ptr id_; + data_cell_id_ptr id_; }; } diff --git a/phlex/core/message.cpp b/phlex/core/message.cpp index 456b147de..5c80cc40b 100644 --- a/phlex/core/message.cpp +++ b/phlex/core/message.cpp @@ -1,5 +1,5 @@ #include "phlex/core/message.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include #include diff --git a/phlex/core/message_sender.hpp b/phlex/core/message_sender.hpp index 2ef9162f1..af9b297a2 100644 --- a/phlex/core/message_sender.hpp +++ b/phlex/core/message_sender.hpp @@ -26,7 +26,7 @@ namespace phlex::experimental { level_hierarchy& hierarchy_; multiplexer& multiplexer_; std::stack& eoms_; - std::map original_message_ids_; + std::map original_message_ids_; std::size_t calls_{}; }; diff --git a/phlex/core/multiplexer.hpp b/phlex/core/multiplexer.hpp index c72fd5f38..0bafd6ad5 100644 --- a/phlex/core/multiplexer.hpp +++ b/phlex/core/multiplexer.hpp @@ -2,7 +2,7 @@ #define PHLEX_CORE_MULTIPLEXER_HPP #include "phlex/core/message.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "oneapi/tbb/concurrent_hash_map.h" #include "oneapi/tbb/flow_graph.h" diff --git a/phlex/core/store_counters.cpp b/phlex/core/store_counters.cpp index 3f9216854..07d08831d 100644 --- a/phlex/core/store_counters.cpp +++ b/phlex/core/store_counters.cpp @@ -18,7 +18,7 @@ namespace phlex::experimental { unsigned int store_flag::original_message_id() const noexcept { return original_message_id_; } - store_flag& detect_flush_flag::flag_for(level_id::hash_type const hash) + store_flag& detect_flush_flag::flag_for(data_cell_id::hash_type const hash) { flag_accessor fa; flags_.emplace(fa, hash, std::make_unique()); @@ -52,7 +52,7 @@ namespace phlex::experimental { original_message_id_ = original_message_id; } - void store_counter::increment(level_id::hash_type const level_hash) { ++counts_[level_hash]; } + void store_counter::increment(data_cell_id::hash_type const level_hash) { ++counts_[level_hash]; } bool store_counter::is_complete() { @@ -88,7 +88,7 @@ namespace phlex::experimental { unsigned int store_counter::original_message_id() const noexcept { return original_message_id_; } - store_counter& count_stores::counter_for(level_id::hash_type const hash) + store_counter& count_stores::counter_for(data_cell_id::hash_type const hash) { counter_accessor ca; if (!counters_.find(ca, hash)) { @@ -97,7 +97,7 @@ namespace phlex::experimental { return *ca->second; } - std::unique_ptr count_stores::done_with(level_id::hash_type const hash) + std::unique_ptr count_stores::done_with(data_cell_id::hash_type const hash) { // Must be called after an insertion has already been performed counter_accessor ca; diff --git a/phlex/core/store_counters.hpp b/phlex/core/store_counters.hpp index a32b083d6..5bab98a95 100644 --- a/phlex/core/store_counters.hpp +++ b/phlex/core/store_counters.hpp @@ -2,8 +2,8 @@ #define PHLEX_CORE_STORE_COUNTERS_HPP #include "phlex/core/fwd.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/level_counter.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/product_store.hpp" #include "oneapi/tbb/concurrent_hash_map.h" @@ -29,11 +29,11 @@ namespace phlex::experimental { class detect_flush_flag { protected: - store_flag& flag_for(level_id::hash_type hash); + store_flag& flag_for(data_cell_id::hash_type hash); bool done_with(product_store_const_ptr const& store); private: - using flags_t = tbb::concurrent_hash_map>; + using flags_t = tbb::concurrent_hash_map>; using flag_accessor = flags_t::accessor; using const_flag_accessor = flags_t::const_accessor; @@ -45,12 +45,13 @@ namespace phlex::experimental { class store_counter { public: void set_flush_value(product_store_const_ptr const& ptr, std::size_t original_message_id); - void increment(level_id::hash_type level_hash); + void increment(data_cell_id::hash_type level_hash); bool is_complete(); unsigned int original_message_id() const noexcept; private: - using counts_t2 = tbb::concurrent_unordered_map>; + using counts_t2 = + tbb::concurrent_unordered_map>; counts_t2 counts_{}; #ifdef __cpp_lib_atomic_shared_ptr @@ -64,12 +65,12 @@ namespace phlex::experimental { class count_stores { protected: - store_counter& counter_for(level_id::hash_type hash); - std::unique_ptr done_with(level_id::hash_type hash); + store_counter& counter_for(data_cell_id::hash_type hash); + std::unique_ptr done_with(data_cell_id::hash_type hash); private: using counters_t = - tbb::concurrent_hash_map>; + tbb::concurrent_hash_map>; using counter_accessor = counters_t::accessor; counters_t counters_; diff --git a/phlex/model/CMakeLists.txt b/phlex/model/CMakeLists.txt index 9ec2f0745..8eff8803e 100644 --- a/phlex/model/CMakeLists.txt +++ b/phlex/model/CMakeLists.txt @@ -3,7 +3,7 @@ add_library( algorithm_name.cpp level_counter.cpp level_hierarchy.cpp - level_id.cpp + data_cell_id.cpp product_matcher.cpp product_store.cpp products.cpp diff --git a/phlex/model/level_id.cpp b/phlex/model/data_cell_id.cpp similarity index 57% rename from phlex/model/level_id.cpp rename to phlex/model/data_cell_id.cpp index 390308921..054b74888 100644 --- a/phlex/model/level_id.cpp +++ b/phlex/model/data_cell_id.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/utilities/hashing.hpp" #include "boost/algorithm/string.hpp" @@ -11,7 +11,7 @@ namespace { - std::vector all_numbers(phlex::experimental::level_id const& id) + std::vector all_numbers(phlex::experimental::data_cell_id const& id) { if (!id.has_parent()) { return {}; @@ -30,9 +30,12 @@ namespace { namespace phlex::experimental { - level_id::level_id() : level_name_{"job"}, level_hash_{phlex::experimental::hash(level_name_)} {} + data_cell_id::data_cell_id() : + level_name_{"job"}, level_hash_{phlex::experimental::hash(level_name_)} + { + } - level_id::level_id(level_id_ptr parent, std::size_t i, std::string level_name) : + data_cell_id::data_cell_id(data_cell_id_ptr parent, std::size_t i, std::string level_name) : parent_{std::move(parent)}, number_{i}, level_name_{std::move(level_name)}, @@ -43,30 +46,30 @@ namespace phlex::experimental { // FIXME: Should it be an error to create an ID with an empty name? } - level_id const& level_id::base() { return *base_ptr(); } - level_id_ptr level_id::base_ptr() + data_cell_id const& data_cell_id::base() { return *base_ptr(); } + data_cell_id_ptr data_cell_id::base_ptr() { - static phlex::experimental::level_id_ptr base_id{new level_id}; + static phlex::experimental::data_cell_id_ptr base_id{new data_cell_id}; return base_id; } - std::string const& level_id::level_name() const noexcept { return level_name_; } - std::size_t level_id::depth() const noexcept { return depth_; } + std::string const& data_cell_id::level_name() const noexcept { return level_name_; } + std::size_t data_cell_id::depth() const noexcept { return depth_; } - level_id_ptr level_id::make_child(std::size_t const new_level_number, - std::string new_level_name) const + data_cell_id_ptr data_cell_id::make_child(std::size_t const new_level_number, + std::string new_level_name) const { - return level_id_ptr{ - new level_id{shared_from_this(), new_level_number, std::move(new_level_name)}}; + return data_cell_id_ptr{ + new data_cell_id{shared_from_this(), new_level_number, std::move(new_level_name)}}; } - bool level_id::has_parent() const noexcept { return static_cast(parent_); } + bool data_cell_id::has_parent() const noexcept { return static_cast(parent_); } - std::size_t level_id::number() const { return number_; } - std::size_t level_id::hash() const noexcept { return hash_; } - std::size_t level_id::level_hash() const noexcept { return level_hash_; } + std::size_t data_cell_id::number() const { return number_; } + std::size_t data_cell_id::hash() const noexcept { return hash_; } + std::size_t data_cell_id::level_hash() const noexcept { return level_hash_; } - bool level_id::operator==(level_id const& other) const + bool data_cell_id::operator==(data_cell_id const& other) const { if (depth_ != other.depth_) return false; @@ -77,7 +80,7 @@ namespace phlex::experimental { return *parent_ == *other.parent_ && same_numbers; } - bool level_id::operator<(level_id const& other) const + bool data_cell_id::operator<(data_cell_id const& other) const { auto these_numbers = all_numbers(*this); auto those_numbers = all_numbers(other); @@ -85,16 +88,16 @@ namespace phlex::experimental { begin(these_numbers), end(these_numbers), begin(those_numbers), end(those_numbers)); } - level_id_ptr id_for(std::vector nums) + data_cell_id_ptr id_for(std::vector nums) { - auto current = level_id::base_ptr(); + auto current = data_cell_id::base_ptr(); for (auto const num : nums) { current = current->make_child(num, ""); } return current; } - level_id_ptr id_for(char const* c_str) + data_cell_id_ptr id_for(char const* c_str) { std::vector strs; split(strs, c_str, boost::is_any_of(":")); @@ -108,13 +111,13 @@ namespace phlex::experimental { return id_for(std::move(nums)); } - level_id_ptr operator""_id(char const* c_str, std::size_t) { return id_for(c_str); } + data_cell_id_ptr operator""_id(char const* c_str, std::size_t) { return id_for(c_str); } - level_id_ptr level_id::parent() const noexcept { return parent_; } + data_cell_id_ptr data_cell_id::parent() const noexcept { return parent_; } - level_id_ptr level_id::parent(std::string const& level_name) const + data_cell_id_ptr data_cell_id::parent(std::string const& level_name) const { - level_id_ptr parent = parent_; + data_cell_id_ptr parent = parent_; while (parent) { if (parent->level_name_ == level_name) { return parent; @@ -124,7 +127,7 @@ namespace phlex::experimental { return nullptr; } - std::string level_id::to_string() const + std::string data_cell_id::to_string() const { // FIXME: prefix needs to be adjusted esp. if a root name can be supplied by the user. std::string prefix{"["}; //"root: ["}; @@ -142,7 +145,7 @@ namespace phlex::experimental { return prefix + result + suffix; } - std::string level_id::to_string_this_level() const + std::string data_cell_id::to_string_this_level() const { if (empty(level_name_)) { return std::to_string(number_); @@ -150,5 +153,8 @@ namespace phlex::experimental { return level_name_ + ":" + std::to_string(number_); } - std::ostream& operator<<(std::ostream& os, level_id const& id) { return os << id.to_string(); } + std::ostream& operator<<(std::ostream& os, data_cell_id const& id) + { + return os << id.to_string(); + } } diff --git a/phlex/model/data_cell_id.hpp b/phlex/model/data_cell_id.hpp new file mode 100644 index 000000000..51aceca90 --- /dev/null +++ b/phlex/model/data_cell_id.hpp @@ -0,0 +1,65 @@ +#ifndef PHLEX_MODEL_DATA_CELL_ID_HPP +#define PHLEX_MODEL_DATA_CELL_ID_HPP + +#include "phlex/model/fwd.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace phlex::experimental { + class data_cell_id : public std::enable_shared_from_this { + public: + static data_cell_id const& base(); + static data_cell_id_ptr base_ptr(); + + using hash_type = std::size_t; + data_cell_id_ptr make_child(std::size_t new_level_number, std::string level_name) const; + std::string const& level_name() const noexcept; + std::size_t depth() const noexcept; + data_cell_id_ptr parent(std::string const& level_name) const; + data_cell_id_ptr parent() const noexcept; + bool has_parent() const noexcept; + std::size_t number() const; + std::size_t hash() const noexcept; + std::size_t level_hash() const noexcept; + bool operator==(data_cell_id const& other) const; + bool operator<(data_cell_id const& other) const; + + std::string to_string() const; + std::string to_string_this_level() const; + + friend std::ostream& operator<<(std::ostream& os, data_cell_id const& id); + + private: + data_cell_id(); + explicit data_cell_id(data_cell_id_ptr parent, std::size_t i, std::string level_name); + data_cell_id_ptr parent_{nullptr}; + std::size_t number_{-1ull}; + std::string level_name_; + std::size_t level_hash_; + std::size_t depth_{}; + hash_type hash_{0}; + }; + + data_cell_id_ptr id_for(char const* str); + data_cell_id_ptr id_for(std::vector nums); + data_cell_id_ptr operator""_id(char const* str, std::size_t); + std::ostream& operator<<(std::ostream& os, data_cell_id const& id); +} + +namespace std { + template <> + struct hash { + std::size_t operator()(phlex::experimental::data_cell_id const& id) const noexcept + { + return id.hash(); + } + }; +} + +#endif // PHLEX_MODEL_DATA_CELL_ID_HPP diff --git a/phlex/model/fwd.hpp b/phlex/model/fwd.hpp index 7aeffc9e6..c1922705f 100644 --- a/phlex/model/fwd.hpp +++ b/phlex/model/fwd.hpp @@ -6,10 +6,10 @@ namespace phlex::experimental { class level_counter; class level_hierarchy; - class level_id; + class data_cell_id; class product_store; - using level_id_ptr = std::shared_ptr; + using data_cell_id_ptr = std::shared_ptr; using product_store_const_ptr = std::shared_ptr; using product_store_ptr = std::shared_ptr; diff --git a/phlex/model/handle.hpp b/phlex/model/handle.hpp index 21987c2e5..e8eb67bb0 100644 --- a/phlex/model/handle.hpp +++ b/phlex/model/handle.hpp @@ -1,7 +1,7 @@ #ifndef PHLEX_MODEL_HANDLE_HPP #define PHLEX_MODEL_HANDLE_HPP -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include #include @@ -53,7 +53,7 @@ namespace phlex::experimental { using const_pointer = value_type const*; // The 'product' parameter is not 'const_reference' to avoid avoid implicit type conversions. - explicit handle(std::same_as auto const& product, level_id const& id) : + explicit handle(std::same_as auto const& product, data_cell_id const& id) : product_{&product}, id_{&id} { } @@ -74,7 +74,7 @@ namespace phlex::experimental { operator const_reference() const noexcept { return operator*(); } operator const_pointer() const noexcept { return operator->(); } - auto const& level_id() const noexcept { return *id_; } + auto const& data_cell_id() const noexcept { return *id_; } template friend class handle; @@ -85,12 +85,12 @@ namespace phlex::experimental { } private: - const_pointer product_; // Non-null, by construction - class level_id const* id_; // Non-null, by construction + const_pointer product_; // Non-null, by construction + class data_cell_id const* id_; // Non-null, by construction }; template - handle(T const&, level_id const&) -> handle; + handle(T const&, data_cell_id const&) -> handle; } #endif // PHLEX_MODEL_HANDLE_HPP diff --git a/phlex/model/level_counter.cpp b/phlex/model/level_counter.cpp index 68770e2e6..7d97e3d2d 100644 --- a/phlex/model/level_counter.cpp +++ b/phlex/model/level_counter.cpp @@ -7,7 +7,7 @@ namespace phlex::experimental { flush_counts::flush_counts() = default; - flush_counts::flush_counts(std::map child_counts) : + flush_counts::flush_counts(std::map child_counts) : child_counts_{std::move(child_counts)} { } @@ -43,7 +43,7 @@ namespace phlex::experimental { } } - void flush_counters::update(level_id_ptr const id) + void flush_counters::update(data_cell_id_ptr const id) { level_counter* parent_counter = nullptr; if (auto parent = id->parent()) { @@ -54,7 +54,7 @@ namespace phlex::experimental { counters_[id->hash()] = std::make_shared(parent_counter, id->level_name()); } - flush_counts flush_counters::extract(level_id_ptr const id) + flush_counts flush_counters::extract(data_cell_id_ptr const id) { auto counter = counters_.extract(id->hash()); return counter.mapped()->result(); diff --git a/phlex/model/level_counter.hpp b/phlex/model/level_counter.hpp index 0ba3c2295..f328f3279 100644 --- a/phlex/model/level_counter.hpp +++ b/phlex/model/level_counter.hpp @@ -1,8 +1,8 @@ #ifndef PHLEX_MODEL_LEVEL_COUNTER_HPP #define PHLEX_MODEL_LEVEL_COUNTER_HPP +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/fwd.hpp" -#include "phlex/model/level_id.hpp" #include "oneapi/tbb/concurrent_hash_map.h" @@ -14,14 +14,14 @@ namespace phlex::experimental { class flush_counts { public: flush_counts(); - explicit flush_counts(std::map child_counts); + explicit flush_counts(std::map child_counts); auto begin() const { return child_counts_.begin(); } auto end() const { return child_counts_.end(); } bool empty() const { return child_counts_.empty(); } auto size() const { return child_counts_.size(); } - std::optional count_for(level_id::hash_type const level_hash) const + std::optional count_for(data_cell_id::hash_type const level_hash) const { if (auto it = child_counts_.find(level_hash); it != child_counts_.end()) { return it->second; @@ -30,7 +30,7 @@ namespace phlex::experimental { } private: - std::map child_counts_{}; + std::map child_counts_{}; }; using flush_counts_ptr = std::shared_ptr; @@ -54,17 +54,17 @@ namespace phlex::experimental { void adjust(level_counter& child); level_counter* parent_; - level_id::hash_type level_hash_; - std::map child_counts_{}; + data_cell_id::hash_type level_hash_; + std::map child_counts_{}; }; class flush_counters { public: - void update(level_id_ptr const id); - flush_counts extract(level_id_ptr const id); + void update(data_cell_id_ptr const id); + flush_counts extract(data_cell_id_ptr const id); private: - std::map> counters_; + std::map> counters_; }; } diff --git a/phlex/model/level_hierarchy.cpp b/phlex/model/level_hierarchy.cpp index eefb430e6..8db6aeb70 100644 --- a/phlex/model/level_hierarchy.cpp +++ b/phlex/model/level_hierarchy.cpp @@ -1,5 +1,5 @@ #include "phlex/model/level_hierarchy.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "fmt/format.h" #include "fmt/std.h" @@ -14,7 +14,7 @@ namespace phlex::experimental { level_hierarchy::~level_hierarchy() { print(); } - void level_hierarchy::increment_count(level_id_ptr const& id) + void level_hierarchy::increment_count(data_cell_id_ptr const& id) { if (auto it = levels_.find(id->level_hash()); it != levels_.cend()) { ++it->second->count; diff --git a/phlex/model/level_hierarchy.hpp b/phlex/model/level_hierarchy.hpp index bf4b8e5ce..13b66f9db 100644 --- a/phlex/model/level_hierarchy.hpp +++ b/phlex/model/level_hierarchy.hpp @@ -1,8 +1,8 @@ #ifndef PHLEX_MODEL_LEVEL_HIERARCHY_HPP #define PHLEX_MODEL_LEVEL_HIERARCHY_HPP +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/fwd.hpp" -#include "phlex/model/level_id.hpp" #include "oneapi/tbb/concurrent_unordered_map.h" @@ -16,7 +16,7 @@ namespace phlex::experimental { class level_hierarchy { public: ~level_hierarchy(); - void increment_count(level_id_ptr const& id); + void increment_count(data_cell_id_ptr const& id); std::size_t count_for(std::string const& level_name) const; void print() const; diff --git a/phlex/model/level_id.hpp b/phlex/model/level_id.hpp deleted file mode 100644 index 94e488e2c..000000000 --- a/phlex/model/level_id.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef PHLEX_MODEL_LEVEL_ID_HPP -#define PHLEX_MODEL_LEVEL_ID_HPP - -#include "phlex/model/fwd.hpp" - -#include -#include -#include -#include -#include -#include -#include - -namespace phlex::experimental { - class level_id : public std::enable_shared_from_this { - public: - static level_id const& base(); - static level_id_ptr base_ptr(); - - using hash_type = std::size_t; - level_id_ptr make_child(std::size_t new_level_number, std::string level_name) const; - std::string const& level_name() const noexcept; - std::size_t depth() const noexcept; - level_id_ptr parent(std::string const& level_name) const; - level_id_ptr parent() const noexcept; - bool has_parent() const noexcept; - std::size_t number() const; - std::size_t hash() const noexcept; - std::size_t level_hash() const noexcept; - bool operator==(level_id const& other) const; - bool operator<(level_id const& other) const; - - std::string to_string() const; - std::string to_string_this_level() const; - - friend std::ostream& operator<<(std::ostream& os, level_id const& id); - - private: - level_id(); - explicit level_id(level_id_ptr parent, std::size_t i, std::string level_name); - level_id_ptr parent_{nullptr}; - std::size_t number_{-1ull}; - std::string level_name_; - std::size_t level_hash_; - std::size_t depth_{}; - hash_type hash_{0}; - }; - - level_id_ptr id_for(char const* str); - level_id_ptr id_for(std::vector nums); - level_id_ptr operator""_id(char const* str, std::size_t); - std::ostream& operator<<(std::ostream& os, level_id const& id); -} - -namespace std { - template <> - struct hash { - std::size_t operator()(phlex::experimental::level_id const& id) const noexcept - { - return id.hash(); - } - }; -} - -#endif // PHLEX_MODEL_LEVEL_ID_HPP diff --git a/phlex/model/product_store.cpp b/phlex/model/product_store.cpp index 22823a49b..5773d7976 100644 --- a/phlex/model/product_store.cpp +++ b/phlex/model/product_store.cpp @@ -1,5 +1,5 @@ #include "phlex/model/product_store.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include #include @@ -7,7 +7,7 @@ namespace phlex::experimental { product_store::product_store(product_store_const_ptr parent, - level_id_ptr id, + data_cell_id_ptr id, std::string source, stage processing_stage, products new_products) : @@ -49,7 +49,7 @@ namespace phlex::experimental { product_store_ptr product_store::base(std::string base_name) { return product_store_ptr{ - new product_store{nullptr, level_id::base_ptr(), std::move(base_name)}}; + new product_store{nullptr, data_cell_id::base_ptr(), std::move(base_name)}}; } product_store_const_ptr product_store::parent(std::string const& level_name) const noexcept @@ -112,7 +112,7 @@ namespace phlex::experimental { std::string const& product_store::level_name() const noexcept { return id_->level_name(); } std::string const& product_store::source() const noexcept { return source_; } product_store_const_ptr product_store::parent() const noexcept { return parent_; } - level_id_ptr const& product_store::id() const noexcept { return id_; } + data_cell_id_ptr const& product_store::id() const noexcept { return id_; } bool product_store::is_flush() const noexcept { return stage_ == stage::flush; } bool product_store::contains_product(std::string const& product_name) const diff --git a/phlex/model/product_store.hpp b/phlex/model/product_store.hpp index c0060902f..4fe82ff74 100644 --- a/phlex/model/product_store.hpp +++ b/phlex/model/product_store.hpp @@ -1,9 +1,9 @@ #ifndef PHLEX_MODEL_PRODUCT_STORE_HPP #define PHLEX_MODEL_PRODUCT_STORE_HPP +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/fwd.hpp" #include "phlex/model/handle.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/products.hpp" #include @@ -38,7 +38,7 @@ namespace phlex::experimental { std::string const& new_level_name, std::string source = {}, stage st = stage::process); - level_id_ptr const& id() const noexcept; + data_cell_id_ptr const& id() const noexcept; bool is_flush() const noexcept; // Product interface @@ -59,7 +59,7 @@ namespace phlex::experimental { private: explicit product_store(product_store_const_ptr parent, - level_id_ptr id, + data_cell_id_ptr id, std::string source, stage processing_stage = stage::process, products new_products = {}); @@ -76,7 +76,7 @@ namespace phlex::experimental { product_store_const_ptr parent_{nullptr}; products products_{}; - level_id_ptr id_; + data_cell_id_ptr id_; std::string source_; // FIXME: Should not have to copy the string (the source should outlive the product store) stage stage_; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3af3c2e16..61512a07b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -44,7 +44,7 @@ add_catch_test(function_registration LIBRARIES phlex::core Boost::json) add_catch_test(hierarchical_nodes LIBRARIES Boost::json TBB::tbb phlex::core) add_catch_test(multiple_function_registration LIBRARIES Boost::json phlex::core) add_catch_test(level_counting LIBRARIES phlex::model phlex::utilities) -add_catch_test(level_id LIBRARIES phlex::model) +add_catch_test(data_cell_id LIBRARIES phlex::model) add_catch_test(product_handle LIBRARIES phlex::core) add_catch_test(product_matcher LIBRARIES phlex::model) add_catch_test(product_store LIBRARIES phlex::core) diff --git a/test/allowed_families.cpp b/test/allowed_families.cpp index 204c5d37a..291cc5c2d 100644 --- a/test/allowed_families.cpp +++ b/test/allowed_families.cpp @@ -1,5 +1,5 @@ #include "phlex/core/framework_graph.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/product_store.hpp" #include "catch2/catch_test_macros.hpp" @@ -30,15 +30,15 @@ namespace { driver.yield(event_store); } - void check_two_ids(level_id const& parent_id, level_id const& id) + void check_two_ids(data_cell_id const& parent_id, data_cell_id const& id) { CHECK(parent_id.depth() + 1ull == id.depth()); CHECK(parent_id.hash() == id.parent()->hash()); } - void check_three_ids(level_id const& grandparent_id, - level_id const& parent_id, - level_id const& id) + void check_three_ids(data_cell_id const& grandparent_id, + data_cell_id const& parent_id, + data_cell_id const& id) { CHECK(id.depth() == 3ull); CHECK(parent_id.depth() == 2ull); diff --git a/test/benchmarks/accept_even_ids.cpp b/test/benchmarks/accept_even_ids.cpp index e490c46b6..bd7319967 100644 --- a/test/benchmarks/accept_even_ids.cpp +++ b/test/benchmarks/accept_even_ids.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/module.hpp" #include @@ -7,7 +7,7 @@ PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config) { m.predicate( "accept_even_ids", - [](phlex::experimental::level_id const& id) { return id.number() % 2 == 0; }, + [](phlex::experimental::data_cell_id const& id) { return id.number() % 2 == 0; }, phlex::experimental::concurrency::unlimited) .input_family(config.get("product_name")); } diff --git a/test/benchmarks/last_index.cpp b/test/benchmarks/last_index.cpp index bf113dfca..708c01064 100644 --- a/test/benchmarks/last_index.cpp +++ b/test/benchmarks/last_index.cpp @@ -1,10 +1,10 @@ -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/module.hpp" using namespace phlex::experimental; namespace { - int last_index(level_id const& id) { return static_cast(id.number()); } + int last_index(data_cell_id const& id) { return static_cast(id.number()); } } PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config) diff --git a/test/benchmarks/read_id.cpp b/test/benchmarks/read_id.cpp index cc8c1667c..ea2825d46 100644 --- a/test/benchmarks/read_id.cpp +++ b/test/benchmarks/read_id.cpp @@ -1,8 +1,8 @@ -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/module.hpp" namespace { - void read_id(phlex::experimental::level_id const&) {} + void read_id(phlex::experimental::data_cell_id const&) {} } PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m) diff --git a/test/benchmarks/read_index.cpp b/test/benchmarks/read_index.cpp index f2de1b186..895f2e4e9 100644 --- a/test/benchmarks/read_index.cpp +++ b/test/benchmarks/read_index.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/module.hpp" namespace { diff --git a/test/cached_product_stores.cpp b/test/cached_product_stores.cpp index c7a09a8f1..94979e024 100644 --- a/test/cached_product_stores.cpp +++ b/test/cached_product_stores.cpp @@ -1,5 +1,5 @@ #include "phlex/core/cached_product_stores.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/product_store.hpp" #include "catch2/catch_test_macros.hpp" @@ -13,7 +13,7 @@ TEST_CASE("Cached product stores", "[data model]") { auto store = stores.get_store(); REQUIRE(store); - CHECK(store->id() == level_id::base_ptr()); + CHECK(store->id() == data_cell_id::base_ptr()); } SECTION("One level down") { @@ -21,7 +21,7 @@ TEST_CASE("Cached product stores", "[data model]") REQUIRE(store); CHECK(*store->id() == *"1"_id); REQUIRE(store->parent()); - CHECK(store->parent()->id() == level_id::base_ptr()); + CHECK(store->parent()->id() == data_cell_id::base_ptr()); } SECTION("One level down, multiple instances") { diff --git a/test/level_id.cpp b/test/data_cell_id.cpp similarity index 88% rename from test/level_id.cpp rename to test/data_cell_id.cpp index be910261b..30d826926 100644 --- a/test/level_id.cpp +++ b/test/data_cell_id.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "catch2/catch_test_macros.hpp" @@ -6,7 +6,7 @@ using namespace phlex::experimental; TEST_CASE("Level ID string literal", "[data model]") { - CHECK(""_id == level_id::base_ptr()); + CHECK(""_id == data_cell_id::base_ptr()); auto id = "2"_id; CHECK(*id == *id_for({2})); CHECK(id->hash() != 0ull); @@ -20,7 +20,7 @@ TEST_CASE("Verify independent hashes", "[data model]") // In the original implementation of the hash algorithm, there was a collision between the hash for // "run:0 subrun:0 event: 760" and "run:0 subrun:1 event: 4999". - auto base = level_id::base_ptr(); + auto base = data_cell_id::base_ptr(); auto run = base->make_child(0, "run"); auto subrun_0 = run->make_child(0, "subrun"); auto event_760 = subrun_0->make_child(760, "event"); diff --git a/test/demo-giantdata/unfold_transform_fold.cpp b/test/demo-giantdata/unfold_transform_fold.cpp index 8c48565b0..0ec40d97b 100644 --- a/test/demo-giantdata/unfold_transform_fold.cpp +++ b/test/demo-giantdata/unfold_transform_fold.cpp @@ -1,5 +1,5 @@ #include "phlex/core/framework_graph.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/async_driver.hpp" #include "test/products_for_output.hpp" @@ -123,10 +123,10 @@ int main(int argc, char* argv[]) // Add the transform node to the graph. demo::log_record("add_transform"); auto wrapped_user_function = [](phlex::experimental::handle hwf) { - auto apa_id = hwf.level_id().number(); - auto spill_id = hwf.level_id().parent()->number(); - auto subrun_id = hwf.level_id().parent()->parent()->number(); - auto run_id = hwf.level_id().parent()->parent()->parent()->number(); + auto apa_id = hwf.data_cell_id().number(); + auto spill_id = hwf.data_cell_id().parent()->number(); + auto subrun_id = hwf.data_cell_id().parent()->parent()->number(); + auto run_id = hwf.data_cell_id().parent()->parent()->parent()->number(); return demo::clampWaveforms(*hwf, run_id, subrun_id, spill_id, apa_id); }; @@ -139,10 +139,10 @@ int main(int argc, char* argv[]) g.fold( "accum_for_spill", [](demo::SummedClampedWaveforms& scw, phlex::experimental::handle hwf) { - auto apa_id = hwf.level_id().number(); - auto spill_id = hwf.level_id().parent()->number(); - auto subrun_id = hwf.level_id().parent()->parent()->number(); - auto run_id = hwf.level_id().parent()->parent()->parent()->number(); + auto apa_id = hwf.data_cell_id().number(); + auto spill_id = hwf.data_cell_id().parent()->number(); + auto subrun_id = hwf.data_cell_id().parent()->parent()->number(); + auto run_id = hwf.data_cell_id().parent()->parent()->parent()->number(); demo::accumulateSCW(scw, *hwf, run_id, subrun_id, spill_id, apa_id); }, concurrency::unlimited, diff --git a/test/fold.cpp b/test/fold.cpp index 6654b9f99..a70bb06c4 100644 --- a/test/fold.cpp +++ b/test/fold.cpp @@ -24,7 +24,7 @@ // ======================================================================================= #include "phlex/core/framework_graph.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/product_store.hpp" #include "catch2/catch_test_macros.hpp" diff --git a/test/hierarchical_nodes.cpp b/test/hierarchical_nodes.cpp index 588d618b1..4d0d30d92 100644 --- a/test/hierarchical_nodes.cpp +++ b/test/hierarchical_nodes.cpp @@ -17,7 +17,7 @@ // ======================================================================================= #include "phlex/core/framework_graph.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/product_store.hpp" #include "test/products_for_output.hpp" @@ -92,7 +92,7 @@ namespace { void print_result(handle result, std::string const& stringized_time) { spdlog::debug("{}: {} @ {}", - result.level_id().to_string(), + result.data_cell_id().to_string(), *result, stringized_time.substr(0, stringized_time.find('\n'))); } diff --git a/test/level_counting.cpp b/test/level_counting.cpp index 3a3726f53..8261e7b4e 100644 --- a/test/level_counting.cpp +++ b/test/level_counting.cpp @@ -1,6 +1,6 @@ +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/level_counter.hpp" #include "phlex/model/level_hierarchy.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/hashing.hpp" diff --git a/test/mock-workflow/MC_truth_algorithm.cpp b/test/mock-workflow/MC_truth_algorithm.cpp index 78ee8ee54..1fe96d927 100644 --- a/test/mock-workflow/MC_truth_algorithm.cpp +++ b/test/mock-workflow/MC_truth_algorithm.cpp @@ -6,5 +6,5 @@ using namespace phlex::experimental::test; PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config) { - define_algorithm(m, config); + define_algorithm(m, config); } diff --git a/test/mock-workflow/three_tuple_algorithm.cpp b/test/mock-workflow/three_tuple_algorithm.cpp index b78de23f9..99cf58429 100644 --- a/test/mock-workflow/three_tuple_algorithm.cpp +++ b/test/mock-workflow/three_tuple_algorithm.cpp @@ -8,7 +8,7 @@ using namespace phlex::experimental::test; PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config) { - using inputs = phlex::experimental::level_id; + using inputs = phlex::experimental::data_cell_id; using outputs = std::tuple; define_algorithm(m, config); } diff --git a/test/product_handle.cpp b/test/product_handle.cpp index 403591a35..c8fb55d91 100644 --- a/test/product_handle.cpp +++ b/test/product_handle.cpp @@ -1,5 +1,5 @@ +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/handle.hpp" -#include "phlex/model/level_id.hpp" #include "phlex/model/product_store.hpp" #include "catch2/catch_test_macros.hpp" @@ -32,10 +32,10 @@ TEST_CASE("Can only construct handles with compatible types (compile-time checks static_assert(std::constructible_from, handle&&>); // Moves static_assert(not std::constructible_from, handle>); - static_assert(std::constructible_from, int, level_id>); - static_assert(std::constructible_from, int const, level_id>); - static_assert(std::constructible_from, int const&, level_id>); - static_assert(not std::constructible_from, double, level_id>); + static_assert(std::constructible_from, int, data_cell_id>); + static_assert(std::constructible_from, int const, data_cell_id>); + static_assert(std::constructible_from, int const&, data_cell_id>); + static_assert(not std::constructible_from, double, data_cell_id>); } TEST_CASE("Can only assign handles with compatible types (compile-time checks)", "[data model]") @@ -50,7 +50,7 @@ TEST_CASE("Handle copies and moves", "[data model]") int const two{2}; int const four{4}; - auto job_data_cell = level_id::base_ptr(); + auto job_data_cell = data_cell_id::base_ptr(); auto subrun_6_data_cell = job_data_cell->make_child(6, "subrun"); handle h2{two, *job_data_cell}; @@ -77,23 +77,23 @@ TEST_CASE("Handle comparisons", "[data model]") { int const seventeen{17}; int const eighteen{18}; - handle const h17{seventeen, level_id::base()}; - handle const h18{eighteen, level_id::base()}; + handle const h17{seventeen, data_cell_id::base()}; + handle const h18{eighteen, data_cell_id::base()}; CHECK(h17 == h17); CHECK(h17 != h18); - auto subrun_6_data_cell = level_id::base_ptr()->make_child(6, "subrun"); + auto subrun_6_data_cell = data_cell_id::base_ptr()->make_child(6, "subrun"); handle const h17sr{seventeen, *subrun_6_data_cell}; - CHECK(*h17 == *h17sr); // Products are the same - CHECK(h17.level_id() != h17sr.level_id()); // Levels are not the same - CHECK(h17 != h17sr); // Therefore handles are not the same + CHECK(*h17 == *h17sr); // Products are the same + CHECK(h17.data_cell_id() != h17sr.data_cell_id()); // Levels are not the same + CHECK(h17 != h17sr); // Therefore handles are not the same } TEST_CASE("Handle type conversions (run-time checks)", "[data model]") { int const number{3}; - handle const h{number, level_id::base()}; - CHECK(h.level_id() == level_id::base()); + handle const h{number, data_cell_id::base()}; + CHECK(h.data_cell_id() == data_cell_id::base()); int const& num_ref = h; int const* num_ptr = h; @@ -102,5 +102,5 @@ TEST_CASE("Handle type conversions (run-time checks)", "[data model]") CHECK(*num_ptr == number); Composer const composer{"Elgar"}; - CHECK(handle{composer, level_id::base()}->name == "Elgar"); + CHECK(handle{composer, data_cell_id::base()}->name == "Elgar"); } diff --git a/test/unfold.cpp b/test/unfold.cpp index 2690b1bc4..0daa5b8e3 100644 --- a/test/unfold.cpp +++ b/test/unfold.cpp @@ -15,7 +15,7 @@ // ======================================================================================= #include "phlex/core/framework_graph.hpp" -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/model/product_store.hpp" #include "test/products_for_output.hpp" @@ -49,7 +49,7 @@ namespace { } auto initial_value() const { return begin_; } bool predicate(numbers_t::const_iterator it) const { return it != end_; } - auto unfold(numbers_t::const_iterator it, level_id const& lid) const + auto unfold(numbers_t::const_iterator it, data_cell_id const& lid) const { spdlog::info("Unfolding into {}", lid.to_string()); auto num = *it; @@ -66,7 +66,7 @@ namespace { void check_sum(handle const sum) { - if (sum.level_id().number() == 0ull) { + if (sum.data_cell_id().number() == 0ull) { CHECK(*sum == 45); } else { CHECK(*sum == 190); @@ -75,7 +75,7 @@ namespace { void check_sum_same(handle const sum) { - auto const expected_sum = (sum.level_id().number() + 1) * 10; + auto const expected_sum = (sum.data_cell_id().number() + 1) * 10; CHECK(*sum == expected_sum); } } diff --git a/test/yielding_driver.cpp b/test/yielding_driver.cpp index de0e04907..264e11ea1 100644 --- a/test/yielding_driver.cpp +++ b/test/yielding_driver.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/level_id.hpp" +#include "phlex/model/data_cell_id.hpp" #include "phlex/utilities/async_driver.hpp" #include "fmt/std.h" @@ -13,13 +13,13 @@ using namespace phlex::experimental; -void levels_to_process(async_driver& d) +void levels_to_process(async_driver& d) { unsigned int const num_runs = 2; unsigned int const num_subruns = 2; unsigned int const num_spills = 3; - auto job_id = level_id::base_ptr(); + auto job_id = data_cell_id::base_ptr(); d.yield(job_id); for (unsigned int r : std::views::iota(0u, num_runs)) { auto run_id = job_id->make_child(r, "run"); @@ -36,9 +36,9 @@ void levels_to_process(async_driver& d) int main() { - async_driver drive{levels_to_process}; + async_driver drive{levels_to_process}; tbb::flow::graph g{}; - tbb::flow::input_node source{g, [&drive](tbb::flow_control& fc) -> level_id_ptr { + tbb::flow::input_node source{g, [&drive](tbb::flow_control& fc) -> data_cell_id_ptr { if (auto next = drive()) { return *next; } @@ -46,7 +46,7 @@ int main() return {}; }}; tbb::flow::function_node receiver{ - g, tbb::flow::unlimited, [](level_id_ptr const& set_id) -> tbb::flow::continue_msg { + g, tbb::flow::unlimited, [](data_cell_id_ptr const& set_id) -> tbb::flow::continue_msg { spdlog::info("Received {}", set_id->to_string()); return {}; }}; From 81b97d1a749cadacf1f45b9190026412f73eebae Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 21 Nov 2025 09:52:18 -0600 Subject: [PATCH 2/8] Rename level_hiearchy to data_layer_hierarchy --- phlex/core/end_of_message.cpp | 6 +++--- phlex/core/end_of_message.hpp | 6 +++--- phlex/core/framework_graph.hpp | 4 ++-- phlex/core/message_sender.cpp | 2 +- phlex/core/message_sender.hpp | 4 ++-- phlex/model/CMakeLists.txt | 2 +- ...hierarchy.cpp => data_layer_hierarchy.cpp} | 21 ++++++++++--------- ...hierarchy.hpp => data_layer_hierarchy.hpp} | 16 +++++++------- phlex/model/fwd.hpp | 2 +- test/level_counting.cpp | 4 ++-- test/multiple_function_registration.cpp | 2 +- 11 files changed, 35 insertions(+), 34 deletions(-) rename phlex/model/{level_hierarchy.cpp => data_layer_hierarchy.cpp} (78%) rename phlex/model/{level_hierarchy.hpp => data_layer_hierarchy.hpp} (76%) diff --git a/phlex/core/end_of_message.cpp b/phlex/core/end_of_message.cpp index 4cdea422d..4090558ee 100644 --- a/phlex/core/end_of_message.cpp +++ b/phlex/core/end_of_message.cpp @@ -1,16 +1,16 @@ #include "phlex/core/end_of_message.hpp" -#include "phlex/model/level_hierarchy.hpp" +#include "phlex/model/data_layer_hierarchy.hpp" namespace phlex::experimental { end_of_message::end_of_message(end_of_message_ptr parent, - level_hierarchy* hierarchy, + data_layer_hierarchy* hierarchy, data_cell_id_ptr id) : parent_{parent}, hierarchy_{hierarchy}, id_{id} { } - end_of_message_ptr end_of_message::make_base(level_hierarchy* hierarchy, data_cell_id_ptr id) + end_of_message_ptr end_of_message::make_base(data_layer_hierarchy* hierarchy, data_cell_id_ptr id) { return end_of_message_ptr{new end_of_message{nullptr, hierarchy, id}}; } diff --git a/phlex/core/end_of_message.hpp b/phlex/core/end_of_message.hpp index 9ae1dc6cb..f9709bf5e 100644 --- a/phlex/core/end_of_message.hpp +++ b/phlex/core/end_of_message.hpp @@ -10,15 +10,15 @@ namespace phlex::experimental { class end_of_message : public std::enable_shared_from_this { public: - static end_of_message_ptr make_base(level_hierarchy* hierarchy, data_cell_id_ptr id); + static end_of_message_ptr make_base(data_layer_hierarchy* hierarchy, data_cell_id_ptr id); end_of_message_ptr make_child(data_cell_id_ptr id); ~end_of_message(); private: - end_of_message(end_of_message_ptr parent, level_hierarchy* hierarchy, data_cell_id_ptr id); + end_of_message(end_of_message_ptr parent, data_layer_hierarchy* hierarchy, data_cell_id_ptr id); end_of_message_ptr parent_; - level_hierarchy* hierarchy_; + data_layer_hierarchy* hierarchy_; data_cell_id_ptr id_; }; diff --git a/phlex/core/framework_graph.hpp b/phlex/core/framework_graph.hpp index 18aa00cc5..7757eecce 100644 --- a/phlex/core/framework_graph.hpp +++ b/phlex/core/framework_graph.hpp @@ -11,7 +11,7 @@ #include "phlex/core/message_sender.hpp" #include "phlex/core/multiplexer.hpp" #include "phlex/core/node_catalog.hpp" -#include "phlex/model/level_hierarchy.hpp" +#include "phlex/model/data_layer_hierarchy.hpp" #include "phlex/model/product_store.hpp" #include "phlex/source.hpp" #include "phlex/utilities/max_allowed_parallelism.hpp" @@ -133,7 +133,7 @@ namespace phlex::experimental { resource_usage graph_resource_usage_{}; max_allowed_parallelism parallelism_limit_; - level_hierarchy hierarchy_{}; + data_layer_hierarchy hierarchy_{}; node_catalog nodes_{}; std::map filters_{}; // The graph_ object uses the filters_, nodes_, and hierarchy_ objects implicitly. diff --git a/phlex/core/message_sender.cpp b/phlex/core/message_sender.cpp index 22c90ff4b..969ed1d77 100644 --- a/phlex/core/message_sender.cpp +++ b/phlex/core/message_sender.cpp @@ -6,7 +6,7 @@ #include namespace phlex::experimental { - message_sender::message_sender(level_hierarchy& hierarchy, + message_sender::message_sender(data_layer_hierarchy& hierarchy, multiplexer& mplexer, std::stack& eoms) : hierarchy_{hierarchy}, multiplexer_{mplexer}, eoms_{eoms} diff --git a/phlex/core/message_sender.hpp b/phlex/core/message_sender.hpp index af9b297a2..67f8c4344 100644 --- a/phlex/core/message_sender.hpp +++ b/phlex/core/message_sender.hpp @@ -13,7 +13,7 @@ namespace phlex::experimental { class message_sender { public: - explicit message_sender(level_hierarchy& hierarchy, + explicit message_sender(data_layer_hierarchy& hierarchy, multiplexer& mplexer, std::stack& eoms); @@ -23,7 +23,7 @@ namespace phlex::experimental { private: std::size_t original_message_id(product_store_ptr const& store); - level_hierarchy& hierarchy_; + data_layer_hierarchy& hierarchy_; multiplexer& multiplexer_; std::stack& eoms_; std::map original_message_ids_; diff --git a/phlex/model/CMakeLists.txt b/phlex/model/CMakeLists.txt index 8eff8803e..00a3c0109 100644 --- a/phlex/model/CMakeLists.txt +++ b/phlex/model/CMakeLists.txt @@ -2,7 +2,7 @@ add_library( phlex_model SHARED algorithm_name.cpp level_counter.cpp - level_hierarchy.cpp + data_layer_hierarchy.cpp data_cell_id.cpp product_matcher.cpp product_store.cpp diff --git a/phlex/model/level_hierarchy.cpp b/phlex/model/data_layer_hierarchy.cpp similarity index 78% rename from phlex/model/level_hierarchy.cpp rename to phlex/model/data_layer_hierarchy.cpp index 8db6aeb70..80fb411d4 100644 --- a/phlex/model/level_hierarchy.cpp +++ b/phlex/model/data_layer_hierarchy.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/level_hierarchy.hpp" +#include "phlex/model/data_layer_hierarchy.hpp" #include "phlex/model/data_cell_id.hpp" #include "fmt/format.h" @@ -12,9 +12,9 @@ namespace { namespace phlex::experimental { - level_hierarchy::~level_hierarchy() { print(); } + data_layer_hierarchy::~data_layer_hierarchy() { print(); } - void level_hierarchy::increment_count(data_cell_id_ptr const& id) + void data_layer_hierarchy::increment_count(data_cell_id_ptr const& id) { if (auto it = levels_.find(id->level_hash()); it != levels_.cend()) { ++it->second->count; @@ -27,11 +27,11 @@ namespace phlex::experimental { // which will either refer to the new node in the map, or to the already-emplaced // node. We then increment the count. auto [it, _] = levels_.emplace(id->level_hash(), - std::make_shared(id->level_name(), parent_hash)); + std::make_shared(id->level_name(), parent_hash)); ++it->second->count; } - std::size_t level_hierarchy::count_for(std::string const& level_name) const + std::size_t data_layer_hierarchy::count_for(std::string const& level_name) const { auto it = find_if(begin(levels_), end(levels_), [&level_name](auto const& level) { return level.second->name == level_name; @@ -39,11 +39,12 @@ namespace phlex::experimental { return it != cend(levels_) ? it->second->count.load() : 0; } - void level_hierarchy::print() const { spdlog::info("{}", graph_layout()); } + void data_layer_hierarchy::print() const { spdlog::info("{}", graph_layout()); } - std::string level_hierarchy::pretty_recurse(std::map const& tree, - std::string const& name, - std::string indent) const + std::string data_layer_hierarchy::pretty_recurse( + std::map const& tree, + std::string const& name, + std::string indent) const { auto it = tree.find(name); if (it == cend(tree)) { @@ -66,7 +67,7 @@ namespace phlex::experimental { return result; } - std::string level_hierarchy::graph_layout() const + std::string data_layer_hierarchy::graph_layout() const { if (empty(levels_)) { return {}; diff --git a/phlex/model/level_hierarchy.hpp b/phlex/model/data_layer_hierarchy.hpp similarity index 76% rename from phlex/model/level_hierarchy.hpp rename to phlex/model/data_layer_hierarchy.hpp index 13b66f9db..a64c06896 100644 --- a/phlex/model/level_hierarchy.hpp +++ b/phlex/model/data_layer_hierarchy.hpp @@ -1,5 +1,5 @@ -#ifndef PHLEX_MODEL_LEVEL_HIERARCHY_HPP -#define PHLEX_MODEL_LEVEL_HIERARCHY_HPP +#ifndef PHLEX_MODEL_DATA_LAYER_HIERARCHY_HPP +#define PHLEX_MODEL_DATA_LAYER_HIERARCHY_HPP #include "phlex/model/data_cell_id.hpp" #include "phlex/model/fwd.hpp" @@ -13,9 +13,9 @@ namespace phlex::experimental { - class level_hierarchy { + class data_layer_hierarchy { public: - ~level_hierarchy(); + ~data_layer_hierarchy(); void increment_count(data_cell_id_ptr const& id); std::size_t count_for(std::string const& level_name) const; @@ -30,8 +30,8 @@ namespace phlex::experimental { std::string const& parent_name, std::string indent = {}) const; - struct level_entry { - level_entry(std::string n, std::size_t par_hash) : name{std::move(n)}, parent_hash{par_hash} + struct layer_entry { + layer_entry(std::string n, std::size_t par_hash) : name{std::move(n)}, parent_hash{par_hash} { } @@ -40,9 +40,9 @@ namespace phlex::experimental { std::atomic count{}; }; - tbb::concurrent_unordered_map> levels_; + tbb::concurrent_unordered_map> levels_; }; } -#endif // PHLEX_MODEL_LEVEL_HIERARCHY_HPP +#endif // PHLEX_MODEL_DATA_LAYER_HIERARCHY_HPP diff --git a/phlex/model/fwd.hpp b/phlex/model/fwd.hpp index c1922705f..ec24a1110 100644 --- a/phlex/model/fwd.hpp +++ b/phlex/model/fwd.hpp @@ -5,7 +5,7 @@ namespace phlex::experimental { class level_counter; - class level_hierarchy; + class data_layer_hierarchy; class data_cell_id; class product_store; diff --git a/test/level_counting.cpp b/test/level_counting.cpp index 8261e7b4e..d5d0c8c3b 100644 --- a/test/level_counting.cpp +++ b/test/level_counting.cpp @@ -1,6 +1,6 @@ #include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_layer_hierarchy.hpp" #include "phlex/model/level_counter.hpp" -#include "phlex/model/level_hierarchy.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/hashing.hpp" @@ -39,7 +39,7 @@ TEST_CASE("Counter multiple layers deep", "[data model]") std::size_t processed_subruns{}; std::size_t processed_events{}; - level_hierarchy h; + data_layer_hierarchy h; flush_counters counters; // Notice the wholesale capture by reference--generally a lazy way of doing things. diff --git a/test/multiple_function_registration.cpp b/test/multiple_function_registration.cpp index 71f564035..876fba44a 100644 --- a/test/multiple_function_registration.cpp +++ b/test/multiple_function_registration.cpp @@ -1,5 +1,5 @@ #include "phlex/core/framework_graph.hpp" -#include "phlex/model/level_hierarchy.hpp" +#include "phlex/model/data_layer_hierarchy.hpp" #include "phlex/model/product_store.hpp" #include "catch2/catch_test_macros.hpp" From 998f8d1ead73b71ad557ae4fafd5cc02c3ac20e3 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 21 Nov 2025 10:15:50 -0600 Subject: [PATCH 3/8] Rename level_counter to data_cell_counter --- phlex/core/declared_unfold.cpp | 2 +- phlex/core/framework_graph.cpp | 2 +- phlex/core/store_counters.cpp | 2 +- phlex/core/store_counters.hpp | 2 +- phlex/model/CMakeLists.txt | 2 +- ...evel_counter.cpp => data_cell_counter.cpp} | 16 +++++++------- ...evel_counter.hpp => data_cell_counter.hpp} | 22 +++++++++---------- phlex/model/fwd.hpp | 2 +- test/CMakeLists.txt | 2 +- ...el_counting.cpp => data_cell_counting.cpp} | 6 ++--- 10 files changed, 29 insertions(+), 29 deletions(-) rename phlex/model/{level_counter.cpp => data_cell_counter.cpp} (68%) rename phlex/model/{level_counter.hpp => data_cell_counter.hpp} (73%) rename test/{level_counting.cpp => data_cell_counting.cpp} (96%) diff --git a/phlex/core/declared_unfold.cpp b/phlex/core/declared_unfold.cpp index 05ce2579c..218a1d7bd 100644 --- a/phlex/core/declared_unfold.cpp +++ b/phlex/core/declared_unfold.cpp @@ -1,6 +1,6 @@ #include "phlex/core/declared_unfold.hpp" +#include "phlex/model/data_cell_counter.hpp" #include "phlex/model/handle.hpp" -#include "phlex/model/level_counter.hpp" #include "fmt/std.h" #include "spdlog/spdlog.h" diff --git a/phlex/core/framework_graph.cpp b/phlex/core/framework_graph.cpp index 64520562f..b1a69fbfb 100644 --- a/phlex/core/framework_graph.cpp +++ b/phlex/core/framework_graph.cpp @@ -2,7 +2,7 @@ #include "phlex/concurrency.hpp" #include "phlex/core/edge_maker.hpp" -#include "phlex/model/level_counter.hpp" +#include "phlex/model/data_cell_counter.hpp" #include "phlex/model/product_store.hpp" #include "fmt/std.h" diff --git a/phlex/core/store_counters.cpp b/phlex/core/store_counters.cpp index 07d08831d..0e4cf1922 100644 --- a/phlex/core/store_counters.cpp +++ b/phlex/core/store_counters.cpp @@ -1,5 +1,5 @@ #include "phlex/core/store_counters.hpp" -#include "phlex/model/level_counter.hpp" +#include "phlex/model/data_cell_counter.hpp" #include "fmt/std.h" #include "spdlog/spdlog.h" diff --git a/phlex/core/store_counters.hpp b/phlex/core/store_counters.hpp index 5bab98a95..6780f0043 100644 --- a/phlex/core/store_counters.hpp +++ b/phlex/core/store_counters.hpp @@ -2,8 +2,8 @@ #define PHLEX_CORE_STORE_COUNTERS_HPP #include "phlex/core/fwd.hpp" +#include "phlex/model/data_cell_counter.hpp" #include "phlex/model/data_cell_id.hpp" -#include "phlex/model/level_counter.hpp" #include "phlex/model/product_store.hpp" #include "oneapi/tbb/concurrent_hash_map.h" diff --git a/phlex/model/CMakeLists.txt b/phlex/model/CMakeLists.txt index 00a3c0109..7ae09d7b0 100644 --- a/phlex/model/CMakeLists.txt +++ b/phlex/model/CMakeLists.txt @@ -1,7 +1,7 @@ add_library( phlex_model SHARED algorithm_name.cpp - level_counter.cpp + data_cell_counter.cpp data_layer_hierarchy.cpp data_cell_id.cpp product_matcher.cpp diff --git a/phlex/model/level_counter.cpp b/phlex/model/data_cell_counter.cpp similarity index 68% rename from phlex/model/level_counter.cpp rename to phlex/model/data_cell_counter.cpp index 7d97e3d2d..7f9b38bf7 100644 --- a/phlex/model/level_counter.cpp +++ b/phlex/model/data_cell_counter.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/level_counter.hpp" +#include "phlex/model/data_cell_counter.hpp" #include "phlex/utilities/hashing.hpp" #include @@ -12,26 +12,26 @@ namespace phlex::experimental { { } - level_counter::level_counter() : level_counter{nullptr, "job"} {} + data_cell_counter::data_cell_counter() : data_cell_counter{nullptr, "job"} {} - level_counter::level_counter(level_counter* parent, std::string const& level_name) : + data_cell_counter::data_cell_counter(data_cell_counter* parent, std::string const& level_name) : parent_{parent}, level_hash_{parent_ ? hash(parent->level_hash_, level_name) : hash(level_name)} { } - level_counter::~level_counter() + data_cell_counter::~data_cell_counter() { if (parent_) { parent_->adjust(*this); } } - level_counter level_counter::make_child(std::string const& level_name) + data_cell_counter data_cell_counter::make_child(std::string const& level_name) { return {this, level_name}; } - void level_counter::adjust(level_counter& child) + void data_cell_counter::adjust(data_cell_counter& child) { auto it2 = child_counts_.find(child.level_hash_); if (it2 == cend(child_counts_)) { @@ -45,13 +45,13 @@ namespace phlex::experimental { void flush_counters::update(data_cell_id_ptr const id) { - level_counter* parent_counter = nullptr; + data_cell_counter* parent_counter = nullptr; if (auto parent = id->parent()) { auto it = counters_.find(parent->hash()); assert(it != counters_.cend()); parent_counter = it->second.get(); } - counters_[id->hash()] = std::make_shared(parent_counter, id->level_name()); + counters_[id->hash()] = std::make_shared(parent_counter, id->level_name()); } flush_counts flush_counters::extract(data_cell_id_ptr const id) diff --git a/phlex/model/level_counter.hpp b/phlex/model/data_cell_counter.hpp similarity index 73% rename from phlex/model/level_counter.hpp rename to phlex/model/data_cell_counter.hpp index f328f3279..2424e3c8e 100644 --- a/phlex/model/level_counter.hpp +++ b/phlex/model/data_cell_counter.hpp @@ -1,5 +1,5 @@ -#ifndef PHLEX_MODEL_LEVEL_COUNTER_HPP -#define PHLEX_MODEL_LEVEL_COUNTER_HPP +#ifndef PHLEX_MODEL_DATA_CELL_COUNTER_HPP +#define PHLEX_MODEL_DATA_CELL_COUNTER_HPP #include "phlex/model/data_cell_id.hpp" #include "phlex/model/fwd.hpp" @@ -35,13 +35,13 @@ namespace phlex::experimental { using flush_counts_ptr = std::shared_ptr; - class level_counter { + class data_cell_counter { public: - level_counter(); - level_counter(level_counter* parent, std::string const& level_name); - ~level_counter(); + data_cell_counter(); + data_cell_counter(data_cell_counter* parent, std::string const& level_name); + ~data_cell_counter(); - level_counter make_child(std::string const& level_name); + data_cell_counter make_child(std::string const& level_name); flush_counts result() const { if (empty(child_counts_)) { @@ -51,9 +51,9 @@ namespace phlex::experimental { } private: - void adjust(level_counter& child); + void adjust(data_cell_counter& child); - level_counter* parent_; + data_cell_counter* parent_; data_cell_id::hash_type level_hash_; std::map child_counts_{}; }; @@ -64,8 +64,8 @@ namespace phlex::experimental { flush_counts extract(data_cell_id_ptr const id); private: - std::map> counters_; + std::map> counters_; }; } -#endif // PHLEX_MODEL_LEVEL_COUNTER_HPP +#endif // PHLEX_MODEL_DATA_CELL_COUNTER_HPP diff --git a/phlex/model/fwd.hpp b/phlex/model/fwd.hpp index ec24a1110..63bfe88fc 100644 --- a/phlex/model/fwd.hpp +++ b/phlex/model/fwd.hpp @@ -4,7 +4,7 @@ #include namespace phlex::experimental { - class level_counter; + class data_cell_counter; class data_layer_hierarchy; class data_cell_id; class product_store; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 61512a07b..f0007a736 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -43,7 +43,7 @@ add_catch_test(filter LIBRARIES phlex::core Boost::json) add_catch_test(function_registration LIBRARIES phlex::core Boost::json) add_catch_test(hierarchical_nodes LIBRARIES Boost::json TBB::tbb phlex::core) add_catch_test(multiple_function_registration LIBRARIES Boost::json phlex::core) -add_catch_test(level_counting LIBRARIES phlex::model phlex::utilities) +add_catch_test(data_cell_counting LIBRARIES phlex::model phlex::utilities) add_catch_test(data_cell_id LIBRARIES phlex::model) add_catch_test(product_handle LIBRARIES phlex::core) add_catch_test(product_matcher LIBRARIES phlex::model) diff --git a/test/level_counting.cpp b/test/data_cell_counting.cpp similarity index 96% rename from test/level_counting.cpp rename to test/data_cell_counting.cpp index d5d0c8c3b..53e08e43b 100644 --- a/test/level_counting.cpp +++ b/test/data_cell_counting.cpp @@ -1,6 +1,6 @@ +#include "phlex/model/data_cell_counter.hpp" #include "phlex/model/data_cell_id.hpp" #include "phlex/model/data_layer_hierarchy.hpp" -#include "phlex/model/level_counter.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/hashing.hpp" @@ -14,13 +14,13 @@ namespace { TEST_CASE("Counter with nothing processed", "[data model]") { - level_counter job_counter{}; + data_cell_counter job_counter{}; CHECK(job_counter.result().empty()); } TEST_CASE("Counter one layer deep", "[data model]") { - level_counter job_counter{}; + data_cell_counter job_counter{}; for (std::size_t i = 0; i != 10; ++i) { job_counter.make_child("event"); } From c525dda727751371ab28761224eea26ceb7e4523 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 21 Nov 2025 10:22:24 -0600 Subject: [PATCH 4/8] Rename levels_to_process to cells_to_process --- test/allowed_families.cpp | 4 ++-- test/different_hierarchies.cpp | 4 ++-- test/fold.cpp | 6 +++--- test/hierarchical_nodes.cpp | 8 ++++---- test/memory-checks/many_events.cpp | 4 ++-- test/unfold.cpp | 4 ++-- test/yielding_driver.cpp | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/allowed_families.cpp b/test/allowed_families.cpp index 291cc5c2d..53cc222ad 100644 --- a/test/allowed_families.cpp +++ b/test/allowed_families.cpp @@ -11,7 +11,7 @@ using namespace oneapi::tbb; namespace { - void levels_to_process(framework_driver& driver) + void cells_to_process(framework_driver& driver) { auto job_store = product_store::base(); job_store->add_product("id", *job_store->id()); @@ -52,7 +52,7 @@ namespace { TEST_CASE("Testing families", "[data model]") { - framework_graph g{levels_to_process, 2}; + framework_graph g{cells_to_process, 2}; g.observe("se", check_two_ids).input_family("id"_in("subrun"), "id"_in("event")); g.observe("rs", check_two_ids).input_family("id"_in("run"), "id"_in("subrun")); g.observe("rse", check_three_ids) diff --git a/test/different_hierarchies.cpp b/test/different_hierarchies.cpp index 9f82fdec8..be248629a 100644 --- a/test/different_hierarchies.cpp +++ b/test/different_hierarchies.cpp @@ -50,7 +50,7 @@ namespace { // job -> trigger primitive levels constexpr auto primitive_limit = 10u; - void levels_to_process(framework_driver& driver) + void cells_to_process(framework_driver& driver) { auto job_store = product_store::base(); driver.yield(job_store); @@ -77,7 +77,7 @@ namespace { TEST_CASE("Different hierarchies used with fold", "[graph]") { - framework_graph g{levels_to_process}; + framework_graph g{cells_to_process}; g.fold("run_add", add, concurrency::unlimited, "run", 0u) .input_family("number") diff --git a/test/fold.cpp b/test/fold.cpp index a70bb06c4..b438ff187 100644 --- a/test/fold.cpp +++ b/test/fold.cpp @@ -47,7 +47,7 @@ TEST_CASE("Different levels of fold", "[graph]") constexpr auto index_limit = 2u; constexpr auto number_limit = 5u; - auto levels_to_process = [index_limit, number_limit](framework_driver& driver) { + auto cells_to_process = [index_limit, number_limit](framework_driver& driver) { auto job_store = product_store::base(); driver.yield(job_store); for (unsigned i : std::views::iota(0u, index_limit)) { @@ -61,8 +61,8 @@ TEST_CASE("Different levels of fold", "[graph]") } }; - // framework_graph g{levels_to_process}; - framework_graph g{levels_to_process}; + // framework_graph g{cells_to_process}; + framework_graph g{cells_to_process}; g.fold("run_add", add, concurrency::unlimited, "run") .input_family("number") diff --git a/test/hierarchical_nodes.cpp b/test/hierarchical_nodes.cpp index 4d0d30d92..d50ac1e0b 100644 --- a/test/hierarchical_nodes.cpp +++ b/test/hierarchical_nodes.cpp @@ -38,16 +38,16 @@ namespace { constexpr auto index_limit = 2u; constexpr auto number_limit = 5u; - void levels_to_process(framework_driver& driver) + void cells_to_process(framework_driver& driver) { auto job_store = product_store::base(); driver.yield(job_store); for (unsigned i : std::views::iota(0u, index_limit)) { - auto run_store = job_store->make_child(i, "run", "levels_to_process"); + auto run_store = job_store->make_child(i, "run", "cells_to_process"); run_store->add_product("time", std::time(nullptr)); driver.yield(run_store); for (unsigned j : std::views::iota(0u, number_limit)) { - auto event_store = run_store->make_child(j, "event", "levels_to_process"); + auto event_store = run_store->make_child(j, "event", "cells_to_process"); event_store->add_product("number", i + j); driver.yield(event_store); } @@ -100,7 +100,7 @@ namespace { TEST_CASE("Hierarchical nodes", "[graph]") { - framework_graph g{levels_to_process}; + framework_graph g{cells_to_process}; g.transform("get_the_time", strtime, concurrency::unlimited) .input_family("time") diff --git a/test/memory-checks/many_events.cpp b/test/memory-checks/many_events.cpp index f6175d501..763d93859 100644 --- a/test/memory-checks/many_events.cpp +++ b/test/memory-checks/many_events.cpp @@ -13,7 +13,7 @@ int main() // constexpr auto max_events{1'000'000u}; // spdlog::flush_on(spdlog::level::trace); - auto levels_to_process = [](framework_driver& driver) { + auto cells_to_process = [](framework_driver& driver) { auto job_store = product_store::base(); driver.yield(job_store); @@ -24,7 +24,7 @@ int main() } }; - framework_graph g{levels_to_process}; + framework_graph g{cells_to_process}; g.transform("pass_on", pass_on, concurrency::unlimited) .input_family("number") .output_products("different"); diff --git a/test/unfold.cpp b/test/unfold.cpp index 0daa5b8e3..448320080 100644 --- a/test/unfold.cpp +++ b/test/unfold.cpp @@ -84,7 +84,7 @@ TEST_CASE("Splitting the processing", "[graph]") { constexpr auto index_limit = 2u; - auto levels_to_process = [index_limit](auto& driver) { + auto cells_to_process = [index_limit](auto& driver) { auto job_store = product_store::base(); driver.yield(job_store); for (unsigned i : std::views::iota(0u, index_limit)) { @@ -95,7 +95,7 @@ TEST_CASE("Splitting the processing", "[graph]") } }; - framework_graph g{levels_to_process}; + framework_graph g{cells_to_process}; g.unfold(&iota::predicate, &iota::unfold, concurrency::unlimited, "lower1") .input_family("max_number") diff --git a/test/yielding_driver.cpp b/test/yielding_driver.cpp index 264e11ea1..67dd59602 100644 --- a/test/yielding_driver.cpp +++ b/test/yielding_driver.cpp @@ -13,7 +13,7 @@ using namespace phlex::experimental; -void levels_to_process(async_driver& d) +void cells_to_process(async_driver& d) { unsigned int const num_runs = 2; unsigned int const num_subruns = 2; @@ -36,7 +36,7 @@ void levels_to_process(async_driver& d) int main() { - async_driver drive{levels_to_process}; + async_driver drive{cells_to_process}; tbb::flow::graph g{}; tbb::flow::input_node source{g, [&drive](tbb::flow_control& fc) -> data_cell_id_ptr { if (auto next = drive()) { From 10fea68d505f108e5018907001ed2fd8ec1e468c Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 21 Nov 2025 10:32:12 -0600 Subject: [PATCH 5/8] Address remaining instances of the term "level" --- phlex/core/cached_product_stores.hpp | 2 +- phlex/core/declared_fold.hpp | 4 ++-- phlex/core/declared_transform.hpp | 2 +- phlex/core/declared_unfold.cpp | 8 ++++---- phlex/core/declared_unfold.hpp | 14 +++++++------- phlex/core/framework_graph.cpp | 6 +++--- phlex/core/framework_graph.hpp | 8 ++++---- phlex/core/multiplexer.cpp | 4 ++-- phlex/core/store_counters.cpp | 6 +++--- phlex/core/store_counters.hpp | 2 +- phlex/model/data_cell_counter.cpp | 18 +++++++++--------- phlex/model/data_cell_counter.hpp | 10 +++++----- phlex/model/data_cell_id.cpp | 26 +++++++++++++------------- phlex/model/data_cell_id.hpp | 14 +++++++------- phlex/model/data_layer_hierarchy.cpp | 28 ++++++++++++++-------------- phlex/model/data_layer_hierarchy.hpp | 4 ++-- phlex/model/product_store.cpp | 22 +++++++++++----------- phlex/model/product_store.hpp | 12 ++++++------ test/data_cell_id.cpp | 2 +- 19 files changed, 96 insertions(+), 96 deletions(-) diff --git a/phlex/core/cached_product_stores.hpp b/phlex/core/cached_product_stores.hpp index 641f37231..c874f9a1b 100644 --- a/phlex/core/cached_product_stores.hpp +++ b/phlex/core/cached_product_stores.hpp @@ -23,7 +23,7 @@ namespace phlex::experimental { } return new_store( get_store(id->parent()) - ->make_child(id->number(), id->level_name(), source_name_, stage::process)); + ->make_child(id->number(), id->layer_name(), source_name_, stage::process)); } private: diff --git a/phlex/core/declared_fold.hpp b/phlex/core/declared_fold.hpp index cc398c0f8..4482b58d6 100644 --- a/phlex/core/declared_fold.hpp +++ b/phlex/core/declared_fold.hpp @@ -92,7 +92,7 @@ namespace phlex::experimental { if (store->is_flush()) { // Downstream nodes always get the flush. get<0>(outputs).try_put(msg); - if (store->id()->level_name() != partition_) { + if (store->id()->layer_name() != partition_) { return; } } @@ -105,7 +105,7 @@ namespace phlex::experimental { counter_for(id_hash_for_counter).set_flush_value(store, original_message_id); } else { call(ft, messages, std::make_index_sequence{}); - counter_for(id_hash_for_counter).increment(store->id()->level_hash()); + counter_for(id_hash_for_counter).increment(store->id()->layer_hash()); } if (auto counter = done_with(id_hash_for_counter)) { diff --git a/phlex/core/declared_transform.hpp b/phlex/core/declared_transform.hpp index 3d1d7fb5e..bfe01fb98 100644 --- a/phlex/core/declared_transform.hpp +++ b/phlex/core/declared_transform.hpp @@ -101,7 +101,7 @@ namespace phlex::experimental { if (stores_.insert(a, store->id()->hash())) { auto result = call(ft, messages, std::make_index_sequence{}); ++calls_; - ++product_count_[store->id()->level_hash()]; + ++product_count_[store->id()->layer_hash()]; products new_products; new_products.add_all(output_, std::move(result)); a->second = diff --git a/phlex/core/declared_unfold.cpp b/phlex/core/declared_unfold.cpp index 218a1d7bd..bd8f5639a 100644 --- a/phlex/core/declared_unfold.cpp +++ b/phlex/core/declared_unfold.cpp @@ -9,17 +9,17 @@ namespace phlex::experimental { generator::generator(product_store_const_ptr const& parent, std::string node_name, - std::string const& new_level_name) : + std::string const& new_layer_name) : parent_{std::const_pointer_cast(parent)}, node_name_{std::move(node_name)}, - new_level_name_{new_level_name} + new_layer_name_{new_layer_name} { } product_store_const_ptr generator::make_child(std::size_t const i, products new_products) { - auto child = parent_->make_child(i, new_level_name_, node_name_, std::move(new_products)); - ++child_counts_[child->id()->level_hash()]; + auto child = parent_->make_child(i, new_layer_name_, node_name_, std::move(new_products)); + ++child_counts_[child->id()->layer_hash()]; return child; } diff --git a/phlex/core/declared_unfold.hpp b/phlex/core/declared_unfold.hpp index e59cf030b..3e27a783a 100644 --- a/phlex/core/declared_unfold.hpp +++ b/phlex/core/declared_unfold.hpp @@ -37,7 +37,7 @@ namespace phlex::experimental { public: explicit generator(product_store_const_ptr const& parent, std::string node_name, - std::string const& new_level_name); + std::string const& new_layer_name); product_store_const_ptr flush_store() const; product_store_const_ptr make_child_for(std::size_t const level_number, products new_products) @@ -49,7 +49,7 @@ namespace phlex::experimental { product_store_const_ptr make_child(std::size_t i, products new_products); product_store_ptr parent_; std::string node_name_; - std::string const& new_level_name_; + std::string const& new_layer_name_; std::map child_counts_; }; @@ -93,12 +93,12 @@ namespace phlex::experimental { Unfold&& unfold, product_queries product_labels, std::vector output_products, - std::string new_level_name) : + std::string new_layer_name) : declared_unfold{std::move(name), std::move(predicates), std::move(product_labels)}, output_{to_product_specifications(full_name(), std::move(output_products), make_type_ids>>())}, - new_level_name_{std::move(new_level_name)}, + new_layer_name_{std::move(new_layer_name)}, join_{make_join_or_none(g, std::make_index_sequence{})}, unfold_{ g, @@ -112,7 +112,7 @@ namespace phlex::experimental { std::get<0>(output).try_put(msg); } else if (accessor a; stores_.insert(a, store->id()->hash())) { std::size_t const original_message_id{msg_counter_}; - generator g{msg.store, this->full_name(), new_level_name_}; + generator g{msg.store, this->full_name(), new_layer_name_}; call(p, ufold, msg.store->id(), g, msg.eom, messages, std::make_index_sequence{}); message const flush_msg{g.flush_store(), msg.eom, ++msg_counter_, original_message_id}; @@ -156,7 +156,7 @@ namespace phlex::experimental { auto running_value = obj.initial_value(); while (std::invoke(predicate, obj, running_value)) { products new_products; - auto new_id = unfolded_id->make_child(counter, new_level_name_); + auto new_id = unfolded_id->make_child(counter, new_layer_name_); if constexpr (requires { std::invoke(unfold, obj, running_value, *new_id); }) { auto [next_value, prods] = std::invoke(unfold, obj, running_value, *new_id); new_products.add_all(output_, std::move(prods)); @@ -178,7 +178,7 @@ namespace phlex::experimental { input_retriever_types input_{input_arguments()}; product_specifications output_; - std::string new_level_name_; + std::string new_layer_name_; join_or_none_t join_; tbb::flow::multifunction_node, messages_t<1u>> unfold_; tbb::concurrent_hash_map stores_; diff --git a/phlex/core/framework_graph.cpp b/phlex/core/framework_graph.cpp index b1a69fbfb..aae1fe9e3 100644 --- a/phlex/core/framework_graph.cpp +++ b/phlex/core/framework_graph.cpp @@ -13,7 +13,7 @@ #include namespace phlex::experimental { - level_sentry::level_sentry(flush_counters& counters, + layer_sentry::layer_sentry(flush_counters& counters, message_sender& sender, product_store_ptr store) : counters_{counters}, sender_{sender}, store_{store}, depth_{store_->id()->depth()} @@ -21,7 +21,7 @@ namespace phlex::experimental { counters_.update(store_->id()); } - level_sentry::~level_sentry() + layer_sentry::~layer_sentry() { auto flush_result = counters_.extract(store_->id()); auto flush_store = store_->make_flush(); @@ -32,7 +32,7 @@ namespace phlex::experimental { sender_.send_flush(std::move(flush_store)); } - std::size_t level_sentry::depth() const noexcept { return depth_; } + std::size_t layer_sentry::depth() const noexcept { return depth_; } framework_graph::framework_graph(product_store_ptr store, int const max_parallelism) : framework_graph{[store](framework_driver& driver) { driver.yield(store); }, max_parallelism} diff --git a/phlex/core/framework_graph.hpp b/phlex/core/framework_graph.hpp index 7757eecce..fbfe367bf 100644 --- a/phlex/core/framework_graph.hpp +++ b/phlex/core/framework_graph.hpp @@ -32,10 +32,10 @@ namespace phlex::experimental { class configuration; - class level_sentry { + class layer_sentry { public: - level_sentry(flush_counters& counters, message_sender& sender, product_store_ptr store); - ~level_sentry(); + layer_sentry(flush_counters& counters, message_sender& sender, product_store_ptr store); + ~layer_sentry(); std::size_t depth() const noexcept; private: @@ -146,7 +146,7 @@ namespace phlex::experimental { message_sender sender_{hierarchy_, multiplexer_, eoms_}; std::queue pending_stores_; flush_counters counters_; - std::stack levels_; + std::stack levels_; bool shutdown_{false}; }; } diff --git a/phlex/core/multiplexer.cpp b/phlex/core/multiplexer.cpp index 2ac6f57d9..d991ea307 100644 --- a/phlex/core/multiplexer.cpp +++ b/phlex/core/multiplexer.cpp @@ -20,7 +20,7 @@ namespace { if (family.empty()) { return store->store_for_product(product_name.full()); } - if (store->level_name() == family and store->contains_product(product_name.full())) { + if (store->layer_name() == family and store->contains_product(product_name.full())) { return store; } auto parent = store->parent(family); @@ -57,7 +57,7 @@ namespace { } if (auto const& allowed_family = product_label.family; not allowed_family.empty()) { - if (store_to_send->level_name() != allowed_family) { + if (store_to_send->layer_name() != allowed_family) { continue; } } diff --git a/phlex/core/store_counters.cpp b/phlex/core/store_counters.cpp index 0e4cf1922..006f5ee14 100644 --- a/phlex/core/store_counters.cpp +++ b/phlex/core/store_counters.cpp @@ -52,7 +52,7 @@ namespace phlex::experimental { original_message_id_ = original_message_id; } - void store_counter::increment(data_cell_id::hash_type const level_hash) { ++counts_[level_hash]; } + void store_counter::increment(data_cell_id::hash_type const layer_hash) { ++counts_[layer_hash]; } bool store_counter::is_complete() { @@ -75,8 +75,8 @@ namespace phlex::experimental { return false; } - for (auto const& [level_hash, count] : counts_) { - auto maybe_count = flush_counts->count_for(level_hash); + for (auto const& [layer_hash, count] : counts_) { + auto maybe_count = flush_counts->count_for(layer_hash); if (!maybe_count or count != *maybe_count) { return false; } diff --git a/phlex/core/store_counters.hpp b/phlex/core/store_counters.hpp index 6780f0043..4406ccb06 100644 --- a/phlex/core/store_counters.hpp +++ b/phlex/core/store_counters.hpp @@ -45,7 +45,7 @@ namespace phlex::experimental { class store_counter { public: void set_flush_value(product_store_const_ptr const& ptr, std::size_t original_message_id); - void increment(data_cell_id::hash_type level_hash); + void increment(data_cell_id::hash_type layer_hash); bool is_complete(); unsigned int original_message_id() const noexcept; diff --git a/phlex/model/data_cell_counter.cpp b/phlex/model/data_cell_counter.cpp index 7f9b38bf7..e52c8647b 100644 --- a/phlex/model/data_cell_counter.cpp +++ b/phlex/model/data_cell_counter.cpp @@ -14,8 +14,8 @@ namespace phlex::experimental { data_cell_counter::data_cell_counter() : data_cell_counter{nullptr, "job"} {} - data_cell_counter::data_cell_counter(data_cell_counter* parent, std::string const& level_name) : - parent_{parent}, level_hash_{parent_ ? hash(parent->level_hash_, level_name) : hash(level_name)} + data_cell_counter::data_cell_counter(data_cell_counter* parent, std::string const& layer_name) : + parent_{parent}, layer_hash_{parent_ ? hash(parent->layer_hash_, layer_name) : hash(layer_name)} { } @@ -26,20 +26,20 @@ namespace phlex::experimental { } } - data_cell_counter data_cell_counter::make_child(std::string const& level_name) + data_cell_counter data_cell_counter::make_child(std::string const& layer_name) { - return {this, level_name}; + return {this, layer_name}; } void data_cell_counter::adjust(data_cell_counter& child) { - auto it2 = child_counts_.find(child.level_hash_); + auto it2 = child_counts_.find(child.layer_hash_); if (it2 == cend(child_counts_)) { - it2 = child_counts_.try_emplace(child.level_hash_, 0).first; + it2 = child_counts_.try_emplace(child.layer_hash_, 0).first; } ++it2->second; - for (auto const& [nested_level_hash, count] : child.child_counts_) { - child_counts_[nested_level_hash] += count; + for (auto const& [nested_layer_hash, count] : child.child_counts_) { + child_counts_[nested_layer_hash] += count; } } @@ -51,7 +51,7 @@ namespace phlex::experimental { assert(it != counters_.cend()); parent_counter = it->second.get(); } - counters_[id->hash()] = std::make_shared(parent_counter, id->level_name()); + counters_[id->hash()] = std::make_shared(parent_counter, id->layer_name()); } flush_counts flush_counters::extract(data_cell_id_ptr const id) diff --git a/phlex/model/data_cell_counter.hpp b/phlex/model/data_cell_counter.hpp index 2424e3c8e..541125b50 100644 --- a/phlex/model/data_cell_counter.hpp +++ b/phlex/model/data_cell_counter.hpp @@ -21,9 +21,9 @@ namespace phlex::experimental { bool empty() const { return child_counts_.empty(); } auto size() const { return child_counts_.size(); } - std::optional count_for(data_cell_id::hash_type const level_hash) const + std::optional count_for(data_cell_id::hash_type const layer_hash) const { - if (auto it = child_counts_.find(level_hash); it != child_counts_.end()) { + if (auto it = child_counts_.find(layer_hash); it != child_counts_.end()) { return it->second; } return std::nullopt; @@ -38,10 +38,10 @@ namespace phlex::experimental { class data_cell_counter { public: data_cell_counter(); - data_cell_counter(data_cell_counter* parent, std::string const& level_name); + data_cell_counter(data_cell_counter* parent, std::string const& layer_name); ~data_cell_counter(); - data_cell_counter make_child(std::string const& level_name); + data_cell_counter make_child(std::string const& layer_name); flush_counts result() const { if (empty(child_counts_)) { @@ -54,7 +54,7 @@ namespace phlex::experimental { void adjust(data_cell_counter& child); data_cell_counter* parent_; - data_cell_id::hash_type level_hash_; + data_cell_id::hash_type layer_hash_; std::map child_counts_{}; }; diff --git a/phlex/model/data_cell_id.cpp b/phlex/model/data_cell_id.cpp index 054b74888..aa1afa732 100644 --- a/phlex/model/data_cell_id.cpp +++ b/phlex/model/data_cell_id.cpp @@ -31,17 +31,17 @@ namespace { namespace phlex::experimental { data_cell_id::data_cell_id() : - level_name_{"job"}, level_hash_{phlex::experimental::hash(level_name_)} + layer_name_{"job"}, layer_hash_{phlex::experimental::hash(layer_name_)} { } - data_cell_id::data_cell_id(data_cell_id_ptr parent, std::size_t i, std::string level_name) : + data_cell_id::data_cell_id(data_cell_id_ptr parent, std::size_t i, std::string layer_name) : parent_{std::move(parent)}, number_{i}, - level_name_{std::move(level_name)}, - level_hash_{phlex::experimental::hash(parent_->level_hash_, level_name_)}, + layer_name_{std::move(layer_name)}, + layer_hash_{phlex::experimental::hash(parent_->layer_hash_, layer_name_)}, depth_{parent_->depth_ + 1}, - hash_{phlex::experimental::hash(parent_->hash_, number_, level_hash_)} + hash_{phlex::experimental::hash(parent_->hash_, number_, layer_hash_)} { // FIXME: Should it be an error to create an ID with an empty name? } @@ -53,21 +53,21 @@ namespace phlex::experimental { return base_id; } - std::string const& data_cell_id::level_name() const noexcept { return level_name_; } + std::string const& data_cell_id::layer_name() const noexcept { return layer_name_; } std::size_t data_cell_id::depth() const noexcept { return depth_; } data_cell_id_ptr data_cell_id::make_child(std::size_t const new_level_number, - std::string new_level_name) const + std::string new_layer_name) const { return data_cell_id_ptr{ - new data_cell_id{shared_from_this(), new_level_number, std::move(new_level_name)}}; + new data_cell_id{shared_from_this(), new_level_number, std::move(new_layer_name)}}; } bool data_cell_id::has_parent() const noexcept { return static_cast(parent_); } std::size_t data_cell_id::number() const { return number_; } std::size_t data_cell_id::hash() const noexcept { return hash_; } - std::size_t data_cell_id::level_hash() const noexcept { return level_hash_; } + std::size_t data_cell_id::layer_hash() const noexcept { return layer_hash_; } bool data_cell_id::operator==(data_cell_id const& other) const { @@ -115,11 +115,11 @@ namespace phlex::experimental { data_cell_id_ptr data_cell_id::parent() const noexcept { return parent_; } - data_cell_id_ptr data_cell_id::parent(std::string const& level_name) const + data_cell_id_ptr data_cell_id::parent(std::string const& layer_name) const { data_cell_id_ptr parent = parent_; while (parent) { - if (parent->level_name_ == level_name) { + if (parent->layer_name_ == layer_name) { return parent; } parent = parent->parent_; @@ -147,10 +147,10 @@ namespace phlex::experimental { std::string data_cell_id::to_string_this_level() const { - if (empty(level_name_)) { + if (empty(layer_name_)) { return std::to_string(number_); } - return level_name_ + ":" + std::to_string(number_); + return layer_name_ + ":" + std::to_string(number_); } std::ostream& operator<<(std::ostream& os, data_cell_id const& id) diff --git a/phlex/model/data_cell_id.hpp b/phlex/model/data_cell_id.hpp index 51aceca90..eb5098f8a 100644 --- a/phlex/model/data_cell_id.hpp +++ b/phlex/model/data_cell_id.hpp @@ -18,15 +18,15 @@ namespace phlex::experimental { static data_cell_id_ptr base_ptr(); using hash_type = std::size_t; - data_cell_id_ptr make_child(std::size_t new_level_number, std::string level_name) const; - std::string const& level_name() const noexcept; + data_cell_id_ptr make_child(std::size_t new_level_number, std::string layer_name) const; + std::string const& layer_name() const noexcept; std::size_t depth() const noexcept; - data_cell_id_ptr parent(std::string const& level_name) const; + data_cell_id_ptr parent(std::string const& layer_name) const; data_cell_id_ptr parent() const noexcept; bool has_parent() const noexcept; std::size_t number() const; std::size_t hash() const noexcept; - std::size_t level_hash() const noexcept; + std::size_t layer_hash() const noexcept; bool operator==(data_cell_id const& other) const; bool operator<(data_cell_id const& other) const; @@ -37,11 +37,11 @@ namespace phlex::experimental { private: data_cell_id(); - explicit data_cell_id(data_cell_id_ptr parent, std::size_t i, std::string level_name); + explicit data_cell_id(data_cell_id_ptr parent, std::size_t i, std::string layer_name); data_cell_id_ptr parent_{nullptr}; std::size_t number_{-1ull}; - std::string level_name_; - std::size_t level_hash_; + std::string layer_name_; + std::size_t layer_hash_; std::size_t depth_{}; hash_type hash_{0}; }; diff --git a/phlex/model/data_layer_hierarchy.cpp b/phlex/model/data_layer_hierarchy.cpp index 80fb411d4..2aaf5ddf6 100644 --- a/phlex/model/data_layer_hierarchy.cpp +++ b/phlex/model/data_layer_hierarchy.cpp @@ -16,27 +16,27 @@ namespace phlex::experimental { void data_layer_hierarchy::increment_count(data_cell_id_ptr const& id) { - if (auto it = levels_.find(id->level_hash()); it != levels_.cend()) { + if (auto it = layers_.find(id->layer_hash()); it != layers_.cend()) { ++it->second->count; return; } - auto const parent_hash = id->has_parent() ? id->parent()->level_hash() : -1ull; + auto const parent_hash = id->has_parent() ? id->parent()->layer_hash() : -1ull; // Warning: It can happen that two threads get to this location at the same time. To // guard against overwriting the value of "count", we use the returned iterator "it", // which will either refer to the new node in the map, or to the already-emplaced // node. We then increment the count. - auto [it, _] = levels_.emplace(id->level_hash(), - std::make_shared(id->level_name(), parent_hash)); + auto [it, _] = layers_.emplace(id->layer_hash(), + std::make_shared(id->layer_name(), parent_hash)); ++it->second->count; } - std::size_t data_layer_hierarchy::count_for(std::string const& level_name) const + std::size_t data_layer_hierarchy::count_for(std::string const& layer_name) const { - auto it = find_if(begin(levels_), end(levels_), [&level_name](auto const& level) { - return level.second->name == level_name; + auto it = find_if(begin(layers_), end(layers_), [&layer_name](auto const& level) { + return level.second->name == layer_name; }); - return it != cend(levels_) ? it->second->count.load() : 0; + return it != cend(layers_) ? it->second->count.load() : 0; } void data_layer_hierarchy::print() const { spdlog::info("{}", graph_layout()); } @@ -56,7 +56,7 @@ namespace phlex::experimental { for (std::size_t i = 0; auto const& [child_name, child_hash] : it->second) { bool const at_end = ++i == n; auto child_prefix = !at_end ? indent + " ├ " : indent + " └ "; - auto const& entry = *levels_.at(child_hash); + auto const& entry = *layers_.at(child_hash); result += "\n" + indent + " │ "; result += fmt::format("\n{}{}: {}", child_prefix, maybe_name(child_name), entry.count); @@ -69,18 +69,18 @@ namespace phlex::experimental { std::string data_layer_hierarchy::graph_layout() const { - if (empty(levels_)) { + if (empty(layers_)) { return {}; } std::map> tree; - for (auto const& [level_hash, level_entry] : levels_) { - auto parent_hash = level_entry->parent_hash; + for (auto const& [layer_hash, layer_entry] : layers_) { + auto parent_hash = layer_entry->parent_hash; if (parent_hash == -1ull) { continue; } - auto const& parent_name = levels_.at(parent_hash)->name; - tree[parent_name].emplace_back(level_entry->name, level_hash); + auto const& parent_name = layers_.at(parent_hash)->name; + tree[parent_name].emplace_back(layer_entry->name, layer_hash); } auto const initial_indent = " "; diff --git a/phlex/model/data_layer_hierarchy.hpp b/phlex/model/data_layer_hierarchy.hpp index a64c06896..3b8025b1a 100644 --- a/phlex/model/data_layer_hierarchy.hpp +++ b/phlex/model/data_layer_hierarchy.hpp @@ -17,7 +17,7 @@ namespace phlex::experimental { public: ~data_layer_hierarchy(); void increment_count(data_cell_id_ptr const& id); - std::size_t count_for(std::string const& level_name) const; + std::size_t count_for(std::string const& layer_name) const; void print() const; @@ -40,7 +40,7 @@ namespace phlex::experimental { std::atomic count{}; }; - tbb::concurrent_unordered_map> levels_; + tbb::concurrent_unordered_map> layers_; }; } diff --git a/phlex/model/product_store.cpp b/phlex/model/product_store.cpp index 5773d7976..5735c3e40 100644 --- a/phlex/model/product_store.cpp +++ b/phlex/model/product_store.cpp @@ -21,12 +21,12 @@ namespace phlex::experimental { product_store::product_store(product_store_const_ptr parent, std::size_t new_level_number, - std::string const& new_level_name, + std::string const& new_layer_name, std::string source, products new_products) : parent_{parent}, products_{std::move(new_products)}, - id_{parent->id()->make_child(new_level_number, new_level_name)}, + id_{parent->id()->make_child(new_level_number, new_layer_name)}, source_{std::move(source)}, stage_{stage::process} { @@ -34,11 +34,11 @@ namespace phlex::experimental { product_store::product_store(product_store_const_ptr parent, std::size_t new_level_number, - std::string const& new_level_name, + std::string const& new_layer_name, std::string source, stage processing_stage) : parent_{parent}, - id_{parent->id()->make_child(new_level_number, new_level_name)}, + id_{parent->id()->make_child(new_level_number, new_layer_name)}, source_{std::move(source)}, stage_{processing_stage} { @@ -52,11 +52,11 @@ namespace phlex::experimental { new product_store{nullptr, data_cell_id::base_ptr(), std::move(base_name)}}; } - product_store_const_ptr product_store::parent(std::string const& level_name) const noexcept + product_store_const_ptr product_store::parent(std::string const& layer_name) const noexcept { auto store = parent_; while (store != nullptr) { - if (store->level_name() == level_name) { + if (store->layer_name() == layer_name) { return store; } store = store->parent_; @@ -89,27 +89,27 @@ namespace phlex::experimental { } product_store_ptr product_store::make_child(std::size_t new_level_number, - std::string const& new_level_name, + std::string const& new_layer_name, std::string source, products new_products) { return product_store_ptr{new product_store{shared_from_this(), new_level_number, - new_level_name, + new_layer_name, std::move(source), std::move(new_products)}}; } product_store_ptr product_store::make_child(std::size_t new_level_number, - std::string const& new_level_name, + std::string const& new_layer_name, std::string source, stage processing_stage) { return product_store_ptr{new product_store{ - shared_from_this(), new_level_number, new_level_name, std::move(source), processing_stage}}; + shared_from_this(), new_level_number, new_layer_name, std::move(source), processing_stage}}; } - std::string const& product_store::level_name() const noexcept { return id_->level_name(); } + std::string const& product_store::layer_name() const noexcept { return id_->layer_name(); } std::string const& product_store::source() const noexcept { return source_; } product_store_const_ptr product_store::parent() const noexcept { return parent_; } data_cell_id_ptr const& product_store::id() const noexcept { return id_; } diff --git a/phlex/model/product_store.hpp b/phlex/model/product_store.hpp index 4fe82ff74..cb53b6287 100644 --- a/phlex/model/product_store.hpp +++ b/phlex/model/product_store.hpp @@ -24,18 +24,18 @@ namespace phlex::experimental { auto begin() const noexcept { return products_.begin(); } auto end() const noexcept { return products_.end(); } - std::string const& level_name() const noexcept; + std::string const& layer_name() const noexcept; std::string const& source() const noexcept; - product_store_const_ptr parent(std::string const& level_name) const noexcept; + product_store_const_ptr parent(std::string const& layer_name) const noexcept; product_store_const_ptr parent() const noexcept; product_store_ptr make_flush() const; product_store_ptr make_continuation(std::string source, products new_products = {}) const; product_store_ptr make_child(std::size_t new_level_number, - std::string const& new_level_name, + std::string const& new_layer_name, std::string source, products new_products); product_store_ptr make_child(std::size_t new_level_number, - std::string const& new_level_name, + std::string const& new_layer_name, std::string source = {}, stage st = stage::process); data_cell_id_ptr const& id() const noexcept; @@ -65,12 +65,12 @@ namespace phlex::experimental { products new_products = {}); explicit product_store(product_store_const_ptr parent, std::size_t new_level_number, - std::string const& new_level_name, + std::string const& new_layer_name, std::string source, products new_products); explicit product_store(product_store_const_ptr parent, std::size_t new_level_number, - std::string const& new_level_name, + std::string const& new_layer_name, std::string source, stage processing_stage); diff --git a/test/data_cell_id.cpp b/test/data_cell_id.cpp index 30d826926..00463cb46 100644 --- a/test/data_cell_id.cpp +++ b/test/data_cell_id.cpp @@ -30,5 +30,5 @@ TEST_CASE("Verify independent hashes", "[data model]") auto event_4999 = subrun_1->make_child(4999, "event"); CHECK(event_760->hash() != event_4999->hash()); - CHECK(event_760->level_hash() == event_4999->level_hash()); + CHECK(event_760->layer_hash() == event_4999->layer_hash()); } From 5668336992e636e5590d5f7890c495252eeca44b Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Mon, 1 Dec 2025 08:50:03 -0600 Subject: [PATCH 6/8] Rename data_cell_id to data_cell_index --- phlex/core/cached_product_stores.hpp | 8 +-- phlex/core/declared_fold.hpp | 4 +- phlex/core/declared_observer.cpp | 2 +- phlex/core/declared_observer.hpp | 4 +- phlex/core/declared_predicate.hpp | 4 +- phlex/core/declared_transform.hpp | 4 +- phlex/core/declared_unfold.hpp | 10 +-- phlex/core/end_of_message.cpp | 7 +- phlex/core/end_of_message.hpp | 10 +-- phlex/core/message.cpp | 2 +- phlex/core/message_sender.hpp | 2 +- phlex/core/multiplexer.hpp | 2 +- phlex/core/store_counters.cpp | 11 ++-- phlex/core/store_counters.hpp | 17 ++--- phlex/model/CMakeLists.txt | 2 +- phlex/model/data_cell_counter.cpp | 6 +- phlex/model/data_cell_counter.hpp | 18 ++--- phlex/model/data_cell_id.hpp | 65 ------------------- .../{data_cell_id.cpp => data_cell_index.cpp} | 60 ++++++++--------- phlex/model/data_cell_index.hpp | 65 +++++++++++++++++++ phlex/model/data_layer_hierarchy.cpp | 4 +- phlex/model/data_layer_hierarchy.hpp | 4 +- phlex/model/fwd.hpp | 4 +- phlex/model/handle.hpp | 12 ++-- phlex/model/product_matcher.cpp | 10 +-- phlex/model/product_matcher.hpp | 4 +- phlex/model/product_store.cpp | 8 +-- phlex/model/product_store.hpp | 8 +-- test/CMakeLists.txt | 2 +- test/allowed_families.cpp | 10 +-- test/benchmarks/accept_even_ids.cpp | 4 +- test/benchmarks/last_index.cpp | 4 +- test/benchmarks/read_id.cpp | 4 +- test/benchmarks/read_index.cpp | 2 +- test/cached_product_stores.cpp | 12 ++-- test/data_cell_counting.cpp | 2 +- .../{data_cell_id.cpp => data_cell_index.cpp} | 8 +-- test/demo-giantdata/unfold_transform_fold.cpp | 26 ++++---- test/fold.cpp | 4 +- test/hierarchical_nodes.cpp | 8 +-- test/mock-workflow/MC_truth_algorithm.cpp | 2 +- test/mock-workflow/three_tuple_algorithm.cpp | 2 +- test/product_handle.cpp | 30 ++++----- test/product_matcher.cpp | 20 +++--- test/unfold.cpp | 8 +-- test/yielding_driver.cpp | 12 ++-- 46 files changed, 263 insertions(+), 254 deletions(-) delete mode 100644 phlex/model/data_cell_id.hpp rename phlex/model/{data_cell_id.cpp => data_cell_index.cpp} (58%) create mode 100644 phlex/model/data_cell_index.hpp rename test/{data_cell_id.cpp => data_cell_index.cpp} (82%) diff --git a/phlex/core/cached_product_stores.hpp b/phlex/core/cached_product_stores.hpp index c874f9a1b..706279e69 100644 --- a/phlex/core/cached_product_stores.hpp +++ b/phlex/core/cached_product_stores.hpp @@ -4,7 +4,7 @@ // FIXME: only intended to be used in a single-threaded context as std::map is not // thread-safe. -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/fwd.hpp" #include "phlex/model/product_store.hpp" @@ -12,13 +12,13 @@ namespace phlex::experimental { class cached_product_stores { public: - product_store_ptr get_store(data_cell_id_ptr id = data_cell_id::base_ptr()) + product_store_ptr get_store(data_cell_index_ptr id = data_cell_index::base_ptr()) { auto it = product_stores_.find(id->hash()); if (it != cend(product_stores_)) { return it->second; } - if (id == data_cell_id::base_ptr()) { + if (id == data_cell_index::base_ptr()) { return new_store(product_store::base()); } return new_store( @@ -33,7 +33,7 @@ namespace phlex::experimental { } std::string const source_name_{"Source"}; - std::map product_stores_{}; + std::map product_stores_{}; }; } diff --git a/phlex/core/declared_fold.hpp b/phlex/core/declared_fold.hpp index 4482b58d6..fdabc8e36 100644 --- a/phlex/core/declared_fold.hpp +++ b/phlex/core/declared_fold.hpp @@ -11,7 +11,7 @@ #include "phlex/core/products_consumer.hpp" #include "phlex/core/store_counters.hpp" #include "phlex/model/algorithm_name.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/handle.hpp" #include "phlex/model/product_specification.hpp" #include "phlex/model/product_store.hpp" @@ -179,7 +179,7 @@ namespace phlex::experimental { std::string partition_; join_or_none_t join_; tbb::flow::multifunction_node, messages_t<1>> fold_; - tbb::concurrent_unordered_map> results_; + tbb::concurrent_unordered_map> results_; std::atomic calls_; std::atomic product_count_; }; diff --git a/phlex/core/declared_observer.cpp b/phlex/core/declared_observer.cpp index d13cb470d..2f53f66e9 100644 --- a/phlex/core/declared_observer.cpp +++ b/phlex/core/declared_observer.cpp @@ -14,7 +14,7 @@ namespace phlex::experimental { declared_observer::~declared_observer() = default; void declared_observer::report_cached_hashes( - tbb::concurrent_hash_map const& hashes) const + tbb::concurrent_hash_map const& hashes) const { if (hashes.size() > 0ull) { spdlog::warn("Monitor {} has {} cached hashes.", full_name(), hashes.size()); diff --git a/phlex/core/declared_observer.hpp b/phlex/core/declared_observer.hpp index b38325d54..568a0a925 100644 --- a/phlex/core/declared_observer.hpp +++ b/phlex/core/declared_observer.hpp @@ -10,7 +10,7 @@ #include "phlex/core/store_counters.hpp" #include "phlex/metaprogramming/type_deduction.hpp" #include "phlex/model/algorithm_name.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/handle.hpp" #include "phlex/model/product_specification.hpp" #include "phlex/model/product_store.hpp" @@ -38,7 +38,7 @@ namespace phlex::experimental { virtual ~declared_observer(); protected: - using hashes_t = tbb::concurrent_hash_map; + using hashes_t = tbb::concurrent_hash_map; using accessor = hashes_t::accessor; void report_cached_hashes(hashes_t const& hashes) const; diff --git a/phlex/core/declared_predicate.hpp b/phlex/core/declared_predicate.hpp index 193aee20c..b9709ebdc 100644 --- a/phlex/core/declared_predicate.hpp +++ b/phlex/core/declared_predicate.hpp @@ -11,7 +11,7 @@ #include "phlex/core/store_counters.hpp" #include "phlex/metaprogramming/type_deduction.hpp" #include "phlex/model/algorithm_name.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/handle.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/simple_ptr_map.hpp" @@ -43,7 +43,7 @@ namespace phlex::experimental { virtual tbb::flow::sender& sender() = 0; protected: - using results_t = tbb::concurrent_hash_map; + using results_t = tbb::concurrent_hash_map; using accessor = results_t::accessor; using const_accessor = results_t::const_accessor; diff --git a/phlex/core/declared_transform.hpp b/phlex/core/declared_transform.hpp index bfe01fb98..125024cd7 100644 --- a/phlex/core/declared_transform.hpp +++ b/phlex/core/declared_transform.hpp @@ -13,7 +13,7 @@ #include "phlex/core/store_counters.hpp" #include "phlex/metaprogramming/type_deduction.hpp" #include "phlex/model/algorithm_name.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/handle.hpp" #include "phlex/model/product_specification.hpp" #include "phlex/model/product_store.hpp" @@ -50,7 +50,7 @@ namespace phlex::experimental { virtual std::size_t product_count() const = 0; protected: - using stores_t = tbb::concurrent_hash_map; + using stores_t = tbb::concurrent_hash_map; using accessor = stores_t::accessor; using const_accessor = stores_t::const_accessor; diff --git a/phlex/core/declared_unfold.hpp b/phlex/core/declared_unfold.hpp index 3e27a783a..2754d9dab 100644 --- a/phlex/core/declared_unfold.hpp +++ b/phlex/core/declared_unfold.hpp @@ -9,7 +9,7 @@ #include "phlex/core/products_consumer.hpp" #include "phlex/core/store_counters.hpp" #include "phlex/model/algorithm_name.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/handle.hpp" #include "phlex/model/product_specification.hpp" #include "phlex/model/product_store.hpp" @@ -50,7 +50,7 @@ namespace phlex::experimental { product_store_ptr parent_; std::string node_name_; std::string const& new_layer_name_; - std::map child_counts_; + std::map child_counts_; }; class declared_unfold : public products_consumer { @@ -66,7 +66,7 @@ namespace phlex::experimental { virtual std::size_t product_count() const = 0; protected: - using stores_t = tbb::concurrent_hash_map; + using stores_t = tbb::concurrent_hash_map; using accessor = stores_t::accessor; using const_accessor = stores_t::const_accessor; @@ -144,7 +144,7 @@ namespace phlex::experimental { template void call(Predicate const& predicate, Unfold const& unfold, - data_cell_id_ptr const& unfolded_id, + data_cell_index_ptr const& unfolded_id, generator& g, end_of_message_ptr const& eom, messages_t const& messages, @@ -181,7 +181,7 @@ namespace phlex::experimental { std::string new_layer_name_; join_or_none_t join_; tbb::flow::multifunction_node, messages_t<1u>> unfold_; - tbb::concurrent_hash_map stores_; + tbb::concurrent_hash_map stores_; std::atomic msg_counter_{}; // Is this sufficient? Probably not. std::atomic calls_{}; std::atomic product_count_{}; diff --git a/phlex/core/end_of_message.cpp b/phlex/core/end_of_message.cpp index 4090558ee..1559aefb1 100644 --- a/phlex/core/end_of_message.cpp +++ b/phlex/core/end_of_message.cpp @@ -5,17 +5,18 @@ namespace phlex::experimental { end_of_message::end_of_message(end_of_message_ptr parent, data_layer_hierarchy* hierarchy, - data_cell_id_ptr id) : + data_cell_index_ptr id) : parent_{parent}, hierarchy_{hierarchy}, id_{id} { } - end_of_message_ptr end_of_message::make_base(data_layer_hierarchy* hierarchy, data_cell_id_ptr id) + end_of_message_ptr end_of_message::make_base(data_layer_hierarchy* hierarchy, + data_cell_index_ptr id) { return end_of_message_ptr{new end_of_message{nullptr, hierarchy, id}}; } - end_of_message_ptr end_of_message::make_child(data_cell_id_ptr id) + end_of_message_ptr end_of_message::make_child(data_cell_index_ptr id) { return end_of_message_ptr{new end_of_message{shared_from_this(), hierarchy_, id}}; } diff --git a/phlex/core/end_of_message.hpp b/phlex/core/end_of_message.hpp index f9709bf5e..efe2f1109 100644 --- a/phlex/core/end_of_message.hpp +++ b/phlex/core/end_of_message.hpp @@ -10,16 +10,18 @@ namespace phlex::experimental { class end_of_message : public std::enable_shared_from_this { public: - static end_of_message_ptr make_base(data_layer_hierarchy* hierarchy, data_cell_id_ptr id); - end_of_message_ptr make_child(data_cell_id_ptr id); + static end_of_message_ptr make_base(data_layer_hierarchy* hierarchy, data_cell_index_ptr id); + end_of_message_ptr make_child(data_cell_index_ptr id); ~end_of_message(); private: - end_of_message(end_of_message_ptr parent, data_layer_hierarchy* hierarchy, data_cell_id_ptr id); + end_of_message(end_of_message_ptr parent, + data_layer_hierarchy* hierarchy, + data_cell_index_ptr id); end_of_message_ptr parent_; data_layer_hierarchy* hierarchy_; - data_cell_id_ptr id_; + data_cell_index_ptr id_; }; } diff --git a/phlex/core/message.cpp b/phlex/core/message.cpp index 5c80cc40b..ac816fbdf 100644 --- a/phlex/core/message.cpp +++ b/phlex/core/message.cpp @@ -1,5 +1,5 @@ #include "phlex/core/message.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include #include diff --git a/phlex/core/message_sender.hpp b/phlex/core/message_sender.hpp index 67f8c4344..8fb9abb51 100644 --- a/phlex/core/message_sender.hpp +++ b/phlex/core/message_sender.hpp @@ -26,7 +26,7 @@ namespace phlex::experimental { data_layer_hierarchy& hierarchy_; multiplexer& multiplexer_; std::stack& eoms_; - std::map original_message_ids_; + std::map original_message_ids_; std::size_t calls_{}; }; diff --git a/phlex/core/multiplexer.hpp b/phlex/core/multiplexer.hpp index 0bafd6ad5..bb956f29c 100644 --- a/phlex/core/multiplexer.hpp +++ b/phlex/core/multiplexer.hpp @@ -2,7 +2,7 @@ #define PHLEX_CORE_MULTIPLEXER_HPP #include "phlex/core/message.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "oneapi/tbb/concurrent_hash_map.h" #include "oneapi/tbb/flow_graph.h" diff --git a/phlex/core/store_counters.cpp b/phlex/core/store_counters.cpp index 006f5ee14..d09cd4e88 100644 --- a/phlex/core/store_counters.cpp +++ b/phlex/core/store_counters.cpp @@ -18,7 +18,7 @@ namespace phlex::experimental { unsigned int store_flag::original_message_id() const noexcept { return original_message_id_; } - store_flag& detect_flush_flag::flag_for(data_cell_id::hash_type const hash) + store_flag& detect_flush_flag::flag_for(data_cell_index::hash_type const hash) { flag_accessor fa; flags_.emplace(fa, hash, std::make_unique()); @@ -52,7 +52,10 @@ namespace phlex::experimental { original_message_id_ = original_message_id; } - void store_counter::increment(data_cell_id::hash_type const layer_hash) { ++counts_[layer_hash]; } + void store_counter::increment(data_cell_index::hash_type const layer_hash) + { + ++counts_[layer_hash]; + } bool store_counter::is_complete() { @@ -88,7 +91,7 @@ namespace phlex::experimental { unsigned int store_counter::original_message_id() const noexcept { return original_message_id_; } - store_counter& count_stores::counter_for(data_cell_id::hash_type const hash) + store_counter& count_stores::counter_for(data_cell_index::hash_type const hash) { counter_accessor ca; if (!counters_.find(ca, hash)) { @@ -97,7 +100,7 @@ namespace phlex::experimental { return *ca->second; } - std::unique_ptr count_stores::done_with(data_cell_id::hash_type const hash) + std::unique_ptr count_stores::done_with(data_cell_index::hash_type const hash) { // Must be called after an insertion has already been performed counter_accessor ca; diff --git a/phlex/core/store_counters.hpp b/phlex/core/store_counters.hpp index 4406ccb06..99216c944 100644 --- a/phlex/core/store_counters.hpp +++ b/phlex/core/store_counters.hpp @@ -3,7 +3,7 @@ #include "phlex/core/fwd.hpp" #include "phlex/model/data_cell_counter.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/product_store.hpp" #include "oneapi/tbb/concurrent_hash_map.h" @@ -29,11 +29,12 @@ namespace phlex::experimental { class detect_flush_flag { protected: - store_flag& flag_for(data_cell_id::hash_type hash); + store_flag& flag_for(data_cell_index::hash_type hash); bool done_with(product_store_const_ptr const& store); private: - using flags_t = tbb::concurrent_hash_map>; + using flags_t = + tbb::concurrent_hash_map>; using flag_accessor = flags_t::accessor; using const_flag_accessor = flags_t::const_accessor; @@ -45,13 +46,13 @@ namespace phlex::experimental { class store_counter { public: void set_flush_value(product_store_const_ptr const& ptr, std::size_t original_message_id); - void increment(data_cell_id::hash_type layer_hash); + void increment(data_cell_index::hash_type layer_hash); bool is_complete(); unsigned int original_message_id() const noexcept; private: using counts_t2 = - tbb::concurrent_unordered_map>; + tbb::concurrent_unordered_map>; counts_t2 counts_{}; #ifdef __cpp_lib_atomic_shared_ptr @@ -65,12 +66,12 @@ namespace phlex::experimental { class count_stores { protected: - store_counter& counter_for(data_cell_id::hash_type hash); - std::unique_ptr done_with(data_cell_id::hash_type hash); + store_counter& counter_for(data_cell_index::hash_type hash); + std::unique_ptr done_with(data_cell_index::hash_type hash); private: using counters_t = - tbb::concurrent_hash_map>; + tbb::concurrent_hash_map>; using counter_accessor = counters_t::accessor; counters_t counters_; diff --git a/phlex/model/CMakeLists.txt b/phlex/model/CMakeLists.txt index 7ae09d7b0..95c2e9766 100644 --- a/phlex/model/CMakeLists.txt +++ b/phlex/model/CMakeLists.txt @@ -3,7 +3,7 @@ add_library( algorithm_name.cpp data_cell_counter.cpp data_layer_hierarchy.cpp - data_cell_id.cpp + data_cell_index.cpp product_matcher.cpp product_store.cpp products.cpp diff --git a/phlex/model/data_cell_counter.cpp b/phlex/model/data_cell_counter.cpp index e52c8647b..f25382d7f 100644 --- a/phlex/model/data_cell_counter.cpp +++ b/phlex/model/data_cell_counter.cpp @@ -7,7 +7,7 @@ namespace phlex::experimental { flush_counts::flush_counts() = default; - flush_counts::flush_counts(std::map child_counts) : + flush_counts::flush_counts(std::map child_counts) : child_counts_{std::move(child_counts)} { } @@ -43,7 +43,7 @@ namespace phlex::experimental { } } - void flush_counters::update(data_cell_id_ptr const id) + void flush_counters::update(data_cell_index_ptr const id) { data_cell_counter* parent_counter = nullptr; if (auto parent = id->parent()) { @@ -54,7 +54,7 @@ namespace phlex::experimental { counters_[id->hash()] = std::make_shared(parent_counter, id->layer_name()); } - flush_counts flush_counters::extract(data_cell_id_ptr const id) + flush_counts flush_counters::extract(data_cell_index_ptr const id) { auto counter = counters_.extract(id->hash()); return counter.mapped()->result(); diff --git a/phlex/model/data_cell_counter.hpp b/phlex/model/data_cell_counter.hpp index 541125b50..f744a18b1 100644 --- a/phlex/model/data_cell_counter.hpp +++ b/phlex/model/data_cell_counter.hpp @@ -1,7 +1,7 @@ #ifndef PHLEX_MODEL_DATA_CELL_COUNTER_HPP #define PHLEX_MODEL_DATA_CELL_COUNTER_HPP -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/fwd.hpp" #include "oneapi/tbb/concurrent_hash_map.h" @@ -14,14 +14,14 @@ namespace phlex::experimental { class flush_counts { public: flush_counts(); - explicit flush_counts(std::map child_counts); + explicit flush_counts(std::map child_counts); auto begin() const { return child_counts_.begin(); } auto end() const { return child_counts_.end(); } bool empty() const { return child_counts_.empty(); } auto size() const { return child_counts_.size(); } - std::optional count_for(data_cell_id::hash_type const layer_hash) const + std::optional count_for(data_cell_index::hash_type const layer_hash) const { if (auto it = child_counts_.find(layer_hash); it != child_counts_.end()) { return it->second; @@ -30,7 +30,7 @@ namespace phlex::experimental { } private: - std::map child_counts_{}; + std::map child_counts_{}; }; using flush_counts_ptr = std::shared_ptr; @@ -54,17 +54,17 @@ namespace phlex::experimental { void adjust(data_cell_counter& child); data_cell_counter* parent_; - data_cell_id::hash_type layer_hash_; - std::map child_counts_{}; + data_cell_index::hash_type layer_hash_; + std::map child_counts_{}; }; class flush_counters { public: - void update(data_cell_id_ptr const id); - flush_counts extract(data_cell_id_ptr const id); + void update(data_cell_index_ptr const id); + flush_counts extract(data_cell_index_ptr const id); private: - std::map> counters_; + std::map> counters_; }; } diff --git a/phlex/model/data_cell_id.hpp b/phlex/model/data_cell_id.hpp deleted file mode 100644 index eb5098f8a..000000000 --- a/phlex/model/data_cell_id.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef PHLEX_MODEL_DATA_CELL_ID_HPP -#define PHLEX_MODEL_DATA_CELL_ID_HPP - -#include "phlex/model/fwd.hpp" - -#include -#include -#include -#include -#include -#include -#include - -namespace phlex::experimental { - class data_cell_id : public std::enable_shared_from_this { - public: - static data_cell_id const& base(); - static data_cell_id_ptr base_ptr(); - - using hash_type = std::size_t; - data_cell_id_ptr make_child(std::size_t new_level_number, std::string layer_name) const; - std::string const& layer_name() const noexcept; - std::size_t depth() const noexcept; - data_cell_id_ptr parent(std::string const& layer_name) const; - data_cell_id_ptr parent() const noexcept; - bool has_parent() const noexcept; - std::size_t number() const; - std::size_t hash() const noexcept; - std::size_t layer_hash() const noexcept; - bool operator==(data_cell_id const& other) const; - bool operator<(data_cell_id const& other) const; - - std::string to_string() const; - std::string to_string_this_level() const; - - friend std::ostream& operator<<(std::ostream& os, data_cell_id const& id); - - private: - data_cell_id(); - explicit data_cell_id(data_cell_id_ptr parent, std::size_t i, std::string layer_name); - data_cell_id_ptr parent_{nullptr}; - std::size_t number_{-1ull}; - std::string layer_name_; - std::size_t layer_hash_; - std::size_t depth_{}; - hash_type hash_{0}; - }; - - data_cell_id_ptr id_for(char const* str); - data_cell_id_ptr id_for(std::vector nums); - data_cell_id_ptr operator""_id(char const* str, std::size_t); - std::ostream& operator<<(std::ostream& os, data_cell_id const& id); -} - -namespace std { - template <> - struct hash { - std::size_t operator()(phlex::experimental::data_cell_id const& id) const noexcept - { - return id.hash(); - } - }; -} - -#endif // PHLEX_MODEL_DATA_CELL_ID_HPP diff --git a/phlex/model/data_cell_id.cpp b/phlex/model/data_cell_index.cpp similarity index 58% rename from phlex/model/data_cell_id.cpp rename to phlex/model/data_cell_index.cpp index aa1afa732..b7fee40a9 100644 --- a/phlex/model/data_cell_id.cpp +++ b/phlex/model/data_cell_index.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/utilities/hashing.hpp" #include "boost/algorithm/string.hpp" @@ -11,7 +11,7 @@ namespace { - std::vector all_numbers(phlex::experimental::data_cell_id const& id) + std::vector all_numbers(phlex::experimental::data_cell_index const& id) { if (!id.has_parent()) { return {}; @@ -30,12 +30,14 @@ namespace { namespace phlex::experimental { - data_cell_id::data_cell_id() : + data_cell_index::data_cell_index() : layer_name_{"job"}, layer_hash_{phlex::experimental::hash(layer_name_)} { } - data_cell_id::data_cell_id(data_cell_id_ptr parent, std::size_t i, std::string layer_name) : + data_cell_index::data_cell_index(data_cell_index_ptr parent, + std::size_t i, + std::string layer_name) : parent_{std::move(parent)}, number_{i}, layer_name_{std::move(layer_name)}, @@ -46,30 +48,30 @@ namespace phlex::experimental { // FIXME: Should it be an error to create an ID with an empty name? } - data_cell_id const& data_cell_id::base() { return *base_ptr(); } - data_cell_id_ptr data_cell_id::base_ptr() + data_cell_index const& data_cell_index::base() { return *base_ptr(); } + data_cell_index_ptr data_cell_index::base_ptr() { - static phlex::experimental::data_cell_id_ptr base_id{new data_cell_id}; + static phlex::experimental::data_cell_index_ptr base_id{new data_cell_index}; return base_id; } - std::string const& data_cell_id::layer_name() const noexcept { return layer_name_; } - std::size_t data_cell_id::depth() const noexcept { return depth_; } + std::string const& data_cell_index::layer_name() const noexcept { return layer_name_; } + std::size_t data_cell_index::depth() const noexcept { return depth_; } - data_cell_id_ptr data_cell_id::make_child(std::size_t const new_level_number, - std::string new_layer_name) const + data_cell_index_ptr data_cell_index::make_child(std::size_t const new_level_number, + std::string new_layer_name) const { - return data_cell_id_ptr{ - new data_cell_id{shared_from_this(), new_level_number, std::move(new_layer_name)}}; + return data_cell_index_ptr{ + new data_cell_index{shared_from_this(), new_level_number, std::move(new_layer_name)}}; } - bool data_cell_id::has_parent() const noexcept { return static_cast(parent_); } + bool data_cell_index::has_parent() const noexcept { return static_cast(parent_); } - std::size_t data_cell_id::number() const { return number_; } - std::size_t data_cell_id::hash() const noexcept { return hash_; } - std::size_t data_cell_id::layer_hash() const noexcept { return layer_hash_; } + std::size_t data_cell_index::number() const { return number_; } + std::size_t data_cell_index::hash() const noexcept { return hash_; } + std::size_t data_cell_index::layer_hash() const noexcept { return layer_hash_; } - bool data_cell_id::operator==(data_cell_id const& other) const + bool data_cell_index::operator==(data_cell_index const& other) const { if (depth_ != other.depth_) return false; @@ -80,7 +82,7 @@ namespace phlex::experimental { return *parent_ == *other.parent_ && same_numbers; } - bool data_cell_id::operator<(data_cell_id const& other) const + bool data_cell_index::operator<(data_cell_index const& other) const { auto these_numbers = all_numbers(*this); auto those_numbers = all_numbers(other); @@ -88,16 +90,16 @@ namespace phlex::experimental { begin(these_numbers), end(these_numbers), begin(those_numbers), end(those_numbers)); } - data_cell_id_ptr id_for(std::vector nums) + data_cell_index_ptr id_for(std::vector nums) { - auto current = data_cell_id::base_ptr(); + auto current = data_cell_index::base_ptr(); for (auto const num : nums) { current = current->make_child(num, ""); } return current; } - data_cell_id_ptr id_for(char const* c_str) + data_cell_index_ptr id_for(char const* c_str) { std::vector strs; split(strs, c_str, boost::is_any_of(":")); @@ -111,13 +113,13 @@ namespace phlex::experimental { return id_for(std::move(nums)); } - data_cell_id_ptr operator""_id(char const* c_str, std::size_t) { return id_for(c_str); } + data_cell_index_ptr operator""_id(char const* c_str, std::size_t) { return id_for(c_str); } - data_cell_id_ptr data_cell_id::parent() const noexcept { return parent_; } + data_cell_index_ptr data_cell_index::parent() const noexcept { return parent_; } - data_cell_id_ptr data_cell_id::parent(std::string const& layer_name) const + data_cell_index_ptr data_cell_index::parent(std::string const& layer_name) const { - data_cell_id_ptr parent = parent_; + data_cell_index_ptr parent = parent_; while (parent) { if (parent->layer_name_ == layer_name) { return parent; @@ -127,7 +129,7 @@ namespace phlex::experimental { return nullptr; } - std::string data_cell_id::to_string() const + std::string data_cell_index::to_string() const { // FIXME: prefix needs to be adjusted esp. if a root name can be supplied by the user. std::string prefix{"["}; //"root: ["}; @@ -145,7 +147,7 @@ namespace phlex::experimental { return prefix + result + suffix; } - std::string data_cell_id::to_string_this_level() const + std::string data_cell_index::to_string_this_level() const { if (empty(layer_name_)) { return std::to_string(number_); @@ -153,7 +155,7 @@ namespace phlex::experimental { return layer_name_ + ":" + std::to_string(number_); } - std::ostream& operator<<(std::ostream& os, data_cell_id const& id) + std::ostream& operator<<(std::ostream& os, data_cell_index const& id) { return os << id.to_string(); } diff --git a/phlex/model/data_cell_index.hpp b/phlex/model/data_cell_index.hpp new file mode 100644 index 000000000..f7338dfef --- /dev/null +++ b/phlex/model/data_cell_index.hpp @@ -0,0 +1,65 @@ +#ifndef PHLEX_MODEL_DATA_CELL_ID_HPP +#define PHLEX_MODEL_DATA_CELL_ID_HPP + +#include "phlex/model/fwd.hpp" + +#include +#include +#include +#include +#include +#include +#include + +namespace phlex::experimental { + class data_cell_index : public std::enable_shared_from_this { + public: + static data_cell_index const& base(); + static data_cell_index_ptr base_ptr(); + + using hash_type = std::size_t; + data_cell_index_ptr make_child(std::size_t new_level_number, std::string layer_name) const; + std::string const& layer_name() const noexcept; + std::size_t depth() const noexcept; + data_cell_index_ptr parent(std::string const& layer_name) const; + data_cell_index_ptr parent() const noexcept; + bool has_parent() const noexcept; + std::size_t number() const; + std::size_t hash() const noexcept; + std::size_t layer_hash() const noexcept; + bool operator==(data_cell_index const& other) const; + bool operator<(data_cell_index const& other) const; + + std::string to_string() const; + std::string to_string_this_level() const; + + friend std::ostream& operator<<(std::ostream& os, data_cell_index const& id); + + private: + data_cell_index(); + explicit data_cell_index(data_cell_index_ptr parent, std::size_t i, std::string layer_name); + data_cell_index_ptr parent_{nullptr}; + std::size_t number_{-1ull}; + std::string layer_name_; + std::size_t layer_hash_; + std::size_t depth_{}; + hash_type hash_{0}; + }; + + data_cell_index_ptr id_for(char const* str); + data_cell_index_ptr id_for(std::vector nums); + data_cell_index_ptr operator""_id(char const* str, std::size_t); + std::ostream& operator<<(std::ostream& os, data_cell_index const& id); +} + +namespace std { + template <> + struct hash { + std::size_t operator()(phlex::experimental::data_cell_index const& id) const noexcept + { + return id.hash(); + } + }; +} + +#endif // PHLEX_MODEL_DATA_CELL_ID_HPP diff --git a/phlex/model/data_layer_hierarchy.cpp b/phlex/model/data_layer_hierarchy.cpp index 2aaf5ddf6..09f6a719e 100644 --- a/phlex/model/data_layer_hierarchy.cpp +++ b/phlex/model/data_layer_hierarchy.cpp @@ -1,5 +1,5 @@ #include "phlex/model/data_layer_hierarchy.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "fmt/format.h" #include "fmt/std.h" @@ -14,7 +14,7 @@ namespace phlex::experimental { data_layer_hierarchy::~data_layer_hierarchy() { print(); } - void data_layer_hierarchy::increment_count(data_cell_id_ptr const& id) + void data_layer_hierarchy::increment_count(data_cell_index_ptr const& id) { if (auto it = layers_.find(id->layer_hash()); it != layers_.cend()) { ++it->second->count; diff --git a/phlex/model/data_layer_hierarchy.hpp b/phlex/model/data_layer_hierarchy.hpp index 3b8025b1a..b6cad43e5 100644 --- a/phlex/model/data_layer_hierarchy.hpp +++ b/phlex/model/data_layer_hierarchy.hpp @@ -1,7 +1,7 @@ #ifndef PHLEX_MODEL_DATA_LAYER_HIERARCHY_HPP #define PHLEX_MODEL_DATA_LAYER_HIERARCHY_HPP -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/fwd.hpp" #include "oneapi/tbb/concurrent_unordered_map.h" @@ -16,7 +16,7 @@ namespace phlex::experimental { class data_layer_hierarchy { public: ~data_layer_hierarchy(); - void increment_count(data_cell_id_ptr const& id); + void increment_count(data_cell_index_ptr const& id); std::size_t count_for(std::string const& layer_name) const; void print() const; diff --git a/phlex/model/fwd.hpp b/phlex/model/fwd.hpp index 63bfe88fc..568d6fc64 100644 --- a/phlex/model/fwd.hpp +++ b/phlex/model/fwd.hpp @@ -6,10 +6,10 @@ namespace phlex::experimental { class data_cell_counter; class data_layer_hierarchy; - class data_cell_id; + class data_cell_index; class product_store; - using data_cell_id_ptr = std::shared_ptr; + using data_cell_index_ptr = std::shared_ptr; using product_store_const_ptr = std::shared_ptr; using product_store_ptr = std::shared_ptr; diff --git a/phlex/model/handle.hpp b/phlex/model/handle.hpp index e8eb67bb0..555b09663 100644 --- a/phlex/model/handle.hpp +++ b/phlex/model/handle.hpp @@ -1,7 +1,7 @@ #ifndef PHLEX_MODEL_HANDLE_HPP #define PHLEX_MODEL_HANDLE_HPP -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include #include @@ -53,7 +53,7 @@ namespace phlex::experimental { using const_pointer = value_type const*; // The 'product' parameter is not 'const_reference' to avoid avoid implicit type conversions. - explicit handle(std::same_as auto const& product, data_cell_id const& id) : + explicit handle(std::same_as auto const& product, data_cell_index const& id) : product_{&product}, id_{&id} { } @@ -74,7 +74,7 @@ namespace phlex::experimental { operator const_reference() const noexcept { return operator*(); } operator const_pointer() const noexcept { return operator->(); } - auto const& data_cell_id() const noexcept { return *id_; } + auto const& data_cell_index() const noexcept { return *id_; } template friend class handle; @@ -85,12 +85,12 @@ namespace phlex::experimental { } private: - const_pointer product_; // Non-null, by construction - class data_cell_id const* id_; // Non-null, by construction + const_pointer product_; // Non-null, by construction + class data_cell_index const* id_; // Non-null, by construction }; template - handle(T const&, data_cell_id const&) -> handle; + handle(T const&, data_cell_index const&) -> handle; } #endif // PHLEX_MODEL_HANDLE_HPP diff --git a/phlex/model/product_matcher.cpp b/phlex/model/product_matcher.cpp index af3b568a9..a190da122 100644 --- a/phlex/model/product_matcher.cpp +++ b/phlex/model/product_matcher.cpp @@ -20,17 +20,17 @@ namespace { throw std::runtime_error("The matcher specification may not start with a forward slash (/)."); } - std::string const optional_level_path{R"((?:(.*)/)?)"}; + std::string const optional_layer_path{R"((?:(.*)/)?)"}; std::string const optional_qualified_node_name{R"((?:(\w+)?(?:@(\w+))?:)?)"}; std::string const product_name{R"((\w+))"}; - std::regex const pattern{optional_level_path + optional_qualified_node_name + product_name}; + std::regex const pattern{optional_layer_path + optional_qualified_node_name + product_name}; std::smatch submatches; bool const matched = std::regex_match(matcher_spec, submatches, pattern); if (not matched) { throw std::runtime_error( "Provided product specification does not match the supported pattern:\n" - "\"[level path spec/][[module name][@node name]:]product name\""); + "\"[layer path spec/][[module name][@node name]:]product name\""); } assert(submatches.size() == 5); assert(submatches[0] == matcher_spec); @@ -46,7 +46,7 @@ namespace phlex::experimental { } product_matcher::product_matcher(std::array fields) : - level_path_{std::move(fields[0])}, + layer_path_{std::move(fields[0])}, module_name_{std::move(fields[1])}, node_name_{std::move(fields[2])}, product_name_{std::move(fields[3])} @@ -55,6 +55,6 @@ namespace phlex::experimental { std::string product_matcher::encode() const { - return fmt::format("{}/{}@{}:{}", level_path_, module_name_, node_name_, product_name_); + return fmt::format("{}/{}@{}:{}", layer_path_, module_name_, node_name_, product_name_); } } diff --git a/phlex/model/product_matcher.hpp b/phlex/model/product_matcher.hpp index 2be28f04a..632273f06 100644 --- a/phlex/model/product_matcher.hpp +++ b/phlex/model/product_matcher.hpp @@ -19,7 +19,7 @@ namespace phlex::experimental { public: explicit product_matcher(std::string matcher_spec); bool matches(product_store_const_ptr const& store) const; - std::string const& level_path() const noexcept { return level_path_; } + std::string const& layer_path() const noexcept { return layer_path_; } std::string const& module_name() const noexcept { return module_name_; } std::string const& node_name() const noexcept { return node_name_; } std::string const& product_name() const noexcept { return product_name_; } @@ -28,7 +28,7 @@ namespace phlex::experimental { private: explicit product_matcher(std::array fields); - std::string level_path_; + std::string layer_path_; std::string module_name_; std::string node_name_; std::string product_name_; diff --git a/phlex/model/product_store.cpp b/phlex/model/product_store.cpp index 5735c3e40..cb35c89fc 100644 --- a/phlex/model/product_store.cpp +++ b/phlex/model/product_store.cpp @@ -1,5 +1,5 @@ #include "phlex/model/product_store.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include #include @@ -7,7 +7,7 @@ namespace phlex::experimental { product_store::product_store(product_store_const_ptr parent, - data_cell_id_ptr id, + data_cell_index_ptr id, std::string source, stage processing_stage, products new_products) : @@ -49,7 +49,7 @@ namespace phlex::experimental { product_store_ptr product_store::base(std::string base_name) { return product_store_ptr{ - new product_store{nullptr, data_cell_id::base_ptr(), std::move(base_name)}}; + new product_store{nullptr, data_cell_index::base_ptr(), std::move(base_name)}}; } product_store_const_ptr product_store::parent(std::string const& layer_name) const noexcept @@ -112,7 +112,7 @@ namespace phlex::experimental { std::string const& product_store::layer_name() const noexcept { return id_->layer_name(); } std::string const& product_store::source() const noexcept { return source_; } product_store_const_ptr product_store::parent() const noexcept { return parent_; } - data_cell_id_ptr const& product_store::id() const noexcept { return id_; } + data_cell_index_ptr const& product_store::id() const noexcept { return id_; } bool product_store::is_flush() const noexcept { return stage_ == stage::flush; } bool product_store::contains_product(std::string const& product_name) const diff --git a/phlex/model/product_store.hpp b/phlex/model/product_store.hpp index cb53b6287..00aa2d4d9 100644 --- a/phlex/model/product_store.hpp +++ b/phlex/model/product_store.hpp @@ -1,7 +1,7 @@ #ifndef PHLEX_MODEL_PRODUCT_STORE_HPP #define PHLEX_MODEL_PRODUCT_STORE_HPP -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/fwd.hpp" #include "phlex/model/handle.hpp" #include "phlex/model/products.hpp" @@ -38,7 +38,7 @@ namespace phlex::experimental { std::string const& new_layer_name, std::string source = {}, stage st = stage::process); - data_cell_id_ptr const& id() const noexcept; + data_cell_index_ptr const& id() const noexcept; bool is_flush() const noexcept; // Product interface @@ -59,7 +59,7 @@ namespace phlex::experimental { private: explicit product_store(product_store_const_ptr parent, - data_cell_id_ptr id, + data_cell_index_ptr id, std::string source, stage processing_stage = stage::process, products new_products = {}); @@ -76,7 +76,7 @@ namespace phlex::experimental { product_store_const_ptr parent_{nullptr}; products products_{}; - data_cell_id_ptr id_; + data_cell_index_ptr id_; std::string source_; // FIXME: Should not have to copy the string (the source should outlive the product store) stage stage_; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f0007a736..d67473cc1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -44,7 +44,7 @@ add_catch_test(function_registration LIBRARIES phlex::core Boost::json) add_catch_test(hierarchical_nodes LIBRARIES Boost::json TBB::tbb phlex::core) add_catch_test(multiple_function_registration LIBRARIES Boost::json phlex::core) add_catch_test(data_cell_counting LIBRARIES phlex::model phlex::utilities) -add_catch_test(data_cell_id LIBRARIES phlex::model) +add_catch_test(data_cell_index LIBRARIES phlex::model) add_catch_test(product_handle LIBRARIES phlex::core) add_catch_test(product_matcher LIBRARIES phlex::model) add_catch_test(product_store LIBRARIES phlex::core) diff --git a/test/allowed_families.cpp b/test/allowed_families.cpp index 53cc222ad..ee64cf34e 100644 --- a/test/allowed_families.cpp +++ b/test/allowed_families.cpp @@ -1,5 +1,5 @@ #include "phlex/core/framework_graph.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/product_store.hpp" #include "catch2/catch_test_macros.hpp" @@ -30,15 +30,15 @@ namespace { driver.yield(event_store); } - void check_two_ids(data_cell_id const& parent_id, data_cell_id const& id) + void check_two_ids(data_cell_index const& parent_id, data_cell_index const& id) { CHECK(parent_id.depth() + 1ull == id.depth()); CHECK(parent_id.hash() == id.parent()->hash()); } - void check_three_ids(data_cell_id const& grandparent_id, - data_cell_id const& parent_id, - data_cell_id const& id) + void check_three_ids(data_cell_index const& grandparent_id, + data_cell_index const& parent_id, + data_cell_index const& id) { CHECK(id.depth() == 3ull); CHECK(parent_id.depth() == 2ull); diff --git a/test/benchmarks/accept_even_ids.cpp b/test/benchmarks/accept_even_ids.cpp index bd7319967..b98b5ddd4 100644 --- a/test/benchmarks/accept_even_ids.cpp +++ b/test/benchmarks/accept_even_ids.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/module.hpp" #include @@ -7,7 +7,7 @@ PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config) { m.predicate( "accept_even_ids", - [](phlex::experimental::data_cell_id const& id) { return id.number() % 2 == 0; }, + [](phlex::experimental::data_cell_index const& id) { return id.number() % 2 == 0; }, phlex::experimental::concurrency::unlimited) .input_family(config.get("product_name")); } diff --git a/test/benchmarks/last_index.cpp b/test/benchmarks/last_index.cpp index 708c01064..41d0a45f1 100644 --- a/test/benchmarks/last_index.cpp +++ b/test/benchmarks/last_index.cpp @@ -1,10 +1,10 @@ -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/module.hpp" using namespace phlex::experimental; namespace { - int last_index(data_cell_id const& id) { return static_cast(id.number()); } + int last_index(data_cell_index const& id) { return static_cast(id.number()); } } PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config) diff --git a/test/benchmarks/read_id.cpp b/test/benchmarks/read_id.cpp index ea2825d46..02d6117ed 100644 --- a/test/benchmarks/read_id.cpp +++ b/test/benchmarks/read_id.cpp @@ -1,8 +1,8 @@ -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/module.hpp" namespace { - void read_id(phlex::experimental::data_cell_id const&) {} + void read_id(phlex::experimental::data_cell_index const&) {} } PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m) diff --git a/test/benchmarks/read_index.cpp b/test/benchmarks/read_index.cpp index 895f2e4e9..ebc8d3677 100644 --- a/test/benchmarks/read_index.cpp +++ b/test/benchmarks/read_index.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/module.hpp" namespace { diff --git a/test/cached_product_stores.cpp b/test/cached_product_stores.cpp index 94979e024..0ba7710b3 100644 --- a/test/cached_product_stores.cpp +++ b/test/cached_product_stores.cpp @@ -1,5 +1,5 @@ #include "phlex/core/cached_product_stores.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/product_store.hpp" #include "catch2/catch_test_macros.hpp" @@ -13,17 +13,17 @@ TEST_CASE("Cached product stores", "[data model]") { auto store = stores.get_store(); REQUIRE(store); - CHECK(store->id() == data_cell_id::base_ptr()); + CHECK(store->id() == data_cell_index::base_ptr()); } - SECTION("One level down") + SECTION("One layer down") { auto store = stores.get_store("1"_id); REQUIRE(store); CHECK(*store->id() == *"1"_id); REQUIRE(store->parent()); - CHECK(store->parent()->id() == data_cell_id::base_ptr()); + CHECK(store->parent()->id() == data_cell_index::base_ptr()); } - SECTION("One level down, multiple instances") + SECTION("One layer down, multiple instances") { auto store1 = stores.get_store("1"_id); auto store2 = stores.get_store("2"_id); @@ -34,7 +34,7 @@ TEST_CASE("Cached product stores", "[data model]") // Make sure both stores have the same parent CHECK(store1->parent() == store2->parent()); } - SECTION("Multiple levels") + SECTION("Multiple layers") { auto store1 = stores.get_store("1"_id); auto store2345 = stores.get_store("2:3:4:5"_id); diff --git a/test/data_cell_counting.cpp b/test/data_cell_counting.cpp index 53e08e43b..23abd5b4c 100644 --- a/test/data_cell_counting.cpp +++ b/test/data_cell_counting.cpp @@ -1,5 +1,5 @@ #include "phlex/model/data_cell_counter.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/data_layer_hierarchy.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/hashing.hpp" diff --git a/test/data_cell_id.cpp b/test/data_cell_index.cpp similarity index 82% rename from test/data_cell_id.cpp rename to test/data_cell_index.cpp index 00463cb46..6f5d55e1f 100644 --- a/test/data_cell_id.cpp +++ b/test/data_cell_index.cpp @@ -1,12 +1,12 @@ -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "catch2/catch_test_macros.hpp" using namespace phlex::experimental; -TEST_CASE("Level ID string literal", "[data model]") +TEST_CASE("Data layer ID string literal", "[data model]") { - CHECK(""_id == data_cell_id::base_ptr()); + CHECK(""_id == data_cell_index::base_ptr()); auto id = "2"_id; CHECK(*id == *id_for({2})); CHECK(id->hash() != 0ull); @@ -20,7 +20,7 @@ TEST_CASE("Verify independent hashes", "[data model]") // In the original implementation of the hash algorithm, there was a collision between the hash for // "run:0 subrun:0 event: 760" and "run:0 subrun:1 event: 4999". - auto base = data_cell_id::base_ptr(); + auto base = data_cell_index::base_ptr(); auto run = base->make_child(0, "run"); auto subrun_0 = run->make_child(0, "subrun"); auto event_760 = subrun_0->make_child(760, "event"); diff --git a/test/demo-giantdata/unfold_transform_fold.cpp b/test/demo-giantdata/unfold_transform_fold.cpp index 0ec40d97b..a3379d8a5 100644 --- a/test/demo-giantdata/unfold_transform_fold.cpp +++ b/test/demo-giantdata/unfold_transform_fold.cpp @@ -1,5 +1,5 @@ #include "phlex/core/framework_graph.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/product_store.hpp" #include "phlex/utilities/async_driver.hpp" #include "test/products_for_output.hpp" @@ -53,15 +53,15 @@ int main(int argc, char* argv[]) std::size_t const wires_per_spill = apas_per_spill * 256ull; - // Create some levels of the data set categories hierarchy. - // We may or may not want to create pre-generated data set categories like this. - // Each data set category gets an index number in the hierarchy. + // Create some data layers of the data-layer hierarchy. + // We may or may not want to create pre-generated data layers. + // Each data layer gets an index number in the hierarchy. auto source = [n_runs, n_subruns, n_spills, wires_per_spill](framework_driver& driver) { auto job_store = product_store::base(); driver.yield(job_store); - // job -> run -> subrun -> spill levels + // job -> run -> subrun -> spill data layers for (unsigned runno : std::views::iota(0u, n_runs)) { auto run_store = job_store->make_child(runno, "run"); driver.yield(run_store); @@ -123,10 +123,10 @@ int main(int argc, char* argv[]) // Add the transform node to the graph. demo::log_record("add_transform"); auto wrapped_user_function = [](phlex::experimental::handle hwf) { - auto apa_id = hwf.data_cell_id().number(); - auto spill_id = hwf.data_cell_id().parent()->number(); - auto subrun_id = hwf.data_cell_id().parent()->parent()->number(); - auto run_id = hwf.data_cell_id().parent()->parent()->parent()->number(); + auto apa_id = hwf.data_cell_index().number(); + auto spill_id = hwf.data_cell_index().parent()->number(); + auto subrun_id = hwf.data_cell_index().parent()->parent()->number(); + auto run_id = hwf.data_cell_index().parent()->parent()->parent()->number(); return demo::clampWaveforms(*hwf, run_id, subrun_id, spill_id, apa_id); }; @@ -139,10 +139,10 @@ int main(int argc, char* argv[]) g.fold( "accum_for_spill", [](demo::SummedClampedWaveforms& scw, phlex::experimental::handle hwf) { - auto apa_id = hwf.data_cell_id().number(); - auto spill_id = hwf.data_cell_id().parent()->number(); - auto subrun_id = hwf.data_cell_id().parent()->parent()->number(); - auto run_id = hwf.data_cell_id().parent()->parent()->parent()->number(); + auto apa_id = hwf.data_cell_index().number(); + auto spill_id = hwf.data_cell_index().parent()->number(); + auto subrun_id = hwf.data_cell_index().parent()->parent()->number(); + auto run_id = hwf.data_cell_index().parent()->parent()->parent()->number(); demo::accumulateSCW(scw, *hwf, run_id, subrun_id, spill_id, apa_id); }, concurrency::unlimited, diff --git a/test/fold.cpp b/test/fold.cpp index b438ff187..328486164 100644 --- a/test/fold.cpp +++ b/test/fold.cpp @@ -24,7 +24,7 @@ // ======================================================================================= #include "phlex/core/framework_graph.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/product_store.hpp" #include "catch2/catch_test_macros.hpp" @@ -42,7 +42,7 @@ namespace { void add(std::atomic& counter, unsigned int number) { counter += number; } } -TEST_CASE("Different levels of fold", "[graph]") +TEST_CASE("Different data layers of fold", "[graph]") { constexpr auto index_limit = 2u; constexpr auto number_limit = 5u; diff --git a/test/hierarchical_nodes.cpp b/test/hierarchical_nodes.cpp index d50ac1e0b..0cc36f8b6 100644 --- a/test/hierarchical_nodes.cpp +++ b/test/hierarchical_nodes.cpp @@ -12,12 +12,12 @@ // print_result [also includes output module] // // where the asterisk (*) indicates a fold step. In terms of the data model, -// whenever the add node receives the flush token, a product is inserted at one level -// higher than the level processed by square and add nodes. +// whenever the add node receives the flush token, a product is inserted in one data layer +// higher than the data layer processed by square and add nodes. // ======================================================================================= #include "phlex/core/framework_graph.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/product_store.hpp" #include "test/products_for_output.hpp" @@ -92,7 +92,7 @@ namespace { void print_result(handle result, std::string const& stringized_time) { spdlog::debug("{}: {} @ {}", - result.data_cell_id().to_string(), + result.data_cell_index().to_string(), *result, stringized_time.substr(0, stringized_time.find('\n'))); } diff --git a/test/mock-workflow/MC_truth_algorithm.cpp b/test/mock-workflow/MC_truth_algorithm.cpp index 1fe96d927..44a8058f8 100644 --- a/test/mock-workflow/MC_truth_algorithm.cpp +++ b/test/mock-workflow/MC_truth_algorithm.cpp @@ -6,5 +6,5 @@ using namespace phlex::experimental::test; PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config) { - define_algorithm(m, config); + define_algorithm(m, config); } diff --git a/test/mock-workflow/three_tuple_algorithm.cpp b/test/mock-workflow/three_tuple_algorithm.cpp index 99cf58429..0424b8665 100644 --- a/test/mock-workflow/three_tuple_algorithm.cpp +++ b/test/mock-workflow/three_tuple_algorithm.cpp @@ -8,7 +8,7 @@ using namespace phlex::experimental::test; PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config) { - using inputs = phlex::experimental::data_cell_id; + using inputs = phlex::experimental::data_cell_index; using outputs = std::tuple; define_algorithm(m, config); } diff --git a/test/product_handle.cpp b/test/product_handle.cpp index c8fb55d91..3af488178 100644 --- a/test/product_handle.cpp +++ b/test/product_handle.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/handle.hpp" #include "phlex/model/product_store.hpp" @@ -32,10 +32,10 @@ TEST_CASE("Can only construct handles with compatible types (compile-time checks static_assert(std::constructible_from, handle&&>); // Moves static_assert(not std::constructible_from, handle>); - static_assert(std::constructible_from, int, data_cell_id>); - static_assert(std::constructible_from, int const, data_cell_id>); - static_assert(std::constructible_from, int const&, data_cell_id>); - static_assert(not std::constructible_from, double, data_cell_id>); + static_assert(std::constructible_from, int, data_cell_index>); + static_assert(std::constructible_from, int const, data_cell_index>); + static_assert(std::constructible_from, int const&, data_cell_index>); + static_assert(not std::constructible_from, double, data_cell_index>); } TEST_CASE("Can only assign handles with compatible types (compile-time checks)", "[data model]") @@ -50,7 +50,7 @@ TEST_CASE("Handle copies and moves", "[data model]") int const two{2}; int const four{4}; - auto job_data_cell = data_cell_id::base_ptr(); + auto job_data_cell = data_cell_index::base_ptr(); auto subrun_6_data_cell = job_data_cell->make_child(6, "subrun"); handle h2{two, *job_data_cell}; @@ -77,23 +77,23 @@ TEST_CASE("Handle comparisons", "[data model]") { int const seventeen{17}; int const eighteen{18}; - handle const h17{seventeen, data_cell_id::base()}; - handle const h18{eighteen, data_cell_id::base()}; + handle const h17{seventeen, data_cell_index::base()}; + handle const h18{eighteen, data_cell_index::base()}; CHECK(h17 == h17); CHECK(h17 != h18); - auto subrun_6_data_cell = data_cell_id::base_ptr()->make_child(6, "subrun"); + auto subrun_6_data_cell = data_cell_index::base_ptr()->make_child(6, "subrun"); handle const h17sr{seventeen, *subrun_6_data_cell}; - CHECK(*h17 == *h17sr); // Products are the same - CHECK(h17.data_cell_id() != h17sr.data_cell_id()); // Levels are not the same - CHECK(h17 != h17sr); // Therefore handles are not the same + CHECK(*h17 == *h17sr); // Products are the same + CHECK(h17.data_cell_index() != h17sr.data_cell_index()); // Data cells are not the same + CHECK(h17 != h17sr); // Therefore handles are not the same } TEST_CASE("Handle type conversions (run-time checks)", "[data model]") { int const number{3}; - handle const h{number, data_cell_id::base()}; - CHECK(h.data_cell_id() == data_cell_id::base()); + handle const h{number, data_cell_index::base()}; + CHECK(h.data_cell_index() == data_cell_index::base()); int const& num_ref = h; int const* num_ptr = h; @@ -102,5 +102,5 @@ TEST_CASE("Handle type conversions (run-time checks)", "[data model]") CHECK(*num_ptr == number); Composer const composer{"Elgar"}; - CHECK(handle{composer, data_cell_id::base()}->name == "Elgar"); + CHECK(handle{composer, data_cell_index::base()}->name == "Elgar"); } diff --git a/test/product_matcher.cpp b/test/product_matcher.cpp index 7f8bfda99..9887ef2fc 100644 --- a/test/product_matcher.cpp +++ b/test/product_matcher.cpp @@ -9,12 +9,12 @@ using namespace phlex::experimental; namespace { - // Spec: [level path spec/][[module name][@node name]:]product name + // Spec: [layer path spec/][[module name][@node name]:]product name - // std::string const optional_level_path{R"((?:(.*)/)?)"}; + // std::string const optional_layer_path{R"((?:(.*)/)?)"}; // std::string const optional_qualified_node_name{R"((?:(\w+)?(?:@(\w+))?:)?)"}; // std::string const product_name{R"((\w+))"}; - // std::regex const pattern{optional_level_path + optional_qualified_node_name + product_name}; + // std::regex const pattern{optional_layer_path + optional_qualified_node_name + product_name}; // void print(std::string const& spec) // { // std::smatch submatches; @@ -36,17 +36,17 @@ TEST_CASE("Simple product matcher", "[data model]") { auto const spec = "event/loaded_module@add:sum"; product_matcher matcher{spec}; - CHECK(matcher.level_path() == "event"); + CHECK(matcher.layer_path() == "event"); CHECK(matcher.module_name() == "loaded_module"); CHECK(matcher.node_name() == "add"); CHECK(matcher.product_name() == "sum"); CHECK(matcher.encode() == spec); } -TEST_CASE("Product matcher with default level path", "[data model]") +TEST_CASE("Product matcher with default layer path", "[data model]") { product_matcher matcher{"loaded_module@add:sum"}; - CHECK(matcher.level_path() == "*"); + CHECK(matcher.layer_path() == "*"); CHECK(matcher.module_name() == "loaded_module"); CHECK(matcher.node_name() == "add"); CHECK(matcher.product_name() == "sum"); @@ -55,10 +55,10 @@ TEST_CASE("Product matcher with default level path", "[data model]") CHECK(product_matcher{"*/loaded_module@add:sum"}.encode() == "*/loaded_module@add:sum"); } -TEST_CASE("Product matcher with multi-part level path", "[data model]") +TEST_CASE("Product matcher with multi-part layer path", "[data model]") { product_matcher matcher{"a/b/c/loaded_module@add:sum"}; - CHECK(matcher.level_path() == "a/b/c"); + CHECK(matcher.layer_path() == "a/b/c"); CHECK(matcher.module_name() == "loaded_module"); CHECK(matcher.node_name() == "add"); CHECK(matcher.product_name() == "sum"); @@ -68,7 +68,7 @@ TEST_CASE("Product matcher with multi-part level path", "[data model]") TEST_CASE("Product with only node spec", "[data model]") { product_matcher matcher{"@add:sum"}; - CHECK(matcher.level_path() == "*"); + CHECK(matcher.layer_path() == "*"); CHECK(matcher.module_name() == ""); CHECK(matcher.node_name() == "add"); CHECK(matcher.product_name() == "sum"); @@ -78,7 +78,7 @@ TEST_CASE("Product with only node spec", "[data model]") TEST_CASE("Product with only module spec", "[data model]") { product_matcher matcher{"loaded_module:sum"}; - CHECK(matcher.level_path() == "*"); + CHECK(matcher.layer_path() == "*"); CHECK(matcher.module_name() == "loaded_module"); CHECK(matcher.node_name() == ""); CHECK(matcher.product_name() == "sum"); diff --git a/test/unfold.cpp b/test/unfold.cpp index 448320080..6665f374d 100644 --- a/test/unfold.cpp +++ b/test/unfold.cpp @@ -15,7 +15,7 @@ // ======================================================================================= #include "phlex/core/framework_graph.hpp" -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/model/product_store.hpp" #include "test/products_for_output.hpp" @@ -49,7 +49,7 @@ namespace { } auto initial_value() const { return begin_; } bool predicate(numbers_t::const_iterator it) const { return it != end_; } - auto unfold(numbers_t::const_iterator it, data_cell_id const& lid) const + auto unfold(numbers_t::const_iterator it, data_cell_index const& lid) const { spdlog::info("Unfolding into {}", lid.to_string()); auto num = *it; @@ -66,7 +66,7 @@ namespace { void check_sum(handle const sum) { - if (sum.data_cell_id().number() == 0ull) { + if (sum.data_cell_index().number() == 0ull) { CHECK(*sum == 45); } else { CHECK(*sum == 190); @@ -75,7 +75,7 @@ namespace { void check_sum_same(handle const sum) { - auto const expected_sum = (sum.data_cell_id().number() + 1) * 10; + auto const expected_sum = (sum.data_cell_index().number() + 1) * 10; CHECK(*sum == expected_sum); } } diff --git a/test/yielding_driver.cpp b/test/yielding_driver.cpp index 67dd59602..0c080cfa2 100644 --- a/test/yielding_driver.cpp +++ b/test/yielding_driver.cpp @@ -1,4 +1,4 @@ -#include "phlex/model/data_cell_id.hpp" +#include "phlex/model/data_cell_index.hpp" #include "phlex/utilities/async_driver.hpp" #include "fmt/std.h" @@ -13,13 +13,13 @@ using namespace phlex::experimental; -void cells_to_process(async_driver& d) +void cells_to_process(async_driver& d) { unsigned int const num_runs = 2; unsigned int const num_subruns = 2; unsigned int const num_spills = 3; - auto job_id = data_cell_id::base_ptr(); + auto job_id = data_cell_index::base_ptr(); d.yield(job_id); for (unsigned int r : std::views::iota(0u, num_runs)) { auto run_id = job_id->make_child(r, "run"); @@ -36,9 +36,9 @@ void cells_to_process(async_driver& d) int main() { - async_driver drive{cells_to_process}; + async_driver drive{cells_to_process}; tbb::flow::graph g{}; - tbb::flow::input_node source{g, [&drive](tbb::flow_control& fc) -> data_cell_id_ptr { + tbb::flow::input_node source{g, [&drive](tbb::flow_control& fc) -> data_cell_index_ptr { if (auto next = drive()) { return *next; } @@ -46,7 +46,7 @@ int main() return {}; }}; tbb::flow::function_node receiver{ - g, tbb::flow::unlimited, [](data_cell_id_ptr const& set_id) -> tbb::flow::continue_msg { + g, tbb::flow::unlimited, [](data_cell_index_ptr const& set_id) -> tbb::flow::continue_msg { spdlog::info("Received {}", set_id->to_string()); return {}; }}; From 6f915d43268bde53912e9b2424bc200075bed617 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Tue, 2 Dec 2025 13:00:01 -0600 Subject: [PATCH 7/8] Remove stale header include --- test/type_distinction.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/type_distinction.cpp b/test/type_distinction.cpp index 3fb29b35c..3784188bb 100644 --- a/test/type_distinction.cpp +++ b/test/type_distinction.cpp @@ -1,5 +1,4 @@ #include "phlex/core/framework_graph.hpp" -#include "phlex/model/level_hierarchy.hpp" #include "phlex/model/product_store.hpp" #include "spdlog/spdlog.h" From c73cd4e5015646c0d6018afe55cb34717ffcb1c1 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Tue, 2 Dec 2025 13:03:57 -0600 Subject: [PATCH 8/8] Replace 'family' with 'layer' where appropriate --- phlex/core/multiplexer.cpp | 12 ++++++------ phlex/core/product_query.cpp | 12 ++++++------ phlex/core/product_query.hpp | 6 +++--- test/product_query.cpp | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/phlex/core/multiplexer.cpp b/phlex/core/multiplexer.cpp index d991ea307..cd3a37e75 100644 --- a/phlex/core/multiplexer.cpp +++ b/phlex/core/multiplexer.cpp @@ -16,14 +16,14 @@ namespace { phlex::experimental::product_store_const_ptr store, phlex::experimental::product_query const& label) { - auto const& [product_name, family] = label; - if (family.empty()) { + auto const& [product_name, layer] = label; + if (layer.empty()) { return store->store_for_product(product_name.full()); } - if (store->layer_name() == family and store->contains_product(product_name.full())) { + if (store->layer_name() == layer and store->contains_product(product_name.full())) { return store; } - auto parent = store->parent(family); + auto parent = store->parent(layer); if (not parent) { return nullptr; } @@ -56,8 +56,8 @@ namespace { continue; } - if (auto const& allowed_family = product_label.family; not allowed_family.empty()) { - if (store_to_send->layer_name() != allowed_family) { + if (auto const& allowed_layer = product_label.layer; not allowed_layer.empty()) { + if (store_to_send->layer_name() != allowed_layer) { continue; } } diff --git a/phlex/core/product_query.cpp b/phlex/core/product_query.cpp index 48421b88f..e3c425030 100644 --- a/phlex/core/product_query.cpp +++ b/phlex/core/product_query.cpp @@ -7,17 +7,17 @@ #include namespace phlex::experimental { - product_query product_query::operator()(std::string family) && + product_query product_query::operator()(std::string layer) && { - return {std::move(name), std::move(family)}; + return {std::move(name), std::move(layer)}; } std::string product_query::to_string() const { - if (family.empty()) { + if (layer.empty()) { return name.full(); } - return fmt::format("{} ϵ {}", name.full(), family); + return fmt::format("{} ϵ {}", name.full(), layer); } product_query operator""_in(char const* name, std::size_t length) @@ -30,14 +30,14 @@ namespace phlex::experimental { bool operator==(product_query const& a, product_query const& b) { - return std::tie(a.name, a.family) == std::tie(b.name, b.family); + return std::tie(a.name, a.layer) == std::tie(b.name, b.layer); } bool operator!=(product_query const& a, product_query const& b) { return !(a == b); } bool operator<(product_query const& a, product_query const& b) { - return std::tie(a.name, a.family) < std::tie(b.name, b.family); + return std::tie(a.name, a.layer) < std::tie(b.name, b.layer); } std::ostream& operator<<(std::ostream& os, product_query const& label) diff --git a/phlex/core/product_query.hpp b/phlex/core/product_query.hpp index 026d51a93..cce79e8f5 100644 --- a/phlex/core/product_query.hpp +++ b/phlex/core/product_query.hpp @@ -12,8 +12,8 @@ namespace phlex::experimental { struct product_query { product_specification name; - std::string family; - product_query operator()(std::string family) &&; + std::string layer; + product_query operator()(std::string layer) &&; std::string to_string() const; static product_query create(char const* c); @@ -24,7 +24,7 @@ namespace phlex::experimental { using product_queries = std::vector; inline auto& to_name(product_query const& label) { return label.name.name(); } - inline auto& to_family(product_query& label) { return label.family; } + inline auto& to_layer(product_query& label) { return label.layer; } product_query operator""_in(char const* str, std::size_t); bool operator==(product_query const& a, product_query const& b); diff --git a/test/product_query.cpp b/test/product_query.cpp index 97fbea257..63e54cb33 100644 --- a/test/product_query.cpp +++ b/test/product_query.cpp @@ -16,11 +16,11 @@ TEST_CASE("Only name in label", "[data model]") product_query label{"product"}; CHECK(label == "product"_in); - // Empty family string is interpreted as a wildcard--i.e. any family. + // Empty layer string is interpreted as a wildcard--i.e. any layer. CHECK(label == "product"_in("")); } -TEST_CASE("Label with family", "[data model]") +TEST_CASE("Label with layer", "[data model]") { product_query label{"product", {"event"}}; CHECK(label == "product"_in("event"));