sstables: mc: reader: Use enum class instead of variant

variant is an overkill here.

Message-Id: <1545409014-16289-1-git-send-email-tgrabiec@scylladb.com>
This commit is contained in:
Tomasz Grabiec
2018-12-21 17:16:54 +01:00
committed by Avi Kivity
parent e6a8883228
commit 07d153c769
2 changed files with 17 additions and 17 deletions

View File

@@ -1089,7 +1089,7 @@ public:
if (maybe_push_range_tombstone(std::move(rt)) == proceed::no) {
_in_progress_row.emplace(std::move(key));
return consumer_m::retry_later{};
return consumer_m::row_processing_result::retry_later;
}
}
@@ -1098,19 +1098,19 @@ public:
switch (_mf_filter->apply(_in_progress_row->position())) {
case mutation_fragment_filter::result::emit:
sstlog.trace("mp_row_consumer_m {}: emit", this);
return consumer_m::do_proceed{};
return consumer_m::row_processing_result::do_proceed;
case mutation_fragment_filter::result::ignore:
sstlog.trace("mp_row_consumer_m {}: ignore", this);
if (_mf_filter->is_current_range_changed()) {
return consumer_m::row_processing_result(consumer_m::retry_later{});
return consumer_m::row_processing_result::retry_later;
} else {
_in_progress_row.reset();
return consumer_m::row_processing_result(consumer_m::skip_row{});
return consumer_m::row_processing_result::skip_row;
}
case mutation_fragment_filter::result::store_and_finish:
sstlog.trace("mp_row_consumer_m {}: store_and_finish", this);
_reader->on_end_of_stream();
return consumer_m::retry_later{};
return consumer_m::row_processing_result::retry_later;
}
abort();
}
@@ -1131,7 +1131,7 @@ public:
sstlog.trace("mp_row_consumer_m {}: consume_static_row_start()", this);
_inside_static_row = true;
_in_progress_static_row = static_row();
return consumer_m::do_proceed{};
return consumer_m::row_processing_result::do_proceed;
}
virtual proceed consume_column(const column_translation::column_info& column_info,

View File

@@ -142,17 +142,17 @@ class consumer_m {
public:
using proceed = data_consumer::proceed;
// Causes the parser to return the control to the caller without advancing.
// Next time when the parser is called, the same consumer method will be called.
struct retry_later {};
enum class row_processing_result {
// Causes the parser to return the control to the caller without advancing.
// Next time when the parser is called, the same consumer method will be called.
retry_later,
// Causes the parser to proceed to the next element.
struct do_proceed {};
// Causes the parser to proceed to the next element.
do_proceed,
// Causes the parser to skip the whole row. consume_row_end() will not be called for the current row.
struct skip_row {};
using row_processing_result = std::variant<retry_later, do_proceed, skip_row>;
// Causes the parser to skip the whole row. consume_row_end() will not be called for the current row.
skip_row
};
consumer_m(reader_resource_tracker resource_tracker, const io_priority_class& pc)
: _resource_tracker(resource_tracker)
@@ -945,10 +945,10 @@ private:
? _consumer.consume_static_row_start()
: _consumer.consume_row_start(_row_key);
if (std::holds_alternative<consumer_m::retry_later>(ret)) {
if (ret == consumer_m::row_processing_result::retry_later) {
_state = state::ROW_BODY_PREV_SIZE;
return consumer_m::proceed::no;
} else if (std::holds_alternative<consumer_m::skip_row>(ret)) {
} else if (ret == consumer_m::row_processing_result::skip_row) {
_state = state::FLAGS;
auto current_pos = position() - data.size();
return skip(data, _next_row_offset - current_pos);