diff --git a/AnyBuildLogs/latest.txt b/AnyBuildLogs/latest.txt index 7d2f2ab9a..3e11e6ab6 100644 --- a/AnyBuildLogs/latest.txt +++ b/AnyBuildLogs/latest.txt @@ -1 +1 @@ -20260110-171520-4f890e5e \ No newline at end of file +20260116-140907-2cca51ce \ No newline at end of file diff --git a/src/index.cpp b/src/index.cpp index 5f1db52b9..e2fc0cacd 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -611,27 +611,27 @@ void Index::load(const IndexLoadParams & load_params) size_t tags_file_num_pts = 0, graph_num_pts = 0, data_file_num_pts = 0, label_num_pts = 0; - // Use file paths from load_params if provided, otherwise derive from index_file_path - std::string labels_file = load_params.labels_file_path.empty() - ? filename + "_labels.txt" : load_params.labels_file_path; - std::string labels_to_medoids = load_params.labels_to_medoids_file_path.empty() - ? filename + "_labels_to_medoids.txt" : load_params.labels_to_medoids_file_path; - std::string labels_map_file = load_params.labels_map_file_path.empty() - ? filename + "_labels_map.txt" : load_params.labels_map_file_path; + // Use file paths from load_params if provided and file exists, otherwise derive from index_file_path + std::string labels_file = (!load_params.labels_file_path.empty() && file_exists(load_params.labels_file_path)) + ? load_params.labels_file_path : filename + "_labels.txt"; + std::string labels_to_medoids = (!load_params.labels_to_medoids_file_path.empty() && file_exists(load_params.labels_to_medoids_file_path)) + ? load_params.labels_to_medoids_file_path : filename + "_labels_to_medoids.txt"; + std::string labels_map_file = (!load_params.labels_map_file_path.empty() && file_exists(load_params.labels_map_file_path)) + ? load_params.labels_map_file_path : filename + "_labels_map.txt"; if (!_save_as_one_file) { // For DLVS Store, we will not support saving the index in multiple // files. #ifndef EXEC_ENV_OLS - std::string data_file = load_params.data_file_path.empty() - ? filename + ".data" : load_params.data_file_path; - std::string tags_file = load_params.tags_file_path.empty() - ? filename + ".tags" : load_params.tags_file_path; - std::string delete_set_file = load_params.delete_set_file_path.empty() - ? filename + ".del" : load_params.delete_set_file_path; - std::string graph_file = load_params.graph_file_path.empty() - ? filename : load_params.graph_file_path; + std::string data_file = (!load_params.data_file_path.empty() && file_exists(load_params.data_file_path)) + ? load_params.data_file_path : filename + ".data"; + std::string tags_file = (!load_params.tags_file_path.empty() && file_exists(load_params.tags_file_path)) + ? load_params.tags_file_path : filename + ".tags"; + std::string delete_set_file = (!load_params.delete_set_file_path.empty() && file_exists(load_params.delete_set_file_path)) + ? load_params.delete_set_file_path : filename + ".del"; + std::string graph_file = (!load_params.graph_file_path.empty() && file_exists(load_params.graph_file_path)) + ? load_params.graph_file_path : filename; data_file_num_pts = load_data(data_file); this->_table_stats.node_count = data_file_num_pts; this->_table_stats.node_mem_usage = this->_data_store->get_data_size(); @@ -666,8 +666,8 @@ void Index::load(const IndexLoadParams & load_params) throw diskann::ANNException(stream.str(), -1, __FUNCSIG__, __FILE__, __LINE__); } - std::string index_seller_file = load_params.seller_file_path.empty() - ? filename + "_sellers.bin" : load_params.seller_file_path; + std::string index_seller_file = (!load_params.seller_file_path.empty() && file_exists(load_params.seller_file_path)) + ? load_params.seller_file_path : filename + "_sellers.bin"; std::string old_index_seller_file = filename + "_sellers.txt"; if (file_exists(index_seller_file)) { @@ -699,10 +699,10 @@ void Index::load(const IndexLoadParams & load_params) _diverse_index = true; } - std::string bitmask_label_file = load_params.bitmask_label_file_path.empty() - ? filename + "_bitmask_labels.bin" : load_params.bitmask_label_file_path; - std::string integer_label_file = load_params.integer_label_file_path.empty() - ? filename + "_integer_labels.bin" : load_params.integer_label_file_path; + std::string bitmask_label_file = (!load_params.bitmask_label_file_path.empty() && file_exists(load_params.bitmask_label_file_path)) + ? load_params.bitmask_label_file_path : filename + "_bitmask_labels.bin"; + std::string integer_label_file = (!load_params.integer_label_file_path.empty() && file_exists(load_params.integer_label_file_path)) + ? load_params.integer_label_file_path : filename + "_integer_labels.bin"; if (file_exists(labels_file) || file_exists(bitmask_label_file) || file_exists(integer_label_file)) @@ -764,8 +764,8 @@ void Index::load(const IndexLoadParams & load_params) _label_to_start_id.clear(); label_helper().load_label_medoids(labels_to_medoids, _label_to_start_id); - std::string universal_label_file = load_params.universal_label_file_path.empty() - ? filename + "_universal_label.txt" : load_params.universal_label_file_path; + std::string universal_label_file = (!load_params.universal_label_file_path.empty() && file_exists(load_params.universal_label_file_path)) + ? load_params.universal_label_file_path : filename + "_universal_label.txt"; if (file_exists(universal_label_file)) { std::ifstream universal_label_reader(universal_label_file);