From f043f8ab3a45f5826f45ed39a439e614e24c8ca4 Mon Sep 17 00:00:00 2001 From: zhiru Date: Tue, 9 Jul 2019 21:11:05 +0800 Subject: [PATCH] update Former-commit-id: 4fa81c562a43672fb80f42c3f1e46b808b622607 --- cpp/cmake/ThirdPartyPackages.cmake | 2 +- cpp/unittest/db/CMakeLists.txt | 4 +- cpp/unittest/db/mem_test.cpp | 160 ++++++++++++++--------------- 3 files changed, 84 insertions(+), 82 deletions(-) diff --git a/cpp/cmake/ThirdPartyPackages.cmake b/cpp/cmake/ThirdPartyPackages.cmake index 9aa3f621..9e19b037 100644 --- a/cpp/cmake/ThirdPartyPackages.cmake +++ b/cpp/cmake/ThirdPartyPackages.cmake @@ -525,7 +525,7 @@ if(MILVUS_BOOST_VENDORED) "" ${EP_LOG_OPTIONS}) set(Boost_INCLUDE_DIR "${BOOST_PREFIX}") - set(Boost_INCLUDE_DIRS "${BOOST_INCLUDE_DIR}") + set(Boost_INCLUDE_DIRS "${Boost_INCLUDE_DIR}") add_dependencies(boost_system_static boost_ep) add_dependencies(boost_filesystem_static boost_ep) add_dependencies(boost_serialization_static boost_ep) diff --git a/cpp/unittest/db/CMakeLists.txt b/cpp/unittest/db/CMakeLists.txt index e893ed70..46015922 100644 --- a/cpp/unittest/db/CMakeLists.txt +++ b/cpp/unittest/db/CMakeLists.txt @@ -23,6 +23,8 @@ link_directories("/usr/local/cuda/lib64") include_directories(/usr/include/mysql) +#add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY) + set(db_test_src #${unittest_srcs} ${config_files} @@ -41,8 +43,8 @@ set(db_libs cudart cublas sqlite - boost_system_static boost_filesystem_static + boost_system_static lz4 mysqlpp ) diff --git a/cpp/unittest/db/mem_test.cpp b/cpp/unittest/db/mem_test.cpp index 860a6653..f0e79d4d 100644 --- a/cpp/unittest/db/mem_test.cpp +++ b/cpp/unittest/db/mem_test.cpp @@ -288,84 +288,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 xb; - BuildVectors(nb, xb); - - int64_t qb = 5; - std::vector 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); - -}; +//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 xb; +// BuildVectors(nb, xb); +// +// int64_t qb = 5; +// std::vector 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); +// +//}; -- GitLab