提交 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.
- MS-1 - Add CHANGELOG.md
- 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) {
//////////////////////////////////////////////////////////////////////////////////////////////
ConnectionImpl::ConnectionImpl() {
client_proxy = std::make_shared<ClientProxy>();
client_proxy_ = std::make_shared<ClientProxy>();
}
Status
ConnectionImpl::Connect(const ConnectParam &param) {
return client_proxy->Connect(param);
return client_proxy_->Connect(param);
}
Status
ConnectionImpl::Connect(const std::string &uri) {
return client_proxy->Connect(uri);
return client_proxy_->Connect(uri);
}
Status
ConnectionImpl::Connected() const {
return client_proxy->Connected();
return client_proxy_->Connected();
}
Status
ConnectionImpl::Disconnect() {
return client_proxy->Disconnect();
return client_proxy_->Disconnect();
}
std::string
ConnectionImpl::ClientVersion() const {
return client_proxy->ClientVersion();
return client_proxy_->ClientVersion();
}
Status
ConnectionImpl::CreateTable(const TableSchema &param) {
return client_proxy->CreateTable(param);
return client_proxy_->CreateTable(param);
}
Status
ConnectionImpl::CreateTablePartition(const CreateTablePartitionParam &param) {
return client_proxy->CreateTablePartition(param);
return client_proxy_->CreateTablePartition(param);
}
Status
ConnectionImpl::DeleteTablePartition(const DeleteTablePartitionParam &param) {
return client_proxy->DeleteTablePartition(param);
return client_proxy_->DeleteTablePartition(param);
}
Status
ConnectionImpl::DeleteTable(const std::string &table_name) {
return client_proxy->DeleteTable(table_name);
return client_proxy_->DeleteTable(table_name);
}
Status
ConnectionImpl::AddVector(const std::string &table_name,
const std::vector<RowRecord> &record_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
......@@ -82,27 +82,27 @@ ConnectionImpl::SearchVector(const std::string &table_name,
const std::vector<QueryRecord> &query_record_array,
std::vector<TopKQueryResult> &topk_query_result_array,
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
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
ConnectionImpl::ShowTables(std::vector<std::string> &table_array) {
return client_proxy->ShowTables(table_array);
return client_proxy_->ShowTables(table_array);
}
std::string
ConnectionImpl::ServerVersion() const {
return client_proxy->ServerVersion();
return client_proxy_->ServerVersion();
}
std::string
ConnectionImpl::ServerStatus() const {
return client_proxy->ServerStatus();
return client_proxy_->ServerStatus();
}
}
......
......@@ -51,7 +51,7 @@ public:
virtual std::string ServerStatus() const override;
private:
std::shared_ptr<ClientProxy> client_proxy;
std::shared_ptr<ClientProxy> client_proxy_;
};
}
......@@ -4,6 +4,7 @@
* Proprietary and confidential.
******************************************************************************/
#include "ConvertUtil.h"
#include "Exception.h"
#include <map>
......@@ -20,7 +21,7 @@ std::string ConvertUtil::IndexType2Str(megasearch::IndexType index) {
const auto& iter = s_index2str.find(index);
if(iter == s_index2str.end()) {
return INDEX_RAW;
throw Exception(StatusCode::Invalid, "Invalid index type");
}
return iter->second;
......@@ -34,7 +35,7 @@ megasearch::IndexType ConvertUtil::Str2IndexType(const std::string& type) {
const auto& iter = s_str2index.find(type);
if(iter == s_str2index.end()) {
return megasearch::IndexType::raw;
throw Exception(StatusCode::Invalid, "Invalid index type");
}
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.
先完成此消息的编辑!
想要评论请 注册