mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 10:08:42 +08:00
fix: [2.5]Skip create tmp dir for growing R-Tree index (#45258)
issue: https://github.com/milvus-io/milvus/issues/45181 master pr: https://github.com/milvus-io/milvus/pull/45256 Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
This commit is contained in:
parent
36a30dd34e
commit
2e4502a4fc
@ -32,19 +32,22 @@ ends_with(const std::string& value, const std::string& suffix) {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void
|
void
|
||||||
RTreeIndex<T>::InitForBuildIndex() {
|
RTreeIndex<T>::InitForBuildIndex(bool is_growing) {
|
||||||
auto field =
|
std::string index_file_path;
|
||||||
std::to_string(disk_file_manager_->GetFieldDataMeta().field_id);
|
if (is_growing) {
|
||||||
auto prefix = disk_file_manager_->GetIndexIdentifier();
|
path_ = "";
|
||||||
path_ = std::string(TMP_RTREE_INDEX_PREFIX) + prefix;
|
} else {
|
||||||
boost::filesystem::create_directories(path_);
|
auto prefix = disk_file_manager_->GetIndexIdentifier();
|
||||||
|
path_ = std::string(TMP_RTREE_INDEX_PREFIX) + prefix;
|
||||||
std::string index_file_path = path_ + "/index_file"; // base path (no ext)
|
boost::filesystem::create_directories(path_);
|
||||||
|
index_file_path = path_ + "/index_file"; // base path (no ext)
|
||||||
if (boost::filesystem::exists(index_file_path + ".bgi")) {
|
if (boost::filesystem::exists(index_file_path + ".bgi")) {
|
||||||
PanicInfo(
|
PanicInfo(IndexBuildError,
|
||||||
IndexBuildError, "build rtree index temp dir:{} not empty", path_);
|
"build rtree index temp dir:{} not empty",
|
||||||
|
path_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper_ = std::make_shared<RTreeIndexWrapper>(index_file_path, true);
|
wrapper_ = std::make_shared<RTreeIndexWrapper>(index_file_path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +224,7 @@ RTreeIndex<T>::Build(const Config& config) {
|
|||||||
GetValueFromConfig<std::vector<std::string>>(config, "insert_files");
|
GetValueFromConfig<std::vector<std::string>>(config, "insert_files");
|
||||||
AssertInfo(insert_files.has_value(),
|
AssertInfo(insert_files.has_value(),
|
||||||
"insert_files were empty for building RTree index");
|
"insert_files were empty for building RTree index");
|
||||||
InitForBuildIndex();
|
InitForBuildIndex(false);
|
||||||
|
|
||||||
// load raw WKB data into memory
|
// load raw WKB data into memory
|
||||||
auto field_datas =
|
auto field_datas =
|
||||||
@ -498,7 +501,7 @@ RTreeIndex<T>::BuildWithRawDataForUT(size_t n,
|
|||||||
// Guard: n should represent number of strings not raw bytes
|
// Guard: n should represent number of strings not raw bytes
|
||||||
AssertInfo(n > 0, "BuildWithRawDataForUT expects element count > 0");
|
AssertInfo(n > 0, "BuildWithRawDataForUT expects element count > 0");
|
||||||
LOG_WARN("BuildWithRawDataForUT:{}", n);
|
LOG_WARN("BuildWithRawDataForUT:{}", n);
|
||||||
this->InitForBuildIndex();
|
this->InitForBuildIndex(false);
|
||||||
|
|
||||||
int64_t offset = 0;
|
int64_t offset = 0;
|
||||||
for (size_t i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
@ -521,7 +524,7 @@ RTreeIndex<T>::BuildWithStrings(const std::vector<std::string>& geometries) {
|
|||||||
LOG_INFO("BuildWithStrings: building RTree index for {} geometries",
|
LOG_INFO("BuildWithStrings: building RTree index for {} geometries",
|
||||||
geometries.size());
|
geometries.size());
|
||||||
|
|
||||||
this->InitForBuildIndex();
|
this->InitForBuildIndex(false);
|
||||||
|
|
||||||
int64_t offset = 0;
|
int64_t offset = 0;
|
||||||
for (const auto& wkb : geometries) {
|
for (const auto& wkb : geometries) {
|
||||||
@ -549,7 +552,7 @@ void
|
|||||||
RTreeIndex<T>::AddGeometry(const std::string& wkb_data, int64_t row_offset) {
|
RTreeIndex<T>::AddGeometry(const std::string& wkb_data, int64_t row_offset) {
|
||||||
if (!wrapper_) {
|
if (!wrapper_) {
|
||||||
// Initialize if not already done
|
// Initialize if not already done
|
||||||
this->InitForBuildIndex();
|
this->InitForBuildIndex(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wkb_data.empty()) {
|
if (!wkb_data.empty()) {
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class RTreeIndex : public ScalarIndex<T> {
|
|||||||
~RTreeIndex();
|
~RTreeIndex();
|
||||||
|
|
||||||
void
|
void
|
||||||
InitForBuildIndex();
|
InitForBuildIndex(bool is_growing);
|
||||||
|
|
||||||
void
|
void
|
||||||
Load(milvus::tracer::TraceContext ctx, const Config& config = {}) override;
|
Load(milvus::tracer::TraceContext ctx, const Config& config = {}) override;
|
||||||
|
|||||||
@ -435,9 +435,9 @@ ScalarFieldIndexing<T>::recreate_index(DataType data_type,
|
|||||||
sync_with_index_ = false;
|
sync_with_index_ = false;
|
||||||
index_cur_ = 0;
|
index_cur_ = 0;
|
||||||
LOG_INFO(
|
LOG_INFO(
|
||||||
"Created R-Tree index for geometry data type: {} with "
|
"Created R-Tree index for geometry fieldID: {} with "
|
||||||
"FileManagerContext",
|
"FileManagerContext",
|
||||||
data_type);
|
field_meta_.get_id().get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
index_ = index::CreateStringIndexSort();
|
index_ = index::CreateStringIndexSort();
|
||||||
@ -554,7 +554,7 @@ ScalarFieldIndexing<T>::process_geometry_data(int64_t reserved_offset,
|
|||||||
if (!built_) {
|
if (!built_) {
|
||||||
try {
|
try {
|
||||||
// Initialize R-Tree for building immediately when first data arrives
|
// Initialize R-Tree for building immediately when first data arrives
|
||||||
rtree_index->InitForBuildIndex();
|
rtree_index->InitForBuildIndex(true);
|
||||||
built_ = true;
|
built_ = true;
|
||||||
sync_with_index_ = true;
|
sync_with_index_ = true;
|
||||||
LOG_INFO(
|
LOG_INFO(
|
||||||
|
|||||||
@ -17485,7 +17485,7 @@ TEST_P(ExprTest, TestSTDWithinFunction) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ExprTest, ParseGISFunctionFilterExprs) {
|
TEST(ExprTest, ParseGISFunctionFilterExprs) {
|
||||||
// Build Schema
|
// Build Schema
|
||||||
auto schema = std::make_shared<Schema>();
|
auto schema = std::make_shared<Schema>();
|
||||||
auto dim = 16;
|
auto dim = 16;
|
||||||
@ -17524,7 +17524,7 @@ TEST_P(ExprTest, ParseGISFunctionFilterExprs) {
|
|||||||
>)PLAN";
|
>)PLAN";
|
||||||
|
|
||||||
// Convert and parse
|
// Convert and parse
|
||||||
auto bin_plan = translate_text_plan_with_metric_type(raw_plan);
|
auto bin_plan = translate_text_plan_to_binary_plan(raw_plan.c_str());
|
||||||
auto plan =
|
auto plan =
|
||||||
CreateSearchPlanByExpr(*schema, bin_plan.data(), bin_plan.size());
|
CreateSearchPlanByExpr(*schema, bin_plan.data(), bin_plan.size());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user