mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 21:09:06 +08:00
update
Former-commit-id: 1575fe6ead3c09caf0d5d3fa764ceb461431ab5e
This commit is contained in:
parent
f57ffefa36
commit
143a172ae8
@ -289,84 +289,84 @@ TEST_F(NewMemManagerTest, INSERT_TEST) {
|
||||
|
||||
}
|
||||
|
||||
//TEST_F(NewMemManagerTest, CONCURRENT_INSERT_SEARCH_TEST) {
|
||||
//
|
||||
// auto options = engine::OptionsFactory::Build();
|
||||
// options.meta.path = "/tmp/milvus_test";
|
||||
// options.meta.backend_uri = "sqlite://:@:/";
|
||||
// auto db_ = engine::DBFactory::Build(options);
|
||||
//
|
||||
// engine::meta::TableSchema table_info = BuildTableSchema();
|
||||
// engine::Status stat = db_->CreateTable(table_info);
|
||||
//
|
||||
// engine::meta::TableSchema table_info_get;
|
||||
// table_info_get.table_id_ = TABLE_NAME;
|
||||
// stat = db_->DescribeTable(table_info_get);
|
||||
// ASSERT_STATS(stat);
|
||||
// ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
//
|
||||
// engine::IDNumbers vector_ids;
|
||||
// engine::IDNumbers target_ids;
|
||||
//
|
||||
// int64_t nb = 409600;
|
||||
// std::vector<float> xb;
|
||||
// BuildVectors(nb, xb);
|
||||
//
|
||||
// int64_t qb = 5;
|
||||
// std::vector<float> qxb;
|
||||
// BuildVectors(qb, qxb);
|
||||
//
|
||||
// std::thread search([&]() {
|
||||
// engine::QueryResults results;
|
||||
// int k = 10;
|
||||
// std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
//
|
||||
// INIT_TIMER;
|
||||
// std::stringstream ss;
|
||||
// uint64_t count = 0;
|
||||
// uint64_t prev_count = 0;
|
||||
//
|
||||
// for (auto j = 0; j < 10; ++j) {
|
||||
// ss.str("");
|
||||
// db_->Size(count);
|
||||
// prev_count = count;
|
||||
//
|
||||
// START_TIMER;
|
||||
// stat = db_->Query(TABLE_NAME, k, qb, qxb.data(), results);
|
||||
// ss << "Search " << j << " With Size " << count / engine::meta::M << " M";
|
||||
// STOP_TIMER(ss.str());
|
||||
//
|
||||
// ASSERT_STATS(stat);
|
||||
// for (auto k = 0; k < qb; ++k) {
|
||||
// ASSERT_EQ(results[k][0].first, target_ids[k]);
|
||||
// ss.str("");
|
||||
// ss << "Result [" << k << "]:";
|
||||
// for (auto result : results[k]) {
|
||||
// ss << result.first << " ";
|
||||
// }
|
||||
// /* LOG(DEBUG) << ss.str(); */
|
||||
// }
|
||||
// ASSERT_TRUE(count >= prev_count);
|
||||
// std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// int loop = 20;
|
||||
//
|
||||
// for (auto i = 0; i < loop; ++i) {
|
||||
// if (i == 0) {
|
||||
// db_->InsertVectors(TABLE_NAME, qb, qxb.data(), target_ids);
|
||||
// ASSERT_EQ(target_ids.size(), qb);
|
||||
// } else {
|
||||
// db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
|
||||
// }
|
||||
// std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||
// }
|
||||
//
|
||||
// search.join();
|
||||
//
|
||||
// delete db_;
|
||||
// boost::filesystem::remove_all(options.meta.path);
|
||||
//
|
||||
//};
|
||||
TEST_F(NewMemManagerTest, CONCURRENT_INSERT_SEARCH_TEST) {
|
||||
|
||||
auto options = engine::OptionsFactory::Build();
|
||||
options.meta.path = "/tmp/milvus_test";
|
||||
options.meta.backend_uri = "sqlite://:@:/";
|
||||
auto db_ = engine::DBFactory::Build(options);
|
||||
|
||||
engine::meta::TableSchema table_info = BuildTableSchema();
|
||||
engine::Status stat = db_->CreateTable(table_info);
|
||||
|
||||
engine::meta::TableSchema table_info_get;
|
||||
table_info_get.table_id_ = TABLE_NAME;
|
||||
stat = db_->DescribeTable(table_info_get);
|
||||
ASSERT_STATS(stat);
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
|
||||
engine::IDNumbers vector_ids;
|
||||
engine::IDNumbers target_ids;
|
||||
|
||||
int64_t nb = 409600;
|
||||
std::vector<float> xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
int64_t qb = 5;
|
||||
std::vector<float> qxb;
|
||||
BuildVectors(qb, qxb);
|
||||
|
||||
std::thread search([&]() {
|
||||
engine::QueryResults results;
|
||||
int k = 10;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
|
||||
INIT_TIMER;
|
||||
std::stringstream ss;
|
||||
uint64_t count = 0;
|
||||
uint64_t prev_count = 0;
|
||||
|
||||
for (auto j = 0; j < 10; ++j) {
|
||||
ss.str("");
|
||||
db_->Size(count);
|
||||
prev_count = count;
|
||||
|
||||
START_TIMER;
|
||||
stat = db_->Query(TABLE_NAME, k, qb, qxb.data(), results);
|
||||
ss << "Search " << j << " With Size " << count / engine::meta::M << " M";
|
||||
STOP_TIMER(ss.str());
|
||||
|
||||
ASSERT_STATS(stat);
|
||||
for (auto k = 0; k < qb; ++k) {
|
||||
ASSERT_EQ(results[k][0].first, target_ids[k]);
|
||||
ss.str("");
|
||||
ss << "Result [" << k << "]:";
|
||||
for (auto result : results[k]) {
|
||||
ss << result.first << " ";
|
||||
}
|
||||
/* LOG(DEBUG) << ss.str(); */
|
||||
}
|
||||
ASSERT_TRUE(count >= prev_count);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
});
|
||||
|
||||
int loop = 20;
|
||||
|
||||
for (auto i = 0; i < loop; ++i) {
|
||||
if (i == 0) {
|
||||
db_->InsertVectors(TABLE_NAME, qb, qxb.data(), target_ids);
|
||||
ASSERT_EQ(target_ids.size(), qb);
|
||||
} else {
|
||||
db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||
}
|
||||
|
||||
search.join();
|
||||
|
||||
delete db_;
|
||||
boost::filesystem::remove_all(options.meta.path);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user