Skip to content

Commit

Permalink
fix: growing-groupby-crush(#38533)
Browse files Browse the repository at this point in the history
Signed-off-by: MrPresent-Han <[email protected]>
  • Loading branch information
MrPresent-Han committed Dec 18, 2024
1 parent b469999 commit 7054fa8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 9 additions & 1 deletion internal/core/src/mmap/ChunkVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class ChunkVectorBase {
virtual SpanBase
get_span(int64_t chunk_id) = 0;

virtual bool
is_mmap() const = 0;

protected:
std::atomic<int64_t> counter_ = 0;
};
Expand Down Expand Up @@ -103,7 +106,7 @@ class ThreadSafeChunkVector : public ChunkVectorBase<Type> {
ChunkViewType<Type>
view_element(int64_t chunk_id, int64_t chunk_offset) override {
std::shared_lock<std::shared_mutex> lck(mutex_);
auto chunk = vec_[chunk_id];
auto& chunk = vec_[chunk_id];
if constexpr (IsMmap) {
return chunk.view(chunk_offset);
} else if constexpr (std::is_same_v<std::string, Type>) {
Expand Down Expand Up @@ -161,6 +164,11 @@ class ThreadSafeChunkVector : public ChunkVectorBase<Type> {
}
}

bool
is_mmap() const override {
return mmap_descriptor_ != nullptr;
}

private:
mutable std::shared_mutex mutex_;
storage::MmapChunkDescriptorPtr mmap_descriptor_ = nullptr;
Expand Down
8 changes: 5 additions & 3 deletions internal/core/src/query/GroupByOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ class GrowingDataGetter : public DataGetter<T> {
T
Get(int64_t idx) const {
if constexpr (std::is_same_v<std::string, T>) {
return T(growing_raw_data_->view_element(idx));
} else {
return growing_raw_data_->operator[](idx);
if (growing_raw_data_->is_mmap()) {
// when scalar data is mapped, it's needed to get the scalar data view and reconstruct string from the view
return T(growing_raw_data_->view_element(idx));
}
}
return growing_raw_data_->operator[](idx);
}
};

Expand Down
5 changes: 5 additions & 0 deletions internal/core/src/segcore/ConcurrentVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ class ConcurrentVectorImpl : public VectorBase {
chunks_ptr_->clear();
}

bool
is_mmap() const {
return chunks_ptr_->is_mmap();
}

private:
void
set_data(ssize_t element_offset,
Expand Down

0 comments on commit 7054fa8

Please sign in to comment.