提交 1d4b2173 编写于 作者: G groot

refine code


Former-commit-id: ace10b37f519bc9b5639030581d813e81d0d4637
上级 a1621905
......@@ -18,7 +18,7 @@ GrpcRequestHandler::CreateTable(::grpc::ServerContext *context,
const ::milvus::grpc::TableSchema *request,
::milvus::grpc::Status *response) {
BaseTaskPtr task_ptr = CreateTableTask::Create(*request);
BaseTaskPtr task_ptr = CreateTableTask::Create(request);
GrpcRequestScheduler::ExecTask(task_ptr, response);
return ::grpc::Status::OK;
}
......@@ -52,7 +52,7 @@ GrpcRequestHandler::CreateIndex(::grpc::ServerContext *context,
const ::milvus::grpc::IndexParam *request,
::milvus::grpc::Status *response) {
BaseTaskPtr task_ptr = CreateIndexTask::Create(*request);
BaseTaskPtr task_ptr = CreateIndexTask::Create(request);
GrpcRequestScheduler::ExecTask(task_ptr, response);
return ::grpc::Status::OK;
}
......@@ -62,7 +62,7 @@ GrpcRequestHandler::Insert(::grpc::ServerContext *context,
const ::milvus::grpc::InsertParam *request,
::milvus::grpc::VectorIds *response) {
BaseTaskPtr task_ptr = InsertTask::Create(*request, *response);
BaseTaskPtr task_ptr = InsertTask::Create(request, response);
::milvus::grpc::Status grpc_status;
GrpcRequestScheduler::ExecTask(task_ptr, &grpc_status);
response->mutable_status()->set_reason(grpc_status.reason());
......@@ -76,7 +76,7 @@ GrpcRequestHandler::Search(::grpc::ServerContext *context,
::grpc::ServerWriter<::milvus::grpc::TopKQueryResult> *writer) {
std::vector<std::string> file_id_array;
BaseTaskPtr task_ptr = SearchTask::Create(*request, file_id_array, *writer);
BaseTaskPtr task_ptr = SearchTask::Create(request, file_id_array, writer);
::milvus::grpc::Status grpc_status;
GrpcRequestScheduler::ExecTask(task_ptr, &grpc_status);
if (grpc_status.error_code() != SERVER_SUCCESS) {
......@@ -93,7 +93,11 @@ GrpcRequestHandler::SearchInFiles(::grpc::ServerContext *context,
::grpc::ServerWriter<::milvus::grpc::TopKQueryResult> *writer) {
std::vector<std::string> file_id_array;
BaseTaskPtr task_ptr = SearchTask::Create(request->search_param(), file_id_array, *writer);
for(int i = 0; i < request->file_id_array_size(); i++) {
file_id_array.push_back(request->file_id_array(i));
}
::milvus::grpc::SearchInFilesParam *request_mutable = const_cast<::milvus::grpc::SearchInFilesParam *>(request);
BaseTaskPtr task_ptr = SearchTask::Create(request_mutable->mutable_search_param(), file_id_array, writer);
::milvus::grpc::Status grpc_status;
GrpcRequestScheduler::ExecTask(task_ptr, &grpc_status);
if (grpc_status.error_code() != SERVER_SUCCESS) {
......@@ -109,7 +113,7 @@ GrpcRequestHandler::DescribeTable(::grpc::ServerContext *context,
const ::milvus::grpc::TableName *request,
::milvus::grpc::TableSchema *response) {
BaseTaskPtr task_ptr = DescribeTableTask::Create(request->table_name(), *response);
BaseTaskPtr task_ptr = DescribeTableTask::Create(request->table_name(), response);
::milvus::grpc::Status grpc_status;
GrpcRequestScheduler::ExecTask(task_ptr, &grpc_status);
response->mutable_table_name()->mutable_status()->set_error_code(grpc_status.error_code());
......@@ -137,7 +141,7 @@ GrpcRequestHandler::ShowTables(::grpc::ServerContext *context,
const ::milvus::grpc::Command *request,
::grpc::ServerWriter<::milvus::grpc::TableName> *writer) {
BaseTaskPtr task_ptr = ShowTablesTask::Create(*writer);
BaseTaskPtr task_ptr = ShowTablesTask::Create(writer);
::milvus::grpc::Status grpc_status;
GrpcRequestScheduler::ExecTask(task_ptr, &grpc_status);
if (grpc_status.error_code() != SERVER_SUCCESS) {
......@@ -167,7 +171,7 @@ GrpcRequestHandler::Cmd(::grpc::ServerContext *context,
GrpcRequestHandler::DeleteByRange(::grpc::ServerContext *context,
const ::milvus::grpc::DeleteByRangeParam *request,
::milvus::grpc::Status *response) {
BaseTaskPtr task_ptr = DeleteByRangeTask::Create(*request);
BaseTaskPtr task_ptr = DeleteByRangeTask::Create(request);
::milvus::grpc::Status grpc_status;
GrpcRequestScheduler::ExecTask(task_ptr, &grpc_status);
response->set_error_code(grpc_status.error_code());
......@@ -191,7 +195,7 @@ GrpcRequestHandler::PreloadTable(::grpc::ServerContext *context,
GrpcRequestHandler::DescribeIndex(::grpc::ServerContext *context,
const ::milvus::grpc::TableName *request,
::milvus::grpc::IndexParam *response) {
BaseTaskPtr task_ptr = DescribeIndexTask::Create(request->table_name(), *response);
BaseTaskPtr task_ptr = DescribeIndexTask::Create(request->table_name(), response);
::milvus::grpc::Status grpc_status;
GrpcRequestScheduler::ExecTask(task_ptr, &grpc_status);
response->mutable_table_name()->mutable_status()->set_reason(grpc_status.reason());
......
......@@ -23,17 +23,17 @@ namespace grpc {
class CreateTableTask : public GrpcBaseTask {
public:
static BaseTaskPtr
Create(const ::milvus::grpc::TableSchema &schema);
Create(const ::milvus::grpc::TableSchema *schema);
protected:
explicit
CreateTableTask(const ::milvus::grpc::TableSchema &request);
CreateTableTask(const ::milvus::grpc::TableSchema *request);
ServerError
OnExecute() override;
private:
const ::milvus::grpc::TableSchema schema_;
const ::milvus::grpc::TableSchema *schema_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -58,10 +58,10 @@ private:
class DescribeTableTask : public GrpcBaseTask {
public:
static BaseTaskPtr
Create(const std::string &table_name, ::milvus::grpc::TableSchema &schema);
Create(const std::string &table_name, ::milvus::grpc::TableSchema *schema);
protected:
DescribeTableTask(const std::string &table_name, ::milvus::grpc::TableSchema &schema);
DescribeTableTask(const std::string &table_name, ::milvus::grpc::TableSchema *schema);
ServerError
OnExecute() override;
......@@ -69,7 +69,7 @@ protected:
private:
std::string table_name_;
::milvus::grpc::TableSchema &schema_;
::milvus::grpc::TableSchema *schema_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -94,76 +94,76 @@ private:
class CreateIndexTask : public GrpcBaseTask {
public:
static BaseTaskPtr
Create(const ::milvus::grpc::IndexParam &index_Param);
Create(const ::milvus::grpc::IndexParam *index_Param);
protected:
explicit
CreateIndexTask(const ::milvus::grpc::IndexParam &index_Param);
CreateIndexTask(const ::milvus::grpc::IndexParam *index_Param);
ServerError
OnExecute() override;
private:
::milvus::grpc::IndexParam index_param_;
const ::milvus::grpc::IndexParam *index_param_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class ShowTablesTask : public GrpcBaseTask {
public:
static BaseTaskPtr
Create(::grpc::ServerWriter<::milvus::grpc::TableName> &writer);
Create(::grpc::ServerWriter<::milvus::grpc::TableName> *writer);
protected:
explicit
ShowTablesTask(::grpc::ServerWriter<::milvus::grpc::TableName> &writer);
ShowTablesTask(::grpc::ServerWriter<::milvus::grpc::TableName> *writer);
ServerError
OnExecute() override;
private:
::grpc::ServerWriter<::milvus::grpc::TableName> writer_;
::grpc::ServerWriter<::milvus::grpc::TableName> *writer_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class InsertTask : public GrpcBaseTask {
public:
static BaseTaskPtr
Create(const ::milvus::grpc::InsertParam &insert_Param,
::milvus::grpc::VectorIds &record_ids_);
Create(const ::milvus::grpc::InsertParam *insert_Param,
::milvus::grpc::VectorIds *record_ids_);
protected:
InsertTask(const ::milvus::grpc::InsertParam &insert_Param,
::milvus::grpc::VectorIds &record_ids_);
InsertTask(const ::milvus::grpc::InsertParam *insert_Param,
::milvus::grpc::VectorIds *record_ids_);
ServerError
OnExecute() override;
private:
const ::milvus::grpc::InsertParam insert_param_;
::milvus::grpc::VectorIds &record_ids_;
const ::milvus::grpc::InsertParam *insert_param_;
::milvus::grpc::VectorIds *record_ids_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class SearchTask : public GrpcBaseTask {
public:
static BaseTaskPtr
Create(const ::milvus::grpc::SearchParam &search_param,
Create(const ::milvus::grpc::SearchParam *search_param,
const std::vector<std::string> &file_id_array,
::grpc::ServerWriter<::milvus::grpc::TopKQueryResult> &writer);
::grpc::ServerWriter<::milvus::grpc::TopKQueryResult> *writer);
protected:
SearchTask(const ::milvus::grpc::SearchParam &search_param,
SearchTask(const ::milvus::grpc::SearchParam *search_param,
const std::vector<std::string> &file_id_array,
::grpc::ServerWriter<::milvus::grpc::TopKQueryResult> &writer);
::grpc::ServerWriter<::milvus::grpc::TopKQueryResult> *writer);
ServerError
OnExecute() override;
private:
const ::milvus::grpc::SearchParam search_param_;
const ::milvus::grpc::SearchParam *search_param_;
std::vector<std::string> file_id_array_;
::grpc::ServerWriter<::milvus::grpc::TopKQueryResult> writer_;
::grpc::ServerWriter<::milvus::grpc::TopKQueryResult> *writer_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -204,16 +204,16 @@ private:
class DeleteByRangeTask : public GrpcBaseTask {
public:
static BaseTaskPtr
Create(const ::milvus::grpc::DeleteByRangeParam &delete_by_range_param);
Create(const ::milvus::grpc::DeleteByRangeParam *delete_by_range_param);
protected:
DeleteByRangeTask(const ::milvus::grpc::DeleteByRangeParam &delete_by_range_param);
DeleteByRangeTask(const ::milvus::grpc::DeleteByRangeParam *delete_by_range_param);
ServerError
OnExecute() override;
private:
::milvus::grpc::DeleteByRangeParam delete_by_range_param_;
const ::milvus::grpc::DeleteByRangeParam *delete_by_range_param_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -237,18 +237,18 @@ class DescribeIndexTask : public GrpcBaseTask {
public:
static BaseTaskPtr
Create(const std::string &table_name,
::milvus::grpc::IndexParam &index_param);
::milvus::grpc::IndexParam *index_param);
protected:
DescribeIndexTask(const std::string &table_name,
::milvus::grpc::IndexParam &index_param);
::milvus::grpc::IndexParam *index_param);
ServerError
OnExecute() override;
private:
std::string table_name_;
::milvus::grpc::IndexParam& index_param_;
::milvus::grpc::IndexParam *index_param_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册