Skip to content

Commit

Permalink
mx sstable reader: reduce code blocks
Browse files Browse the repository at this point in the history
Some blocks of code were surrounded by curly braces, because
a variable was declared inside a switch case. After changes,
some of the variable declarations are in if/else/while cases,
and no longer need to be in separate code blocks, while other
blocks can be extended to entire labels for simplicity.
  • Loading branch information
wmitros committed Jul 14, 2021
1 parent 9b33390 commit 4505877
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions sstables/mx/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,13 @@ class data_consume_rows_context_m : public data_consumer::continuous_data_consum
if (_state != state::PARTITION_START) {
goto flags_label;
}
partition_start_label:
partition_start_label: {
_is_first_unfiltered = true;
_state = state::DELETION_TIME;
co_yield read_short_length_bytes(*_processing_data, _pk);
_state = state::OTHER;
co_yield read_32(*_processing_data);
co_yield read_64(*_processing_data);
{
deletion_time del;
del.local_deletion_time = _u32;
del.marked_for_delete_at = _u64;
Expand Down Expand Up @@ -361,7 +360,6 @@ class data_consume_rows_context_m : public data_consumer::continuous_data_consum
co_yield read_unsigned_vint(*_processing_data);
_ck_blocks_header = _u64;
}
{
if (is_block_null()) {
_null_component_occured = true;
move_to_next_ck_block();
Expand All @@ -382,19 +380,17 @@ class data_consume_rows_context_m : public data_consumer::continuous_data_consum
status = read_unsigned_vint_length_bytes(*_processing_data, _column_value);
}
co_yield status;
}
_row_key.push_back(std::move(_column_value));
move_to_next_ck_block();
}
if (_reading_range_tombstone_ck) {
_reading_range_tombstone_ck = false;
goto range_tombstone_body_label;
}
row_body_label:
row_body_label: {
co_yield read_unsigned_vint(*_processing_data);
_next_row_offset = position() - _processing_data->size() + _u64;
co_yield read_unsigned_vint(*_processing_data);
{
// Ignore the result
consumer_m::row_processing_result ret = _extended_flags.is_static()
? _consumer.consume_static_row_start()
Expand All @@ -415,7 +411,6 @@ class data_consume_rows_context_m : public data_consumer::continuous_data_consum
}
goto flags_label;
}
}
if (_extended_flags.is_static()) {
if (_flags.has_timestamp() || _flags.has_ttl() || _flags.has_deletion()) {
throw malformed_sstable_exception(format("Static row has unexpected flags: timestamp={}, ttl={}, deletion={}",
Expand Down Expand Up @@ -453,7 +448,6 @@ class data_consume_rows_context_m : public data_consumer::continuous_data_consum
}
if (!_flags.has_all_columns()) {
co_yield read_unsigned_vint(*_processing_data);
{
uint64_t missing_column_bitmap_or_count = _u64;
if (_row->_columns.size() < 64) {
_row->_columns_selector.clear();
Expand All @@ -471,7 +465,6 @@ class data_consume_rows_context_m : public data_consumer::continuous_data_consum
_missing_columns_to_read = missing_column_bitmap_or_count;
_row->_columns_selector.set();
}
}
while (_missing_columns_to_read > 0) {
--_missing_columns_to_read;
co_yield read_unsigned_vint(*_processing_data);
Expand All @@ -481,6 +474,7 @@ class data_consume_rows_context_m : public data_consumer::continuous_data_consum
} else {
_row->_columns_selector.set();
}
}
column_label:
if (_subcolumns_to_read == 0) {
if (no_more_columns()) {
Expand Down

0 comments on commit 4505877

Please sign in to comment.