@@ -218,62 +218,105 @@ tl::mask rpcInvokeReqExtra::get_flags() const noexcept {
218218 return flags;
219219}
220220
221+ bool rpcReqResultExtra::fetch (tl::fetcher& tlf, const tl::mask& flags) noexcept {
222+ bool ok{true };
223+ if (ok && static_cast <bool >(flags.value & BINLOG_POS_FLAG)) {
224+ ok = opt_binlog_pos.emplace ().fetch (tlf);
225+ }
226+ if (ok && static_cast <bool >(flags.value & BINLOG_TIME_FLAG)) {
227+ ok = opt_binlog_time.emplace ().fetch (tlf);
228+ }
229+ if (ok && static_cast <bool >(flags.value & ENGINE_PID_FLAG)) {
230+ ok = opt_engine_pid.emplace ().fetch (tlf);
231+ }
232+ if (ok && static_cast <bool >(flags.value & REQUEST_SIZE_FLAG)) {
233+ kphp::log::assertion (static_cast <bool >(flags.value & RESPONSE_SIZE_FLAG));
234+ ok = opt_request_size.emplace ().fetch (tlf) && opt_response_size.emplace ().fetch (tlf);
235+ }
236+ if (ok && static_cast <bool >(flags.value & FAILED_SUBQUERIES_FLAG)) {
237+ ok = opt_failed_subqueries.emplace ().fetch (tlf);
238+ }
239+ if (ok && static_cast <bool >(flags.value & COMPRESSION_VERSION_FLAG)) {
240+ ok = opt_compression_version.emplace ().fetch (tlf);
241+ }
242+ if (ok && static_cast <bool >(flags.value & STATS_FLAG)) {
243+ ok = opt_stats.emplace ().fetch (tlf);
244+ }
245+ if (ok && static_cast <bool >(flags.value & EPOCH_NUMBER_FLAG)) {
246+ kphp::log::assertion (static_cast <bool >(flags.value & VIEW_NUMBER_FLAG));
247+ ok = opt_epoch_number.emplace ().fetch (tlf) && opt_view_number.emplace ().fetch (tlf);
248+ }
249+ return ok;
250+ }
251+
221252void rpcReqResultExtra::store (tl::storer& tls, const tl::mask& flags) const noexcept {
222253 if (static_cast <bool >(flags.value & BINLOG_POS_FLAG)) {
223- binlog_pos.store (tls);
254+ kphp::log::assertion (opt_binlog_pos.has_value ());
255+ opt_binlog_pos->store (tls);
224256 }
225257 if (static_cast <bool >(flags.value & BINLOG_TIME_FLAG)) {
226- binlog_time.store (tls);
258+ kphp::log::assertion (opt_binlog_time.has_value ());
259+ opt_binlog_time->store (tls);
227260 }
228- if (static_cast <bool >(flags.value ) & ENGINE_PID_FLAG) {
229- engine_pid.store (tls);
261+ if (static_cast <bool >(flags.value & ENGINE_PID_FLAG)) {
262+ kphp::log::assertion (opt_engine_pid.has_value ());
263+ opt_engine_pid->store (tls);
230264 }
231265 if (static_cast <bool >(flags.value & REQUEST_SIZE_FLAG)) {
232- kphp::log::assertion (static_cast <bool >(flags.value & RESPONSE_SIZE_FLAG));
233- request_size. store (tls), response_size. store (tls);
266+ kphp::log::assertion (opt_request_size. has_value () && static_cast <bool >(flags.value & RESPONSE_SIZE_FLAG) && opt_response_size. has_value ( ));
267+ opt_request_size-> store (tls), opt_response_size-> store (tls);
234268 }
235269 if (static_cast <bool >(flags.value & FAILED_SUBQUERIES_FLAG)) {
236- failed_subqueries.store (tls);
270+ kphp::log::assertion (opt_failed_subqueries.has_value ());
271+ opt_failed_subqueries->store (tls);
237272 }
238273 if (static_cast <bool >(flags.value & COMPRESSION_VERSION_FLAG)) {
239- compression_version.store (tls);
274+ kphp::log::assertion (opt_compression_version.has_value ());
275+ opt_compression_version->store (tls);
240276 }
241277 if (static_cast <bool >(flags.value & STATS_FLAG)) {
242- stats.store (tls);
278+ kphp::log::assertion (opt_stats.has_value ());
279+ opt_stats->store (tls);
243280 }
244281 if (static_cast <bool >(flags.value & EPOCH_NUMBER_FLAG)) {
245- kphp::log::assertion (static_cast <bool >(flags.value & VIEW_NUMBER_FLAG));
246- epoch_number. store (tls), view_number. store (tls);
282+ kphp::log::assertion (opt_epoch_number. has_value () && static_cast <bool >(flags.value & VIEW_NUMBER_FLAG) && opt_view_number. has_value ( ));
283+ opt_epoch_number-> store (tls), opt_view_number-> store (tls);
247284 }
248285}
249286
250287size_t rpcReqResultExtra::footprint (const tl::mask& flags) const noexcept {
251288 size_t footprint{};
252289 if (static_cast <bool >(flags.value & BINLOG_POS_FLAG)) {
253- footprint += binlog_pos.footprint ();
290+ kphp::log::assertion (opt_binlog_pos.has_value ());
291+ footprint += opt_binlog_pos->footprint ();
254292 }
255293 if (static_cast <bool >(flags.value & BINLOG_TIME_FLAG)) {
256- footprint += binlog_time.footprint ();
294+ kphp::log::assertion (opt_binlog_time.has_value ());
295+ footprint += opt_binlog_time->footprint ();
257296 }
258- if (static_cast <bool >(flags.value ) & ENGINE_PID_FLAG) {
259- footprint += engine_pid.footprint ();
297+ if (static_cast <bool >(flags.value & ENGINE_PID_FLAG)) {
298+ kphp::log::assertion (opt_engine_pid.has_value ());
299+ footprint += opt_engine_pid->footprint ();
260300 }
261301 if (static_cast <bool >(flags.value & REQUEST_SIZE_FLAG)) {
262- kphp::log::assertion (static_cast <bool >(flags.value & RESPONSE_SIZE_FLAG));
263- footprint += request_size. footprint () + response_size. footprint ();
302+ kphp::log::assertion (opt_request_size. has_value () && static_cast <bool >(flags.value & RESPONSE_SIZE_FLAG) && opt_response_size. has_value ( ));
303+ footprint += opt_request_size-> footprint () + opt_response_size-> footprint ();
264304 }
265305 if (static_cast <bool >(flags.value & FAILED_SUBQUERIES_FLAG)) {
266- footprint += failed_subqueries.footprint ();
306+ kphp::log::assertion (opt_failed_subqueries.has_value ());
307+ footprint += opt_failed_subqueries->footprint ();
267308 }
268309 if (static_cast <bool >(flags.value & COMPRESSION_VERSION_FLAG)) {
269- footprint += compression_version.footprint ();
310+ kphp::log::assertion (opt_compression_version.has_value ());
311+ footprint += opt_compression_version->footprint ();
270312 }
271313 if (static_cast <bool >(flags.value & STATS_FLAG)) {
272- footprint += stats.footprint ();
314+ kphp::log::assertion (opt_stats.has_value ());
315+ footprint += opt_stats->footprint ();
273316 }
274317 if (static_cast <bool >(flags.value & EPOCH_NUMBER_FLAG)) {
275- kphp::log::assertion (static_cast <bool >(flags.value & VIEW_NUMBER_FLAG));
276- footprint += epoch_number. footprint () + view_number. footprint ();
318+ kphp::log::assertion (opt_epoch_number. has_value () && static_cast <bool >(flags.value & VIEW_NUMBER_FLAG) && opt_view_number. has_value ( ));
319+ footprint += opt_epoch_number-> footprint () + opt_view_number-> footprint ();
277320 }
278321 return footprint;
279322}
0 commit comments