Skip to content

Commit

Permalink
fix static code checks by clang-tidy
Browse files Browse the repository at this point in the history
Signed-off-by: fzhedu <[email protected]>
  • Loading branch information
fzhedu committed Jun 17, 2022
1 parent a21809b commit c33fb6f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 28 deletions.
6 changes: 3 additions & 3 deletions dbms/src/Common/FailPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ class FailPointChannel : private boost::noncopyable
{
public:
// wake up all waiting threads when destroy
~FailPointChannel() { notify_all(); }
~FailPointChannel() { notifyAll(); }

void wait()
{
std::unique_lock lock(m);
cv.wait(lock);
}

void notify_all()
void notifyAll()
{
std::unique_lock lock(m);
cv.notify_all();
Expand Down Expand Up @@ -161,7 +161,7 @@ void FailPointHelper::disableFailPoint(const String & fail_point_name)
{
/// can not rely on deconstruction to do the notify_all things, because
/// if someone wait on this, the deconstruct will never be called.
iter->second->notify_all();
iter->second->notifyAll();
fail_point_wait_channels.erase(iter);
}
fiu_disable(fail_point_name.c_str());
Expand Down
6 changes: 3 additions & 3 deletions dbms/src/DataStreams/CreatingSetsBlockInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CreatingSetsBlockInputStream::CreatingSetsBlockInputStream(
: subqueries_for_sets_list(std::move(subqueries_for_sets_list_))
, network_transfer_limits(network_transfer_limits)
, mpp_task_id(mpp_task_id_)
, log(getMPPTaskLog(log_, getName(), mpp_task_id))
, log(getMPPTaskLog(log_, name, mpp_task_id))
{
init(input);
}
Expand All @@ -43,7 +43,7 @@ CreatingSetsBlockInputStream::CreatingSetsBlockInputStream(
const SizeLimits & network_transfer_limits,
const LogWithPrefixPtr & log_)
: network_transfer_limits(network_transfer_limits)
, log(getMPPTaskLog(log_, getName(), mpp_task_id))
, log(getMPPTaskLog(log_, name, mpp_task_id))
{
subqueries_for_sets_list.push_back(subqueries_for_sets);
init(input);
Expand Down Expand Up @@ -90,7 +90,7 @@ void CreatingSetsBlockInputStream::readPrefixImpl()

Block CreatingSetsBlockInputStream::getTotals()
{
auto input = dynamic_cast<IProfilingBlockInputStream *>(children.back().get());
auto *input = dynamic_cast<IProfilingBlockInputStream *>(children.back().get());

if (input)
return input->getTotals();
Expand Down
4 changes: 3 additions & 1 deletion dbms/src/DataStreams/CreatingSetsBlockInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class CreatingSetsBlockInputStream : public IProfilingBlockInputStream
}
}

String getName() const override { return "CreatingSets"; }
static constexpr auto name = "CreatingSets";

String getName() const override { return name; }

Block getHeader() const override { return children.back()->getHeader(); }

Expand Down
41 changes: 20 additions & 21 deletions dbms/src/Interpreters/Join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ size_t Join::getTotalByteCount() const
res += getTotalByteCountImpl(maps_all, type);
res += getTotalByteCountImpl(maps_any_full, type);
res += getTotalByteCountImpl(maps_all_full, type);
for (auto & pool : pools)
for (const auto & pool : pools)
{
/// note the return value might not be accurate since it does not use lock, but should be enough for current usage
res += pool->size();
Expand Down Expand Up @@ -421,7 +421,7 @@ namespace
{
void insertRowToList(Join::RowRefList * list, Join::RowRefList * elem, Block * stored_block, size_t index)
{
elem->next = list->next;
elem->next = list->next; // NOLINT(clang-analyzer-core.NullDereference)
list->next = elem;
elem->block = stored_block;
elem->row_num = index;
Expand Down Expand Up @@ -493,7 +493,7 @@ void NO_INLINE insertFromBlockImplTypeCase(
if (rows_not_inserted_to_map)
{
/// for right/full out join, need to record the rows not inserted to map
auto elem = reinterpret_cast<Join::RowRefList *>(pool.alloc(sizeof(Join::RowRefList)));
auto *elem = reinterpret_cast<Join::RowRefList *>(pool.alloc(sizeof(Join::RowRefList)));
insertRowToList(rows_not_inserted_to_map, elem, stored_block, i);
}
continue;
Expand Down Expand Up @@ -536,9 +536,9 @@ void NO_INLINE insertFromBlockImplTypeCaseWithLock(
segment_index_info.resize(segment_size);
}
size_t rows_per_seg = rows / segment_index_info.size();
for (size_t i = 0; i < segment_index_info.size(); i++)
for (auto & segment_index : segment_index_info)
{
segment_index_info[i].reserve(rows_per_seg);
segment_index.reserve(rows_per_seg);
}
for (size_t i = 0; i < rows; i++)
{
Expand Down Expand Up @@ -567,11 +567,11 @@ void NO_INLINE insertFromBlockImplTypeCaseWithLock(
{
/// null value
/// here ignore mutex because rows_not_inserted_to_map is privately owned by each stream thread
for (size_t i = 0; i < segment_index_info[segment_index].size(); i++)
for (auto index : segment_index_info[segment_index])
{
/// for right/full out join, need to record the rows not inserted to map
auto elem = reinterpret_cast<Join::RowRefList *>(pool.alloc(sizeof(Join::RowRefList)));
insertRowToList(rows_not_inserted_to_map, elem, stored_block, segment_index_info[segment_index][i]);
auto *elem = reinterpret_cast<Join::RowRefList *>(pool.alloc(sizeof(Join::RowRefList)));
insertRowToList(rows_not_inserted_to_map, elem, stored_block, index);
}
}
else
Expand Down Expand Up @@ -705,7 +705,7 @@ void recordFilteredRows(const Block & block, const String & filter_column, Colum
MutableColumnPtr mutable_null_map_holder = (*std::move(null_map_holder)).mutate();
PaddedPODArray<UInt8> & mutable_null_map = static_cast<ColumnUInt8 &>(*mutable_null_map_holder).getData();

auto & nested_column = column->isColumnNullable() ? static_cast<const ColumnNullable &>(*column).getNestedColumnPtr() : column;
const auto & nested_column = column->isColumnNullable() ? static_cast<const ColumnNullable &>(*column).getNestedColumnPtr() : column;
for (size_t i = 0, size = nested_column->size(); i < size; ++i)
mutable_null_map[i] |= (!nested_column->getInt(i));

Expand Down Expand Up @@ -981,11 +981,11 @@ void NO_INLINE joinBlockImplTypeCase(
hash_value = map.hash(key);
segment_index = hash_value % map.getSegmentSize();
}
auto & internalMap = map.getSegmentTable(segment_index);
auto & internal_map = map.getSegmentTable(segment_index);
/// do not require segment lock because in join, the hash table can not be changed in probe stage.
auto it = map.getSegmentSize() > 0 ? internalMap.find(key, hash_value) : internalMap.find(key);
auto it = map.getSegmentSize() > 0 ? internal_map.find(key, hash_value) : internal_map.find(key);

if (it != internalMap.end())
if (it != internal_map.end())
{
it->getMapped().setUsed();
Adder<KIND, STRICTNESS, Map>::addFound(
Expand Down Expand Up @@ -1061,8 +1061,8 @@ void mergeNullAndFilterResult(Block & block, ColumnVector<UInt8>::Container & fi
orig_filter_column = orig_filter_column->convertToFullColumnIfConst();
if (orig_filter_column->isColumnNullable())
{
auto * nullable_column = checkAndGetColumn<ColumnNullable>(orig_filter_column.get());
auto & nested_column_data = static_cast<const ColumnVector<UInt8> *>(nullable_column->getNestedColumnPtr().get())->getData();
const auto * nullable_column = checkAndGetColumn<ColumnNullable>(orig_filter_column.get());
const auto & nested_column_data = static_cast<const ColumnVector<UInt8> *>(nullable_column->getNestedColumnPtr().get())->getData();
for (size_t i = 0; i < nullable_column->size(); i++)
{
if (filter_column[i] == 0)
Expand All @@ -1075,8 +1075,8 @@ void mergeNullAndFilterResult(Block & block, ColumnVector<UInt8>::Container & fi
}
else
{
auto * other_filter_column = checkAndGetColumn<ColumnVector<UInt8>>(orig_filter_column.get());
auto & other_filter_column_data = static_cast<const ColumnVector<UInt8> *>(other_filter_column)->getData();
const auto * other_filter_column = checkAndGetColumn<ColumnVector<UInt8>>(orig_filter_column.get());
const auto & other_filter_column_data = static_cast<const ColumnVector<UInt8> *>(other_filter_column)->getData();
for (size_t i = 0; i < other_filter_column->size(); i++)
filter_column[i] = filter_column[i] && other_filter_column_data[i];
}
Expand All @@ -1100,7 +1100,7 @@ void Join::handleOtherConditions(Block & block, std::unique_ptr<IColumn::Filter>

auto filter_column = ColumnUInt8::create();
auto & filter = filter_column->getData();
filter.assign(block.rows(), (UInt8)1);
filter.assign(block.rows(), static_cast<UInt8>(1));
if (!other_filter_column.empty())
{
mergeNullAndFilterResult(block, filter, other_filter_column, false);
Expand Down Expand Up @@ -1179,9 +1179,9 @@ void Join::handleOtherConditions(Block & block, std::unique_ptr<IColumn::Filter>
if (isLeftJoin(kind))
{
/// for left join, convert right column to null if not joined
for (size_t i = 0; i < right_table_columns.size(); i++)
for (size_t right_table_column : right_table_columns)
{
auto & column = block.getByPosition(right_table_columns[i]);
auto & column = block.getByPosition(right_table_column);
auto full_column = column.column->isColumnConst() ? column.column->convertToFullColumnIfConst() : column.column;
if (!full_column->isColumnNullable())
{
Expand Down Expand Up @@ -1561,9 +1561,8 @@ void Join::joinBlockImplCrossInternal(Block & block, ConstNullMapPtr null_map [[
{
dst_columns[i] = sample_block.getByPosition(i).column->cloneEmpty();
}
for (size_t i = 0; i < result_blocks.size(); i++)
for (auto & current_block : result_blocks)
{
auto & current_block = result_blocks[i];
if (current_block.rows() > 0)
{
for (size_t column = 0; column < current_block.columns(); column++)
Expand Down

0 comments on commit c33fb6f

Please sign in to comment.