mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 17:48:29 +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>
|
||||
void
|
||||
RTreeIndex<T>::InitForBuildIndex() {
|
||||
auto field =
|
||||
std::to_string(disk_file_manager_->GetFieldDataMeta().field_id);
|
||||
auto prefix = disk_file_manager_->GetIndexIdentifier();
|
||||
path_ = std::string(TMP_RTREE_INDEX_PREFIX) + prefix;
|
||||
boost::filesystem::create_directories(path_);
|
||||
|
||||
std::string index_file_path = path_ + "/index_file"; // base path (no ext)
|
||||
|
||||
if (boost::filesystem::exists(index_file_path + ".bgi")) {
|
||||
PanicInfo(
|
||||
IndexBuildError, "build rtree index temp dir:{} not empty", path_);
|
||||
RTreeIndex<T>::InitForBuildIndex(bool is_growing) {
|
||||
std::string index_file_path;
|
||||
if (is_growing) {
|
||||
path_ = "";
|
||||
} else {
|
||||
auto prefix = disk_file_manager_->GetIndexIdentifier();
|
||||
path_ = std::string(TMP_RTREE_INDEX_PREFIX) + prefix;
|
||||
boost::filesystem::create_directories(path_);
|
||||
index_file_path = path_ + "/index_file"; // base path (no ext)
|
||||
if (boost::filesystem::exists(index_file_path + ".bgi")) {
|
||||
PanicInfo(IndexBuildError,
|
||||
"build rtree index temp dir:{} not empty",
|
||||
path_);
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
AssertInfo(insert_files.has_value(),
|
||||
"insert_files were empty for building RTree index");
|
||||
InitForBuildIndex();
|
||||
InitForBuildIndex(false);
|
||||
|
||||
// load raw WKB data into memory
|
||||
auto field_datas =
|
||||
@ -498,7 +501,7 @@ RTreeIndex<T>::BuildWithRawDataForUT(size_t n,
|
||||
// Guard: n should represent number of strings not raw bytes
|
||||
AssertInfo(n > 0, "BuildWithRawDataForUT expects element count > 0");
|
||||
LOG_WARN("BuildWithRawDataForUT:{}", n);
|
||||
this->InitForBuildIndex();
|
||||
this->InitForBuildIndex(false);
|
||||
|
||||
int64_t offset = 0;
|
||||
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",
|
||||
geometries.size());
|
||||
|
||||
this->InitForBuildIndex();
|
||||
this->InitForBuildIndex(false);
|
||||
|
||||
int64_t offset = 0;
|
||||
for (const auto& wkb : geometries) {
|
||||
@ -549,7 +552,7 @@ void
|
||||
RTreeIndex<T>::AddGeometry(const std::string& wkb_data, int64_t row_offset) {
|
||||
if (!wrapper_) {
|
||||
// Initialize if not already done
|
||||
this->InitForBuildIndex();
|
||||
this->InitForBuildIndex(true);
|
||||
}
|
||||
|
||||
if (!wkb_data.empty()) {
|
||||
|
||||
@ -43,7 +43,7 @@ class RTreeIndex : public ScalarIndex<T> {
|
||||
~RTreeIndex();
|
||||
|
||||
void
|
||||
InitForBuildIndex();
|
||||
InitForBuildIndex(bool is_growing);
|
||||
|
||||
void
|
||||
Load(milvus::tracer::TraceContext ctx, const Config& config = {}) override;
|
||||
|
||||
@ -435,9 +435,9 @@ ScalarFieldIndexing<T>::recreate_index(DataType data_type,
|
||||
sync_with_index_ = false;
|
||||
index_cur_ = 0;
|
||||
LOG_INFO(
|
||||
"Created R-Tree index for geometry data type: {} with "
|
||||
"Created R-Tree index for geometry fieldID: {} with "
|
||||
"FileManagerContext",
|
||||
data_type);
|
||||
field_meta_.get_id().get());
|
||||
return;
|
||||
}
|
||||
index_ = index::CreateStringIndexSort();
|
||||
@ -554,7 +554,7 @@ ScalarFieldIndexing<T>::process_geometry_data(int64_t reserved_offset,
|
||||
if (!built_) {
|
||||
try {
|
||||
// Initialize R-Tree for building immediately when first data arrives
|
||||
rtree_index->InitForBuildIndex();
|
||||
rtree_index->InitForBuildIndex(true);
|
||||
built_ = true;
|
||||
sync_with_index_ = true;
|
||||
LOG_INFO(
|
||||
|
||||
@ -17485,7 +17485,7 @@ TEST_P(ExprTest, TestSTDWithinFunction) {
|
||||
});
|
||||
}
|
||||
|
||||
TEST_P(ExprTest, ParseGISFunctionFilterExprs) {
|
||||
TEST(ExprTest, ParseGISFunctionFilterExprs) {
|
||||
// Build Schema
|
||||
auto schema = std::make_shared<Schema>();
|
||||
auto dim = 16;
|
||||
@ -17524,7 +17524,7 @@ TEST_P(ExprTest, ParseGISFunctionFilterExprs) {
|
||||
>)PLAN";
|
||||
|
||||
// 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 =
|
||||
CreateSearchPlanByExpr(*schema, bin_plan.data(), bin_plan.size());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user