diff --git a/include/ircd/db/compactor.h b/include/ircd/db/compactor.h index 9c9445a70..85fc5bd6a 100644 --- a/include/ircd/db/compactor.h +++ b/include/ircd/db/compactor.h @@ -25,12 +25,21 @@ namespace ircd::db /// struct ircd::db::compactor { - using prototype = db::op (const int &level, - const string_view &key, - const string_view &val, - std::string *const replace, - std::string *const skip_until); + struct args; + using proto = db::op (const args &); + using callback = std::function; - std::function value; - std::function merge; + callback value; + callback merge; +}; + +struct ircd::db::compactor::args +{ + const int &level; + + const string_view key; + const string_view val; + + std::string *const &replace; + std::string *const &skip_until; }; diff --git a/ircd/db.cc b/ircd/db.cc index 2a3f0b003..006c5aaba 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -2436,28 +2436,26 @@ const }; #endif - db::op ret + const db::compactor::callback &callback { - db::op::GET + type == ValueType::kValue && user.value? + user.value: + + type == ValueType::kMergeOperand && user.merge? + user.merge: + + compactor::callback{} }; - switch(type) + if(!callback) + return Decision::kKeep; + + const compactor::args args { - case ValueType::kValue: - if(user.value) - ret = user.value(level, slice(key), slice(oldval), newval, skip); - break; + level, slice(key), slice(oldval), newval, skip + }; - case ValueType::kMergeOperand: - if(user.merge) - ret = user.merge(level, slice(key), slice(oldval), newval, skip); - break; - - case ValueType::kBlobIndex: - break; - } - - switch(ret) + switch(callback(args)) { default: case db::op::GET: return Decision::kKeep;