Skip to content

Commit

Permalink
fix clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
amorynan committed Oct 27, 2024
1 parent 9110e39 commit 513d4a9
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 47 deletions.
124 changes: 84 additions & 40 deletions be/src/vec/columns/column_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,43 +521,63 @@ void ColumnArray::insert_range_from_ignore_overflow(const IColumn& src, size_t s
}

ColumnPtr ColumnArray::filter(const Filter& filt, ssize_t result_size_hint) const {
if (typeid_cast<const ColumnUInt8*>(data.get()))
if (typeid_cast<const ColumnUInt8*>(data.get())) {
return filter_number<UInt8>(filt, result_size_hint);
if (typeid_cast<const ColumnUInt16*>(data.get()))
}
if (typeid_cast<const ColumnUInt16*>(data.get())) {
return filter_number<UInt16>(filt, result_size_hint);
if (typeid_cast<const ColumnUInt32*>(data.get()))
}
if (typeid_cast<const ColumnUInt32*>(data.get())) {
return filter_number<UInt32>(filt, result_size_hint);
if (typeid_cast<const ColumnUInt64*>(data.get()))
}
if (typeid_cast<const ColumnUInt64*>(data.get())) {
return filter_number<UInt64>(filt, result_size_hint);
if (typeid_cast<const ColumnUInt128*>(data.get()))
}
if (typeid_cast<const ColumnUInt128*>(data.get())) {
return filter_number<UInt128>(filt, result_size_hint);
if (typeid_cast<const ColumnInt8*>(data.get()))
}
if (typeid_cast<const ColumnInt8*>(data.get())) {
return filter_number<Int8>(filt, result_size_hint);
if (typeid_cast<const ColumnInt16*>(data.get()))
}
if (typeid_cast<const ColumnInt16*>(data.get())) {
return filter_number<Int16>(filt, result_size_hint);
if (typeid_cast<const ColumnInt32*>(data.get()))
}
if (typeid_cast<const ColumnInt32*>(data.get())) {
return filter_number<Int32>(filt, result_size_hint);
if (typeid_cast<const ColumnInt64*>(data.get()))
}
if (typeid_cast<const ColumnInt64*>(data.get())) {
return filter_number<Int64>(filt, result_size_hint);
if (typeid_cast<const ColumnInt128*>(data.get()))
}
if (typeid_cast<const ColumnInt128*>(data.get())) {
return filter_number<Int128>(filt, result_size_hint);
if (typeid_cast<const ColumnFloat32*>(data.get()))
}
if (typeid_cast<const ColumnFloat32*>(data.get())) {
return filter_number<Float32>(filt, result_size_hint);
if (typeid_cast<const ColumnFloat64*>(data.get()))
}
if (typeid_cast<const ColumnFloat64*>(data.get())) {
return filter_number<Float64>(filt, result_size_hint);
if (typeid_cast<const ColumnDecimal32*>(data.get()))
}
if (typeid_cast<const ColumnDecimal32*>(data.get())) {
return filter_number<Decimal32>(filt, result_size_hint);
if (typeid_cast<const ColumnDecimal64*>(data.get()))
}
if (typeid_cast<const ColumnDecimal64*>(data.get())) {
return filter_number<Decimal64>(filt, result_size_hint);
if (typeid_cast<const ColumnDecimal128V2*>(data.get()))
}
if (typeid_cast<const ColumnDecimal128V2*>(data.get())) {
return filter_number<Decimal128V2>(filt, result_size_hint);
if (typeid_cast<const ColumnDecimal128V3*>(data.get()))
}
if (typeid_cast<const ColumnDecimal128V3*>(data.get())) {
return filter_number<Decimal128V3>(filt, result_size_hint);
if (typeid_cast<const ColumnDecimal256*>(data.get()))
}
if (typeid_cast<const ColumnDecimal256*>(data.get())) {
return filter_number<Decimal256>(filt, result_size_hint);
if (typeid_cast<const ColumnString*>(data.get())) return filter_string(filt, result_size_hint);
if (typeid_cast<const ColumnNullable*>(data.get()))
}
if (typeid_cast<const ColumnString*>(data.get())) {
return filter_string(filt, result_size_hint);
}
if (typeid_cast<const ColumnNullable*>(data.get())) {
return filter_nullable(filt, result_size_hint);
}
return filter_generic(filt, result_size_hint);
}

