From 703909c0b5495994f741cd9cfc25134dc9ca1491 Mon Sep 17 00:00:00 2001 From: sunby Date: Thu, 16 Jan 2025 16:23:03 +0800 Subject: [PATCH] fix: Fix some bugs 1. fix use after free bug 2. fix performance issue Signed-off-by: sunby --- internal/core/src/exec/expression/Expr.h | 19 +++++++++++-------- .../core/src/segcore/SegmentChunkReader.cpp | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/internal/core/src/exec/expression/Expr.h b/internal/core/src/exec/expression/Expr.h index f2bbc8cd7f6bb..6c6d7e3ca5faa 100644 --- a/internal/core/src/exec/expression/Expr.h +++ b/internal/core/src/exec/expression/Expr.h @@ -684,10 +684,13 @@ class SegmentExpr : public Expr { if constexpr (std::is_same_v || std::is_same_v) { if (segment_->type() == SegmentType::Sealed) { - valid_data = segment_ - ->get_batch_views( - field_id_, i, data_pos, size) - .second.data(); + auto batch_views = segment_->get_batch_views( + field_id_, i, data_pos, size); + valid_data = batch_views.second.data(); + ApplyValidData(valid_data, + res + processed_size, + valid_res + processed_size, + size); } } else { auto chunk = segment_->chunk_data(field_id_, i); @@ -695,11 +698,11 @@ class SegmentExpr : public Expr { if (valid_data != nullptr) { valid_data += data_pos; } + ApplyValidData(valid_data, + res + processed_size, + valid_res + processed_size, + size); } - ApplyValidData(valid_data, - res + processed_size, - valid_res + processed_size, - size); } processed_size += size; diff --git a/internal/core/src/segcore/SegmentChunkReader.cpp b/internal/core/src/segcore/SegmentChunkReader.cpp index 207248acf888e..6aa2b920b271c 100644 --- a/internal/core/src/segcore/SegmentChunkReader.cpp +++ b/internal/core/src/segcore/SegmentChunkReader.cpp @@ -138,8 +138,8 @@ SegmentChunkReader::GetChunkDataAccessor( current_chunk_size = segment_->chunk_size(field_id, current_chunk_id); } - auto chunk_data = chunk_info.first; - auto chunk_valid_data = chunk_info.second; + auto& chunk_data = chunk_info.first; + auto& chunk_valid_data = chunk_info.second; if (current_chunk_pos < chunk_valid_data.size() && !chunk_valid_data[current_chunk_pos]) { current_chunk_pos++;