mirror of https://github.com/milvus-io/milvus.git
related: #38533 Signed-off-by: MrPresent-Han <chun.han@gmail.com> Co-authored-by: MrPresent-Han <chun.han@gmail.com>pull/38542/head
parent
1ec858434f
commit
decdfdae10
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -47,6 +47,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;
|
||||
};
|
||||
|
@ -107,7 +110,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>) {
|
||||
|
@ -184,6 +187,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;
|
||||
|
|
|
@ -318,6 +318,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,
|
||||
|
|
Loading…
Reference in New Issue