Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: growing-groupby-crush(#38533) #38553

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading