提交 1dade01e 编写于 作者: X xj.lin

Merge branch 'branch-0.4.0' into MS-351


Former-commit-id: 9f15d938e50a106ffa724f64cbd24b64193db932
[submodule "cpp/thirdparty/knowhere"]
path = cpp/thirdparty/knowhere
url = git@192.168.1.105:megasearch/knowhere.git
branch = branch-0.4.0
......@@ -3,11 +3,18 @@ container('milvus-build-env') {
gitlabCommitStatus(name: 'Build Engine') {
dir ("milvus_engine") {
try {
def knowhere_build_dir = "${env.WORKSPACE}/milvus_engine/cpp/thirdparty/knowhere/cmake_build"
checkout([$class: 'GitSCM', branches: [[name: "${SEMVER}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption',disableSubmodules: false,parentCredentials: true,recursiveSubmodules: true,reference: '',trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_USER}", url: "git@192.168.1.105:megasearch/milvus.git", name: 'origin', refspec: "+refs/heads/${SEMVER}:refs/remotes/origin/${SEMVER}"]]])
dir ("cpp/thirdparty/knowhere") {
checkout([$class: 'GitSCM', branches: [[name: "${SEMVER}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption',disableSubmodules: false,parentCredentials: true,recursiveSubmodules: true,reference: '',trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_USER}", url: "git@192.168.1.105:megasearch/knowhere.git", name: 'origin', refspec: "+refs/heads/${SEMVER}:refs/remotes/origin/${SEMVER}"]]])
sh "./build.sh -t ${params.BUILD_TYPE} -p ${knowhere_build_dir} -j"
}
dir ("cpp") {
sh "git config --global user.email \"test@zilliz.com\""
sh "git config --global user.name \"test\""
sh "./build.sh -t ${params.BUILD_TYPE} -j -u -c"
sh "./build.sh -t ${params.BUILD_TYPE} -k ${knowhere_build_dir} -j -u -c"
}
} catch (exc) {
updateGitlabCommitStatus name: 'Build Engine', state: 'failed'
......
container('milvus-build-env') {
timeout(time: 30, unit: 'MINUTES') {
timeout(time: 40, unit: 'MINUTES') {
gitlabCommitStatus(name: 'Build Engine') {
dir ("milvus_engine") {
try {
def knowhere_build_dir = "${env.WORKSPACE}/milvus_engine/cpp/thirdparty/knowhere/cmake_build"
checkout([$class: 'GitSCM', branches: [[name: "${SEMVER}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption',disableSubmodules: false,parentCredentials: true,recursiveSubmodules: true,reference: '',trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_USER}", url: "git@192.168.1.105:megasearch/milvus.git", name: 'origin', refspec: "+refs/heads/${SEMVER}:refs/remotes/origin/${SEMVER}"]]])
dir ("cpp/thirdparty/knowhere") {
checkout([$class: 'GitSCM', branches: [[name: "${SEMVER}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption',disableSubmodules: false,parentCredentials: true,recursiveSubmodules: true,reference: '',trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_USER}", url: "git@192.168.1.105:megasearch/knowhere.git", name: 'origin', refspec: "+refs/heads/${SEMVER}:refs/remotes/origin/${SEMVER}"]]])
sh "./build.sh -t ${params.BUILD_TYPE} -p ${knowhere_build_dir} -j"
}
dir ("cpp") {
sh "git config --global user.email \"test@zilliz.com\""
sh "git config --global user.name \"test\""
sh "./build.sh -t ${params.BUILD_TYPE}"
sh "./build.sh -t ${params.BUILD_TYPE} -k ${knowhere_build_dir}"
}
} catch (exc) {
updateGitlabCommitStatus name: 'Build Engine', state: 'failed'
......
......@@ -2,7 +2,6 @@ milvus/
conf/server_config.yaml
conf/log_config.conf
version.h
megasearch/
lcov_out/
base.info
output.info
......
......@@ -3,16 +3,17 @@
Please mark all change in change log and use the ticket from JIRA.
# Milvus 0.4.0 (2019-07-28)
- MS-336 - Scheduler interface
- MS-344 - Add TaskTable Test
- MS-345 - Add Node Test
- MS-346 - Add some implementation of scheduler to solve compile error
- MS-348 - Add ResourceFactory Test
## Bug
## Improvement
- MS-327 - Clean code for milvus
- MS-336 - Scheduler interface
- MS-344 - Add TaskTable Test
- MS-345 - Add Node Test
- MS-346 - Add some implementation of scheduler to solve compile error
- MS-348 - Add ResourceFactory Test
- MS-350 - Remove knowhere submodule
## New Feature
- MS-343 - Implement ResourceMgr
......
......@@ -52,7 +52,7 @@ if(MILVUS_VERSION_MAJOR STREQUAL ""
OR MILVUS_VERSION_MINOR STREQUAL ""
OR MILVUS_VERSION_PATCH STREQUAL "")
message(WARNING "Failed to determine Milvus version from git branch name")
set(MILVUS_VERSION "0.3.1")
set(MILVUS_VERSION "0.4.0")
endif()
message(STATUS "Build version = ${MILVUS_VERSION}")
......
......@@ -19,15 +19,15 @@ sudo ln -s /path/to/libmysqlclient.so /path/to/libmysqlclient_r.so
cmake_build/src/milvus_server is the server
cmake_build/src/libmilvus_engine.a is the static library
git submodule init
git submodule update
cd [sourcecode path]/cpp/thirdparty
git clone git@192.168.1.105:megasearch/knowhere.git
cd knowhere
./build.sh -t Debug
or ./build.sh -t Release
cd [sourcecode path]/cpp
./build.sh -t Debug
./build.sh -t Release
./build.sh -l -t Release # Build license version(only available for Release)
or ./build.sh -t Release
If you encounter the following error when building:
`protocol https not supported or disabled in libcurl`
......@@ -68,19 +68,5 @@ Then launch server with config:
stop_server.sh
### Launch test_client(only for debug)
If you want to test remote api, you can build test_client.
test_client use same config file with server:
cd [build output path]/test_client
test_client -c [sourcecode path]/cpp/conf/server_config.yaml
### License Generate
Use get_sys_info to get system info file.
./get_sys_info # system.info will be generated
Use license_generator to generate license file.
./license_generator -s system.info -l system.license -b 2019-05-15 -e 2019-08-14
Copy the license file to path assigned by license_path in server config file.
\ No newline at end of file
If you want to test remote api, you can run sdk example.
[build output path]/sdk/examples/grpcsimple/sdk_simple
......@@ -10,14 +10,13 @@ DB_PATH="/opt/milvus"
PROFILING="OFF"
BUILD_FAISS_WITH_MKL="OFF"
USE_JFROG_CACHE="OFF"
KNOWHERE_OPTS=""
KNOWHERE_BUILD_DIR="`pwd`/thirdparty/knowhere/cmake_build"
while getopts "p:d:t:uhlrcgmj" arg
while getopts "p:d:t:k:uhlrcgmj" arg
do
case $arg in
t)
BUILD_TYPE=$OPTARG # BUILD_TYPE
KNOWHERE_OPTS="${KNOWHERE_OPTS} -t $OPTARG"
;;
u)
echo "Build and run unittest cases" ;
......@@ -44,12 +43,14 @@ do
g)
PROFILING="ON"
;;
k)
KNOWHERE_BUILD_DIR=$OPTARG
;;
m)
BUILD_FAISS_WITH_MKL="ON"
;;
j)
USE_JFROG_CACHE="ON"
KNOWHERE_OPTS="${KNOWHERE_OPTS} -j"
;;
h) # help
echo "
......@@ -63,11 +64,12 @@ parameter:
-r: remove previous build directory(default: OFF)
-c: code coverage(default: OFF)
-g: profiling(default: OFF)
-k: specify knowhere header/binary path
-m: build faiss with MKL(default: OFF)
-j: use jfrog cache build directory
usage:
./build.sh -t \${BUILD_TYPE} [-u] [-h] [-g] [-r] [-c] [-m] [-j]
./build.sh -t \${BUILD_TYPE} [-u] [-h] [-g] [-r] [-c] [-k] [-m] [-j]
"
exit 0
;;
......@@ -83,12 +85,6 @@ if [[ ! -d cmake_build ]]; then
MAKE_CLEAN="ON"
fi
# Build Knowhere
KNOWHERE_BUILD_DIR="`pwd`/thirdparty/knowhere_build"
pushd `pwd`/thirdparty/knowhere
./build.sh -t Release -p ${KNOWHERE_BUILD_DIR} ${KNOWHERE_OPTS}
popd
cd cmake_build
CUDA_COMPILER=/usr/local/cuda/bin/nvcc
......@@ -105,7 +101,7 @@ if [[ ${MAKE_CLEAN} == "ON" ]]; then
-DBUILD_FAISS_WITH_MKL=${BUILD_FAISS_WITH_MKL} \
-DKNOWHERE_BUILD_DIR=${KNOWHERE_BUILD_DIR} \
-DUSE_JFROG_CACHE=${USE_JFROG_CACHE} \
$@ ../"
../"
echo ${CMAKE_CMD}
${CMAKE_CMD}
......
......@@ -28,6 +28,7 @@ public:
virtual Status HasTable(const std::string& table_id, bool& has_or_not_) = 0;
virtual Status AllTables(std::vector<meta::TableSchema>& table_schema_array) = 0;
virtual Status GetTableRowCount(const std::string& table_id, uint64_t& row_count) = 0;
virtual Status PreloadTable(const std::string& table_id) = 0;
virtual Status InsertVectors(const std::string& table_id_,
uint64_t n, const float* vectors, IDNumbers& vector_ids_) = 0;
......
......@@ -127,6 +127,46 @@ Status DBImpl::AllTables(std::vector<meta::TableSchema>& table_schema_array) {
return meta_ptr_->AllTables(table_schema_array);
}
Status DBImpl::PreloadTable(const std::string &table_id) {
meta::DatePartionedTableFilesSchema files;
meta::DatesT dates;
auto status = meta_ptr_->FilesToSearch(table_id, dates, files);
if (!status.ok()) {
return status;
}
int64_t size = 0;
int64_t cache_total = cache::CpuCacheMgr::GetInstance()->CacheCapacity();
int64_t cache_usage = cache::CpuCacheMgr::GetInstance()->CacheUsage();
int64_t available_size = cache_total - cache_usage;
for(auto &day_files : files) {
for (auto &file : day_files.second) {
ExecutionEnginePtr engine = EngineFactory::Build(file.dimension_, file.location_, (EngineType)file.engine_type_);
if(engine == nullptr) {
ENGINE_LOG_ERROR << "Invalid engine type";
return Status::Error("Invalid engine type");
}
size += engine->PhysicalSize();
if (size > available_size) {
break;
} else {
try {
//step 1: load index
engine->Load(true);
} catch (std::exception &ex) {
std::string msg = "load to cache exception" + std::string(ex.what());
ENGINE_LOG_ERROR << msg;
return Status::Error(msg);
}
}
}
}
return Status::OK();
}
Status DBImpl::GetTableRowCount(const std::string& table_id, uint64_t& row_count) {
return meta_ptr_->Count(table_id, row_count);
}
......
......@@ -51,6 +51,9 @@ class DBImpl : public DB {
Status
AllTables(std::vector<meta::TableSchema> &table_schema_array) override;
Status
PreloadTable(const std::string &table_id) override;
Status
GetTableRowCount(const std::string &table_id, uint64_t &row_count) override;
......
......@@ -838,6 +838,7 @@ class InsertParam :
enum : int {
kRowRecordArrayFieldNumber = 2,
kRowIdArrayFieldNumber = 3,
kTableNameFieldNumber = 1,
};
// repeated .milvus.grpc.RowRecord row_record_array = 2;
......@@ -851,6 +852,17 @@ class InsertParam :
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::milvus::grpc::RowRecord >&
row_record_array() const;
// repeated int64 row_id_array = 3;
int row_id_array_size() const;
void clear_row_id_array();
::PROTOBUF_NAMESPACE_ID::int64 row_id_array(int index) const;
void set_row_id_array(int index, ::PROTOBUF_NAMESPACE_ID::int64 value);
void add_row_id_array(::PROTOBUF_NAMESPACE_ID::int64 value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >&
row_id_array() const;
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >*
mutable_row_id_array();
// string table_name = 1;
void clear_table_name();
const std::string& table_name() const;
......@@ -868,6 +880,8 @@ class InsertParam :
::PROTOBUF_NAMESPACE_ID::internal::InternalMetadataWithArena _internal_metadata_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::milvus::grpc::RowRecord > row_record_array_;
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 > row_id_array_;
mutable std::atomic<int> _row_id_array_cached_byte_size_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr table_name_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_milvus_2eproto;
......@@ -1139,6 +1153,7 @@ class SearchParam :
kQueryRangeArrayFieldNumber = 3,
kTableNameFieldNumber = 1,
kTopkFieldNumber = 4,
kNprobeFieldNumber = 5,
};
// repeated .milvus.grpc.RowRecord query_record_array = 2;
int query_record_array_size() const;
......@@ -1178,6 +1193,11 @@ class SearchParam :
::PROTOBUF_NAMESPACE_ID::int64 topk() const;
void set_topk(::PROTOBUF_NAMESPACE_ID::int64 value);
// int64 nprobe = 5;
void clear_nprobe();
::PROTOBUF_NAMESPACE_ID::int64 nprobe() const;
void set_nprobe(::PROTOBUF_NAMESPACE_ID::int64 value);
// @@protoc_insertion_point(class_scope:milvus.grpc.SearchParam)
private:
class _Internal;
......@@ -1187,6 +1207,7 @@ class SearchParam :
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::milvus::grpc::Range > query_range_array_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr table_name_;
::PROTOBUF_NAMESPACE_ID::int64 topk_;
::PROTOBUF_NAMESPACE_ID::int64 nprobe_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_milvus_2eproto;
};
......@@ -2312,6 +2333,7 @@ class Index :
kNlistFieldNumber = 2,
kIndexTypeFieldNumber = 1,
kIndexFileSizeFieldNumber = 3,
kMetricTypeFieldNumber = 4,
};
// int64 nlist = 2;
void clear_nlist();
......@@ -2328,6 +2350,11 @@ class Index :
::PROTOBUF_NAMESPACE_ID::int32 index_file_size() const;
void set_index_file_size(::PROTOBUF_NAMESPACE_ID::int32 value);
// int32 metric_type = 4;
void clear_metric_type();
::PROTOBUF_NAMESPACE_ID::int32 metric_type() const;
void set_metric_type(::PROTOBUF_NAMESPACE_ID::int32 value);
// @@protoc_insertion_point(class_scope:milvus.grpc.Index)
private:
class _Internal;
......@@ -2336,6 +2363,7 @@ class Index :
::PROTOBUF_NAMESPACE_ID::int64 nlist_;
::PROTOBUF_NAMESPACE_ID::int32 index_type_;
::PROTOBUF_NAMESPACE_ID::int32 index_file_size_;
::PROTOBUF_NAMESPACE_ID::int32 metric_type_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_milvus_2eproto;
};
......@@ -3059,6 +3087,36 @@ InsertParam::row_record_array() const {
return row_record_array_;
}
// repeated int64 row_id_array = 3;
inline int InsertParam::row_id_array_size() const {
return row_id_array_.size();
}
inline void InsertParam::clear_row_id_array() {
row_id_array_.Clear();
}
inline ::PROTOBUF_NAMESPACE_ID::int64 InsertParam::row_id_array(int index) const {
// @@protoc_insertion_point(field_get:milvus.grpc.InsertParam.row_id_array)
return row_id_array_.Get(index);
}
inline void InsertParam::set_row_id_array(int index, ::PROTOBUF_NAMESPACE_ID::int64 value) {
row_id_array_.Set(index, value);
// @@protoc_insertion_point(field_set:milvus.grpc.InsertParam.row_id_array)
}
inline void InsertParam::add_row_id_array(::PROTOBUF_NAMESPACE_ID::int64 value) {
row_id_array_.Add(value);
// @@protoc_insertion_point(field_add:milvus.grpc.InsertParam.row_id_array)
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >&
InsertParam::row_id_array() const {
// @@protoc_insertion_point(field_list:milvus.grpc.InsertParam.row_id_array)
return row_id_array_;
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int64 >*
InsertParam::mutable_row_id_array() {
// @@protoc_insertion_point(field_mutable_list:milvus.grpc.InsertParam.row_id_array)
return &row_id_array_;
}
// -------------------------------------------------------------------
// VectorIds
......@@ -3267,6 +3325,20 @@ inline void SearchParam::set_topk(::PROTOBUF_NAMESPACE_ID::int64 value) {
// @@protoc_insertion_point(field_set:milvus.grpc.SearchParam.topk)
}
// int64 nprobe = 5;
inline void SearchParam::clear_nprobe() {
nprobe_ = PROTOBUF_LONGLONG(0);
}
inline ::PROTOBUF_NAMESPACE_ID::int64 SearchParam::nprobe() const {
// @@protoc_insertion_point(field_get:milvus.grpc.SearchParam.nprobe)
return nprobe_;
}
inline void SearchParam::set_nprobe(::PROTOBUF_NAMESPACE_ID::int64 value) {
nprobe_ = value;
// @@protoc_insertion_point(field_set:milvus.grpc.SearchParam.nprobe)
}
// -------------------------------------------------------------------
// SearchInFilesParam
......@@ -3825,6 +3897,20 @@ inline void Index::set_index_file_size(::PROTOBUF_NAMESPACE_ID::int32 value) {
// @@protoc_insertion_point(field_set:milvus.grpc.Index.index_file_size)
}
// int32 metric_type = 4;
inline void Index::clear_metric_type() {
metric_type_ = 0;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 Index::metric_type() const {
// @@protoc_insertion_point(field_get:milvus.grpc.Index.metric_type)
return metric_type_;
}
inline void Index::set_metric_type(::PROTOBUF_NAMESPACE_ID::int32 value) {
metric_type_ = value;
// @@protoc_insertion_point(field_set:milvus.grpc.Index.metric_type)
}
// -------------------------------------------------------------------
// IndexParam
......
......@@ -43,6 +43,7 @@ message RowRecord {
message InsertParam {
string table_name = 1;
repeated RowRecord row_record_array = 2;
repeated int64 row_id_array = 3; //optional
}
/**
......@@ -61,6 +62,7 @@ message SearchParam {
repeated RowRecord query_record_array = 2;
repeated Range query_range_array = 3;
int64 topk = 4;
int64 nprobe = 5;
}
/**
......@@ -125,6 +127,7 @@ message Index {
int32 index_type = 1;
int64 nlist = 2;
int32 index_file_size = 3;
int32 metric_type = 4;
}
/**
......
......@@ -328,7 +328,14 @@ ClientProxy::DeleteByRange(milvus::Range &range, const std::string &table_name)
Status
ClientProxy::PreloadTable(const std::string &table_name) const {
try {
::milvus::grpc::TableName grpc_table_name;
grpc_table_name.set_table_name(table_name);
Status status = client_ptr_->PreloadTable(grpc_table_name);
return status;
} catch (std::exception &ex) {
return Status(StatusCode::UnknownError, "fail to show tables: " + std::string(ex.what()));
}
}
IndexParam
......
......@@ -234,7 +234,7 @@ GrpcClient::Cmd(std::string &result,
result = response.string_reply();
if (!grpc_status.ok()) {
std::cerr << "Ping gRPC failed!" << std::endl;
std::cerr << "Cmd gRPC failed!" << std::endl;
return Status(StatusCode::RPCFailed, grpc_status.error_message());
}
......@@ -246,6 +246,24 @@ GrpcClient::Cmd(std::string &result,
return Status::OK();
}
Status
GrpcClient::PreloadTable(milvus::grpc::TableName &table_name) {
ClientContext context;
::milvus::grpc::Status response;
::grpc::Status grpc_status = stub_->PreloadTable(&context, table_name, &response);
if (!grpc_status.ok()) {
std::cerr << "PreloadTable gRPC failed!" << std::endl;
return Status(StatusCode::RPCFailed, grpc_status.error_message());
}
if (response.error_code() != grpc::SUCCESS) {
std::cerr << response.reason() << std::endl;
return Status(StatusCode::ServerFailed, response.reason());
}
return Status::OK();
}
Status
GrpcClient::Disconnect() {
stub_.release();
......
......@@ -175,7 +175,12 @@ GrpcRequestHandler::DeleteByRange(::grpc::ServerContext *context,
GrpcRequestHandler::PreloadTable(::grpc::ServerContext *context,
const ::milvus::grpc::TableName *request,
::milvus::grpc::Status *response) {
BaseTaskPtr task_ptr = PreloadTableTask::Create(request->table_name());
::milvus::grpc::Status grpc_status;
GrpcRequestScheduler::ExecTask(task_ptr, &grpc_status);
response->set_reason(grpc_status.reason());
response->set_error_code(grpc_status.error_code());
return ::grpc::Status::OK;
}
::grpc::Status
......
......@@ -706,6 +706,45 @@ CmdTask::OnExecute() {
return SERVER_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PreloadTableTask::PreloadTableTask(const std::string &table_name)
: GrpcBaseTask(DDL_DML_TASK_GROUP),
table_name_(table_name) {
}
BaseTaskPtr
PreloadTableTask::Create(const std::string &table_name){
return std::shared_ptr<GrpcBaseTask>(new PreloadTableTask(table_name));
}
ServerError
PreloadTableTask::OnExecute() {
try {
TimeRecorder rc("PreloadTableTask");
//step 1: check arguments
ServerError res = ValidationUtil::ValidateTableName(table_name_);
if (res != SERVER_SUCCESS) {
return SetError(res, "Invalid table name: " + table_name_);
}
//step 2: check table existence
engine::Status stat = DBWrapper::DB()->PreloadTable(table_name_);
if (!stat.ok()) {
return SetError(DB_META_TRANSACTION_FAILED, "Engine failed: " + stat.ToString());
}
rc.ElapseFromBegin("totally cost");
} catch (std::exception &ex) {
return SetError(SERVER_UNEXPECTED_ERROR, ex.what());
}
return SERVER_SUCCESS;
}
}
}
}
......
knowhere @ 98c56500
Subproject commit 98c56500b5b26a3502e2fea474586267ac6625f0
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册