Skip to content

Commit 306f200

Browse files
MrPresent-HanMrPresent-Han
andauthored
fix: growing-groupby-crush(#38533) (#38553)
related: #38533 pr: #38538 Signed-off-by: MrPresent-Han <[email protected]> Co-authored-by: MrPresent-Han <[email protected]>
1 parent b469999 commit 306f200

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

internal/core/src/mmap/ChunkVector.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class ChunkVectorBase {
4343
virtual SpanBase
4444
get_span(int64_t chunk_id) = 0;
4545

46+
virtual bool
47+
is_mmap() const = 0;
48+
4649
protected:
4750
std::atomic<int64_t> counter_ = 0;
4851
};
@@ -103,7 +106,7 @@ class ThreadSafeChunkVector : public ChunkVectorBase<Type> {
103106
ChunkViewType<Type>
104107
view_element(int64_t chunk_id, int64_t chunk_offset) override {
105108
std::shared_lock<std::shared_mutex> lck(mutex_);
106-
auto chunk = vec_[chunk_id];
109+
auto& chunk = vec_[chunk_id];
107110
if constexpr (IsMmap) {
108111
return chunk.view(chunk_offset);
109112
} else if constexpr (std::is_same_v<std::string, Type>) {
@@ -161,6 +164,11 @@ class ThreadSafeChunkVector : public ChunkVectorBase<Type> {
161164
}
162165
}
163166

167+
bool
168+
is_mmap() const override {
169+
return mmap_descriptor_ != nullptr;
170+
}
171+
164172
private:
165173
mutable std::shared_mutex mutex_;
166174
storage::MmapChunkDescriptorPtr mmap_descriptor_ = nullptr;

internal/core/src/query/GroupByOperator.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ class GrowingDataGetter : public DataGetter<T> {
5151
T
5252
Get(int64_t idx) const {
5353
if constexpr (std::is_same_v<std::string, T>) {
54-
return T(growing_raw_data_->view_element(idx));
55-
} else {
56-
return growing_raw_data_->operator[](idx);
54+
if (growing_raw_data_->is_mmap()) {
55+
// when scalar data is mapped, it's needed to get the scalar data view and reconstruct string from the view
56+
return T(growing_raw_data_->view_element(idx));
57+
}
5758
}
59+
return growing_raw_data_->operator[](idx);
5860
}
5961
};
6062

internal/core/src/segcore/ConcurrentVector.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ class ConcurrentVectorImpl : public VectorBase {
290290
chunks_ptr_->clear();
291291
}
292292

293+
bool
294+
is_mmap() const {
295+
return chunks_ptr_->is_mmap();
296+
}
297+
293298
private:
294299
void
295300
set_data(ssize_t element_offset,

0 commit comments

Comments
 (0)