Merge branch 'branch-0.4.0' into 'branch-0.4.0'

clean code

See merge request megasearch/milvus!342

Former-commit-id: f68abd3aeb74d796fc4d6ac000b7e61921fce2d8
This commit is contained in:
peng.xu 2019-08-13 18:51:35 +08:00
commit 331535c89f
9 changed files with 82 additions and 86 deletions

View File

@ -11,7 +11,7 @@ PROFILING="OFF"
BUILD_FAISS_WITH_MKL="OFF"
USE_JFROG_CACHE="OFF"
KNOWHERE_OPTS=""
MILVUS_WITH_THRIFT="OFF"
MILVUS_WITH_THRIFT="ON"
while getopts "p:d:t:uhlrcgmj" arg
do

View File

@ -80,9 +80,12 @@ include_directories(grpc/gen-status)
include_directories(grpc/gen-milvus)
if (MILVUS_WITH_THRIFT STREQUAL "ON")
message("Build thrift server")
add_definitions("-DMILVUS_ENABLE_THRIFT")
set(client_thrift_lib
thrift)
else()
message("Build grpc server")
set(client_grpc_lib
grpcpp_channelz
grpc++
@ -200,7 +203,7 @@ set(knowhere_libs
)
if (MILVUS_WITH_THRIFT STREQUAL "ON")
add_executable(milvus_thrift_server
add_executable(milvus_server
${config_files}
${server_files}
${thriftserver_files}
@ -219,33 +222,15 @@ else()
)
endif()
if (ENABLE_LICENSE STREQUAL "ON")
add_executable(get_sys_info ${get_sys_info_files})
add_executable(license_generator ${license_generator_files})
target_link_libraries(get_sys_info ${license_libs} license_check ${third_party_libs})
target_link_libraries(license_generator ${license_libs} ${third_party_libs})
if(MILVUS_WITH_THRIFT STREQUAL "ON")
target_link_libraries(milvus_thrift_server ${server_libs} license_check ${knowhere_libs} ${third_party_libs})
else()
target_link_libraries(milvus_server ${server_libs} license_check ${knowhere_libs} ${third_party_libs})
endif()
else ()
if(MILVUS_WITH_THRIFT STREQUAL "ON")
target_link_libraries(milvus_thrift_server ${server_libs} ${knowhere_libs} ${third_party_libs})
else()
target_link_libraries(milvus_server ${server_libs} ${knowhere_libs} ${third_party_libs})
endif()
endif()
if (MILVUS_WITH_THRIFT STREQUAL "ON")
install(TARGETS milvus_thrift_server DESTINATION bin)
if(MILVUS_WITH_THRIFT STREQUAL "ON")
target_link_libraries(milvus_server ${server_libs} ${knowhere_libs} ${third_party_libs})
else()
install(TARGETS milvus_server DESTINATION bin)
target_link_libraries(milvus_server ${server_libs} ${knowhere_libs} ${third_party_libs})
endif()
install(TARGETS milvus_server DESTINATION bin)
install(FILES
${KNOWHERE_BUILD_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}tbb${CMAKE_SHARED_LIBRARY_SUFFIX}
${KNOWHERE_BUILD_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}tbb${CMAKE_SHARED_LIBRARY_SUFFIX}.2

View File

@ -23,17 +23,12 @@ if (MILVUS_WITH_THRIFT STREQUAL "ON")
${CMAKE_SOURCE_DIR}/src/thrift/gen-cpp/milvus_types.cpp
)
add_library(milvus_thrift_sdk STATIC
add_library(milvus_sdk STATIC
${interface_files}
${thrift_client_files}
${util_files}
${thrift_service_files}
)
target_link_libraries(milvus_thrift_sdk
${third_party_libs}
)
install(TARGETS milvus_thrift_sdk DESTINATION lib)
else()
aux_source_directory(grpc grpc_client_files)
@ -47,17 +42,18 @@ else()
${CMAKE_SOURCE_DIR}/src/grpc/gen-status/status.pb.cc
)
add_library(milvus_grpc_sdk STATIC
add_library(milvus_sdk STATIC
${interface_files}
${grpc_client_files}
${util_files}
${grpc_service_files}
)
target_link_libraries(milvus_grpc_sdk
${third_party_libs}
)
install(TARGETS milvus_grpc_sdk DESTINATION lib)
endif()
target_link_libraries(milvus_sdk
${third_party_libs}
)
install(TARGETS milvus_sdk DESTINATION lib)
add_subdirectory(examples)

View File

@ -11,14 +11,14 @@ include_directories(../../include)
link_directories(${CMAKE_BINARY_DIR})
add_executable(grpc_sdk_simple
add_executable(sdk_simple
main.cpp
${src_files}
)
target_link_libraries(grpc_sdk_simple
milvus_grpc_sdk
target_link_libraries(sdk_simple
milvus_sdk
pthread
)
install(TARGETS grpc_sdk_simple DESTINATION bin)
install(TARGETS sdk_simple DESTINATION bin)

View File

@ -11,14 +11,14 @@ include_directories(../../include)
link_directories(${CMAKE_BINARY_DIR})
add_executable(thrift_sdk_simple
add_executable(sdk_simple
./main.cpp
${src_files}
)
target_link_libraries(thrift_sdk_simple
milvus_thrift_sdk
target_link_libraries(sdk_simple
milvus_sdk
pthread
)
install(TARGETS thrift_sdk_simple DESTINATION bin)
install(TARGETS sdk_simple DESTINATION bin)

View File

@ -22,7 +22,7 @@ namespace {
constexpr int64_t NQ = 10;
constexpr int64_t TOP_K = 10;
constexpr int64_t SEARCH_TARGET = 5000; //change this value, result is different
constexpr int64_t ADD_VECTOR_LOOP = 10;
constexpr int64_t ADD_VECTOR_LOOP = 5;
constexpr int64_t SECONDS_EACH_HOUR = 3600;
#define BLOCK_SPLITER std::cout << "===========================================" << std::endl;
@ -173,7 +173,7 @@ namespace {
std::vector<TopKQueryResult> topk_query_result_array;
{
TimeRecorder rc(phase_name);
Status stat = conn->SearchVector(TABLE_NAME, record_array, query_range_array, TOP_K, topk_query_result_array);
Status stat = conn->Search(TABLE_NAME, record_array, query_range_array, TOP_K, topk_query_result_array);
std::cout << "SearchVector function call status: " << stat.ToString() << std::endl;
}
@ -209,7 +209,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
std::cout << "All tables: " << std::endl;
for(auto& table : tables) {
int64_t row_count = 0;
stat = conn->GetTableRowCount(table, row_count);
stat = conn->CountTable(table, row_count);
std::cout << "\t" << table << "(" << row_count << " rows)" << std::endl;
}
}
@ -241,7 +241,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
int64_t begin_index = i * BATCH_ROW_COUNT;
BuildVectors(begin_index, begin_index + BATCH_ROW_COUNT, record_array);
std::vector<int64_t> record_ids;
Status stat = conn->AddVector(TABLE_NAME, record_array, record_ids);
Status stat = conn->Insert(TABLE_NAME, record_array, record_ids);
std::cout << "AddVector function call status: " << stat.ToString() << std::endl;
std::cout << "Returned id array count: " << record_ids.size() << std::endl;
@ -261,7 +261,9 @@ ClientTest::Test(const std::string& address, const std::string& port) {
{//wait unit build index finish
TimeRecorder recorder("Build index");
std::cout << "Wait until build all index done" << std::endl;
Status stat = conn->BuildIndex(TABLE_NAME);
IndexParam index_param;
index_param.table_name = TABLE_NAME;
Status stat = conn->CreateIndex(index_param);
std::cout << "BuildIndex function call status: " << stat.ToString() << std::endl;
}
@ -270,7 +272,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
}
{//delete table
Status stat = conn->DeleteTable(TABLE_NAME);
Status stat = conn->DropTable(TABLE_NAME);
std::cout << "DeleteTable function call status: " << stat.ToString() << std::endl;
}

View File

@ -112,7 +112,7 @@ ClientProxy::HasTable(const std::string &table_name) {
}
Status
ClientProxy::DeleteTable(const std::string &table_name) {
ClientProxy::DropTable(const std::string &table_name) {
if(!IsConnected()) {
return Status(StatusCode::NotConnected, "not connected to server");
}
@ -128,18 +128,13 @@ ClientProxy::DeleteTable(const std::string &table_name) {
}
Status
ClientProxy::DropTable(const std::string &table_name) {
return this->DeleteTable(table_name);
}
Status
ClientProxy::BuildIndex(const std::string &table_name) {
ClientProxy::CreateIndex(const IndexParam &index_param) {
if(!IsConnected()) {
return Status(StatusCode::NotConnected, "not connected to server");
}
try {
ClientPtr()->interface()->BuildIndex(table_name);
ClientPtr()->interface()->BuildIndex(index_param.table_name);
} catch ( std::exception& ex) {
return Status(StatusCode::UnknownError, "failed to build index: " + std::string(ex.what()));
@ -149,7 +144,7 @@ ClientProxy::BuildIndex(const std::string &table_name) {
}
Status
ClientProxy::AddVector(const std::string &table_name,
ClientProxy::Insert(const std::string &table_name,
const std::vector<RowRecord> &record_array,
std::vector<int64_t> &id_array) {
if(!IsConnected()) {
@ -179,14 +174,7 @@ ClientProxy::AddVector(const std::string &table_name,
}
Status
ClientProxy::InsertVector(const std::string &table_name,
const std::vector<RowRecord> &record_array,
std::vector<int64_t> &id_array) {
return this->AddVector(table_name, record_array, id_array);
}
Status
ClientProxy::SearchVector(const std::string &table_name,
ClientProxy::Search(const std::string &table_name,
const std::vector<RowRecord> &query_record_array,
const std::vector<Range> &query_range_array,
int64_t topk,
@ -277,7 +265,7 @@ ClientProxy::DescribeTable(const std::string &table_name, TableSchema &table_sch
}
Status
ClientProxy::GetTableRowCount(const std::string &table_name, int64_t &row_count) {
ClientProxy::CountTable(const std::string &table_name, int64_t &row_count) {
if(!IsConnected()) {
return Status(StatusCode::NotConnected, "not connected to server");
}
@ -337,5 +325,23 @@ ClientProxy::ServerStatus() const {
return "connection lost";
}
}
Status ClientProxy::DeleteByRange(Range &range, const std::string &table_name) {
return Status::OK();
}
Status ClientProxy::PreloadTable(const std::string &table_name) const {
return Status::OK();
}
IndexParam ClientProxy::DescribeIndex(const std::string &table_name) const {
IndexParam index_param;
index_param.table_name = table_name;
return index_param;
}
Status ClientProxy::DropIndex(const std::string &table_name) const {
return Status::OK();
}
}

View File

@ -25,21 +25,15 @@ public:
virtual bool HasTable(const std::string &table_name) override;
virtual Status DeleteTable(const std::string &table_name) override;
virtual Status DropTable(const std::string &table_name) override;
virtual Status BuildIndex(const std::string &table_name) override;
virtual Status CreateIndex(const IndexParam &index_param) override;
virtual Status AddVector(const std::string &table_name,
virtual Status Insert(const std::string &table_name,
const std::vector<RowRecord> &record_array,
std::vector<int64_t> &id_array) override;
virtual Status InsertVector(const std::string &table_name,
const std::vector<RowRecord> &record_array,
std::vector<int64_t> &id_array) override;
virtual Status SearchVector(const std::string &table_name,
virtual Status Search(const std::string &table_name,
const std::vector<RowRecord> &query_record_array,
const std::vector<Range> &query_range_array,
int64_t topk,
@ -47,7 +41,7 @@ public:
virtual Status DescribeTable(const std::string &table_name, TableSchema &table_schema) override;
virtual Status GetTableRowCount(const std::string &table_name, int64_t &row_count) override;
virtual Status CountTable(const std::string &table_name, int64_t &row_count) override;
virtual Status ShowTables(std::vector<std::string> &table_array) override;
@ -57,6 +51,14 @@ public:
virtual std::string ServerStatus() const override;
virtual Status DeleteByRange(Range &range, const std::string &table_name) override;
virtual Status PreloadTable(const std::string &table_name) const override;
virtual IndexParam DescribeIndex(const std::string &table_name) const override;
virtual Status DropIndex(const std::string &table_name) const override;
private:
std::shared_ptr<ThriftClient>& ClientPtr() const;

View File

@ -6,11 +6,11 @@
#include <thread>
#include "Server.h"
//#include "ServerConfig.h"
//#ifdef MILVUS_ENABLE_THRIFT
#ifdef MILVUS_ENABLE_THRIFT
#include "server/thrift_impl/MilvusServer.h"
//#else
#else
#include "server/grpc_impl/GrpcMilvusServer.h"
//#endif
#endif
#include "utils/Log.h"
#include "utils/SignalUtil.h"
@ -225,15 +225,20 @@ Server::LoadConfig() {
void
Server::StartService() {
// std::thread thrift_thread = std::thread(&MilvusServer::StartService);
#ifdef MILVUS_ENABLE_THRIFT
MilvusServer::StartService();
#else
grpc::GrpcMilvusServer::StartService();
// thrift_thread.join();
#endif
}
void
Server::StopService() {
// MilvusServer::StartService();
#ifdef MILVUS_ENABLE_THRIFT
MilvusServer::StopService();
#else
grpc::GrpcMilvusServer::StopService();
#endif
}
}