| 23 | #include "flow/UnitTest.h" |
| 24 | |
| 25 | ConfigKey ConfigKeyRef::decodeKey(KeyRef const& key) { |
| 26 | Tuple tuple; |
| 27 | try { |
| 28 | tuple = Tuple::unpack(key); |
| 29 | } catch (Error& e) { |
| 30 | TraceEvent(SevWarnAlways, "FailedToUnpackConfigKey").error(e).detail("Key", printable(key)); |
| 31 | throw invalid_config_db_key(); |
| 32 | } |
| 33 | if (tuple.size() != 2) { |
| 34 | throw invalid_config_db_key(); |
| 35 | } |
| 36 | if (tuple.getType(0) == Tuple::NULL_TYPE) { |
| 37 | return ConfigKeyRef({}, tuple.getString(1)); |
| 38 | } else { |
| 39 | if (tuple.getType(0) != Tuple::BYTES || tuple.getType(1) != Tuple::BYTES) { |
| 40 | throw invalid_config_db_key(); |
| 41 | } |
| 42 | return ConfigKeyRef(tuple.getString(0), tuple.getString(1)); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | Value KnobValueRef::ToValueFunc::operator()(int v) const { |
| 47 | return BinaryWriter::toValue(v, Unversioned()); |