Current state: Accepted
ISSUE: https://github.com/milvus-io/milvus/issues/7713
PRs:
Keywords: C++ SDK
Released: with Milvus 2.1
Authors:
Summary
Deliver C++ SDK toolkit with full functionality for Milvus 2.0. Provide both static lib and dynamic lib for users.
Motivation
We've seen many users demands for C++ SDK, it is probably the most useful SDK which could be used in distributed systems.
Public Interfaces
Client interfaces declaration:
class MilvusClient { public: static std::shared_ptr<MilvusClient> Create(); virtual Status Connect(const ConnectParam& connect_param) = 0; virtual Status Disconnect() = 0; virtual Status CreateCollection(const CollectionSchema& schema) = 0; virtual Status HasCollection(const std::string& collection_name, bool& has) = 0; virtual Status DropCollection(const std::string& collection_name) = 0; virtual Status LoadCollection(const std::string& collection_name, const TimeoutSetting* timeout) = 0; virtual Status ReleaseCollection(const std::string& collection_name) = 0; virtual Status DescribeCollection(const std::string& collection_name, CollectionDesc& collection_desc) = 0; virtual Status GetCollectionStatistics(const std::string& collection_name, bool do_flush, CollectionStat& collection_stat) = 0; virtual Status ShowCollections(const std::vector<std::string>& collection_names, CollectionsInfo& collection_desc) = 0; };
Design Details
Project framework
The C++ sdk can be designed as two levels:
- the orm classes: ConnectionInstance/Collection/Partition/Index/Schema/Parameters, and maybe ConnectionPool
- the client implementation: a class to maintain grpc channel, a class to transfer parameters to rpc interface
CI Workflow
Use github ci process to run code lint, clang format check, compile project and run unittest.
Use mergify to automatically add ci-passed label.
Use code coverage tool to generate report and upload to codecov.io.
API Document
Add description for each class/method/constant, follow the Doxygen comment style.
ORM
To be determined.
C++ versions to support
Support C++ version above C++11. The Reason is:
- Wider user range, as may organizations and devices support C++11.
- Easy to maintain as it will get a large group of developer support.
OS platform to support
For the supported platform, need to be tested with mainstream distributions(e.g. Ubuntu 18.04+, CentOS 7+) using google tests.
Milvus cpp SDK 1.1 using cmake, and only build a shared library as output. In this new SDK for milvus 2, the user can choose which version to be built by setting cmake options. Quality gates such as clang-format, clang-tidy, cpplint are needed.
Code Style
A basic rule of C++ code style:
- Namespace should use
lower_case
- Class should use
CamelCase
Class member should use lower_case_ (with a underscore append)
- Enum member should use
UPPER_CASE
- Function should use
CamelCase
, and the private member Function usecamelBack
For more details, follow the Google C++ Style Guide.
Test Plan
- Unit test
- C++ SDK will implement a mock milvus for basic testing, need to be tested with mainstream distributions(e.g. Ubuntu 18.04+, CentOS 7+)
- Start a standalone milvus complicated test.
- CI test
- Do we need to setup basic CI test for further improvement?
- Examples
- finish all the examples in user guide and make sure it works like https://milvus.io/docs/v2.0.0/example_code.md
References
Current state: Accepted
ISSUE: https://github.com/milvus-io/milvus/issues/7713
PRs:
Keywords: C++ SDK
Released: with Milvus 2.1
Authors: @matrixji @ArkaprabhaChakraborty @yhmo