fix insert null as string type may coredump (#6615)
This commit is contained in:
@ -180,6 +180,11 @@ public:
|
||||
// memory allocation.
|
||||
template <typename DstCellType, typename SrcCellType>
|
||||
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<Slice*>(dst->mutable_cell_ptr());
|
||||
auto src_slice = reinterpret_cast<const Slice*>(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());
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -255,7 +255,6 @@ EncodingInfoResolver::EncodingInfoResolver() {
|
||||
_add_map<OLAP_FIELD_TYPE_VARCHAR, PLAIN_ENCODING>();
|
||||
_add_map<OLAP_FIELD_TYPE_VARCHAR, PREFIX_ENCODING, true>();
|
||||
|
||||
_add_map<OLAP_FIELD_TYPE_STRING, DICT_ENCODING>();
|
||||
_add_map<OLAP_FIELD_TYPE_STRING, PLAIN_ENCODING>();
|
||||
_add_map<OLAP_FIELD_TYPE_STRING, PREFIX_ENCODING, true>();
|
||||
|
||||
|
||||
@ -23,11 +23,11 @@
|
||||
#include <snappy/snappy.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "gutil/strings/substitute.h"
|
||||
#include "util/faststring.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
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<int32_t>::max() ||
|
||||
output->size > std::numeric_limits<int32_t>::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<int32_t>::max()) {
|
||||
return 0;
|
||||
}
|
||||
return LZ4_compressBound(len);
|
||||
return LZ4_compressBound(len);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user