Mark unexercised attribute accumulation cases as "can't happen"

This commit is contained in:
Erica Fischer
2024-09-19 09:00:24 -07:00
parent e60ca59502
commit 0299706c47
+6 -31
View File
@@ -175,41 +175,12 @@ void preserve_attribute(attribute_op const &op, std::string const &key, serial_v
serial_val sv;
switch (op) {
case op_sum:
case op_product:
case op_max:
case op_min:
sv.s = val.s;
sv.type = mvt_double;
break;
case op_mean: {
auto state = attribute_accum_state.find(key);
if (state == attribute_accum_state.end()) {
accum_state s;
s.sum = atof(val.s.c_str());
s.count = 1;
attribute_accum_state.insert(std::pair<std::string, accum_state>(key, s));
sv.s = milo::dtoa_milo(s.sum / s.count);
} else {
state->second.sum += atof(val.s.c_str());
state->second.count += 1;
sv.s = milo::dtoa_milo(state->second.sum / state->second.count);
}
break;
}
case op_concat:
sv.s = val.s;
sv.type = mvt_string;
break;
case op_comma:
sv.s = val.s;
sv.type = mvt_string;
break;
case op_count: {
auto state = attribute_accum_state.find(key);
if (state == attribute_accum_state.end()) { // not already present
@@ -219,12 +190,16 @@ void preserve_attribute(attribute_op const &op, std::string const &key, serial_v
sv.s = std::to_string(s.count);
} else { // already present, incrementing
state->second.count += 1;
sv.s = std::to_string(state->second.count);
fprintf(stderr, "preserve_attribute: can't happen (count)\n");
exit(EXIT_IMPOSSIBLE);
}
sv.type = mvt_double;
break;
}
default:
fprintf(stderr, "can't happen: operation that isn't used by --accumulate-numeric-attributes\n");
exit(EXIT_IMPOSSIBLE);
}
full_keys.push_back(key);