diff --git a/internal/core/src/mmap/ChunkVector.h b/internal/core/src/mmap/ChunkVector.h index 3e155fd172306..7b024a603f93b 100644 --- a/internal/core/src/mmap/ChunkVector.h +++ b/internal/core/src/mmap/ChunkVector.h @@ -43,6 +43,9 @@ class ChunkVectorBase { virtual SpanBase get_span(int64_t chunk_id) = 0; + virtual bool + is_mmap() const = 0; + protected: std::atomic counter_ = 0; }; @@ -103,7 +106,7 @@ class ThreadSafeChunkVector : public ChunkVectorBase { ChunkViewType view_element(int64_t chunk_id, int64_t chunk_offset) override { std::shared_lock 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) { @@ -161,6 +164,11 @@ class ThreadSafeChunkVector : public ChunkVectorBase { } } + bool + is_mmap() const override { + return mmap_descriptor_ != nullptr; + } + private: mutable std::shared_mutex mutex_; storage::MmapChunkDescriptorPtr mmap_descriptor_ = nullptr; diff --git a/internal/core/src/query/GroupByOperator.h b/internal/core/src/query/GroupByOperator.h index 4ef1297bf1df5..4c8f94622a361 100644 --- a/internal/core/src/query/GroupByOperator.h +++ b/internal/core/src/query/GroupByOperator.h @@ -51,10 +51,12 @@ class GrowingDataGetter : public DataGetter { T Get(int64_t idx) const { if constexpr (std::is_same_v) { - 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); } }; diff --git a/internal/core/src/segcore/ConcurrentVector.h b/internal/core/src/segcore/ConcurrentVector.h index 3591758d0292a..01e76843a3825 100644 --- a/internal/core/src/segcore/ConcurrentVector.h +++ b/internal/core/src/segcore/ConcurrentVector.h @@ -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,