Skip to content

Commit

Permalink
[Enhancement] clang-19 compatibility (#52058)
Browse files Browse the repository at this point in the history
(cherry picked from commit f56aac4)

# Conflicts:
#	be/src/exprs/agg/array_agg.h
#	be/src/exprs/agg/array_union_agg.h
#	be/src/exprs/agg/distinct.h
  • Loading branch information
murphyatwork authored and mergify[bot] committed Oct 18, 2024
1 parent 48c16ec commit f56cf84
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
8 changes: 8 additions & 0 deletions be/src/exprs/agg/array_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ struct ArrayAggAggregateState {
for (int i = 0; i < count; i++) {
auto raw_key = column.get_slice(offset + i);
KeyType key(raw_key);
#if defined(__clang__) && (__clang_major__ >= 16)
set.lazy_emplace(key, [&](const auto& ctor) {
#else
set.template lazy_emplace(key, [&](const auto& ctor) {
<<<<<<< HEAD
uint8_t* pos = mem_pool->allocate(key.size);
=======
#endif
uint8_t* pos = mem_pool->allocate_with_reserve(key.size, SLICE_MEMEQUAL_OVERFLOW_PADDING);
>>>>>>> f56aac479d ([Enhancement] clang-19 compatibility (#52058))
assert(pos != nullptr);
memcpy(pos, key.data, key.size);
ctor(pos, key.size, key.hash);
Expand Down
8 changes: 8 additions & 0 deletions be/src/exprs/agg/array_union_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ struct ArrayUnionAggAggregateState {
for (int i = 0; i < count; i++) {
auto raw_key = column.get_slice(offset + i);
KeyType key(raw_key);
#if defined(__clang__) && (__clang_major__ >= 16)
set.lazy_emplace(key, [&](const auto& ctor) {
#else
set.template lazy_emplace(key, [&](const auto& ctor) {
<<<<<<< HEAD
uint8_t* pos = mem_pool->allocate(key.size);
=======
#endif
uint8_t* pos = mem_pool->allocate_with_reserve(key.size, SLICE_MEMEQUAL_OVERFLOW_PADDING);
>>>>>>> f56aac479d ([Enhancement] clang-19 compatibility (#52058))
assert(pos != nullptr);
memcpy(pos, key.data, key.size);
ctor(pos, key.size, key.hash);
Expand Down
24 changes: 24 additions & 0 deletions be/src/exprs/agg/distinct.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,16 @@ struct DistinctAggregateState<LT, SumLT, StringLTGuard<LT>> {
size_t update(MemPool* mem_pool, Slice raw_key) {
size_t ret = 0;
KeyType key(raw_key);
#if defined(__clang__) && (__clang_major__ >= 16)
set.lazy_emplace(key, [&](const auto& ctor) {
#else
set.template lazy_emplace(key, [&](const auto& ctor) {
<<<<<<< HEAD
uint8_t* pos = mem_pool->allocate(key.size);
=======
#endif
uint8_t* pos = mem_pool->allocate_with_reserve(key.size, SLICE_MEMEQUAL_OVERFLOW_PADDING);
>>>>>>> f56aac479d ([Enhancement] clang-19 compatibility (#52058))
assert(pos != nullptr);
memcpy(pos, key.data, key.size);
ctor(pos, key.size, key.hash);
Expand All @@ -128,8 +136,16 @@ struct DistinctAggregateState<LT, SumLT, StringLTGuard<LT>> {
size_t update_with_hash(MemPool* mem_pool, Slice raw_key, size_t hash) {
size_t ret = 0;
KeyType key(reinterpret_cast<uint8_t*>(raw_key.data), raw_key.size, hash);
#if defined(__clang__) && (__clang_major__ >= 16)
set.lazy_emplace_with_hash(key, hash, [&](const auto& ctor) {
#else
set.template lazy_emplace_with_hash(key, hash, [&](const auto& ctor) {
<<<<<<< HEAD
uint8_t* pos = mem_pool->allocate(key.size);
=======
#endif
uint8_t* pos = mem_pool->allocate_with_reserve(key.size, SLICE_MEMEQUAL_OVERFLOW_PADDING);
>>>>>>> f56aac479d ([Enhancement] clang-19 compatibility (#52058))
assert(pos != nullptr);
memcpy(pos, key.data, key.size);
ctor(pos, key.size, key.hash);
Expand Down Expand Up @@ -170,8 +186,16 @@ struct DistinctAggregateState<LT, SumLT, StringLTGuard<LT>> {
Slice raw_key(src, size);
KeyType key(raw_key);
// we only memcpy when the key is new
#if defined(__clang__) && (__clang_major__ >= 16)
set.lazy_emplace(key, [&](const auto& ctor) {
#else
set.template lazy_emplace(key, [&](const auto& ctor) {
<<<<<<< HEAD
uint8_t* pos = mem_pool->allocate(key.size);
=======
#endif
uint8_t* pos = mem_pool->allocate_with_reserve(key.size, SLICE_MEMEQUAL_OVERFLOW_PADDING);
>>>>>>> f56aac479d ([Enhancement] clang-19 compatibility (#52058))
assert(pos != nullptr);
memcpy(pos, key.data, key.size);
ctor(pos, key.size, key.hash);
Expand Down
8 changes: 4 additions & 4 deletions be/src/storage/chunk_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ struct ColumnPtrBuilder {
std::vector<std::string> names;
std::vector<ColumnPtr> fields;
for (auto& sub_field : field.sub_fields()) {
names.template emplace_back(sub_field.name());
fields.template emplace_back(sub_field.create_column());
names.emplace_back(sub_field.name());
fields.emplace_back(sub_field.create_column());
}
auto struct_column = StructColumn::create(std::move(fields), std::move(names));
return NullableIfNeed(struct_column);
Expand Down Expand Up @@ -426,8 +426,8 @@ ColumnPtr ChunkHelper::column_from_field(const Field& field) {
std::vector<std::string> names;
std::vector<ColumnPtr> fields;
for (auto& sub_field : field.sub_fields()) {
names.template emplace_back(sub_field.name());
fields.template emplace_back(sub_field.create_column());
names.emplace_back(sub_field.name());
fields.emplace_back(sub_field.create_column());
}
auto struct_column = StructColumn::create(std::move(fields), std::move(names));
return NullableIfNeed(struct_column);
Expand Down
6 changes: 3 additions & 3 deletions be/test/exec/parquet_scanner_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ class ParquetScannerTest : public ::testing::Test {
}
std::vector<std::string> column_names;
column_names.reserve(columns_from_file.size() + columns_from_path.size());
column_names.template insert(column_names.end(), columns_from_file.begin(), columns_from_file.end());
column_names.template insert(column_names.end(), columns_from_path.begin(), columns_from_path.end());
column_names.insert(column_names.end(), columns_from_file.begin(), columns_from_file.end());
column_names.insert(column_names.end(), columns_from_path.begin(), columns_from_path.end());

auto src_slot_infos = select_columns(columns_from_file, is_nullable);
for (const auto& i : columns_from_path) {
src_slot_infos.template emplace_back(i, TypeDescriptor::from_logical_type(TYPE_VARCHAR), is_nullable);
src_slot_infos.emplace_back(i, TypeDescriptor::from_logical_type(TYPE_VARCHAR), is_nullable);
}

auto dst_slot_infos = select_columns(column_names, is_nullable);
Expand Down

0 comments on commit f56cf84

Please sign in to comment.