diff --git a/be/src/olap/field.h b/be/src/olap/field.h index ffe0221c2d..7602363bcb 100644 --- a/be/src/olap/field.h +++ b/be/src/olap/field.h @@ -180,6 +180,11 @@ public: // memory allocation. template void direct_copy(DstCellType* dst, const SrcCellType& src) const { + bool is_null = src.is_null(); + dst->set_is_null(is_null); + if (is_null) { + return; + } if (type() == OLAP_FIELD_TYPE_STRING) { auto dst_slice = reinterpret_cast(dst->mutable_cell_ptr()); auto src_slice = reinterpret_cast(src.cell_ptr()); @@ -189,11 +194,6 @@ public: dst_slice->size = src_slice->size; } } - bool is_null = src.is_null(); - dst->set_is_null(is_null); - if (is_null) { - return; - } return _type_info->direct_copy(dst->mutable_cell_ptr(), src.cell_ptr()); } diff --git a/be/src/olap/rowset/segment_v2/binary_plain_page.h b/be/src/olap/rowset/segment_v2/binary_plain_page.h index 97e7fa8bbc..0747df2173 100644 --- a/be/src/olap/rowset/segment_v2/binary_plain_page.h +++ b/be/src/olap/rowset/segment_v2/binary_plain_page.h @@ -215,7 +215,7 @@ public: char* destination = (char*)dst->column_block()->pool()->allocate(mem_size); if (destination == nullptr) { return Status::MemoryAllocFailed( - strings::Substitute("memory allocate failed, size:$0", mem_size)); + strings::Substitute("memory allocate failed, size:$0", mem_size)); } for (int i = 0; i < max_fetch; ++i) { out->relocate(destination); @@ -245,7 +245,7 @@ public: private: // Return the offset within '_data' where the string value with index 'idx' can be found. - uint32_t offset(int idx) const { + uint32_t offset(size_t idx) const { if (idx >= _num_elems) { return _offsets_pos; } diff --git a/be/src/olap/rowset/segment_v2/encoding_info.cpp b/be/src/olap/rowset/segment_v2/encoding_info.cpp index e4ce43cf77..801cdb406f 100644 --- a/be/src/olap/rowset/segment_v2/encoding_info.cpp +++ b/be/src/olap/rowset/segment_v2/encoding_info.cpp @@ -255,7 +255,6 @@ EncodingInfoResolver::EncodingInfoResolver() { _add_map(); _add_map(); - _add_map(); _add_map(); _add_map(); diff --git a/be/src/util/block_compression.cpp b/be/src/util/block_compression.cpp index 290ffec66c..8ba1e4f909 100644 --- a/be/src/util/block_compression.cpp +++ b/be/src/util/block_compression.cpp @@ -23,11 +23,11 @@ #include #include +#include + #include "gutil/strings/substitute.h" #include "util/faststring.h" -#include - namespace doris { using strings::Substitute; @@ -52,6 +52,10 @@ public: ~Lz4BlockCompression() override {} Status compress(const Slice& input, Slice* output) const override { + if (input.size > std::numeric_limits::max() || + output->size > std::numeric_limits::max()) { + return Status::InvalidArgument("LZ4 cannot handle data large than 2G"); + } auto compressed_len = LZ4_compress_default(input.data, output->data, input.size, output->size); if (compressed_len == 0) { @@ -73,11 +77,11 @@ public: return Status::OK(); } - size_t max_compressed_len(size_t len) const override { + size_t max_compressed_len(size_t len) const override { if (len > std::numeric_limits::max()) { return 0; } - return LZ4_compressBound(len); + return LZ4_compressBound(len); } };