Skip to content

Commit

Permalink
change std::cout to log
Browse files Browse the repository at this point in the history
  • Loading branch information
amorynan committed Dec 31, 2024
1 parent 076e679 commit c49cca2
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 142 deletions.
4 changes: 1 addition & 3 deletions be/src/vec/columns/column_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,6 @@ ColumnPtr ColumnArray::replicate_generic(const IColumn::Offsets& replicate_offse
size_t size_to_replicate = replicate_offsets[i] - prev_offset;
prev_offset = replicate_offsets[i];

std::cout << "replicate_generic: " << i << " " << i << " with prev:" << prev_offset
<< " with size_to_replicate: " << size_to_replicate << std::endl;
for (size_t j = 0; j < size_to_replicate; ++j) {
res_concrete.insert_from(*this, i);
}
Expand Down Expand Up @@ -1107,4 +1105,4 @@ ColumnPtr ColumnArray::permute(const Permutation& perm, size_t limit) const {
return res;
}

} // namespace doris::vectorized
} // namespace doris::vectorized
59 changes: 39 additions & 20 deletions be/test/vec/columns/column_array_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class ColumnArrayTest : public CommonColumnTest {
auto& data_file = data_files[i];
// first is array type
auto& type = desc[0].data_type;
std::cout << "type: " << type->get_name() << " with file: " << data_file << std::endl;
LOG(INFO) << "type: " << type->get_name() << " with file: " << data_file;
MutableColumns columns;
columns.push_back(type->create_column());
auto serde = type->get_serde(1);
Expand All @@ -293,7 +293,7 @@ class ColumnArrayTest : public CommonColumnTest {
auto& data_file = data_files[i + array_typeIndex.size()];
// first is array type
auto& type = desc[0].data_type;
std::cout << "type: " << type->get_name() << " with file: " << data_file << std::endl;
LOG(INFO) << "type: " << type->get_name() << " with file: " << data_file;
MutableColumns columns;
columns.push_back(type->create_column());
auto serde = type->get_serde(1);
Expand All @@ -308,7 +308,7 @@ class ColumnArrayTest : public CommonColumnTest {
auto& data_file = data_files[i + array_typeIndex.size() + array_array_typeIndex.size()];
// first is array type
auto& type = desc[0].data_type;
std::cout << "type: " << type->get_name() << " with file: " << data_file << std::endl;
LOG(INFO) << "type: " << type->get_name() << " with file: " << data_file;
MutableColumns columns;
columns.push_back(type->create_column());
auto serde = type->get_serde(1);
Expand All @@ -325,7 +325,7 @@ class ColumnArrayTest : public CommonColumnTest {
array_map_typeIndex.size()];
// first is array type
auto& type = desc[0].data_type;
std::cout << "type: " << type->get_name() << " with file: " << data_file << std::endl;
LOG(INFO) << "type: " << type->get_name() << " with file: " << data_file;
MutableColumns columns;
columns.push_back(type->create_column());
auto serde = type->get_serde(1);
Expand Down Expand Up @@ -438,13 +438,18 @@ TEST_F(ColumnArrayTest, ReplicateTest) {
// just skip array_array_char use vector copy
for (int i = 0; i < array_columns.size(); i++) {
if (i == 31) {
std::cout << array_columns[i]->get_name() << " is skipped" << std::endl;
continue;
}
array_columns_copy.push_back(array_columns[i]->assume_mutable());
serdes_copy.push_back(serdes[i]);
}
assert_replicate_callback(array_columns_copy, serdes_copy);
// expect error columns
MutableColumns error_columns;
error_columns.push_back(array_columns[31]->assume_mutable());
DataTypeSerDeSPtrs error_serdes;
error_serdes.push_back(serdes[31]);
EXPECT_ANY_THROW(assert_replicate_callback(error_columns, error_serdes));
}

TEST_F(ColumnArrayTest, ReplaceColumnTest) {
Expand All @@ -462,7 +467,7 @@ TEST_F(ColumnArrayTest, PermutationAndSortTest) {
auto& column = array_columns[i];
auto& type = array_types[i];
auto column_type = type->get_name();
std::cout << "column_type: " << column_type << std::endl;
LOG(INFO) << "column_type: " << column_type;
// permutation
EXPECT_ANY_THROW(assert_column_permutations(column->assume_mutable_ref(), type));
}
Expand Down Expand Up @@ -505,12 +510,14 @@ TEST_F(ColumnArrayTest, CreateArrayTest) {
auto& type = array_types[i];
auto column_size = column->size();
auto column_type = type->get_name();
std::cout << "column_type: " << column_type << std::endl;
LOG(INFO) << "column_type: " << column_type;
// test create_array
auto last_offset = column->get_offsets().back();
EXPECT_ANY_THROW(
{ auto const_col = ColumnConst::create(column->get_data_ptr(), last_offset); });
auto tmp_data_col = column->get_data_ptr()->clone_resized(1);
Field assert_field;
column->get(0, assert_field);
auto const_col = ColumnConst::create(tmp_data_col->assume_mutable(), last_offset);
EXPECT_ANY_THROW({
// const_col is not empty
Expand All @@ -522,6 +529,12 @@ TEST_F(ColumnArrayTest, CreateArrayTest) {
<< "array_column size is not equal to column size";
EXPECT_EQ(new_array_column->get_data_ptr()->size(), column->get_data_ptr()->size());
EXPECT_EQ(new_array_column->get_offsets_ptr()->size(), column->get_offsets_ptr()->size());
// check column data
for (size_t j = 0; j < column_size; j++) {
Field f1;
new_array_column->get(j, f1);
EXPECT_EQ(f1, assert_field) << "array_column data is not equal to column data";
}
}
}

Expand All @@ -543,18 +556,24 @@ TEST_F(ColumnArrayTest, ConvertIfOverflowAndInsertTest) {
auto type = array_types[i];
auto nested_type =
assert_cast<const DataTypeArray*>(remove_nullable(type).get())->get_nested_type();
if (!is_string(nested_type)) {
// check ptr is itself
auto ptr = column->convert_column_if_overflow();
EXPECT_EQ(ptr.get(), column.get());
auto arr_col = check_and_get_column<ColumnArray>(
remove_nullable(column->assume_mutable()).get());
auto nested_col = arr_col->get_data_ptr();
auto array_col1 = check_and_get_column<ColumnArray>(remove_nullable(ptr).get());
auto nested_col1 = array_col1->get_data_ptr();
EXPECT_EQ(nested_col.get(), nested_col1.get());
} else {
auto ptr = column->convert_column_if_overflow();
// check ptr is itself
auto ptr = column->convert_column_if_overflow();
EXPECT_EQ(ptr.get(), column.get());
auto arr_col =
check_and_get_column<ColumnArray>(remove_nullable(column->assume_mutable()).get());
auto nested_col = arr_col->get_data_ptr();
auto array_col1 = check_and_get_column<ColumnArray>(remove_nullable(ptr).get());
auto nested_col1 = array_col1->get_data_ptr();
EXPECT_EQ(nested_col.get(), nested_col1.get());
// check column data
auto column_size = column->size();
LOG(INFO) << "column_size: " << column_size;
for (size_t j = 0; j < column_size; j++) {
Field f1;
column->get(j, f1);
Field f2;
ptr->get(j, f2);
EXPECT_EQ(f1, f2) << "array_column data is not equal to column data";
}
}
}
Expand Down Expand Up @@ -754,4 +773,4 @@ TEST_F(ColumnArrayTest, IntArrayPermuteTest) {
}
}

} // namespace doris::vectorized
} // namespace doris::vectorized
Loading

0 comments on commit c49cca2

Please sign in to comment.