style and tsan fix

This commit is contained in:
Nikita Mikhailov 2021-03-02 01:32:11 +03:00 committed by Nikita Mikhaylov
parent 369c9da161
commit 3a7d48f3a4
3 changed files with 9 additions and 3 deletions

View File

@ -10,6 +10,8 @@ namespace DB
/// Used to pass info from header between different InputFormats in ParallelParsing
struct ColumnMapping
{
/// Non-atomic because only read access in possible
bool is_set;
/// Maps indexes of columns in the input file to indexes of table columns
using OptionalIndexes = std::vector<std::optional<size_t>>;
OptionalIndexes column_indexes_for_input_fields;
@ -59,7 +61,7 @@ public:
/// Must be called from ParallelParsingInputFormat after readSuffix
ColumnMappingPtr getColumnMapping() const { return column_mapping; }
/// Must be called from ParallelParsingInputFormat before readPrefix
void setColumnMapping(ColumnMappingPtr column_mapping_ ) { column_mapping = column_mapping_; }
void setColumnMapping(ColumnMappingPtr column_mapping_) { column_mapping = column_mapping_; }
size_t getCurrentUnitNumber() const { return current_unit_number; }
void setCurrentUnitNumber(size_t current_unit_number_) { current_unit_number = current_unit_number_; }

View File

@ -92,7 +92,11 @@ void ParallelParsingInputFormat::parserThreadFunction(ThreadGroupStatusPtr threa
/// Propagate column_mapping to other parsers.
/// Note: column_mapping is used only for *WithNames types
if (current_ticket_number != 0)
{
column_mapping->is_set = true;
input_format->setColumnMapping(column_mapping);
}
// We don't know how many blocks will be. So we have to read them all
// until an empty block occurred.
@ -105,7 +109,7 @@ void ParallelParsingInputFormat::parserThreadFunction(ThreadGroupStatusPtr threa
unit.chunk_ext.block_missing_values.emplace_back(parser.getMissingValues());
}
/// Extract column_mapping from first parser to propage it to others
/// Extract column_mapping from first parser to propagate it to others
if (current_ticket_number == 0)
column_mapping = input_format->getColumnMapping();

View File

@ -170,7 +170,7 @@ void TabSeparatedRowInputFormat::readPrefix()
skipTSVRow(in, column_mapping->column_indexes_for_input_fields.size());
}
}
else
else if (!column_mapping->is_set)
setupAllColumnsByTableSchema();
if (with_types)