Expand Down Expand Up @@ -861,47 +881,71 @@ void ColumnArray::insert_many_from(const IColumn& src, size_t position, size_t l
}

ColumnPtr ColumnArray::replicate(const IColumn::Offsets& replicate_offsets) const {
if (replicate_offsets.empty()) return clone_empty();
if (replicate_offsets.empty()) {
return clone_empty();
}

// keep ColumnUInt8 for ColumnNullable::null_map
if (typeid_cast<const ColumnUInt8*>(data.get()))
if (typeid_cast<const ColumnUInt8*>(data.get())) {
return replicate_number<UInt8>(replicate_offsets);
if (typeid_cast<const ColumnUInt16*>(data.get()))
}
if (typeid_cast<const ColumnUInt16*>(data.get())) {
return replicate_number<UInt16>(replicate_offsets);
if (typeid_cast<const ColumnUInt32*>(data.get()))
}
if (typeid_cast<const ColumnUInt32*>(data.get())) {
return replicate_number<UInt32>(replicate_offsets);
if (typeid_cast<const ColumnUInt64*>(data.get()))
}
if (typeid_cast<const ColumnUInt64*>(data.get())) {
return replicate_number<UInt64>(replicate_offsets);
if (typeid_cast<const ColumnUInt128*>(data.get()))
}
if (typeid_cast<const ColumnUInt128*>(data.get())) {
return replicate_number<UInt128>(replicate_offsets);
if (typeid_cast<const ColumnInt8*>(data.get()))
}
if (typeid_cast<const ColumnInt8*>(data.get())) {
return replicate_number<Int8>(replicate_offsets);
if (typeid_cast<const ColumnInt16*>(data.get()))
}
if (typeid_cast<const ColumnInt16*>(data.get())) {
return replicate_number<Int16>(replicate_offsets);
if (typeid_cast<const ColumnInt32*>(data.get()))
}
if (typeid_cast<const ColumnInt32*>(data.get())) {
return replicate_number<Int32>(replicate_offsets);
if (typeid_cast<const ColumnInt64*>(data.get()))
}
if (typeid_cast<const ColumnInt64*>(data.get())) {
return replicate_number<Int64>(replicate_offsets);
if (typeid_cast<const ColumnInt128*>(data.get()))
}
if (typeid_cast<const ColumnInt128*>(data.get())) {
return replicate_number<Int128>(replicate_offsets);
if (typeid_cast<const ColumnFloat32*>(data.get()))
}
if (typeid_cast<const ColumnFloat32*>(data.get())) {
return replicate_number<Float32>(replicate_offsets);
if (typeid_cast<const ColumnFloat64*>(data.get()))
}
if (typeid_cast<const ColumnFloat64*>(data.get())) {
return replicate_number<Float64>(replicate_offsets);
if (typeid_cast<const ColumnDecimal32*>(data.get()))
}
if (typeid_cast<const ColumnDecimal32*>(data.get())) {
return replicate_number<Decimal32>(replicate_offsets);
if (typeid_cast<const ColumnDecimal64*>(data.get()))
}
if (typeid_cast<const ColumnDecimal64*>(data.get())) {
return replicate_number<Decimal64>(replicate_offsets);
if (typeid_cast<const ColumnDecimal128V2*>(data.get()))
}
if (typeid_cast<const ColumnDecimal128V2*>(data.get())) {
return replicate_number<Decimal128V2>(replicate_offsets);
if (typeid_cast<const ColumnDecimal128V3*>(data.get()))
}
if (typeid_cast<const ColumnDecimal128V3*>(data.get())) {
return replicate_number<Decimal128V3>(replicate_offsets);
if (typeid_cast<const ColumnDecimal256*>(data.get()))
}
if (typeid_cast<const ColumnDecimal256*>(data.get())) {
return replicate_number<Decimal256>(replicate_offsets);
if (typeid_cast<const ColumnString*>(data.get())) return replicate_string(replicate_offsets);
if (typeid_cast<const ColumnConst*>(data.get())) return replicate_const(replicate_offsets);
if (typeid_cast<const ColumnNullable*>(data.get()))
}
if (typeid_cast<const ColumnString*>(data.get())) {
return replicate_string(replicate_offsets);
}
if (typeid_cast<const ColumnConst*>(data.get())) {
return replicate_const(replicate_offsets);
}
if (typeid_cast<const ColumnNullable*>(data.get())) {
return replicate_nullable(replicate_offsets);
}
return replicate_generic(replicate_offsets);
}

