Skip to content

Commit

Permalink
fix: Fix some bugs
Browse files Browse the repository at this point in the history
1. fix use after free bug
2. fix performance issue

Signed-off-by: sunby <[email protected]>
  • Loading branch information
sunby committed Jan 16, 2025
1 parent 2439278 commit 703909c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions internal/core/src/exec/expression/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,22 +684,25 @@ class SegmentExpr : public Expr {
if constexpr (std::is_same_v<T, std::string_view> ||
std::is_same_v<T, Json>) {
if (segment_->type() == SegmentType::Sealed) {
valid_data = segment_
->get_batch_views<T>(
field_id_, i, data_pos, size)
.second.data();
auto batch_views = segment_->get_batch_views<T>(

Check warning on line 687 in internal/core/src/exec/expression/Expr.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/exec/expression/Expr.h#L687

Added line #L687 was not covered by tests
field_id_, i, data_pos, size);
valid_data = batch_views.second.data();
ApplyValidData(valid_data,

Check warning on line 690 in internal/core/src/exec/expression/Expr.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/exec/expression/Expr.h#L690

Added line #L690 was not covered by tests
res + processed_size,
valid_res + processed_size,
size);
}
} else {
auto chunk = segment_->chunk_data<T>(field_id_, i);
valid_data = chunk.valid_data();
if (valid_data != nullptr) {
valid_data += data_pos;
}
ApplyValidData(valid_data,

Check warning on line 701 in internal/core/src/exec/expression/Expr.h

View check run for this annotation

Codecov / codecov/patch

internal/core/src/exec/expression/Expr.h#L701

Added line #L701 was not covered by tests
res + processed_size,
valid_res + processed_size,
size);
}
ApplyValidData(valid_data,
res + processed_size,
valid_res + processed_size,
size);
}

processed_size += size;
Expand Down
4 changes: 2 additions & 2 deletions internal/core/src/segcore/SegmentChunkReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ SegmentChunkReader::GetChunkDataAccessor<std::string>(
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++;
Expand Down

0 comments on commit 703909c

Please sign in to comment.