Skip to content

Commit

Permalink
Avoid checks for empty sets in the select action: (#34)
Browse files Browse the repository at this point in the history
- Update check conditions in MetadataMatcher
- Change the construction of the matcher in the Select action

Co-authored-by: Mirco Valentini <[email protected]>
  • Loading branch information
dsarmany and MircoValentiniECMWF committed Nov 21, 2024
1 parent ec7149c commit 9509fdf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/multio/action/select/Select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace multio::action {

//--------------------------------------------------------------------------------------------------

Select::Select(const ComponentConfiguration& compConf) : ChainedAction{compConf}, selectors_{compConf.parsedConfig()} {}
Select::Select(const ComponentConfiguration& compConf) : ChainedAction{compConf}, selectors_{MatchReduce::construct( compConf.parsedConfig())} {}

void Select::executeImpl(Message msg) {
if (matches(msg)) {
Expand Down
13 changes: 7 additions & 6 deletions src/multio/message/MetadataMatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ bool MatchKeys::matches(const Metadata& md) const {
break;
}
if (kv.second.find(searchKey->second) == kv.second.end()) {
if (enforceSameKeyTypes_) {
if (kv.second.size() == 0) {
std::ostringstream oss;
oss << "[enforce-same-key-type] Matcher for key \"" << kv.first << "\" is an empty set";
throw MetadataException(oss.str());
}
if (enforceSameKeyTypes_ && kv.second.size() > 0 ) {
// Note: NEMO needs the possibiity to use empty sets!!!
//if (kv.second.size() == 0) {
// std::ostringstream oss;
// oss << "[enforce-same-key-type] Matcher for key \"" << kv.first << "\" is an empty set";
// throw MetadataException(oss.str());
//}

if (kv.second.begin()->index() != searchKey->second.index()) {
std::ostringstream oss;
Expand Down

0 comments on commit 9509fdf

Please sign in to comment.