提交 22e2a2bc 编写于 作者: G groot

throw exception for invalid index type


Former-commit-id: b028167c2460be4738af5f092a443749dba89bc0
上级 fe5b5115
...@@ -16,3 +16,4 @@ Please mark all change in change log and use the ticket from JIRA. ...@@ -16,3 +16,4 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-1 - Add CHANGELOG.md - MS-1 - Add CHANGELOG.md
- MS-4 - Refactor the vecwise_engine code structure - MS-4 - Refactor the vecwise_engine code structure
- MS-6 - Implement SDK interface part 1
...@@ -22,59 +22,59 @@ Connection::Destroy(std::shared_ptr<megasearch::Connection> connection_ptr) { ...@@ -22,59 +22,59 @@ Connection::Destroy(std::shared_ptr<megasearch::Connection> connection_ptr) {
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
ConnectionImpl::ConnectionImpl() { ConnectionImpl::ConnectionImpl() {
client_proxy = std::make_shared<ClientProxy>(); client_proxy_ = std::make_shared<ClientProxy>();
} }
Status Status
ConnectionImpl::Connect(const ConnectParam &param) { ConnectionImpl::Connect(const ConnectParam &param) {
return client_proxy->Connect(param); return client_proxy_->Connect(param);
} }
Status Status
ConnectionImpl::Connect(const std::string &uri) { ConnectionImpl::Connect(const std::string &uri) {
return client_proxy->Connect(uri); return client_proxy_->Connect(uri);
} }
Status Status
ConnectionImpl::Connected() const { ConnectionImpl::Connected() const {
return client_proxy->Connected(); return client_proxy_->Connected();
} }
Status Status
ConnectionImpl::Disconnect() { ConnectionImpl::Disconnect() {
return client_proxy->Disconnect(); return client_proxy_->Disconnect();
} }
std::string std::string
ConnectionImpl::ClientVersion() const { ConnectionImpl::ClientVersion() const {
return client_proxy->ClientVersion(); return client_proxy_->ClientVersion();
} }
Status Status
ConnectionImpl::CreateTable(const TableSchema &param) { ConnectionImpl::CreateTable(const TableSchema &param) {
return client_proxy->CreateTable(param); return client_proxy_->CreateTable(param);
} }
Status Status
ConnectionImpl::CreateTablePartition(const CreateTablePartitionParam &param) { ConnectionImpl::CreateTablePartition(const CreateTablePartitionParam &param) {
return client_proxy->CreateTablePartition(param); return client_proxy_->CreateTablePartition(param);
} }
Status Status
ConnectionImpl::DeleteTablePartition(const DeleteTablePartitionParam &param) { ConnectionImpl::DeleteTablePartition(const DeleteTablePartitionParam &param) {
return client_proxy->DeleteTablePartition(param); return client_proxy_->DeleteTablePartition(param);
} }
Status Status
ConnectionImpl::DeleteTable(const std::string &table_name) { ConnectionImpl::DeleteTable(const std::string &table_name) {
return client_proxy->DeleteTable(table_name); return client_proxy_->DeleteTable(table_name);
} }
Status Status
ConnectionImpl::AddVector(const std::string &table_name, ConnectionImpl::AddVector(const std::string &table_name,
const std::vector<RowRecord> &record_array, const std::vector<RowRecord> &record_array,
std::vector<int64_t> &id_array) { std::vector<int64_t> &id_array) {
return client_proxy->AddVector(table_name, record_array, id_array); return client_proxy_->AddVector(table_name, record_array, id_array);
} }
Status Status
...@@ -82,27 +82,27 @@ ConnectionImpl::SearchVector(const std::string &table_name, ...@@ -82,27 +82,27 @@ ConnectionImpl::SearchVector(const std::string &table_name,
const std::vector<QueryRecord> &query_record_array, const std::vector<QueryRecord> &query_record_array,
std::vector<TopKQueryResult> &topk_query_result_array, std::vector<TopKQueryResult> &topk_query_result_array,
int64_t topk) { int64_t topk) {
return client_proxy->SearchVector(table_name, query_record_array, topk_query_result_array, topk); return client_proxy_->SearchVector(table_name, query_record_array, topk_query_result_array, topk);
} }
Status Status
ConnectionImpl::DescribeTable(const std::string &table_name, TableSchema &table_schema) { ConnectionImpl::DescribeTable(const std::string &table_name, TableSchema &table_schema) {
return client_proxy->DescribeTable(table_name, table_schema); return client_proxy_->DescribeTable(table_name, table_schema);
} }
Status Status
ConnectionImpl::ShowTables(std::vector<std::string> &table_array) { ConnectionImpl::ShowTables(std::vector<std::string> &table_array) {
return client_proxy->ShowTables(table_array); return client_proxy_->ShowTables(table_array);
} }
std::string std::string
ConnectionImpl::ServerVersion() const { ConnectionImpl::ServerVersion() const {
return client_proxy->ServerVersion(); return client_proxy_->ServerVersion();
} }
std::string std::string
ConnectionImpl::ServerStatus() const { ConnectionImpl::ServerStatus() const {
return client_proxy->ServerStatus(); return client_proxy_->ServerStatus();
} }
} }
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
virtual std::string ServerStatus() const override; virtual std::string ServerStatus() const override;
private: private:
std::shared_ptr<ClientProxy> client_proxy; std::shared_ptr<ClientProxy> client_proxy_;
}; };
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Proprietary and confidential. * Proprietary and confidential.
******************************************************************************/ ******************************************************************************/
#include "ConvertUtil.h" #include "ConvertUtil.h"
#include "Exception.h"
#include <map> #include <map>
...@@ -20,7 +21,7 @@ std::string ConvertUtil::IndexType2Str(megasearch::IndexType index) { ...@@ -20,7 +21,7 @@ std::string ConvertUtil::IndexType2Str(megasearch::IndexType index) {
const auto& iter = s_index2str.find(index); const auto& iter = s_index2str.find(index);
if(iter == s_index2str.end()) { if(iter == s_index2str.end()) {
return INDEX_RAW; throw Exception(StatusCode::Invalid, "Invalid index type");
} }
return iter->second; return iter->second;
...@@ -34,7 +35,7 @@ megasearch::IndexType ConvertUtil::Str2IndexType(const std::string& type) { ...@@ -34,7 +35,7 @@ megasearch::IndexType ConvertUtil::Str2IndexType(const std::string& type) {
const auto& iter = s_str2index.find(type); const auto& iter = s_str2index.find(type);
if(iter == s_str2index.end()) { if(iter == s_str2index.end()) {
return megasearch::IndexType::raw; throw Exception(StatusCode::Invalid, "Invalid index type");
} }
return iter->second; return iter->second;
......
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
#include "Status.h"
#include <exception>
namespace megasearch {
class Exception : public std::exception {
public:
Exception(StatusCode error_code,
const std::string &message = std::string())
: error_code_(error_code), message_(message) {}
public:
StatusCode error_code() const {
return error_code_;
}
virtual const char *what() const noexcept {
return message_.c_str();
}
private:
StatusCode error_code_;
std::string message_;
};
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册