This commit is contained in:
avogar 2024-07-23 14:45:54 +00:00
parent 3cb35efb31
commit ea15ad4ff5
4 changed files with 14 additions and 2 deletions

View File

@ -286,11 +286,13 @@ public:
void forEachSubcolumn(MutableColumnCallback callback) override
{
callback(variant_column);
variant_column_ptr = assert_cast<ColumnVariant *>(variant_column.get());
}
void forEachSubcolumnRecursively(RecursiveMutableColumnCallback callback) override
{
callback(*variant_column);
variant_column_ptr = assert_cast<ColumnVariant *>(variant_column.get());
variant_column->forEachSubcolumnRecursively(callback);
}
@ -364,6 +366,9 @@ private:
void updateVariantInfoAndExpandVariantColumn(const DataTypePtr & new_variant_type);
WrappedPtr variant_column;
/// Store and use pointer to ColumnVariant to avoid virtual calls.
/// ColumnDynamic is widely used inside ColumnObject for each path and
/// with hundreds of paths these virtual calls are noticeable.
ColumnVariant * variant_column_ptr;
/// Store the type of current variant with some additional information.
VariantInfo variant_info;

View File

@ -955,8 +955,11 @@ void ColumnObject::forEachSubcolumn(DB::IColumn::MutableColumnCallback callback)
{
for (auto & [_, column] : typed_paths)
callback(column);
for (auto & [_, column] : dynamic_paths)
for (auto & [path, column] : dynamic_paths)
{
callback(column);
dynamic_paths_ptrs[path] = assert_cast<ColumnDynamic *>(column.get());
}
callback(shared_data);
}
@ -967,10 +970,11 @@ void ColumnObject::forEachSubcolumnRecursively(DB::IColumn::RecursiveMutableColu
callback(*column);
column->forEachSubcolumnRecursively(callback);
}
for (auto & [_, column] : dynamic_paths_ptrs)
for (auto & [path, column] : dynamic_paths)
{
callback(*column);
column->forEachSubcolumnRecursively(callback);
dynamic_paths_ptrs[path] = assert_cast<ColumnDynamic *>(column.get());
}
callback(*shared_data);
shared_data->forEachSubcolumnRecursively(callback);

View File

@ -201,6 +201,8 @@ private:
/// here are Dynamic columns. This set of paths can be extended
/// during inerts into the column.
std::unordered_map<String, WrappedPtr> dynamic_paths;
/// Store and use pointers to ColumnDynamic to avoid virtual calls.
/// With hundreds of dynamic paths these virtual calls are noticeable.
std::unordered_map<String, ColumnDynamic *> dynamic_paths_ptrs;
/// Shared storage for all other paths and values. It's filled
/// when the number of dynamic paths reaches the limit.

View File

@ -2117,6 +2117,7 @@ natively
nats
nestjs
netloc
newjson
ngram
ngramDistance
ngramDistanceCaseInsensitive