diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 45c3f18d7551a3dac452226d8925f397ed24bab9..2bb18211a624cbbb79f69bfeb05807bd242016b0 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -22,6 +22,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-98 - Install all unit test to installation directory - MS-115 - Change is_startup of metric_config switch from true to on - MS-122 - Archive criteria config +- MS-124 - HasTable interface ## New Feature diff --git a/cpp/src/sdk/examples/simple/src/ClientTest.cpp b/cpp/src/sdk/examples/simple/src/ClientTest.cpp index 78145446a67a3c865d754052c3d95d12bf7e6483..19c764fd0a1c47b11d21e5b31323193f6ab58b8b 100644 --- a/cpp/src/sdk/examples/simple/src/ClientTest.cpp +++ b/cpp/src/sdk/examples/simple/src/ClientTest.cpp @@ -165,6 +165,11 @@ ClientTest::Test(const std::string& address, const std::string& port) { Status stat = conn->CreateTable(tb_schema); std::cout << "CreateTable function call status: " << stat.ToString() << std::endl; PrintTableSchema(tb_schema); + + bool has_table = conn->HasTable(tb_schema.table_name); + if(has_table) { + std::cout << "Table is created" << std::endl; + } } {//describe table diff --git a/cpp/src/sdk/include/MilvusApi.h b/cpp/src/sdk/include/MilvusApi.h index 2f4532b76166cd45b573e9475e6a5879b75eee13..302871c48b535434065ed99a475df02b0cb43885 100644 --- a/cpp/src/sdk/include/MilvusApi.h +++ b/cpp/src/sdk/include/MilvusApi.h @@ -156,6 +156,18 @@ public: virtual Status CreateTable(const TableSchema ¶m) = 0; + /** + * @brief Test table existence method + * + * This method is used to create table + * + * @param table_name, table name is going to be tested. + * + * @return Indicate if table is cexist + */ + virtual bool HasTable(const std::string &table_name) = 0; + + /** * @brief Delete table method * diff --git a/cpp/src/sdk/src/client/ClientProxy.cpp b/cpp/src/sdk/src/client/ClientProxy.cpp index 6f68344faca25e9325f50568faa249aa37fe5c81..1185e4988c65a5bb9f8298925fb39b1a3e75dc8d 100644 --- a/cpp/src/sdk/src/client/ClientProxy.cpp +++ b/cpp/src/sdk/src/client/ClientProxy.cpp @@ -102,6 +102,15 @@ ClientProxy::CreateTable(const TableSchema ¶m) { return Status::OK(); } +bool +ClientProxy::HasTable(const std::string &table_name) { + if(!IsConnected()) { + return false; + } + + return ClientPtr()->interface()->HasTable(table_name); +} + Status ClientProxy::DeleteTable(const std::string &table_name) { if(!IsConnected()) { diff --git a/cpp/src/sdk/src/client/ClientProxy.h b/cpp/src/sdk/src/client/ClientProxy.h index 601bcddd8a0633b7b91b881afb4580a896c8a347..a2ede77c407262a004e82c39b344c6baa2de4560 100644 --- a/cpp/src/sdk/src/client/ClientProxy.h +++ b/cpp/src/sdk/src/client/ClientProxy.h @@ -23,6 +23,8 @@ public: virtual Status CreateTable(const TableSchema ¶m) override; + virtual bool HasTable(const std::string &table_name) override; + virtual Status DeleteTable(const std::string &table_name) override; virtual Status AddVector(const std::string &table_name, diff --git a/cpp/src/sdk/src/interface/ConnectionImpl.cpp b/cpp/src/sdk/src/interface/ConnectionImpl.cpp index e303cf0aa0a99c9d962932bbc37c4fe34f798a9c..efb5f61b1bf293f018e40523002711236252bffc 100644 --- a/cpp/src/sdk/src/interface/ConnectionImpl.cpp +++ b/cpp/src/sdk/src/interface/ConnectionImpl.cpp @@ -56,6 +56,11 @@ ConnectionImpl::CreateTable(const TableSchema ¶m) { return client_proxy_->CreateTable(param); } +bool +ConnectionImpl::HasTable(const std::string &table_name) { + return client_proxy_->HasTable(table_name); +} + Status ConnectionImpl::DeleteTable(const std::string &table_name) { return client_proxy_->DeleteTable(table_name); diff --git a/cpp/src/sdk/src/interface/ConnectionImpl.h b/cpp/src/sdk/src/interface/ConnectionImpl.h index 61e11c93907c65c935f0928b2431a06d57bfcf9b..0f9cd14e39c7be5c54158c9ee7935550b1fbff83 100644 --- a/cpp/src/sdk/src/interface/ConnectionImpl.h +++ b/cpp/src/sdk/src/interface/ConnectionImpl.h @@ -25,6 +25,8 @@ public: virtual Status CreateTable(const TableSchema ¶m) override; + virtual bool HasTable(const std::string &table_name) override; + virtual Status DeleteTable(const std::string &table_name) override; virtual Status AddVector(const std::string &table_name, diff --git a/cpp/src/server/RequestHandler.cpp b/cpp/src/server/RequestHandler.cpp index 62ce0711b4fcdbe1a00eb60e28a6cf83274fa0eb..037f80e0db7f56857df9d4c2691a87f99d8453cc 100644 --- a/cpp/src/server/RequestHandler.cpp +++ b/cpp/src/server/RequestHandler.cpp @@ -24,6 +24,15 @@ RequestHandler::CreateTable(const thrift::TableSchema ¶m) { RequestScheduler::ExecTask(task_ptr); } +bool +RequestHandler::HasTable(const std::string &table_name) { + bool has_table = false; + BaseTaskPtr task_ptr = HasTableTask::Create(table_name, has_table); + RequestScheduler::ExecTask(task_ptr); + + return has_table; +} + void RequestHandler::DeleteTable(const std::string &table_name) { BaseTaskPtr task_ptr = DeleteTableTask::Create(table_name); diff --git a/cpp/src/server/RequestHandler.h b/cpp/src/server/RequestHandler.h index 8f3eca576b36bf76ddd2c0cb2c1a94143f71aa19..e736b7593fa83ff56f5d72d8d6790cca9a051761 100644 --- a/cpp/src/server/RequestHandler.h +++ b/cpp/src/server/RequestHandler.h @@ -19,16 +19,28 @@ public: RequestHandler(); /** - * @brief Create table method - * - * This method is used to create table - * - * @param param, use to provide table information to be created. - * - * - * @param param - */ - void CreateTable(const ::milvus::thrift::TableSchema& param); + * @brief Create table method + * + * This method is used to create table + * + * @param param, use to provide table information to be created. + * + * + * @param param + */ + void CreateTable(const ::milvus::thrift::TableSchema ¶m); + + /** + * @brief Test table existence method + * + * This method is used to test table existence. + * + * @param table_name, table name is going to be tested. + * + * + * @param table_name + */ + bool HasTable(const std::string &table_name); /** * @brief Delete table method diff --git a/cpp/src/server/RequestTask.cpp b/cpp/src/server/RequestTask.cpp index dbe4e6a7406ebd0b512608fe3b2b6123344fd442..b645d15a4e1ffeccba68307dfacd221e2288cbd8 100644 --- a/cpp/src/server/RequestTask.cpp +++ b/cpp/src/server/RequestTask.cpp @@ -70,7 +70,7 @@ namespace { uint64_t vec_dim = record.vector_data.size()/sizeof(double);//how many double value? if(vec_dim != dimension) { SERVER_LOG_ERROR << "Invalid vector dimension: " << vec_dim - << " vs. group dimension:" << dimension; + << " vs. table dimension:" << dimension; error_code = SERVER_INVALID_VECTOR_DIMENSION; return error_code; } @@ -233,6 +233,44 @@ ServerError DescribeTableTask::OnExecute() { return SERVER_SUCCESS; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +HasTableTask::HasTableTask(const std::string& table_name, bool& has_table) + : BaseTask(DDL_DML_TASK_GROUP), + table_name_(table_name), + has_table_(has_table) { + +} + +BaseTaskPtr HasTableTask::Create(const std::string& table_name, bool& has_table) { + return std::shared_ptr(new HasTableTask(table_name, has_table)); +} + +ServerError HasTableTask::OnExecute() { + try { + TimeRecorder rc("HasTableTask"); + + //step 1: check arguments + if (table_name_.empty()) { + error_code_ = SERVER_INVALID_ARGUMENT; + error_msg_ = "Table name cannot be empty"; + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + + //step 2: check table existence + engine::Status stat = DBWrapper::DB()->HasTable(table_name_, has_table_); + + rc.Elapse("totally cost"); + } catch (std::exception& ex) { + error_code_ = SERVER_UNEXPECTED_ERROR; + error_msg_ = ex.what(); + SERVER_LOG_ERROR << error_msg_; + return error_code_; + } + + return SERVER_SUCCESS; +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DeleteTableTask::DeleteTableTask(const std::string& table_name) : BaseTask(DDL_DML_TASK_GROUP), @@ -240,8 +278,8 @@ DeleteTableTask::DeleteTableTask(const std::string& table_name) } -BaseTaskPtr DeleteTableTask::Create(const std::string& group_id) { - return std::shared_ptr(new DeleteTableTask(group_id)); +BaseTaskPtr DeleteTableTask::Create(const std::string& table_name) { + return std::shared_ptr(new DeleteTableTask(table_name)); } ServerError DeleteTableTask::OnExecute() { diff --git a/cpp/src/server/RequestTask.h b/cpp/src/server/RequestTask.h index b4ddc69726cc6f7ddcb02013a77a1ad99503cb4e..3061b3b75d73b5f266974e4464b1c21c06aef33d 100644 --- a/cpp/src/server/RequestTask.h +++ b/cpp/src/server/RequestTask.h @@ -33,6 +33,22 @@ private: const ::milvus::thrift::TableSchema& schema_; }; +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class HasTableTask : public BaseTask { +public: + static BaseTaskPtr Create(const std::string& table_name, bool& has_table); + +protected: + HasTableTask(const std::string& table_name, bool& has_table); + + ServerError OnExecute() override; + + +private: + std::string table_name_; + bool& has_table_; +}; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class DescribeTableTask : public BaseTask { public: diff --git a/cpp/src/thrift/gen-cpp/MilvusService.cpp b/cpp/src/thrift/gen-cpp/MilvusService.cpp index 7e0a120bc09ef6c18a0b6b4e542d85bfa5000f2d..7a591276f6be4a94f84d33ac915eb462d4078904 100644 --- a/cpp/src/thrift/gen-cpp/MilvusService.cpp +++ b/cpp/src/thrift/gen-cpp/MilvusService.cpp @@ -196,6 +196,213 @@ uint32_t MilvusService_CreateTable_presult::read(::apache::thrift::protocol::TPr } +MilvusService_HasTable_args::~MilvusService_HasTable_args() throw() { +} + + +uint32_t MilvusService_HasTable_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->table_name); + this->__isset.table_name = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MilvusService_HasTable_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MilvusService_HasTable_args"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->table_name); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MilvusService_HasTable_pargs::~MilvusService_HasTable_pargs() throw() { +} + + +uint32_t MilvusService_HasTable_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("MilvusService_HasTable_pargs"); + + xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString((*(this->table_name))); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MilvusService_HasTable_result::~MilvusService_HasTable_result() throw() { +} + + +uint32_t MilvusService_HasTable_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_BOOL) { + xfer += iprot->readBool(this->success); + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t MilvusService_HasTable_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("MilvusService_HasTable_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_BOOL, 0); + xfer += oprot->writeBool(this->success); + xfer += oprot->writeFieldEnd(); + } else if (this->__isset.e) { + xfer += oprot->writeFieldBegin("e", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->e.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +MilvusService_HasTable_presult::~MilvusService_HasTable_presult() throw() { +} + + +uint32_t MilvusService_HasTable_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_BOOL) { + xfer += iprot->readBool((*(this->success))); + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->e.read(iprot); + this->__isset.e = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + + MilvusService_DeleteTable_args::~MilvusService_DeleteTable_args() throw() { } @@ -2290,6 +2497,67 @@ void MilvusServiceClient::recv_CreateTable() return; } +bool MilvusServiceClient::HasTable(const std::string& table_name) +{ + send_HasTable(table_name); + return recv_HasTable(); +} + +void MilvusServiceClient::send_HasTable(const std::string& table_name) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("HasTable", ::apache::thrift::protocol::T_CALL, cseqid); + + MilvusService_HasTable_pargs args; + args.table_name = &table_name; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +bool MilvusServiceClient::recv_HasTable() +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("HasTable") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + bool _return; + MilvusService_HasTable_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + return _return; + } + if (result.__isset.e) { + throw result.e; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "HasTable failed: unknown result"); +} + void MilvusServiceClient::DeleteTable(const std::string& table_name) { send_DeleteTable(table_name); @@ -2855,6 +3123,63 @@ void MilvusServiceProcessor::process_CreateTable(int32_t seqid, ::apache::thrift } } +void MilvusServiceProcessor::process_HasTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = NULL; + if (this->eventHandler_.get() != NULL) { + ctx = this->eventHandler_->getContext("MilvusService.HasTable", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "MilvusService.HasTable"); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preRead(ctx, "MilvusService.HasTable"); + } + + MilvusService_HasTable_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postRead(ctx, "MilvusService.HasTable", bytes); + } + + MilvusService_HasTable_result result; + try { + result.success = iface_->HasTable(args.table_name); + result.__isset.success = true; + } catch (Exception &e) { + result.e = e; + result.__isset.e = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->handlerError(ctx, "MilvusService.HasTable"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("HasTable", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->preWrite(ctx, "MilvusService.HasTable"); + } + + oprot->writeMessageBegin("HasTable", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != NULL) { + this->eventHandler_->postWrite(ctx, "MilvusService.HasTable", bytes); + } +} + void MilvusServiceProcessor::process_DeleteTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) { void* ctx = NULL; @@ -3399,6 +3724,94 @@ void MilvusServiceConcurrentClient::recv_CreateTable(const int32_t seqid) } // end while(true) } +bool MilvusServiceConcurrentClient::HasTable(const std::string& table_name) +{ + int32_t seqid = send_HasTable(table_name); + return recv_HasTable(seqid); +} + +int32_t MilvusServiceConcurrentClient::send_HasTable(const std::string& table_name) +{ + int32_t cseqid = this->sync_.generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + oprot_->writeMessageBegin("HasTable", ::apache::thrift::protocol::T_CALL, cseqid); + + MilvusService_HasTable_pargs args; + args.table_name = &table_name; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +bool MilvusServiceConcurrentClient::recv_HasTable(const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + + while(true) { + if(!this->sync_.getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("HasTable") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + bool _return; + MilvusService_HasTable_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + sentry.commit(); + return _return; + } + if (result.__isset.e) { + sentry.commit(); + throw result.e; + } + // in a bad state, don't commit + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "HasTable failed: unknown result"); + } + // seqid != rseqid + this->sync_.updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_.waitForWork(seqid); + } // end while(true) +} + void MilvusServiceConcurrentClient::DeleteTable(const std::string& table_name) { int32_t seqid = send_DeleteTable(table_name); diff --git a/cpp/src/thrift/gen-cpp/MilvusService.h b/cpp/src/thrift/gen-cpp/MilvusService.h index 4c1183de60514659605274d61c2d78eb7ff665db..38686814635639b5afe15a80329e18e85cc26d2a 100644 --- a/cpp/src/thrift/gen-cpp/MilvusService.h +++ b/cpp/src/thrift/gen-cpp/MilvusService.h @@ -34,6 +34,18 @@ class MilvusServiceIf { */ virtual void CreateTable(const TableSchema& param) = 0; + /** + * @brief Test table existence method + * + * This method is used to test table existence. + * + * @param table_name, table name is going to be tested. + * + * + * @param table_name + */ + virtual bool HasTable(const std::string& table_name) = 0; + /** * @brief Delete table method * @@ -178,6 +190,10 @@ class MilvusServiceNull : virtual public MilvusServiceIf { void CreateTable(const TableSchema& /* param */) { return; } + bool HasTable(const std::string& /* table_name */) { + bool _return = false; + return _return; + } void DeleteTable(const std::string& /* table_name */) { return; } @@ -309,6 +325,118 @@ class MilvusService_CreateTable_presult { }; +typedef struct _MilvusService_HasTable_args__isset { + _MilvusService_HasTable_args__isset() : table_name(false) {} + bool table_name :1; +} _MilvusService_HasTable_args__isset; + +class MilvusService_HasTable_args { + public: + + MilvusService_HasTable_args(const MilvusService_HasTable_args&); + MilvusService_HasTable_args& operator=(const MilvusService_HasTable_args&); + MilvusService_HasTable_args() : table_name() { + } + + virtual ~MilvusService_HasTable_args() throw(); + std::string table_name; + + _MilvusService_HasTable_args__isset __isset; + + void __set_table_name(const std::string& val); + + bool operator == (const MilvusService_HasTable_args & rhs) const + { + if (!(table_name == rhs.table_name)) + return false; + return true; + } + bool operator != (const MilvusService_HasTable_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MilvusService_HasTable_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class MilvusService_HasTable_pargs { + public: + + + virtual ~MilvusService_HasTable_pargs() throw(); + const std::string* table_name; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MilvusService_HasTable_result__isset { + _MilvusService_HasTable_result__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MilvusService_HasTable_result__isset; + +class MilvusService_HasTable_result { + public: + + MilvusService_HasTable_result(const MilvusService_HasTable_result&); + MilvusService_HasTable_result& operator=(const MilvusService_HasTable_result&); + MilvusService_HasTable_result() : success(0) { + } + + virtual ~MilvusService_HasTable_result() throw(); + bool success; + Exception e; + + _MilvusService_HasTable_result__isset __isset; + + void __set_success(const bool val); + + void __set_e(const Exception& val); + + bool operator == (const MilvusService_HasTable_result & rhs) const + { + if (!(success == rhs.success)) + return false; + if (!(e == rhs.e)) + return false; + return true; + } + bool operator != (const MilvusService_HasTable_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const MilvusService_HasTable_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _MilvusService_HasTable_presult__isset { + _MilvusService_HasTable_presult__isset() : success(false), e(false) {} + bool success :1; + bool e :1; +} _MilvusService_HasTable_presult__isset; + +class MilvusService_HasTable_presult { + public: + + + virtual ~MilvusService_HasTable_presult() throw(); + bool* success; + Exception e; + + _MilvusService_HasTable_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + typedef struct _MilvusService_DeleteTable_args__isset { _MilvusService_DeleteTable_args__isset() : table_name(false) {} bool table_name :1; @@ -1269,6 +1397,9 @@ class MilvusServiceClient : virtual public MilvusServiceIf { void CreateTable(const TableSchema& param); void send_CreateTable(const TableSchema& param); void recv_CreateTable(); + bool HasTable(const std::string& table_name); + void send_HasTable(const std::string& table_name); + bool recv_HasTable(); void DeleteTable(const std::string& table_name); void send_DeleteTable(const std::string& table_name); void recv_DeleteTable(); @@ -1309,6 +1440,7 @@ class MilvusServiceProcessor : public ::apache::thrift::TDispatchProcessor { typedef std::map ProcessMap; ProcessMap processMap_; void process_CreateTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_HasTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_DeleteTable(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_AddVector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_SearchVector(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); @@ -1321,6 +1453,7 @@ class MilvusServiceProcessor : public ::apache::thrift::TDispatchProcessor { MilvusServiceProcessor(::apache::thrift::stdcxx::shared_ptr iface) : iface_(iface) { processMap_["CreateTable"] = &MilvusServiceProcessor::process_CreateTable; + processMap_["HasTable"] = &MilvusServiceProcessor::process_HasTable; processMap_["DeleteTable"] = &MilvusServiceProcessor::process_DeleteTable; processMap_["AddVector"] = &MilvusServiceProcessor::process_AddVector; processMap_["SearchVector"] = &MilvusServiceProcessor::process_SearchVector; @@ -1366,6 +1499,15 @@ class MilvusServiceMultiface : virtual public MilvusServiceIf { ifaces_[i]->CreateTable(param); } + bool HasTable(const std::string& table_name) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->HasTable(table_name); + } + return ifaces_[i]->HasTable(table_name); + } + void DeleteTable(const std::string& table_name) { size_t sz = ifaces_.size(); size_t i = 0; @@ -1477,6 +1619,9 @@ class MilvusServiceConcurrentClient : virtual public MilvusServiceIf { void CreateTable(const TableSchema& param); int32_t send_CreateTable(const TableSchema& param); void recv_CreateTable(const int32_t seqid); + bool HasTable(const std::string& table_name); + int32_t send_HasTable(const std::string& table_name); + bool recv_HasTable(const int32_t seqid); void DeleteTable(const std::string& table_name); int32_t send_DeleteTable(const std::string& table_name); void recv_DeleteTable(const int32_t seqid); diff --git a/cpp/src/thrift/gen-cpp/MilvusService_server.skeleton.cpp b/cpp/src/thrift/gen-cpp/MilvusService_server.skeleton.cpp index 55d73b96426077d6b123fcd1a5de05919e0a503b..ecb22c0b62ee4984c2b3b0bb46133fb4c1008dcc 100644 --- a/cpp/src/thrift/gen-cpp/MilvusService_server.skeleton.cpp +++ b/cpp/src/thrift/gen-cpp/MilvusService_server.skeleton.cpp @@ -35,6 +35,21 @@ class MilvusServiceHandler : virtual public MilvusServiceIf { printf("CreateTable\n"); } + /** + * @brief Test table existence method + * + * This method is used to test table existence. + * + * @param table_name, table name is going to be tested. + * + * + * @param table_name + */ + bool HasTable(const std::string& table_name) { + // Your implementation goes here + printf("HasTable\n"); + } + /** * @brief Delete table method * diff --git a/cpp/src/thrift/milvus.thrift b/cpp/src/thrift/milvus.thrift index 2936b85a5ca72dab588e52384141d960c7f489aa..48116256e87072359b7a02960f9cfa056ef0f8d7 100644 --- a/cpp/src/thrift/milvus.thrift +++ b/cpp/src/thrift/milvus.thrift @@ -80,6 +80,16 @@ service MilvusService { */ void CreateTable(2: TableSchema param) throws(1: Exception e); + /** + * @brief Test table existence method + * + * This method is used to test table existence. + * + * @param table_name, table name is going to be tested. + * + */ + bool HasTable(2: string table_name) throws(1: Exception e); + /** * @brief Delete table method