File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ class ChunkVectorBase {
43
43
virtual SpanBase
44
44
get_span (int64_t chunk_id) = 0 ;
45
45
46
+ virtual bool
47
+ is_mmap () const = 0 ;
48
+
46
49
protected:
47
50
std::atomic<int64_t > counter_ = 0 ;
48
51
};
@@ -103,7 +106,7 @@ class ThreadSafeChunkVector : public ChunkVectorBase<Type> {
103
106
ChunkViewType<Type>
104
107
view_element (int64_t chunk_id, int64_t chunk_offset) override {
105
108
std::shared_lock<std::shared_mutex> lck (mutex_);
106
- auto chunk = vec_[chunk_id];
109
+ auto & chunk = vec_[chunk_id];
107
110
if constexpr (IsMmap) {
108
111
return chunk.view (chunk_offset);
109
112
} else if constexpr (std::is_same_v<std::string, Type>) {
@@ -161,6 +164,11 @@ class ThreadSafeChunkVector : public ChunkVectorBase<Type> {
161
164
}
162
165
}
163
166
167
+ bool
168
+ is_mmap () const override {
169
+ return mmap_descriptor_ != nullptr ;
170
+ }
171
+
164
172
private:
165
173
mutable std::shared_mutex mutex_;
166
174
storage::MmapChunkDescriptorPtr mmap_descriptor_ = nullptr ;
Original file line number Diff line number Diff line change @@ -51,10 +51,12 @@ class GrowingDataGetter : public DataGetter<T> {
51
51
T
52
52
Get (int64_t idx) const {
53
53
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
+ }
57
58
}
59
+ return growing_raw_data_->operator [](idx);
58
60
}
59
61
};
60
62
Original file line number Diff line number Diff line change @@ -290,6 +290,11 @@ class ConcurrentVectorImpl : public VectorBase {
290
290
chunks_ptr_->clear ();
291
291
}
292
292
293
+ bool
294
+ is_mmap () const {
295
+ return chunks_ptr_->is_mmap ();
296
+ }
297
+
293
298
private:
294
299
void
295
300
set_data (ssize_t element_offset,
You can’t perform that action at this time.
0 commit comments