Expand Down
8 changes: 6 additions & 2 deletions be/test/vec/columns/common_column_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ TEST_F(CommonColumnTest, Permute) {
vectorized::IColumn::Permutation permutation;

size_t num_rows = 10;
for (size_t i = 0; i < num_rows; ++i) permutation.emplace_back(num_rows - 1 - i);
for (size_t i = 0; i < num_rows; ++i) {
permutation.emplace_back(num_rows - 1 - i);
}

std::cout << "permutation size:" << permutation.size() << std::endl;

Expand All @@ -143,7 +145,9 @@ TEST_F(CommonColumnTest, SortColumnDescription) {
std::vector<std::vector<Field>> ranges(num_rows);
IColumn::Permutation permutation;

for (size_t i = 0; i < num_rows; ++i) permutation.emplace_back(num_rows - 1 - i);
for (size_t i = 0; i < num_rows; ++i) {
permutation.emplace_back(num_rows - 1 - i);
}
generateRanges(ranges, num_rows, columnStringGetter);
insertRangesIntoColumn(ranges, permutation, *col_s);

Expand Down
6 changes: 1 addition & 5 deletions be/test/vec/columns/common_column_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include "vec/data_types/data_type.h"
#include "vec/data_types/data_type_array.h"
#include "vec/data_types/data_type_map.h"
#include "vec/data_types/data_type_number.h"
#include "vec/data_types/data_type_string.h"

// this test is gonna to be a column test template for all column which should make ut test to coverage the function defined in column
// for example column_array should test this function:
Expand Down Expand Up @@ -85,7 +83,6 @@ class CommonColumnTest : public ::testing::Test {
col_map->insert(map2);
}

public:
ColumnString::MutablePtr col_str;
ColumnInt64::MutablePtr col_int;
ColumnDecimal64::MutablePtr col_dcm;
Expand Down Expand Up @@ -224,7 +221,7 @@ class CommonColumnTest : public ::testing::Test {
} else if (WhichDataType(dataType).is_array()) {
auto array = check_and_get_column<ColumnArray>(column);
std::cout << "array: " << std::endl;
const DataTypeArray& rhs_array = static_cast<const DataTypeArray&>(dataType);
const auto& rhs_array = static_cast<const DataTypeArray&>(dataType);
printColumn(array->get_data(), *rhs_array.get_nested_type());
} else {
size_t column_size = column.size();
Expand Down Expand Up @@ -548,7 +545,6 @@ class CommonColumnTest : public ::testing::Test {
int iter = 0;
for (size_t i = 0; i < filter.size(); i++) {
if (filter[i]) {
EXPECT_EQ(col->get_data_at(i), filted_col->get_data_at(iter));
iter++;
}
}
Expand Down

0 comments on commit 513d4a9

Please sign in to comment.