mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Improve implementation
This commit is contained in:
parent
2b6ffc557a
commit
ea30bb7abf
@ -721,6 +721,9 @@ private:
|
||||
#undef DBMS_MIN_FIELD_SIZE
|
||||
|
||||
|
||||
using Row = std::vector<Field>;
|
||||
|
||||
|
||||
template <> struct Field::TypeToEnum<Null> { static const Types::Which value = Types::Null; };
|
||||
template <> struct Field::TypeToEnum<UInt64> { static const Types::Which value = Types::UInt64; };
|
||||
template <> struct Field::TypeToEnum<UInt128> { static const Types::Which value = Types::UInt128; };
|
||||
|
@ -452,7 +452,7 @@ namespace MySQLReplication
|
||||
UInt32 number_columns;
|
||||
String schema;
|
||||
String table;
|
||||
std::vector<Field> rows;
|
||||
Row rows;
|
||||
|
||||
RowsEvent(std::shared_ptr<TableMapEvent> table_map_, EventHeader && header_, const RowsEventHeader & rows_header)
|
||||
: EventBase(std::move(header_)), number_columns(0), table_map(table_map_)
|
||||
|
@ -193,7 +193,7 @@ void PostgreSQLBlockInputStream::insertValue(IColumn & column, std::string_view
|
||||
|
||||
size_t dimension = 0, max_dimension = 0, expected_dimensions = array_info[idx].num_dimensions;
|
||||
const auto parse_value = array_info[idx].pqxx_parser;
|
||||
std::vector<std::vector<Field>> dimensions(expected_dimensions + 1);
|
||||
std::vector<Row> dimensions(expected_dimensions + 1);
|
||||
|
||||
while (parsed.first != pqxx::array_parser::juncture::done)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ private:
|
||||
|
||||
const Block header;
|
||||
std::unique_ptr<Aggregator> aggregator;
|
||||
std::vector<Field> current_key_value;
|
||||
Row current_key_value;
|
||||
AggregatedDataVariants aggregation_result;
|
||||
ColumnRawPtrs key_columns;
|
||||
Aggregator::AggregateColumns columns_for_aggregator;
|
||||
|
@ -477,7 +477,7 @@ static inline void fillSignAndVersionColumnsData(Block & data, Int8 sign_value,
|
||||
|
||||
template <bool assert_nullable = false>
|
||||
static void writeFieldsToColumn(
|
||||
IColumn & column_to, const std::vector<Field> & rows_data, size_t column_index, const std::vector<bool> & mask, ColumnUInt8 * null_map_column = nullptr)
|
||||
IColumn & column_to, const Row & rows_data, size_t column_index, const std::vector<bool> & mask, ColumnUInt8 * null_map_column = nullptr)
|
||||
{
|
||||
if (ColumnNullable * column_nullable = typeid_cast<ColumnNullable *>(&column_to))
|
||||
writeFieldsToColumn<true>(column_nullable->getNestedColumn(), rows_data, column_index, mask, &column_nullable->getNullMapColumn());
|
||||
@ -599,7 +599,7 @@ static void writeFieldsToColumn(
|
||||
}
|
||||
|
||||
template <Int8 sign>
|
||||
static size_t onWriteOrDeleteData(const std::vector<Field> & rows_data, Block & buffer, size_t version)
|
||||
static size_t onWriteOrDeleteData(const Row & rows_data, Block & buffer, size_t version)
|
||||
{
|
||||
size_t prev_bytes = buffer.bytes();
|
||||
for (size_t column = 0; column < buffer.columns() - 2; ++column)
|
||||
@ -623,7 +623,7 @@ static inline bool differenceSortingKeys(const Tuple & row_old_data, const Tuple
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline size_t onUpdateData(const std::vector<Field> & rows_data, Block & buffer, size_t version, const std::vector<size_t> & sorting_columns_index)
|
||||
static inline size_t onUpdateData(const Row & rows_data, Block & buffer, size_t version, const std::vector<size_t> & sorting_columns_index)
|
||||
{
|
||||
if (rows_data.size() % 2 != 0)
|
||||
throw Exception("LOGICAL ERROR: It is a bug.", ErrorCodes::LOGICAL_ERROR);
|
||||
|
@ -232,7 +232,7 @@ private:
|
||||
|
||||
if (unlikely(attribute.is_complex_type))
|
||||
{
|
||||
auto & container = std::get<std::vector<Field>>(attribute.attribute_container);
|
||||
auto & container = std::get<Row>(attribute.attribute_container);
|
||||
|
||||
for (size_t fetched_key_index = 0; fetched_key_index < fetched_columns_index; ++fetched_key_index)
|
||||
{
|
||||
@ -506,7 +506,7 @@ private:
|
||||
|
||||
if (unlikely(attribute.is_complex_type))
|
||||
{
|
||||
auto & container = std::get<std::vector<Field>>(attribute.attribute_container);
|
||||
auto & container = std::get<Row>(attribute.attribute_container);
|
||||
std::forward<GetContainerFunc>(func)(container);
|
||||
}
|
||||
else
|
||||
@ -564,7 +564,7 @@ private:
|
||||
last_attribute.is_complex_type = dictionary_attribute.is_nullable || dictionary_attribute.is_array;
|
||||
|
||||
if (dictionary_attribute.is_nullable)
|
||||
last_attribute.attribute_container = std::vector<Field>();
|
||||
last_attribute.attribute_container = Row();
|
||||
else
|
||||
last_attribute.attribute_container = PaddedPODArray<ValueType>();
|
||||
};
|
||||
@ -609,7 +609,7 @@ private:
|
||||
PaddedPODArray<Float64>,
|
||||
PaddedPODArray<UUID>,
|
||||
PaddedPODArray<StringRef>,
|
||||
std::vector<Field>> attribute_container;
|
||||
Row> attribute_container;
|
||||
};
|
||||
|
||||
CacheDictionaryStorageConfiguration configuration;
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
auto result_column = ColumnString::create();
|
||||
for (size_t j = 0; j < input_rows_count; ++j)
|
||||
{
|
||||
std::vector<Field> row(size);
|
||||
Row row(size);
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
arguments[i].column->get(j, row[i]);
|
||||
MergeTreePartition partition(std::move(row));
|
||||
|
@ -79,7 +79,7 @@ static Block createBlockFromCollection(const Collection & collection, const Data
|
||||
for (size_t i = 0; i < columns_num; ++i)
|
||||
columns[i] = types[i]->createColumn();
|
||||
|
||||
std::vector<Field> tuple_values;
|
||||
Row tuple_values;
|
||||
for (const auto & value : collection)
|
||||
{
|
||||
if (columns_num == 1)
|
||||
@ -153,7 +153,7 @@ static Block createBlockFromAST(const ASTPtr & node, const DataTypes & types, Co
|
||||
MutableColumns columns = header.cloneEmptyColumns();
|
||||
|
||||
DataTypePtr tuple_type;
|
||||
std::vector<Field> tuple_values;
|
||||
Row tuple_values;
|
||||
const auto & list = node->as<ASTExpressionList &>();
|
||||
bool transform_null_in = context->getSettingsRef().transform_null_in;
|
||||
for (const auto & elem : list.children)
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
FillColumnDescription & getFillDescription(size_t ind) { return description[ind].fill_description; }
|
||||
|
||||
private:
|
||||
std::vector<Field> row;
|
||||
Row row;
|
||||
SortDescription description;
|
||||
};
|
||||
|
||||
|
@ -344,7 +344,7 @@ AvroDeserializer::DeserializeFn AvroDeserializer::createDeserializeFn(avro::Node
|
||||
if (target.isEnum())
|
||||
{
|
||||
const auto & enum_type = dynamic_cast<const IDataTypeEnum &>(*target_type);
|
||||
std::vector<Field> symbol_mapping;
|
||||
Row symbol_mapping;
|
||||
for (size_t i = 0; i < root_node->names(); i++)
|
||||
{
|
||||
symbol_mapping.push_back(enum_type.castToValue(root_node->nameAt(i)));
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
|
||||
bool is_group_started = false;
|
||||
|
||||
std::vector<Field> current_row;
|
||||
Row current_row;
|
||||
bool current_row_is_zero = true; /// Are all summed columns zero (or empty)? It is updated incrementally.
|
||||
|
||||
void addRowImpl(ColumnRawPtrs & raw_columns, size_t row);
|
||||
|
@ -214,7 +214,7 @@ namespace
|
||||
|
||||
virtual void insertPartitionValueColumn(
|
||||
size_t rows,
|
||||
const std::vector<Field> & partition_value,
|
||||
const Row & partition_value,
|
||||
const DataTypePtr & partition_value_type,
|
||||
const String & name) = 0;
|
||||
};
|
||||
@ -322,7 +322,7 @@ namespace
|
||||
}
|
||||
|
||||
void insertPartitionValueColumn(
|
||||
size_t rows, const std::vector<Field> & partition_value, const DataTypePtr & partition_value_type, const String & name) final
|
||||
size_t rows, const Row & partition_value, const DataTypePtr & partition_value_type, const String & name) final
|
||||
{
|
||||
ColumnPtr column;
|
||||
if (rows)
|
||||
@ -362,7 +362,7 @@ namespace
|
||||
}
|
||||
|
||||
void insertPartitionValueColumn(
|
||||
size_t rows, const std::vector<Field> & partition_value, const DataTypePtr & partition_value_type, const String &) final
|
||||
size_t rows, const Row & partition_value, const DataTypePtr & partition_value_type, const String &) final
|
||||
{
|
||||
ColumnPtr column;
|
||||
if (rows)
|
||||
|
@ -3144,7 +3144,7 @@ String MergeTreeData::getPartitionIDFromQuery(const ASTPtr & ast, ContextPtr loc
|
||||
ErrorCodes::INVALID_PARTITION_VALUE);
|
||||
|
||||
const FormatSettings format_settings;
|
||||
std::vector<Field> partition_row(fields_count);
|
||||
Row partition_row(fields_count);
|
||||
|
||||
if (fields_count)
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ BlocksWithPartition MergeTreeDataWriter::splitBlockIntoParts(const Block & block
|
||||
|
||||
if (!metadata_snapshot->hasPartitionKey()) /// Table is not partitioned.
|
||||
{
|
||||
result.emplace_back(Block(block), std::vector<Field>{});
|
||||
result.emplace_back(Block(block), Row{});
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ BlocksWithPartition MergeTreeDataWriter::splitBlockIntoParts(const Block & block
|
||||
|
||||
auto get_partition = [&](size_t num)
|
||||
{
|
||||
std::vector<Field> partition(partition_columns.size());
|
||||
Row partition(partition_columns.size());
|
||||
for (size_t i = 0; i < partition_columns.size(); ++i)
|
||||
partition[i] = Field((*partition_columns[i])[partition_num_to_first_row[num]]);
|
||||
return partition;
|
||||
|
@ -18,9 +18,9 @@ namespace DB
|
||||
struct BlockWithPartition
|
||||
{
|
||||
Block block;
|
||||
std::vector<Field> partition;
|
||||
Row partition;
|
||||
|
||||
BlockWithPartition(Block && block_, std::vector<Field> && partition_)
|
||||
BlockWithPartition(Block && block_, Row && partition_)
|
||||
: block(block_), partition(std::move(partition_))
|
||||
{
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ using StorageMetadataPtr = std::shared_ptr<const StorageInMemoryMetadata>;
|
||||
/// This class represents a partition value of a single part and encapsulates its loading/storing logic.
|
||||
struct MergeTreePartition
|
||||
{
|
||||
std::vector<Field> value;
|
||||
Row value;
|
||||
|
||||
public:
|
||||
MergeTreePartition() = default;
|
||||
|
||||
explicit MergeTreePartition(std::vector<Field> value_) : value(std::move(value_)) {}
|
||||
explicit MergeTreePartition(Row value_) : value(std::move(value_)) {}
|
||||
|
||||
/// For month-based partitioning.
|
||||
explicit MergeTreePartition(UInt32 yyyymm) : value(1, yyyymm) {}
|
||||
|
Loading…
Reference in New Issue
Block a user