mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-29 06:55:27 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
c08ef96db0
@ -43,8 +43,11 @@ Please mark all change in change log and use the issue from GitHub
|
||||
- \#1530 Set table file with correct engine type in meta
|
||||
- \#1532 Search with ivf_flat failed with open-dataset: sift-256-hamming
|
||||
- \#1535 Degradation searching performance with metric_type: binary_idmap
|
||||
- \#1549 Fix server/wal config setting bug
|
||||
- \#1556 Index file not created after table and index created
|
||||
- \#1560 Search crashed with Super-high dimensional binary vector
|
||||
- \#1574 Set all existing bitset in cache when applying deletes
|
||||
- \#1577 Row count incorrect if delete vectors then create index
|
||||
|
||||
## Feature
|
||||
- \#216 Add CLI to get server info
|
||||
|
||||
@ -236,11 +236,27 @@ MemTable::ApplyDeletes() {
|
||||
utils::GetParentPath(table_file.location_, segment_dir);
|
||||
segment::SegmentReader segment_reader(segment_dir);
|
||||
|
||||
auto index =
|
||||
std::static_pointer_cast<VecIndex>(cache::CpuCacheMgr::GetInstance()->GetIndex(table_file.location_));
|
||||
faiss::ConcurrentBitsetPtr blacklist = nullptr;
|
||||
if (index != nullptr) {
|
||||
status = index->GetBlacklist(blacklist);
|
||||
auto& segment_id = table_file.segment_id_;
|
||||
meta::TableFilesSchema segment_files;
|
||||
status = meta_->GetTableFilesBySegmentId(segment_id, segment_files);
|
||||
if (!status.ok()) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Get all index that contains blacklist in cache
|
||||
std::vector<VecIndexPtr> indexes;
|
||||
std::vector<faiss::ConcurrentBitsetPtr> blacklists;
|
||||
for (auto& file : segment_files) {
|
||||
auto index =
|
||||
std::static_pointer_cast<VecIndex>(cache::CpuCacheMgr::GetInstance()->GetIndex(file.location_));
|
||||
faiss::ConcurrentBitsetPtr blacklist = nullptr;
|
||||
if (index != nullptr) {
|
||||
index->GetBlacklist(blacklist);
|
||||
if (blacklist != nullptr) {
|
||||
indexes.emplace_back(index);
|
||||
blacklists.emplace_back(blacklist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<segment::doc_id_t> uids;
|
||||
@ -293,7 +309,7 @@ MemTable::ApplyDeletes() {
|
||||
id_bloom_filter_ptr->Remove(uids[i]);
|
||||
}
|
||||
|
||||
if (blacklist != nullptr) {
|
||||
for (auto& blacklist : blacklists) {
|
||||
if (!blacklist->test(i)) {
|
||||
blacklist->set(i);
|
||||
}
|
||||
@ -308,8 +324,8 @@ MemTable::ApplyDeletes() {
|
||||
<< find_diff.count() << " s in total";
|
||||
ENGINE_LOG_DEBUG << "Setting deleted docs and bloom filter took " << set_diff.count() << " s in total";
|
||||
|
||||
if (index != nullptr) {
|
||||
index->SetBlacklist(blacklist);
|
||||
for (auto i = 0; i < indexes.size(); ++i) {
|
||||
indexes[i]->SetBlacklist(blacklists[i]);
|
||||
}
|
||||
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
@ -339,12 +355,6 @@ MemTable::ApplyDeletes() {
|
||||
<< " s";
|
||||
|
||||
// Update table file row count
|
||||
auto& segment_id = table_file.segment_id_;
|
||||
meta::TableFilesSchema segment_files;
|
||||
status = meta_->GetTableFilesBySegmentId(segment_id, segment_files);
|
||||
if (!status.ok()) {
|
||||
break;
|
||||
}
|
||||
for (auto& file : segment_files) {
|
||||
if (file.file_type_ == meta::TableFileSchema::RAW || file.file_type_ == meta::TableFileSchema::TO_INDEX ||
|
||||
file.file_type_ == meta::TableFileSchema::INDEX || file.file_type_ == meta::TableFileSchema::BACKUP) {
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include "scheduler/task/BuildIndexTask.h"
|
||||
|
||||
#include <fiu-local.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
@ -206,7 +207,7 @@ XBuildIndexTask::Execute() {
|
||||
// step 6: update meta
|
||||
table_file.file_type_ = engine::meta::TableFileSchema::INDEX;
|
||||
table_file.file_size_ = index->PhysicalSize();
|
||||
table_file.row_count_ = index->Count();
|
||||
table_file.row_count_ = file_->row_count_; // index->Count();
|
||||
|
||||
auto origin_file = *file_;
|
||||
origin_file.file_type_ = engine::meta::TableFileSchema::BACKUP;
|
||||
|
||||
@ -1529,8 +1529,7 @@ Status
|
||||
Config::GetStorageConfigS3Enable(bool& value) {
|
||||
std::string str = GetConfigStr(CONFIG_STORAGE, CONFIG_STORAGE_S3_ENABLE, CONFIG_STORAGE_S3_ENABLE_DEFAULT);
|
||||
CONFIG_CHECK(CheckStorageConfigS3Enable(str));
|
||||
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||
value = (str == "true" || str == "on" || str == "yes" || str == "1");
|
||||
CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, value));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -1569,8 +1568,7 @@ Status
|
||||
Config::GetMetricConfigEnableMonitor(bool& value) {
|
||||
std::string str = GetConfigStr(CONFIG_METRIC, CONFIG_METRIC_ENABLE_MONITOR, CONFIG_METRIC_ENABLE_MONITOR_DEFAULT);
|
||||
CONFIG_CHECK(CheckMetricConfigEnableMonitor(str));
|
||||
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||
value = (str == "true" || str == "on" || str == "yes" || str == "1");
|
||||
CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, value));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -1671,8 +1669,7 @@ Status
|
||||
Config::GetGpuResourceConfigEnable(bool& value) {
|
||||
std::string str = GetConfigStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_ENABLE, CONFIG_GPU_RESOURCE_ENABLE_DEFAULT);
|
||||
CONFIG_CHECK(CheckGpuResourceConfigEnable(str));
|
||||
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||
value = (str == "true" || str == "on" || str == "yes" || str == "1");
|
||||
CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, value));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -1774,8 +1771,7 @@ Status
|
||||
Config::GetWalConfigEnable(bool& wal_enable) {
|
||||
std::string str = GetConfigStr(CONFIG_WAL, CONFIG_WAL_ENABLE, CONFIG_WAL_ENABLE_DEFAULT);
|
||||
CONFIG_CHECK(CheckWalConfigEnable(str));
|
||||
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||
wal_enable = (str == "true" || str == "on" || str == "yes" || str == "1");
|
||||
CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, wal_enable));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -1784,8 +1780,7 @@ Config::GetWalConfigRecoveryErrorIgnore(bool& recovery_error_ignore) {
|
||||
std::string str =
|
||||
GetConfigStr(CONFIG_WAL, CONFIG_WAL_RECOVERY_ERROR_IGNORE, CONFIG_WAL_RECOVERY_ERROR_IGNORE_DEFAULT);
|
||||
CONFIG_CHECK(CheckWalConfigRecoveryErrorIgnore(str));
|
||||
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
||||
recovery_error_ignore = (str == "true" || str == "on" || str == "yes" || str == "1");
|
||||
CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, recovery_error_ignore));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -2013,7 +2008,7 @@ Config::SetWalConfigEnable(const std::string& value) {
|
||||
Status
|
||||
Config::SetWalConfigRecoveryErrorIgnore(const std::string& value) {
|
||||
CONFIG_CHECK(CheckWalConfigRecoveryErrorIgnore(value));
|
||||
return SetConfigValueInMem(CONFIG_WAL, CONFIG_WAL_RECOVERY_ERROR_IGNORE_DEFAULT, value);
|
||||
return SetConfigValueInMem(CONFIG_WAL, CONFIG_WAL_RECOVERY_ERROR_IGNORE, value);
|
||||
}
|
||||
|
||||
Status
|
||||
|
||||
@ -336,7 +336,7 @@ class WebController : public oatpp::web::server::api::ApiController {
|
||||
|
||||
ADD_CORS(CreateIndex)
|
||||
|
||||
ENDPOINT("POST", "/tables/{collection_name}/indexes", CreateIndex,
|
||||
ENDPOINT("POST", "/collections/{collection_name}/indexes", CreateIndex,
|
||||
PATH(String, collection_name), BODY_STRING(String, body)) {
|
||||
TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/tables/" + collection_name->std_str() + "/indexes\'");
|
||||
tr.RecordSection("Received request.");
|
||||
@ -674,15 +674,15 @@ class WebController : public oatpp::web::server::api::ApiController {
|
||||
|
||||
ADD_CORS(SystemOp)
|
||||
|
||||
ENDPOINT("PUT", "/system/{Op}", SystemOp, PATH(String, Op), BODY_STRING(String, body_str)) {
|
||||
TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "PUT \'/system/" + Op->std_str() + "\'");
|
||||
ENDPOINT("PUT", "/system/{op}", SystemOp, PATH(String, op), BODY_STRING(String, body_str)) {
|
||||
TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "PUT \'/system/" + op->std_str() + "\'");
|
||||
tr.RecordSection("Received request.");
|
||||
|
||||
WebRequestHandler handler = WebRequestHandler();
|
||||
handler.RegisterRequestHandler(::milvus::server::RequestHandler());
|
||||
|
||||
String response_str;
|
||||
auto status_dto = handler.SystemOp(Op, body_str, response_str);
|
||||
auto status_dto = handler.SystemOp(op, body_str, response_str);
|
||||
|
||||
std::shared_ptr<OutgoingResponse> response;
|
||||
switch (status_dto->code->getValue()) {
|
||||
|
||||
@ -1046,7 +1046,9 @@ WebRequestHandler::CreateIndex(const OString& table_name, const OString& body) {
|
||||
auto status = request_handler_.CreateIndex(context_ptr_, table_name->std_str(), index, request_json["params"]);
|
||||
ASSIGN_RETURN_STATUS_DTO(status);
|
||||
} catch (nlohmann::detail::parse_error& e) {
|
||||
RETURN_STATUS_DTO(BODY_PARSE_FAIL, e.what())
|
||||
} catch (nlohmann::detail::type_error& e) {
|
||||
RETURN_STATUS_DTO(BODY_PARSE_FAIL, e.what())
|
||||
}
|
||||
|
||||
ASSIGN_RETURN_STATUS_DTO(Status::OK())
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <faiss/utils/ConcurrentBitset.h>
|
||||
#include <thirdparty/nlohmann/json.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thirdparty/nlohmann/json.hpp>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -180,13 +180,14 @@ class VecIndex : public cache::DataObj {
|
||||
|
||||
virtual Status
|
||||
SetBlacklist(faiss::ConcurrentBitsetPtr list) {
|
||||
ENGINE_LOG_ERROR << "SetBlacklist not support";
|
||||
// ENGINE_LOG_ERROR << "SetBlacklist not support";
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
virtual Status
|
||||
GetBlacklist(faiss::ConcurrentBitsetPtr& list) {
|
||||
ENGINE_LOG_ERROR << "GetBlacklist not support";
|
||||
// ENGINE_LOG_ERROR << "GetBlacklist not support";
|
||||
ENGINE_LOG_WARNING << "Deletion on unsupported index type";
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ TEST_F(DeleteTest, delete_in_mem) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -81,7 +81,7 @@ TEST_F(DeleteTest, delete_in_mem) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -105,7 +105,7 @@ TEST_F(DeleteTest, delete_in_mem) {
|
||||
ids_to_delete.emplace_back(kv.first);
|
||||
}
|
||||
|
||||
stat = db_->DeleteVectors(GetTableName(), ids_to_delete);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, ids_to_delete);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
// std::this_thread::sleep_for(std::chrono::seconds(3)); // ensure raw data write to disk
|
||||
@ -113,7 +113,7 @@ TEST_F(DeleteTest, delete_in_mem) {
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb - search_vectors.size());
|
||||
|
||||
@ -124,7 +124,8 @@ TEST_F(DeleteTest, delete_in_mem) {
|
||||
std::vector<std::string> tags;
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
stat = db_->Query(dummy_context_, GetTableName(), tags, topk, nprobe, search, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, {{"nprobe", nprobe}}, search, result_ids,
|
||||
result_distances);
|
||||
ASSERT_NE(result_ids[0], pair.first);
|
||||
// ASSERT_LT(result_distances[0], 1e-4);
|
||||
ASSERT_GT(result_distances[0], 1);
|
||||
@ -136,7 +137,7 @@ TEST_F(DeleteTest, delete_on_disk) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -149,7 +150,7 @@ TEST_F(DeleteTest, delete_on_disk) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -173,7 +174,7 @@ TEST_F(DeleteTest, delete_on_disk) {
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
for (auto& kv : search_vectors) {
|
||||
stat = db_->DeleteVector(GetTableName(), kv.first);
|
||||
stat = db_->DeleteVector(table_info.table_id_, kv.first);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
}
|
||||
|
||||
@ -181,7 +182,7 @@ TEST_F(DeleteTest, delete_on_disk) {
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb - search_vectors.size());
|
||||
|
||||
@ -192,7 +193,8 @@ TEST_F(DeleteTest, delete_on_disk) {
|
||||
std::vector<std::string> tags;
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
stat = db_->Query(dummy_context_, GetTableName(), tags, topk, nprobe, search, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, {{"nprobe", nprobe}}, search, result_ids,
|
||||
result_distances);
|
||||
ASSERT_NE(result_ids[0], pair.first);
|
||||
// ASSERT_LT(result_distances[0], 1e-4);
|
||||
ASSERT_GT(result_distances[0], 1);
|
||||
@ -204,7 +206,7 @@ TEST_F(DeleteTest, delete_multiple_times) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -217,7 +219,7 @@ TEST_F(DeleteTest, delete_multiple_times) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -243,7 +245,7 @@ TEST_F(DeleteTest, delete_multiple_times) {
|
||||
int topk = 10, nprobe = 10;
|
||||
for (auto& pair : search_vectors) {
|
||||
std::vector<int64_t> to_delete{pair.first};
|
||||
stat = db_->DeleteVectors(GetTableName(), to_delete);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, to_delete);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat = db_->Flush();
|
||||
@ -254,20 +256,21 @@ TEST_F(DeleteTest, delete_multiple_times) {
|
||||
std::vector<std::string> tags;
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
stat = db_->Query(dummy_context_, GetTableName(), tags, topk, nprobe, search, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, {{"nprobe", nprobe}}, search, result_ids,
|
||||
result_distances);
|
||||
ASSERT_NE(result_ids[0], pair.first);
|
||||
// ASSERT_LT(result_distances[0], 1e-4);
|
||||
ASSERT_GT(result_distances[0], 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DeleteTest, delete_with_index) {
|
||||
TEST_F(DeleteTest, delete_before_create_index) {
|
||||
milvus::engine::meta::TableSchema table_info = BuildTableSchema();
|
||||
table_info.engine_type_ = (int32_t)milvus::engine::EngineType::FAISS_IVFFLAT;
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -280,7 +283,83 @@ TEST_F(DeleteTest, delete_with_index) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<int64_t> dis(0, nb - 1);
|
||||
|
||||
int64_t num_query = 10;
|
||||
std::map<int64_t, milvus::engine::VectorsData> search_vectors;
|
||||
for (int64_t i = 0; i < num_query; ++i) {
|
||||
int64_t index = dis(gen);
|
||||
milvus::engine::VectorsData search;
|
||||
search.vector_count_ = 1;
|
||||
for (int64_t j = 0; j < TABLE_DIM; j++) {
|
||||
search.float_data_.push_back(xb.float_data_[index * TABLE_DIM + j]);
|
||||
}
|
||||
search_vectors.insert(std::make_pair(xb.id_array_[index], search));
|
||||
}
|
||||
|
||||
milvus::engine::IDNumbers ids_to_delete;
|
||||
for (auto& kv : search_vectors) {
|
||||
ids_to_delete.emplace_back(kv.first);
|
||||
}
|
||||
stat = db_->DeleteVectors(table_info.table_id_, ids_to_delete);
|
||||
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
milvus::engine::TableIndex index;
|
||||
index.engine_type_ = (int)milvus::engine::EngineType::FAISS_IVFSQ8;
|
||||
index.extra_params_ = {{"nlist", 100}};
|
||||
stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb - ids_to_delete.size());
|
||||
|
||||
int topk = 10, nprobe = 10;
|
||||
for (auto& pair : search_vectors) {
|
||||
auto& search = pair.second;
|
||||
|
||||
std::vector<std::string> tags;
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, {{"nprobe", nprobe}}, search, result_ids,
|
||||
result_distances);
|
||||
ASSERT_NE(result_ids[0], pair.first);
|
||||
// ASSERT_LT(result_distances[0], 1e-4);
|
||||
ASSERT_GT(result_distances[0], 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DeleteTest, delete_with_index) {
|
||||
milvus::engine::meta::TableSchema table_info = BuildTableSchema();
|
||||
table_info.engine_type_ = (int32_t)milvus::engine::EngineType::FAISS_IVFFLAT;
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
|
||||
int64_t nb = 10000;
|
||||
milvus::engine::VectorsData xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
for (int64_t i = 0; i < nb; i++) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -302,7 +381,7 @@ TEST_F(DeleteTest, delete_with_index) {
|
||||
milvus::engine::TableIndex index;
|
||||
index.engine_type_ = (int)milvus::engine::EngineType::FAISS_IVFSQ8;
|
||||
index.extra_params_ = {{"nlist", 100}};
|
||||
stat = db_->CreateIndex(GetTableName(), index);
|
||||
stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
// std::this_thread::sleep_for(std::chrono::seconds(3)); // ensure raw data write to disk
|
||||
@ -313,13 +392,13 @@ TEST_F(DeleteTest, delete_with_index) {
|
||||
for (auto& kv : search_vectors) {
|
||||
ids_to_delete.emplace_back(kv.first);
|
||||
}
|
||||
stat = db_->DeleteVectors(GetTableName(), ids_to_delete);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, ids_to_delete);
|
||||
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb - ids_to_delete.size());
|
||||
|
||||
@ -330,7 +409,86 @@ TEST_F(DeleteTest, delete_with_index) {
|
||||
std::vector<std::string> tags;
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
stat = db_->Query(dummy_context_, GetTableName(), tags, topk, nprobe, search, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, {{"nprobe", nprobe}}, search, result_ids,
|
||||
result_distances);
|
||||
ASSERT_NE(result_ids[0], pair.first);
|
||||
// ASSERT_LT(result_distances[0], 1e-4);
|
||||
ASSERT_GT(result_distances[0], 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DeleteTest, delete_multiple_times_with_index) {
|
||||
milvus::engine::meta::TableSchema table_info = BuildTableSchema();
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
|
||||
int64_t nb = 100000;
|
||||
milvus::engine::VectorsData xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
for (int64_t i = 0; i < nb; i++) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<int64_t> dis(0, nb - 1);
|
||||
|
||||
int64_t num_query = 10;
|
||||
std::map<int64_t, milvus::engine::VectorsData> search_vectors;
|
||||
for (int64_t i = 0; i < num_query; ++i) {
|
||||
int64_t index = dis(gen);
|
||||
milvus::engine::VectorsData search;
|
||||
search.vector_count_ = 1;
|
||||
for (int64_t j = 0; j < TABLE_DIM; j++) {
|
||||
search.float_data_.push_back(xb.float_data_[index * TABLE_DIM + j]);
|
||||
}
|
||||
search_vectors.insert(std::make_pair(xb.id_array_[index], search));
|
||||
}
|
||||
|
||||
// std::this_thread::sleep_for(std::chrono::seconds(3)); // ensure raw data write to disk
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
milvus::engine::TableIndex index;
|
||||
index.engine_type_ = (int)milvus::engine::EngineType::FAISS_IVFFLAT;
|
||||
index.extra_params_ = {{"nlist", 1}};
|
||||
stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
int topk = 10, nprobe = 10;
|
||||
int deleted = 0;
|
||||
for (auto& pair : search_vectors) {
|
||||
std::vector<int64_t> to_delete{pair.first};
|
||||
stat = db_->DeleteVectors(table_info.table_id_, to_delete);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
++deleted;
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb - deleted);
|
||||
|
||||
auto& search = pair.second;
|
||||
|
||||
std::vector<std::string> tags;
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, {{"nprobe", nprobe}}, search, result_ids,
|
||||
result_distances);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_NE(result_ids[0], pair.first);
|
||||
// ASSERT_LT(result_distances[0], 1e-4);
|
||||
ASSERT_GT(result_distances[0], 1);
|
||||
@ -342,7 +500,7 @@ TEST_F(DeleteTest, delete_single_vector) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -351,21 +509,21 @@ TEST_F(DeleteTest, delete_single_vector) {
|
||||
milvus::engine::VectorsData xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
// std::this_thread::sleep_for(std::chrono::seconds(3)); // ensure raw data write to disk
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat = db_->DeleteVectors(GetTableName(), xb.id_array_);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, xb.id_array_);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, 0);
|
||||
|
||||
@ -375,7 +533,7 @@ TEST_F(DeleteTest, delete_single_vector) {
|
||||
std::vector<std::string> tags;
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
stat = db_->Query(dummy_context_, GetTableName(), tags, topk, json_params, xb, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, json_params, xb, result_ids, result_distances);
|
||||
ASSERT_TRUE(result_ids.empty());
|
||||
ASSERT_TRUE(result_distances.empty());
|
||||
// ASSERT_EQ(result_ids[0], -1);
|
||||
@ -388,7 +546,7 @@ TEST_F(DeleteTest, delete_add_create_index) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -397,7 +555,7 @@ TEST_F(DeleteTest, delete_add_create_index) {
|
||||
milvus::engine::VectorsData xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
// stat = db_->Flush();
|
||||
@ -405,27 +563,27 @@ TEST_F(DeleteTest, delete_add_create_index) {
|
||||
milvus::engine::TableIndex index;
|
||||
index.engine_type_ = (int)milvus::engine::EngineType::FAISS_IVFSQ8;
|
||||
index.extra_params_ = {{"nlist", 100}};
|
||||
stat = db_->CreateIndex(GetTableName(), index);
|
||||
stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::vector<milvus::engine::IDNumber> ids_to_delete;
|
||||
ids_to_delete.emplace_back(xb.id_array_.front());
|
||||
stat = db_->DeleteVectors(GetTableName(), ids_to_delete);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, ids_to_delete);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
milvus::engine::VectorsData xb2 = xb;
|
||||
xb2.id_array_.clear(); // same vector, different id
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb2);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb2);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
// stat = db_->Flush();
|
||||
// ASSERT_TRUE(stat.ok());
|
||||
stat = db_->CreateIndex(GetTableName(), index);
|
||||
stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb * 2 - 1);
|
||||
|
||||
@ -439,15 +597,15 @@ TEST_F(DeleteTest, delete_add_create_index) {
|
||||
qb.float_data_.resize(TABLE_DIM);
|
||||
qb.vector_count_ = 1;
|
||||
qb.id_array_.clear();
|
||||
stat = db_->Query(dummy_context_, GetTableName(), tags, topk, json_params, qb, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, json_params, qb, result_ids, result_distances);
|
||||
|
||||
ASSERT_EQ(result_ids[0], xb2.id_array_.front());
|
||||
ASSERT_LT(result_distances[0], 1e-4);
|
||||
|
||||
result_ids.clear();
|
||||
result_distances.clear();
|
||||
stat = db_->QueryByID(dummy_context_, GetTableName(), tags, topk, json_params, ids_to_delete.front(), result_ids,
|
||||
result_distances);
|
||||
stat = db_->QueryByID(dummy_context_, table_info.table_id_, tags, topk, json_params, ids_to_delete.front(),
|
||||
result_ids, result_distances);
|
||||
ASSERT_EQ(result_ids[0], -1);
|
||||
ASSERT_EQ(result_distances[0], std::numeric_limits<float>::max());
|
||||
}
|
||||
@ -457,7 +615,7 @@ TEST_F(DeleteTest, delete_add_auto_flush) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -466,7 +624,7 @@ TEST_F(DeleteTest, delete_add_auto_flush) {
|
||||
milvus::engine::VectorsData xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
@ -475,28 +633,28 @@ TEST_F(DeleteTest, delete_add_auto_flush) {
|
||||
// ASSERT_TRUE(stat.ok());
|
||||
// milvus::engine::TableIndex index;
|
||||
// index.engine_type_ = (int)milvus::engine::EngineType::FAISS_IVFSQ8;
|
||||
// stat = db_->CreateIndex(GetTableName(), index);
|
||||
// stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
// ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::vector<milvus::engine::IDNumber> ids_to_delete;
|
||||
ids_to_delete.emplace_back(xb.id_array_.front());
|
||||
stat = db_->DeleteVectors(GetTableName(), ids_to_delete);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, ids_to_delete);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
milvus::engine::VectorsData xb2 = xb;
|
||||
xb2.id_array_.clear(); // same vector, different id
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb2);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb2);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
// stat = db_->Flush();
|
||||
// ASSERT_TRUE(stat.ok());
|
||||
// stat = db_->CreateIndex(GetTableName(), index);
|
||||
// stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
// ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb * 2 - 1);
|
||||
|
||||
@ -510,15 +668,15 @@ TEST_F(DeleteTest, delete_add_auto_flush) {
|
||||
qb.float_data_.resize(TABLE_DIM);
|
||||
qb.vector_count_ = 1;
|
||||
qb.id_array_.clear();
|
||||
stat = db_->Query(dummy_context_, GetTableName(), tags, topk, json_params, qb, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, json_params, qb, result_ids, result_distances);
|
||||
|
||||
ASSERT_EQ(result_ids[0], xb2.id_array_.front());
|
||||
ASSERT_LT(result_distances[0], 1e-4);
|
||||
|
||||
result_ids.clear();
|
||||
result_distances.clear();
|
||||
stat = db_->QueryByID(dummy_context_, GetTableName(), tags, topk, nprobe, ids_to_delete.front(), result_ids,
|
||||
result_distances);
|
||||
stat = db_->QueryByID(dummy_context_, table_info.table_id_, tags, topk, {{"nprobe", nprobe}}, ids_to_delete.front(),
|
||||
result_ids, result_distances);
|
||||
ASSERT_EQ(result_ids[0], -1);
|
||||
ASSERT_EQ(result_distances[0], std::numeric_limits<float>::max());
|
||||
}
|
||||
@ -528,7 +686,7 @@ TEST_F(CompactTest, compact_basic) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -537,7 +695,7 @@ TEST_F(CompactTest, compact_basic) {
|
||||
milvus::engine::VectorsData xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat = db_->Flush();
|
||||
@ -546,18 +704,18 @@ TEST_F(CompactTest, compact_basic) {
|
||||
std::vector<milvus::engine::IDNumber> ids_to_delete;
|
||||
ids_to_delete.emplace_back(xb.id_array_.front());
|
||||
ids_to_delete.emplace_back(xb.id_array_.back());
|
||||
stat = db_->DeleteVectors(GetTableName(), ids_to_delete);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, ids_to_delete);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb - 2);
|
||||
|
||||
stat = db_->Compact(GetTableName());
|
||||
stat = db_->Compact(table_info.table_id_);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
const int topk = 1, nprobe = 1;
|
||||
@ -569,8 +727,8 @@ TEST_F(CompactTest, compact_basic) {
|
||||
milvus::engine::VectorsData qb = xb;
|
||||
|
||||
for (auto& id : ids_to_delete) {
|
||||
stat =
|
||||
db_->QueryByID(dummy_context_, GetTableName(), tags, topk, json_params, id, result_ids, result_distances);
|
||||
stat = db_->QueryByID(dummy_context_, table_info.table_id_, tags, topk, json_params, id, result_ids,
|
||||
result_distances);
|
||||
ASSERT_EQ(result_ids[0], -1);
|
||||
ASSERT_EQ(result_distances[0], std::numeric_limits<float>::max());
|
||||
}
|
||||
@ -583,7 +741,7 @@ TEST_F(CompactTest, compact_with_index) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -597,7 +755,7 @@ TEST_F(CompactTest, compact_with_index) {
|
||||
xb.id_array_.emplace_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -618,7 +776,7 @@ TEST_F(CompactTest, compact_with_index) {
|
||||
|
||||
milvus::engine::TableIndex index;
|
||||
index.engine_type_ = (int)milvus::engine::EngineType::FAISS_IVFSQ8;
|
||||
stat = db_->CreateIndex(GetTableName(), index);
|
||||
stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat = db_->Flush();
|
||||
@ -628,25 +786,25 @@ TEST_F(CompactTest, compact_with_index) {
|
||||
for (auto& kv : search_vectors) {
|
||||
ids_to_delete.emplace_back(kv.first);
|
||||
}
|
||||
stat = db_->DeleteVectors(GetTableName(), ids_to_delete);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, ids_to_delete);
|
||||
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb - ids_to_delete.size());
|
||||
|
||||
stat = db_->Compact(GetTableName());
|
||||
stat = db_->Compact(table_info.table_id_);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb - ids_to_delete.size());
|
||||
|
||||
milvus::engine::TableIndex table_index;
|
||||
stat = db_->DescribeIndex(GetTableName(), table_index);
|
||||
stat = db_->DescribeIndex(table_info.table_id_, table_index);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_FLOAT_EQ(table_index.engine_type_, index.engine_type_);
|
||||
|
||||
@ -659,8 +817,8 @@ TEST_F(CompactTest, compact_with_index) {
|
||||
std::vector<std::string> tags;
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
stat =
|
||||
db_->Query(dummy_context_, GetTableName(), tags, topk, json_params, search, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, json_params, search, result_ids,
|
||||
result_distances);
|
||||
ASSERT_NE(result_ids[0], pair.first);
|
||||
// ASSERT_LT(result_distances[0], 1e-4);
|
||||
ASSERT_GT(result_distances[0], 1);
|
||||
|
||||
@ -68,7 +68,7 @@ TEST_F(SearchByIdTest, basic) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -81,7 +81,7 @@ TEST_F(SearchByIdTest, basic) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -108,7 +108,8 @@ TEST_F(SearchByIdTest, basic) {
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
|
||||
stat = db_->QueryByID(dummy_context_, GetTableName(), tags, topk, json_params, i, result_ids, result_distances);
|
||||
stat = db_->QueryByID(dummy_context_, table_info.table_id_, tags, topk, json_params, i, result_ids,
|
||||
result_distances);
|
||||
ASSERT_EQ(result_ids[0], i);
|
||||
ASSERT_LT(result_distances[0], 1e-4);
|
||||
}
|
||||
@ -119,7 +120,7 @@ TEST_F(SearchByIdTest, with_index) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -132,7 +133,7 @@ TEST_F(SearchByIdTest, with_index) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -153,7 +154,7 @@ TEST_F(SearchByIdTest, with_index) {
|
||||
milvus::engine::TableIndex index;
|
||||
index.engine_type_ = (int)milvus::engine::EngineType::FAISS_IVFSQ8;
|
||||
index.extra_params_ = {{"nlist", 10}};
|
||||
stat = db_->CreateIndex(GetTableName(), index);
|
||||
stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
const int topk = 10, nprobe = 10;
|
||||
@ -165,7 +166,8 @@ TEST_F(SearchByIdTest, with_index) {
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
|
||||
stat = db_->QueryByID(dummy_context_, GetTableName(), tags, topk, json_params, i, result_ids, result_distances);
|
||||
stat = db_->QueryByID(dummy_context_, table_info.table_id_, tags, topk, json_params, i, result_ids,
|
||||
result_distances);
|
||||
ASSERT_EQ(result_ids[0], i);
|
||||
ASSERT_LT(result_distances[0], 1e-3);
|
||||
}
|
||||
@ -176,7 +178,7 @@ TEST_F(SearchByIdTest, with_delete) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -189,7 +191,7 @@ TEST_F(SearchByIdTest, with_delete) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -211,7 +213,7 @@ TEST_F(SearchByIdTest, with_delete) {
|
||||
for (auto& id : ids_to_search) {
|
||||
ids_to_delete.emplace_back(id);
|
||||
}
|
||||
stat = db_->DeleteVectors(GetTableName(), ids_to_delete);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, ids_to_delete);
|
||||
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
@ -225,7 +227,8 @@ TEST_F(SearchByIdTest, with_delete) {
|
||||
milvus::engine::ResultIds result_ids;
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
|
||||
stat = db_->QueryByID(dummy_context_, GetTableName(), tags, topk, json_params, i, result_ids, result_distances);
|
||||
stat = db_->QueryByID(dummy_context_, table_info.table_id_, tags, topk, json_params, i, result_ids,
|
||||
result_distances);
|
||||
ASSERT_EQ(result_ids[0], -1);
|
||||
ASSERT_EQ(result_distances[0], std::numeric_limits<float>::max());
|
||||
}
|
||||
@ -236,7 +239,7 @@ TEST_F(GetVectorByIdTest, basic) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -249,7 +252,7 @@ TEST_F(GetVectorByIdTest, basic) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -277,11 +280,11 @@ TEST_F(GetVectorByIdTest, basic) {
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
|
||||
milvus::engine::VectorsData vector;
|
||||
stat = db_->GetVectorByID(GetTableName(), id, vector);
|
||||
stat = db_->GetVectorByID(table_info.table_id_, id, vector);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat =
|
||||
db_->Query(dummy_context_, GetTableName(), tags, topk, json_params, vector, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, json_params, vector, result_ids,
|
||||
result_distances);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(result_ids[0], id);
|
||||
ASSERT_LT(result_distances[0], 1e-4);
|
||||
@ -293,7 +296,7 @@ TEST_F(GetVectorByIdTest, with_index) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -306,7 +309,7 @@ TEST_F(GetVectorByIdTest, with_index) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -327,7 +330,7 @@ TEST_F(GetVectorByIdTest, with_index) {
|
||||
milvus::engine::TableIndex index;
|
||||
index.extra_params_ = {{"nlist", 10}};
|
||||
index.engine_type_ = (int)milvus::engine::EngineType::FAISS_IVFSQ8;
|
||||
stat = db_->CreateIndex(GetTableName(), index);
|
||||
stat = db_->CreateIndex(table_info.table_id_, index);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
const int topk = 10, nprobe = 10;
|
||||
@ -340,11 +343,11 @@ TEST_F(GetVectorByIdTest, with_index) {
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
|
||||
milvus::engine::VectorsData vector;
|
||||
stat = db_->GetVectorByID(GetTableName(), id, vector);
|
||||
stat = db_->GetVectorByID(table_info.table_id_, id, vector);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
stat =
|
||||
db_->Query(dummy_context_, GetTableName(), tags, topk, json_params, vector, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, json_params, vector, result_ids,
|
||||
result_distances);
|
||||
ASSERT_EQ(result_ids[0], id);
|
||||
ASSERT_LT(result_distances[0], 1e-3);
|
||||
}
|
||||
@ -355,7 +358,7 @@ TEST_F(GetVectorByIdTest, with_delete) {
|
||||
auto stat = db_->CreateTable(table_info);
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -368,7 +371,7 @@ TEST_F(GetVectorByIdTest, with_delete) {
|
||||
xb.id_array_.push_back(i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", xb);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", xb);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
std::random_device rd;
|
||||
@ -390,7 +393,7 @@ TEST_F(GetVectorByIdTest, with_delete) {
|
||||
for (auto& id : ids_to_search) {
|
||||
ids_to_delete.emplace_back(id);
|
||||
}
|
||||
stat = db_->DeleteVectors(GetTableName(), ids_to_delete);
|
||||
stat = db_->DeleteVectors(table_info.table_id_, ids_to_delete);
|
||||
|
||||
stat = db_->Flush();
|
||||
ASSERT_TRUE(stat.ok());
|
||||
@ -402,7 +405,7 @@ TEST_F(GetVectorByIdTest, with_delete) {
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
|
||||
milvus::engine::VectorsData vector;
|
||||
stat = db_->GetVectorByID(GetTableName(), id, vector);
|
||||
stat = db_->GetVectorByID(table_info.table_id_, id, vector);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_TRUE(vector.float_data_.empty());
|
||||
ASSERT_EQ(vector.vector_count_, 0);
|
||||
@ -419,7 +422,7 @@ TEST_F(SearchByIdTest, BINARY) {
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
milvus::engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = GetTableName();
|
||||
table_info_get.table_id_ = table_info.table_id_;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
@ -445,7 +448,7 @@ TEST_F(SearchByIdTest, BINARY) {
|
||||
vectors.id_array_.emplace_back(k * nb + i);
|
||||
}
|
||||
|
||||
stat = db_->InsertVectors(GetTableName(), "", vectors);
|
||||
stat = db_->InsertVectors(table_info.table_id_, "", vectors);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
}
|
||||
|
||||
@ -465,7 +468,7 @@ TEST_F(SearchByIdTest, BINARY) {
|
||||
ASSERT_TRUE(stat.ok());
|
||||
|
||||
uint64_t row_count;
|
||||
stat = db_->GetTableRowCount(GetTableName(), row_count);
|
||||
stat = db_->GetTableRowCount(table_info.table_id_, row_count);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(row_count, nb * insert_loop);
|
||||
|
||||
@ -479,12 +482,12 @@ TEST_F(SearchByIdTest, BINARY) {
|
||||
milvus::engine::ResultDistances result_distances;
|
||||
|
||||
milvus::engine::VectorsData vector;
|
||||
stat = db_->GetVectorByID(GetTableName(), id, vector);
|
||||
stat = db_->GetVectorByID(table_info.table_id_, id, vector);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(vector.vector_count_, 1);
|
||||
|
||||
stat =
|
||||
db_->Query(dummy_context_, GetTableName(), tags, topk, json_params, vector, result_ids, result_distances);
|
||||
stat = db_->Query(dummy_context_, table_info.table_id_, tags, topk, json_params, vector, result_ids,
|
||||
result_distances);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(result_ids[0], id);
|
||||
ASSERT_LT(result_distances[0], 1e-4);
|
||||
@ -493,8 +496,8 @@ TEST_F(SearchByIdTest, BINARY) {
|
||||
result_ids.clear();
|
||||
result_distances.clear();
|
||||
|
||||
stat =
|
||||
db_->QueryByID(dummy_context_, GetTableName(), tags, topk, json_params, id, result_ids, result_distances);
|
||||
stat = db_->QueryByID(dummy_context_, table_info.table_id_, tags, topk, json_params, id, result_ids,
|
||||
result_distances);
|
||||
ASSERT_TRUE(stat.ok());
|
||||
ASSERT_EQ(result_ids[0], id);
|
||||
ASSERT_LT(result_distances[0], 1e-4);
|
||||
|
||||
@ -646,7 +646,7 @@ class TestClient : public oatpp::web::client::ApiClient {
|
||||
|
||||
API_CALL("OPTIONS", "/collections/{collection_name}/indexes", optionsIndexes, PATH(String, collection_name, "collection_name"))
|
||||
|
||||
API_CALL("POST", "/tables/{table_name}/indexes", createIndex, PATH(String, table_name, "table_name"),
|
||||
API_CALL("POST", "/collections/{collection_name}/indexes", createIndex, PATH(String, collection_name, "collection_name"),
|
||||
BODY_STRING(OString, body))
|
||||
|
||||
API_CALL("GET", "/collections/{collection_name}/indexes", getIndex, PATH(String, collection_name, "collection_name"))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user