Skip to content
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
14 changes: 5 additions & 9 deletions internal/core/src/index/RTreeIndexWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ void
RTreeIndexWrapper::add_geometry(const uint8_t* wkb_data,
size_t len,
int64_t row_offset) {
// Acquire write lock to protect rtree_ modification
folly::SharedMutexWritePriority::WriteHolder lock(rtree_mutex_);
// Acquire write lock to protect rtree_
std::unique_lock<std::shared_mutex> guard(rtree_mutex_);

AssertInfo(is_build_mode_, "Cannot add geometry in load mode");
std::unique_lock<std::shared_mutex> guard(rtree_mutex_);

// Parse WKB data to OGR geometry
OGRGeometry* geom = nullptr;
Expand Down Expand Up @@ -79,10 +78,10 @@ RTreeIndexWrapper::bulk_load_from_field_data(
const std::vector<std::shared_ptr<::milvus::FieldDataBase>>& field_datas,
bool nullable) {
// Acquire write lock to protect rtree_ creation and modification
folly::SharedMutexWritePriority::WriteHolder lock(rtree_mutex_);
std::unique_lock<std::shared_mutex> guard(rtree_mutex_);

AssertInfo(is_build_mode_, "Cannot bulk load in load mode");
std::unique_lock<std::shared_mutex> guard(rtree_mutex_);

std::vector<Value> local_values;
local_values.reserve(1024);
int64_t absolute_offset = 0;
Expand Down Expand Up @@ -123,8 +122,6 @@ RTreeIndexWrapper::bulk_load_from_field_data(
void
RTreeIndexWrapper::finish() {
// Acquire write lock to protect rtree_ modification and cleanup
folly::SharedMutexWritePriority::WriteHolder lock(rtree_mutex_);

// Guard against repeated invocations which could otherwise attempt to
// release resources multiple times (e.g. BuildWithRawDataForUT() calls
// finish(), and Upload() may call it again).
Expand Down Expand Up @@ -164,11 +161,10 @@ RTreeIndexWrapper::finish() {
void
RTreeIndexWrapper::load() {
// Acquire write lock to protect rtree_ initialization during loading
folly::SharedMutexWritePriority::WriteHolder lock(rtree_mutex_);
std::unique_lock<std::shared_mutex> guard(rtree_mutex_);

AssertInfo(!is_build_mode_, "Cannot load in build mode");

std::unique_lock<std::shared_mutex> guard(rtree_mutex_);
try {
// Read meta (optional)
try {
Expand Down
1 change: 0 additions & 1 deletion internal/core/src/index/RTreeIndexWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <boost/geometry/index/rtree.hpp>
#include "ogr_geometry.h"
#include "pb/plan.pb.h"
#include <folly/SharedMutex.h>

// Forward declaration to avoid pulling heavy field data headers here
namespace milvus {
Expand Down
Loading