Skip to content

Commit 2995d46

Browse files
beojangithub-actions[bot]knoepfel
authored
Actually using the new product_query (Part 1) (#344)
* This handles the API change, and ports the existing creator name check to work with the new product_query. * Make algorithm_name use identifiers * type_id now has an std::hash * Fix product_specification creation from product_query * Fix FORM test * Make default constructed identifiers valid --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Kyle Knoepfel <knoepfel@fnal.gov>
1 parent 103c08c commit 2995d46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+391
-213
lines changed

.github/workflows/codeql-analysis.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,13 @@ jobs:
218218
fi
219219
220220
determine-languages:
221-
needs: [pre-check, detect-changes-cpp, detect-changes-python, detect-changes-actions]
221+
needs:
222+
[
223+
pre-check,
224+
detect-changes-cpp,
225+
detect-changes-python,
226+
detect-changes-actions,
227+
]
222228
if: always() && needs.pre-check.result == 'success'
223229
runs-on: ubuntu-latest
224230
outputs:

form/form_module.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace {
6363
auto segment_id = store.index()->to_string();
6464

6565
std::cout << "\n=== FormOutputModule::save_data_products ===\n";
66-
std::cout << "Creator: " << creator << "\n";
66+
std::cout << "Creator: " << creator.full() << "\n";
6767
std::cout << "Segment ID: " << segment_id << "\n";
6868
std::cout << "Number of products: " << store.size() << "\n";
6969

@@ -81,10 +81,10 @@ namespace {
8181
// product_ptr: pointer to the actual product data
8282
assert(product_ptr && "store should not contain null product_ptr");
8383

84-
std::cout << " Product: " << product_name << "\n";
84+
std::cout << " Product: " << product_name.full() << "\n";
8585

8686
// Create FORM product with metadata
87-
products.emplace_back(product_name, // label, from map key
87+
products.emplace_back(product_name.name().trans_get_string(), // label, from map key
8888
product_ptr->address(), // data, from phlex product_base
8989
&product_ptr->type() // type, from phlex product_base
9090
);
@@ -95,7 +95,7 @@ namespace {
9595
// Write all products to FORM
9696
// Pass segment_id once for entire collection (not duplicated in each product)
9797
// No need to check if products is empty - already checked store.empty() above
98-
m_form_interface->write(creator, segment_id, products);
98+
m_form_interface->write(creator.full(), segment_id, products);
9999
std::cout << "Wrote " << products.size() << " products to FORM\n";
100100
}
101101

phlex/core/consumer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ namespace phlex::experimental {
88

99
std::string consumer::full_name() const { return name_.full(); }
1010

11-
std::string const& consumer::plugin() const noexcept { return name_.plugin(); }
12-
std::string const& consumer::algorithm() const noexcept { return name_.algorithm(); }
11+
identifier const& consumer::plugin() const noexcept { return name_.plugin(); }
12+
identifier const& consumer::algorithm() const noexcept { return name_.algorithm(); }
1313

1414
std::vector<std::string> const& consumer::when() const noexcept { return predicates_; }
1515
}

phlex/core/consumer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace phlex::experimental {
1212
consumer(algorithm_name name, std::vector<std::string> predicates);
1313

1414
std::string full_name() const;
15-
std::string const& plugin() const noexcept;
16-
std::string const& algorithm() const noexcept;
15+
identifier const& plugin() const noexcept;
16+
identifier const& algorithm() const noexcept;
1717
std::vector<std::string> const& when() const noexcept;
1818

1919
private:

phlex/core/declared_fold.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ namespace phlex::experimental {
186186
{
187187
auto& result = results_.at(store->index()->hash());
188188
if constexpr (requires { send(*result); }) {
189-
store->add_product(output()[0].name(), send(*result));
189+
store->add_product(output()[0], send(*result));
190190
} else {
191-
store->add_product(output()[0].name(), std::move(result));
191+
store->add_product(output()[0], std::move(result));
192192
}
193193
// Reclaim some memory; it would be better to erase the entire entry from the map,
194194
// but that is not thread-safe.
@@ -198,7 +198,7 @@ namespace phlex::experimental {
198198
InitTuple initializer_;
199199
input_retriever_types<input_parameter_types> input_{input_arguments<input_parameter_types>()};
200200
product_specifications output_;
201-
std::string partition_;
201+
identifier partition_;
202202
tbb::flow::function_node<flush_message> flush_receiver_;
203203
join_or_none_t<num_inputs> join_;
204204
tbb::flow::multifunction_node<messages_t<num_inputs>, message_tuple<1>> fold_;

phlex/core/declared_provider.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ namespace phlex::experimental {
5656
AlgorithmBits alg,
5757
product_query output) :
5858
declared_provider{std::move(name), output},
59-
output_{output.spec()},
59+
output_{algorithm_name::create(std::string_view(identifier(output.creator))),
60+
output.suffix.value_or(identifier("")),
61+
output.type},
6062
provider_{g,
6163
concurrency,
6264
[this, ft = alg.release_algorithm()](index_message const& index_msg, auto& output) {
@@ -66,7 +68,7 @@ namespace phlex::experimental {
6668
++calls_;
6769

6870
products new_products;
69-
new_products.add(output_.name(), std::move(result));
71+
new_products.add(output_, std::move(result));
7072
auto store = std::make_shared<product_store>(
7173
index, this->full_name(), std::move(new_products));
7274

phlex/core/declared_unfold.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace phlex::experimental {
99

1010
generator::generator(product_store_const_ptr const& parent,
11-
std::string node_name,
11+
algorithm_name node_name,
1212
std::string const& child_layer_name) :
1313
parent_{std::const_pointer_cast<product_store>(parent)},
1414
node_name_{std::move(node_name)},

phlex/core/declared_unfold.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "phlex/model/algorithm_name.hpp"
1111
#include "phlex/model/data_cell_index.hpp"
1212
#include "phlex/model/handle.hpp"
13+
#include "phlex/model/identifier.hpp"
1314
#include "phlex/model/product_specification.hpp"
1415
#include "phlex/model/product_store.hpp"
1516
#include "phlex/utilities/simple_ptr_map.hpp"
@@ -34,7 +35,7 @@ namespace phlex::experimental {
3435
class generator {
3536
public:
3637
explicit generator(product_store_const_ptr const& parent,
37-
std::string node_name,
38+
algorithm_name node_name,
3839
std::string const& child_layer_name);
3940
flush_counts_ptr flush_result() const;
4041

@@ -47,7 +48,7 @@ namespace phlex::experimental {
4748
private:
4849
product_store_const_ptr make_child(std::size_t i, products new_products);
4950
product_store_ptr parent_;
50-
std::string node_name_;
51+
algorithm_name node_name_;
5152
std::string const& child_layer_name_;
5253
std::map<data_cell_index::hash_type, std::size_t> child_counts_;
5354
};

phlex/core/detail/filter_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace phlex::experimental {
7676

7777
// Fill slots in the order of the input arguments to the downstream node.
7878
for (std::size_t i = 0; i != nargs_; ++i) {
79-
if (elem[i] or not store->contains_product((*product_names_)[i].spec().full()))
79+
if (elem[i] or not store->contains_product((*product_names_)[i].spec()))
8080
continue;
8181
elem[i] = store;
8282
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#include "phlex/core/detail/make_algorithm_name.hpp"
22
#include "phlex/configuration.hpp"
33
#include "phlex/model/algorithm_name.hpp"
4+
#include "phlex/model/identifier.hpp"
45

56
namespace phlex::experimental::detail {
6-
algorithm_name make_algorithm_name(configuration const* config, std::string name)
7+
algorithm_name make_algorithm_name(configuration const* config, std::string_view name)
78
{
8-
return {config ? config->get<std::string>("module_label") : "", std::move(name)};
9+
return {config ? identifier(config->get<std::string_view>("module_label")) : ""_id,
10+
identifier(name)};
911
}
1012
}

0 commit comments

Comments
 (0)