From 681d7d679900b6444654a9061ba3ebb3aeadeeb5 Mon Sep 17 00:00:00 2001 From: lgbo-ustc Date: Fri, 22 Apr 2022 11:00:00 +0800 Subject: [PATCH] update dispatchBlock() --- src/Interpreters/ConcurrentHashJoin.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/Interpreters/ConcurrentHashJoin.cpp b/src/Interpreters/ConcurrentHashJoin.cpp index ab4ea242882..84feae500b4 100644 --- a/src/Interpreters/ConcurrentHashJoin.cpp +++ b/src/Interpreters/ConcurrentHashJoin.cpp @@ -137,6 +137,7 @@ size_t ConcurrentHashJoin::getTotalRowCount() const size_t res = 0; for (const auto & hash_join : hash_joins) { + std::lock_guard lokc(hash_join->mutex); res += hash_join->data->getTotalRowCount(); } return res; @@ -147,6 +148,7 @@ size_t ConcurrentHashJoin::getTotalByteCount() const size_t res = 0; for (const auto & hash_join : hash_joins) { + std::lock_guard lokc(hash_join->mutex); res += hash_join->data->getTotalByteCount(); } return res; @@ -156,6 +158,7 @@ bool ConcurrentHashJoin::alwaysReturnsEmptySet() const { for (const auto & hash_join : hash_joins) { + std::lock_guard lokc(hash_join->mutex); if (!hash_join->data->alwaysReturnsEmptySet()) return false; } @@ -226,25 +229,8 @@ void ConcurrentHashJoin::dispatchBlock(BlockDispatchControlData & dispatch_data, } if (selector_column.column->isNullable()) { - const auto * nullable_col = typeid_cast(selector_column.column.get()); - const auto & nested_col = nullable_col->getNestedColumnPtr(); - size_t last_offset = 0; - MutableColumnPtr dst = nullable_col->cloneEmpty(); - for (size_t i = 0, sz = selector_column.column->size(); i < sz; ++i) - { - if (selector_column.column->isNullAt(i))[[unlikely]] - { - if (i > last_offset)[[likely]] - dst->insertRangeFrom(*nested_col, last_offset, i - last_offset); - dst->insertDefault(); - last_offset = i + 1; - } - } - if (last_offset < selector_column.column->size()) - { - dst->insertRangeFrom(*nested_col, last_offset, selector_column.column->size() - last_offset); - } - selector_column.column = std::move(dst); + // use the default value for null rows. + selector_column.column = typeid_cast(selector_column.column.get())->getNestedColumnPtr(); } auto selector = createBlockSelector(*selector_column.column, selector_slots);