diff --git a/.clang-tidy b/.clang-tidy index af5c483a101d45..4d02250c7debf1 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,7 +5,6 @@ Checks: > modernize-concat-nested-namespaces, modernize-deprecated-headers, modernize-deprecated-ios-base-aliases, - modernize-loop-convert, modernize-make-shared, modernize-make-unique, modernize-pass-by-value, diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index e3a4e778fb01f7..18787b4ad40f98 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -511,7 +511,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} $ENV{STARROCKS_CXX_LINKER_ # -fno-omit-frame-pointers: Keep frame pointer for functions in register set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall -Wno-sign-compare -Wno-unknown-pragmas -pthread -Wno-register") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-strict-aliasing -fno-omit-frame-pointer") -set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -std=gnu++17 -D__STDC_FORMAT_MACROS") +set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -std=gnu++20 -D__STDC_FORMAT_MACROS") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-deprecated -Wno-vla -Wno-comment") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") @@ -522,7 +522,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-documentation-unknown-command -Wno-old-style-cast") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-c++20-designator -Wno-mismatched-tags") if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "14.0.0") - set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-bitwise-instead-of-logical") + set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-bitwise-instead-of-logical -Wno-inconsistent-missing-override -Wno-ambiguous-reversed-operator") endif() if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16.0.0") # ignore warning from apache-orc diff --git a/be/src/column/column_hash.h b/be/src/column/column_hash.h index 862dc99bfee3c9..4a13b94e7353e2 100644 --- a/be/src/column/column_hash.h +++ b/be/src/column/column_hash.h @@ -227,10 +227,12 @@ class SliceHashWithSeed { #if defined(__SSE2__) && !defined(ADDRESS_SANITIZER) -// NOTE: This function will access 15 excessive bytes after p1 and p2. +// NOTE: This function will access 15 excessive bytes after p1 and p2, which should has padding bytes when allocating +// memory. if withoud pad, please use memequal. // NOTE: typename T must be uint8_t or int8_t template -typename std::enable_if::type memequal(const T* p1, size_t size1, const T* p2, size_t size2) { +typename std::enable_if::type memequal_padded(const T* p1, size_t size1, const T* p2, + size_t size2) { if (size1 != size2) { return false; } @@ -249,7 +251,8 @@ typename std::enable_if::type memequal(const T* p1, size_t #else template -typename std::enable_if::type memequal(const T* p1, size_t size1, const T* p2, size_t size2) { +typename std::enable_if::type memequal_padded(const T* p1, size_t size1, const T* p2, + size_t size2) { return (size1 == size2) && (memcmp(p1, p2, size1) == 0); } #endif @@ -257,7 +260,7 @@ typename std::enable_if::type memequal(const T* p1, size_t static constexpr uint16_t SLICE_MEMEQUAL_OVERFLOW_PADDING = 15; class SliceEqual { public: - bool operator()(const Slice& x, const Slice& y) const { return memequal(x.data, x.size, y.data, y.size); } + bool operator()(const Slice& x, const Slice& y) const { return memequal_padded(x.data, x.size, y.data, y.size); } }; class SliceNormalEqual { diff --git a/be/src/column/column_pool.h b/be/src/column/column_pool.h index f116391b277383..eaf632596b0149 100644 --- a/be/src/column/column_pool.h +++ b/be/src/column/column_pool.h @@ -30,6 +30,7 @@ #include "common/type_list.h" #include "gutil/dynamic_annotations.h" #include "runtime/current_thread.h" +#include "util/json.h" namespace starrocks { diff --git a/be/src/column/hash_set.h b/be/src/column/hash_set.h index 218c6c8bf519e5..965957f380641e 100644 --- a/be/src/column/hash_set.h +++ b/be/src/column/hash_set.h @@ -50,7 +50,7 @@ class EqualOnSliceWithHash { bool operator()(const SliceWithHash& x, const SliceWithHash& y) const { // by comparing hash value first, we can avoid comparing real data // which may touch another memory area and has bad cache locality. - return x.hash == y.hash && memequal(x.data, x.size, y.data, y.size); + return x.hash == y.hash && memequal_padded(x.data, x.size, y.data, y.size); } }; @@ -74,7 +74,7 @@ class TEqualOnSliceWithHash { bool operator()(const TSliceWithHash& x, const TSliceWithHash& y) const { // by comparing hash value first, we can avoid comparing real data // which may touch another memory area and has bad cache locality. - return x.hash == y.hash && memequal(x.data, x.size, y.data, y.size); + return x.hash == y.hash && memequal_padded(x.data, x.size, y.data, y.size); } }; diff --git a/be/src/connector/binlog_connector.cpp b/be/src/connector/binlog_connector.cpp index 0481e5c77b04da..b52a0dd0b6fa5c 100644 --- a/be/src/connector/binlog_connector.cpp +++ b/be/src/connector/binlog_connector.cpp @@ -90,7 +90,7 @@ Status BinlogDataSource::get_next(RuntimeState* state, ChunkPtr* chunk) { return _mock_chunk_test(chunk); } #endif - if (_need_seek_binlog.load(std::memory_order::memory_order_acquire)) { + if (_need_seek_binlog.load(std::memory_order::acquire)) { if (!_is_stream_pipeline) { RETURN_IF_ERROR(_prepare_non_stream_pipeline()); } diff --git a/be/src/exec/except_hash_set.h b/be/src/exec/except_hash_set.h index 383279fa933a03..1470bb52ae3190 100644 --- a/be/src/exec/except_hash_set.h +++ b/be/src/exec/except_hash_set.h @@ -38,7 +38,7 @@ class ExceptSliceFlag { struct ExceptSliceFlagEqual { bool operator()(const ExceptSliceFlag& x, const ExceptSliceFlag& y) const { - return memequal(x.slice.data, x.slice.size, y.slice.data, y.slice.size); + return memequal_padded(x.slice.data, x.slice.size, y.slice.data, y.slice.size); } }; diff --git a/be/src/exec/intersect_hash_set.h b/be/src/exec/intersect_hash_set.h index b9771983e005ed..76ae84d54f185d 100644 --- a/be/src/exec/intersect_hash_set.h +++ b/be/src/exec/intersect_hash_set.h @@ -36,7 +36,7 @@ class IntersectSliceFlag { struct IntersectSliceFlagEqual { bool operator()(const IntersectSliceFlag& x, const IntersectSliceFlag& y) const { - return memequal(x.slice.data, x.slice.size, y.slice.data, y.slice.size); + return memequal_padded(x.slice.data, x.slice.size, y.slice.data, y.slice.size); } }; diff --git a/be/src/exec/schema_scanner/schema_be_compactions_scanner.cpp b/be/src/exec/schema_scanner/schema_be_compactions_scanner.cpp index f93445f0e15b8f..bc07b8021ce43b 100644 --- a/be/src/exec/schema_scanner/schema_be_compactions_scanner.cpp +++ b/be/src/exec/schema_scanner/schema_be_compactions_scanner.cpp @@ -45,7 +45,7 @@ Status SchemaBeCompactionsScanner::start(RuntimeState* state) { auto o_id = get_backend_id(); _be_id = o_id.has_value() ? o_id.value() : -1; _infos.clear(); - CompactionInfo info; + CompactionInformation info; auto compaction_manager = StorageEngine::instance()->compaction_manager(); info.candidates_num = compaction_manager->candidates_size(); info.base_compaction_concurrency = compaction_manager->base_compaction_concurrency(); diff --git a/be/src/exec/schema_scanner/schema_be_compactions_scanner.h b/be/src/exec/schema_scanner/schema_be_compactions_scanner.h index 420cb18e45d3e9..c309dfa7504525 100644 --- a/be/src/exec/schema_scanner/schema_be_compactions_scanner.h +++ b/be/src/exec/schema_scanner/schema_be_compactions_scanner.h @@ -21,7 +21,7 @@ namespace starrocks { -struct CompactionInfo { +struct CompactionInformation { int64_t candidates_num = 0; int64_t base_compaction_concurrency = 0; int64_t cumulative_compaction_concurrency = 0; @@ -43,7 +43,7 @@ class SchemaBeCompactionsScanner : public SchemaScanner { Status fill_chunk(ChunkPtr* chunk); int64_t _be_id{0}; - std::vector _infos; + std::vector _infos; size_t _cur_idx{0}; static SchemaScanner::ColumnDesc _s_columns[]; }; diff --git a/be/src/exec/schema_scanner/schema_load_tracking_logs_scanner.cpp b/be/src/exec/schema_scanner/schema_load_tracking_logs_scanner.cpp index e4a70503b1b5fb..530a1dea311be2 100644 --- a/be/src/exec/schema_scanner/schema_load_tracking_logs_scanner.cpp +++ b/be/src/exec/schema_scanner/schema_load_tracking_logs_scanner.cpp @@ -17,6 +17,7 @@ #include #include "exec/schema_scanner/schema_helper.h" +#include "gutil/strings/substitute.h" #include "http/http_client.h" #include "runtime/runtime_state.h" #include "runtime/string_value.h" @@ -75,7 +76,7 @@ Status SchemaLoadTrackingLogsScanner::fill_chunk(ChunkPtr* chunk) { auto& info = _result.trackingLoads[_cur_idx]; for (const auto& [slot_id, index] : slot_id_to_index_map) { if (slot_id < 1 || slot_id > 5) { - return Status::InternalError(fmt::format("invalid slot id:{}}", slot_id)); + return Status::InternalError(strings::Substitute("invalid slot id: $0", slot_id)); } ColumnPtr column = (*chunk)->get_column_by_slot_id(slot_id); switch (slot_id) { diff --git a/be/src/exec/schema_scanner/schema_routine_load_jobs_scanner.cpp b/be/src/exec/schema_scanner/schema_routine_load_jobs_scanner.cpp index 8c99e57c0a12b6..dd521dbaa6dab0 100644 --- a/be/src/exec/schema_scanner/schema_routine_load_jobs_scanner.cpp +++ b/be/src/exec/schema_scanner/schema_routine_load_jobs_scanner.cpp @@ -15,6 +15,7 @@ #include "exec/schema_scanner/schema_routine_load_jobs_scanner.h" #include "exec/schema_scanner/schema_helper.h" +#include "gutil/strings/substitute.h" #include "http/http_client.h" #include "runtime/runtime_state.h" #include "runtime/string_value.h" @@ -79,7 +80,7 @@ Status SchemaRoutineLoadJobsScanner::fill_chunk(ChunkPtr* chunk) { auto& info = _result.loads[_cur_idx]; for (const auto& [slot_id, index] : slot_id_to_index_map) { if (slot_id < 1 || slot_id > 19) { - return Status::InternalError(fmt::format("invalid slot id:{}}", slot_id)); + return Status::InternalError(strings::Substitute("invalid slot id: $0", slot_id)); } ColumnPtr column = (*chunk)->get_column_by_slot_id(slot_id); switch (slot_id) { diff --git a/be/src/exec/spill/spiller.hpp b/be/src/exec/spill/spiller.hpp index 2c3464cdd6a367..d70bea2e10b00b 100644 --- a/be/src/exec/spill/spiller.hpp +++ b/be/src/exec/spill/spiller.hpp @@ -273,7 +273,7 @@ Status PartitionedSpillerWriter::flush(RuntimeState* state, bool is_final_flush, DCHECK_EQ(_running_flush_tasks, 0); _running_flush_tasks++; - auto task = [this, state, guard = guard, splitting_partitions = std::move(splitting_partitions), + auto task = [this, guard = guard, splitting_partitions = std::move(splitting_partitions), spilling_partitions = std::move(spilling_partitions), trace = TraceInfo(state)]() { SCOPED_SET_TRACE_INFO({}, trace.query_id, trace.fragment_id); RETURN_IF(!guard.scoped_begin(), Status::Cancelled("cancelled")); diff --git a/be/src/exprs/cast_expr.cpp b/be/src/exprs/cast_expr.cpp index abe9231e0a7793..9b264f40489e39 100644 --- a/be/src/exprs/cast_expr.cpp +++ b/be/src/exprs/cast_expr.cpp @@ -1450,7 +1450,7 @@ StatusOr MustNullExpr::evaluate_checked(ExprContext* context, Chunk* // only null auto column = ColumnHelper::create_column(_type, true); column->append_nulls(1); - auto only_null = std::move(ConstColumn::create(column, 1)); + auto only_null = ConstColumn::create(column, 1); if (ptr != nullptr) { only_null->resize(ptr->num_rows()); } diff --git a/be/src/formats/orc/apache-orc/CMakeLists.txt b/be/src/formats/orc/apache-orc/CMakeLists.txt index 472e4c662c7d84..44c432d5f42284 100644 --- a/be/src/formats/orc/apache-orc/CMakeLists.txt +++ b/be/src/formats/orc/apache-orc/CMakeLists.txt @@ -115,7 +115,7 @@ if (NOT MSVC) endif () message(STATUS "compiler ${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION}") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set (CMAKE_CXX_STANDARD 17) + set (CMAKE_CXX_STANDARD 20) set (WARN_FLAGS "-Weverything -Wno-c++98-compat -Wno-missing-prototypes") set (WARN_FLAGS "${WARN_FLAGS} -Wno-c++98-compat-pedantic -Wno-padded") set (WARN_FLAGS "${WARN_FLAGS} -Wno-covered-switch-default") @@ -138,7 +138,7 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7") set (CXX11_FLAGS "-std=c++0x") else () - set (CMAKE_CXX_STANDARD 17) + set (CMAKE_CXX_STANDARD 20) endif () elseif (MSVC) add_definitions (-D_SCL_SECURE_NO_WARNINGS) diff --git a/be/src/fs/fs.h b/be/src/fs/fs.h index b499e414cc7d90..bed8860fadceeb 100644 --- a/be/src/fs/fs.h +++ b/be/src/fs/fs.h @@ -90,8 +90,6 @@ struct SequentialFileOptions { }; struct RandomAccessFileOptions { - RandomAccessFileOptions() = default; - // Don't cache remote file locally on read requests. // This options can be ignored if the underlying filesystem does not support local cache. bool skip_fill_local_cache = false; diff --git a/be/src/fs/fs_s3.cpp b/be/src/fs/fs_s3.cpp index e63db5a2b12690..a30bcfa4f18928 100644 --- a/be/src/fs/fs_s3.cpp +++ b/be/src/fs/fs_s3.cpp @@ -60,7 +60,7 @@ static Status to_status(Aws::S3::S3Errors error, const std::string& msg) { case Aws::S3::S3Errors::NO_SUCH_UPLOAD: return Status::NotFound(fmt::format("no such upload: {}", msg)); default: - return Status::InternalError(fmt::format(msg)); + return Status::InternalError(msg); } } diff --git a/be/src/fs/fs_starlet.cpp b/be/src/fs/fs_starlet.cpp index 11c78a0c44ade3..3ff44092f8b4ae 100644 --- a/be/src/fs/fs_starlet.cpp +++ b/be/src/fs/fs_starlet.cpp @@ -250,8 +250,9 @@ class StarletFileSystem : public FileSystem { if (!fs_st.ok()) { return to_status(fs_st.status()); } - - auto file_st = (*fs_st)->open(pair.first, ReadOptions{.skip_fill_local_cache = opts.skip_fill_local_cache}); + auto opt = ReadOptions(); + opt.skip_fill_local_cache = opts.skip_fill_local_cache; + auto file_st = (*fs_st)->open(pair.first, std::move(opt)); if (!file_st.ok()) { return to_status(file_st.status()); @@ -274,7 +275,9 @@ class StarletFileSystem : public FileSystem { if (!fs_st.ok()) { return to_status(fs_st.status()); } - auto file_st = (*fs_st)->open(pair.first, ReadOptions{.skip_fill_local_cache = opts.skip_fill_local_cache}); + auto opt = ReadOptions(); + opt.skip_fill_local_cache = opts.skip_fill_local_cache; + auto file_st = (*fs_st)->open(pair.first, std::move(opt)); if (!file_st.ok()) { return to_status(file_st.status()); diff --git a/be/src/gutil/stl_util.h b/be/src/gutil/stl_util.h index 958eed91291b09..27a4d7042944f1 100644 --- a/be/src/gutil/stl_util.h +++ b/be/src/gutil/stl_util.h @@ -756,8 +756,10 @@ BinaryComposeBinary BinaryCompose2(F f, G1 g1, G2 g2) { template > class STLCountingAllocator : public Alloc { public: - typedef typename Alloc::pointer pointer; - typedef typename Alloc::size_type size_type; + using AllocatorTraits = std::allocator_traits; + + typedef typename AllocatorTraits::pointer pointer; + typedef typename AllocatorTraits::size_type size_type; STLCountingAllocator() {} STLCountingAllocator(int64* b) : bytes_used_(b) {} // TODO(user): explicit? @@ -766,10 +768,10 @@ class STLCountingAllocator : public Alloc { template STLCountingAllocator(const STLCountingAllocator& x) : Alloc(x), bytes_used_(x.bytes_used()) {} - pointer allocate(size_type n, std::allocator::const_pointer hint = nullptr) { + pointer allocate(size_type n) { assert(bytes_used_ != NULL); *bytes_used_ += n * sizeof(T); - return Alloc::allocate(n, hint); + return Alloc::allocate(n); } void deallocate(pointer p, size_type n) { diff --git a/be/src/storage/persistent_index.cpp b/be/src/storage/persistent_index.cpp index 3ce77da5d9648a..d0696f515c69f0 100644 --- a/be/src/storage/persistent_index.cpp +++ b/be/src/storage/persistent_index.cpp @@ -874,7 +874,7 @@ struct StringHasher2 { class EqualOnStringWithHash { public: bool operator()(const std::string& lhs, const std::string& rhs) const { - return memequal(lhs.data(), lhs.size() - kIndexValueSize, rhs.data(), rhs.size() - kIndexValueSize); + return memequal_padded(lhs.data(), lhs.size() - kIndexValueSize, rhs.data(), rhs.size() - kIndexValueSize); } }; diff --git a/be/src/util/download_util.cpp b/be/src/util/download_util.cpp index abcc0af72d9852..91337e884e2a44 100644 --- a/be/src/util/download_util.cpp +++ b/be/src/util/download_util.cpp @@ -17,6 +17,7 @@ #include #include "fmt/format.h" +#include "gutil/strings/substitute.h" #include "http/http_client.h" #include "util/defer_op.h" #include "util/md5.h" @@ -47,7 +48,8 @@ Status DownloadUtil::download(const std::string& url, const std::string& tmp_fil auto res = fwrite(data, length, 1, fp); if (res != 1) { LOG(ERROR) << fmt::format("fail to write data to file {}, error={}", tmp_file, ferror(fp)); - status = Status::InternalError(fmt::format("file to write data when downloading file from {}" + url)); + status = + Status::InternalError(strings::Substitute("file to write data when downloading file from $0", url)); return false; } return true; diff --git a/be/src/util/memcmp.h b/be/src/util/memcmp.h index 8697cb4ccab9f1..3c5e4e10149e74 100644 --- a/be/src/util/memcmp.h +++ b/be/src/util/memcmp.h @@ -56,10 +56,11 @@ inline int compare(T lhs, T rhs) { } } -// mem_equal is used to optimize the comparastion between the two strings. +// memequal is used to optimize the comparison between the two strings. // 1. If the length is equal and larger than 16, use SSE4.1 // 2. If the length is small than 16, convert the address to int16/int32/int64 -// to comparasion +// to comparison +// so it does not need to consider extra padding bytes for SIMD, which is required by memequal_padded(). // TODO: If know the size in advance, call the function by constant parameter // like memequal(p1, 10, p2, 10) is efficient diff --git a/be/src/util/path_trie.hpp b/be/src/util/path_trie.hpp index 65f0b6763cdf57..141a6f0f1ee6c6 100644 --- a/be/src/util/path_trie.hpp +++ b/be/src/util/path_trie.hpp @@ -33,8 +33,8 @@ class PathTrie { ~PathTrie() { if (_root_value != nullptr) { - _allocator.destroy(_root_value); - _allocator.deallocate(_root_value, 1); + traits_alloc::destroy(_allocator, _root_value); + traits_alloc::deallocate(_allocator, _root_value, 1); } } @@ -48,8 +48,8 @@ class PathTrie { TrieNode(const std::string& key, const T& value, std::string wildcard) : _value(nullptr), _wildcard(std::move(wildcard)) { - _value = _allocator.allocate(1); - _allocator.construct(_value, value); + _value = traits_alloc::allocate(_allocator, 1); + traits_alloc::construct(_allocator, _value, value); if (is_named_wildcard(key)) { _named_wildcard = extract_template(key); } @@ -61,8 +61,8 @@ class PathTrie { iter.second = nullptr; } if (_value != nullptr) { - _allocator.destroy(_value); - _allocator.deallocate(_value, 1); + traits_alloc::destroy(_allocator, _value); + traits_alloc::deallocate(_allocator, _value, 1); } } @@ -103,8 +103,8 @@ class PathTrie { } if (index == path.size() - 1) { if (node->_value == nullptr) { - node->_value = _allocator.allocate(1); - _allocator.construct(node->_value, value); + node->_value = traits_alloc::allocate(_allocator, 1); + traits_alloc::construct(_allocator, node->_value, value); return true; } // Already register by other path @@ -145,7 +145,7 @@ class PathTrie { if (node->_value == nullptr) { return false; } - _allocator.construct(value, *node->_value); + traits_alloc::construct(_allocator, value, *node->_value); return true; } @@ -198,6 +198,7 @@ class PathTrie { std::string _named_wildcard; std::map _children; std::allocator _allocator; + using traits_alloc = std::allocator_traits; }; bool insert(const std::string& path, const T& value) { @@ -205,8 +206,8 @@ class PathTrie { split(path, &path_array); if (path_array.empty()) { if (_root_value == nullptr) { - _root_value = _allocator.allocate(1); - _allocator.construct(_root_value, value); + _root_value = traits_alloc::allocate(_allocator, 1); + traits_alloc::construct(_allocator, _root_value, value); return true; } else { return false; @@ -226,7 +227,7 @@ class PathTrie { if (_root_value == nullptr) { return false; } else { - _allocator.construct(value, *_root_value); + traits_alloc::construct(_allocator, value, *_root_value); return true; } } @@ -236,7 +237,7 @@ class PathTrie { if (_root_value == nullptr) { return false; } else { - _allocator.construct(value, *_root_value); + traits_alloc::construct(_allocator, value, *_root_value); return true; } } @@ -269,6 +270,7 @@ class PathTrie { T* _root_value; char _separator{'/'}; std::allocator _allocator; + using traits_alloc = std::allocator_traits; }; } // namespace starrocks diff --git a/be/src/util/raw_container.h b/be/src/util/raw_container.h index 52e186bbb79e59..684fce206beb43 100644 --- a/be/src/util/raw_container.h +++ b/be/src/util/raw_container.h @@ -55,13 +55,9 @@ class RawAllocator : public A { T* x = A::allocate(n + RawAllocator::_trailing); return x; } - T* allocate(size_t n, const void* hint) { - T* x = A::allocate(n + RawAllocator::_trailing, hint); - return x; - } // deallocate the storage referenced by the pointer p - void deallocate(T* p, size_t n) { A::deallocate(p, n + RawAllocator::_trailing); } + void deallocate(T* p, size_t n) { A::deallocate(p, (n + RawAllocator::_trailing)); } // do not initialized allocated. template @@ -166,7 +162,7 @@ inline void make_room(std::vector* v, size_t n) { } inline void make_room(std::string* s, size_t n) { - RawStringPad16 rs; + RawString rs; rs.resize(n); s->swap(reinterpret_cast(rs)); } diff --git a/be/test/exec/arrow_converter_test.cpp b/be/test/exec/arrow_converter_test.cpp index 1f85315d0babee..c1cb098060bb56 100644 --- a/be/test/exec/arrow_converter_test.cpp +++ b/be/test/exec/arrow_converter_test.cpp @@ -50,7 +50,7 @@ std::tuple get_conv_func(const TypeDescriptor& type, const TypeDes std::shared_ptr arrow_type; convert_to_arrow_type(to_arrow_type, &arrow_type); TypeDescriptor raw_type; - bool need_cast; + bool need_cast = false; auto st = ParquetScanner::build_dest(arrow_type.get(), &type, is_nullable, &raw_type, &cf, need_cast, false); return {need_cast, st}; } diff --git a/be/test/exprs/binary_functions_test.cpp b/be/test/exprs/binary_functions_test.cpp index 8f7a347167bf5c..e58e54ded0b7ae 100644 --- a/be/test/exprs/binary_functions_test.cpp +++ b/be/test/exprs/binary_functions_test.cpp @@ -51,7 +51,7 @@ class BinaryFunctionsTest : public ::testing::Test { return BinaryFunctions::from_binary(ctx.get(), columns); } - Slice hex_binary(const Slice& str) { + std::string hex_binary(const Slice& str) { std::stringstream ss; ss << std::hex << std::uppercase << std::setfill('0'); for (int i = 0; i < str.size; ++i) { @@ -79,7 +79,6 @@ TEST_F(BinaryFunctionsTest, TestToBinaryNormal) { for (auto& c : good_cases) { auto [binary_type, arg, expect] = c; - std::cout << "good case, arg:" << arg << std::endl; auto result = test_to_binary(arg, binary_type); ASSERT_TRUE(result.ok()); @@ -88,7 +87,7 @@ TEST_F(BinaryFunctionsTest, TestToBinaryNormal) { ASSERT_TRUE(!v->is_null(0)); ASSERT_EQ(v->size(), 1); if (binary_type == BinaryFormatType::HEX) { - ASSERT_EQ(Slice(expect), hex_binary(v->get_data()[0])); + ASSERT_EQ(Slice(expect).to_string(), hex_binary(v->get_data()[0])); } else { ASSERT_EQ(Slice(expect), v->get_data()[0]); } @@ -100,7 +99,6 @@ TEST_F(BinaryFunctionsTest, TestToBinaryNormal) { }; for (auto& c : bad_cases) { auto [binary_type, arg] = c; - std::cout << "bad case, arg:" << arg << std::endl; auto result = test_to_binary(arg, binary_type); ASSERT_TRUE(result.ok()); auto v = ColumnHelper::as_column(result.value()); @@ -135,7 +133,6 @@ TEST_F(BinaryFunctionsTest, TestFromToBinaryNormal) { for (auto& c : good_cases) { auto [binary_type, arg, expect] = c; - std::cout << "good case, arg:" << arg << std::endl; auto result = test_to_binary(arg, binary_type); ASSERT_TRUE(result.ok()); diff --git a/be/test/formats/avro/binary_column_test.cpp b/be/test/formats/avro/binary_column_test.cpp index a594026c42b164..50ee2e218d3d2a 100644 --- a/be/test/formats/avro/binary_column_test.cpp +++ b/be/test/formats/avro/binary_column_test.cpp @@ -42,6 +42,7 @@ struct AvroHelper { avro_schema_t schema = NULL; avro_value_iface_t* iface = NULL; avro_value_t avro_val; + std::string schema_text; }; static void init_avro_value(std::string schema_path, AvroHelper& avro_helper) { diff --git a/be/test/formats/avro/nullable_column_test.cpp b/be/test/formats/avro/nullable_column_test.cpp index c57bf0c1f78683..a77cfadd85e19e 100644 --- a/be/test/formats/avro/nullable_column_test.cpp +++ b/be/test/formats/avro/nullable_column_test.cpp @@ -43,6 +43,7 @@ struct AvroHelper { avro_schema_t schema = NULL; avro_value_iface_t* iface = NULL; avro_value_t avro_val; + std::string schema_text; }; static void init_avro_value(std::string schema_path, AvroHelper& avro_helper) { diff --git a/be/test/formats/avro/numeric_column_test.cpp b/be/test/formats/avro/numeric_column_test.cpp index a67032d79a2335..30c7f8313c52dd 100644 --- a/be/test/formats/avro/numeric_column_test.cpp +++ b/be/test/formats/avro/numeric_column_test.cpp @@ -41,6 +41,7 @@ struct AvroHelper { avro_schema_t schema = NULL; avro_value_iface_t* iface = NULL; avro_value_t avro_val; + std::string schema_text; }; static void init_avro_value(std::string schema_path, AvroHelper& avro_helper) { diff --git a/be/test/formats/csv/varbinary_converter_test.cpp b/be/test/formats/csv/varbinary_converter_test.cpp index 32dc134cbabf9c..93d5542e288057 100644 --- a/be/test/formats/csv/varbinary_converter_test.cpp +++ b/be/test/formats/csv/varbinary_converter_test.cpp @@ -32,7 +32,7 @@ class VarBinaryConverterTest : public ::testing::Test { _type.len = 6000; } - Slice hex_binary(const Slice& str) { + std::string hex_binary(const Slice& str) { std::stringstream ss; ss << std::hex << std::uppercase << std::setfill('0'); for (int i = 0; i < str.size; ++i) { @@ -56,10 +56,10 @@ TEST_F(VarBinaryConverterTest, test_read_varbinary) { EXPECT_TRUE(conv->read_string(col.get(), " 0101", Converter::Options())); EXPECT_EQ(4, col->size()); - ASSERT_EQ(Slice("AB"), hex_binary(col->get(0).get_slice())); - ASSERT_EQ(Slice("0101"), hex_binary(col->get(1).get_slice())); - ASSERT_EQ(Slice("AB"), hex_binary(col->get(2).get_slice())); - ASSERT_EQ(Slice("0101"), hex_binary(col->get(3).get_slice())); + ASSERT_EQ(Slice("AB").to_string(), hex_binary(col->get(0).get_slice())); + ASSERT_EQ(Slice("0101").to_string(), hex_binary(col->get(1).get_slice())); + ASSERT_EQ(Slice("AB").to_string(), hex_binary(col->get(2).get_slice())); + ASSERT_EQ(Slice("0101").to_string(), hex_binary(col->get(3).get_slice())); EXPECT_FALSE(conv->read_string(col.get(), "xyz", Converter::Options())); EXPECT_FALSE(conv->read_string(col.get(), "1", Converter::Options())); diff --git a/be/test/formats/orc/orc_chunk_reader_test.cpp b/be/test/formats/orc/orc_chunk_reader_test.cpp index fc11d41d805928..8983088468417b 100644 --- a/be/test/formats/orc/orc_chunk_reader_test.cpp +++ b/be/test/formats/orc/orc_chunk_reader_test.cpp @@ -1136,8 +1136,8 @@ TEST_F(OrcChunkReaderTest, TestReadBinaryColumn) { EXPECT_FALSE(nulls[0]); EXPECT_EQ(vo[0], 0); EXPECT_EQ(vo[1], 2); - EXPECT_EQ(vb[0], u'\n'); - EXPECT_EQ(vb[1], u'\274'); + EXPECT_EQ((int)vb[0], 10); + EXPECT_EQ((int)vb[1], 188); } } diff --git a/be/test/storage/schema_change_test.cpp b/be/test/storage/schema_change_test.cpp index 18ff368c2e6050..f334b52fdbc030 100644 --- a/be/test/storage/schema_change_test.cpp +++ b/be/test/storage/schema_change_test.cpp @@ -263,7 +263,7 @@ TEST_F(SchemaChangeTest, convert_datetime_to_date) { ASSERT_TRUE(st.ok()); int dst_value = (time_tm.tm_year + 1900) * 16 * 32 + (time_tm.tm_mon + 1) * 32 + time_tm.tm_mday; - EXPECT_EQ(dst_value, dst_datum.get_uint24()); + EXPECT_EQ(dst_value, (int)dst_datum.get_uint24()); } TEST_F(SchemaChangeTest, convert_date_to_datetime) { @@ -332,7 +332,7 @@ TEST_F(SchemaChangeTest, convert_int_to_date) { ASSERT_TRUE(st.ok()); int dst_value = (time_tm.tm_year + 1900) * 16 * 32 + (time_tm.tm_mon + 1) * 32 + time_tm.tm_mday; - EXPECT_EQ(dst_value, dst_datum.get_uint24()); + EXPECT_EQ(dst_value, (int)dst_datum.get_uint24()); } TEST_F(SchemaChangeTest, convert_int_to_bitmap) {