From bd41630b1f596992920821bf71bc7f7fc43b08a2 Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 12 Nov 2019 15:29:04 +0800 Subject: [PATCH 1/4] fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a951cb041f..363c2cc385 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ Please mark all change in change log and use the ticket from JIRA. - \#226 - Experimental shards middleware for Milvus ## Improvement -- \#284 - Change C++ SDK to shread library +- \#284 - Change C++ SDK to shared library ## Task From dfcce896e2cd7ab6910730e2e384762095ad4cad Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 12 Nov 2019 19:11:07 +0800 Subject: [PATCH 2/4] #260 C++ SDK README --- CHANGELOG.md | 1 + core/src/sdk/README.md | 93 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 core/src/sdk/README.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 363c2cc385..02fb05d9cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Please mark all change in change log and use the ticket from JIRA. ## Improvement - \#284 - Change C++ SDK to shared library +- \#260 - C++ SDK README ## Task diff --git a/core/src/sdk/README.md b/core/src/sdk/README.md new file mode 100644 index 0000000000..5dc5c733e0 --- /dev/null +++ b/core/src/sdk/README.md @@ -0,0 +1,93 @@ +### Build C++ sdk + +The C++ sdk source code is under milvus/core/src/sdk. Build entire milvus project will also build the sdk project. +If you don't want to build entire milvus project, you can do the following steps: +```shell + # generate make files + $ cd [Milvus root path]/core + $ ./build.sh -l + + # build C++ SDK project + $ cd [Milvus root path]/core/cmake_build + $ make -C src/sdk +``` + +### Try C++ example + +Firstly you need to launch a milvus server. +If you build whole milvus project, just run: +```shell + # start milvus server + $ cd [Milvus root path]/core + $ ./start_server.sh +``` +You also can pull milvus release docker image to launch milvus server. +```shell + # pull milvus docker image and start milvus server + $ docker pull milvusdb/milvus:latest + $ docker run --runtime=nvidia -p 19530:19530 -d milvusdb/milvus:latest +``` + +To run C++ example, use below command: + +```shell + # run milvus C++ example + $ cd [Milvus root path]/core/cmake_build/src/sdk/examples/simple + $ ./sdk_simple +``` + +### Make your own C++ client project + +Firstly create a project folder. And copy C++ sdk header and library into the folder. +```shell + # create project folder + $ mkdir MyMilvusClient + $ cd MyMilvusClient + + # copy necessary files + $ cp [Milvus root path]/core/cmake_build/src/sdk/libmilvus_sdk.so . + $ cp [Milvus root path]/core/src/sdk/include/MilvusApi.h . + $ cp [Milvus root path]/core/src/sdk/include/Status.h . +``` + +Create a main.cpp under the project folder, and include C++ sdk headers: +```shell +#include "./MilvusApi.h" +#include "./Status.h" + +int main() { + // connect to milvus server + std::shared_ptr conn = milvus::Connection::Create(); + milvus::ConnectParam param = {"127.0.0.1", "19530"}; + conn->Connect(param); + + // put your client code here + + milvus::Connection::Destroy(conn); + return 0; +} +``` + +Create a CMakeList.txt under the project folder, and paste the follow code into the file: +```shell + cmake_minimum_required(VERSION 3.14) + project(test) + set(CMAKE_CXX_STANDARD 14) + + add_executable(milvus_client main.cpp) + target_link_libraries(milvus_client + ${PROJECT_SOURCE_DIR}/libmilvus_sdk.so) +``` + +Build the client project: +```shell + $ mkdir cmake_build + $ cd cmake_build + $ cmake .. + $ make +``` + +Run your client program: +```shell + $ ./milvus_client +``` \ No newline at end of file From 919846ea6d329a995c2d4febb678c9f3261a72e1 Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 12 Nov 2019 19:47:37 +0800 Subject: [PATCH 3/4] #260 C++ SDK README --- core/src/sdk/README.md | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/core/src/sdk/README.md b/core/src/sdk/README.md index 5dc5c733e0..48a047df1f 100644 --- a/core/src/sdk/README.md +++ b/core/src/sdk/README.md @@ -7,7 +7,7 @@ If you don't want to build entire milvus project, you can do the following steps $ cd [Milvus root path]/core $ ./build.sh -l - # build C++ SDK project + # build C++ sdk project $ cd [Milvus root path]/core/cmake_build $ make -C src/sdk ``` @@ -15,20 +15,20 @@ If you don't want to build entire milvus project, you can do the following steps ### Try C++ example Firstly you need to launch a milvus server. -If you build whole milvus project, just run: +If you already build entire milvus project, just run: ```shell # start milvus server $ cd [Milvus root path]/core $ ./start_server.sh ``` -You also can pull milvus release docker image to launch milvus server. +You also can pull milvus release docker image to launch milvus server: ```shell # pull milvus docker image and start milvus server $ docker pull milvusdb/milvus:latest $ docker run --runtime=nvidia -p 19530:19530 -d milvusdb/milvus:latest ``` -To run C++ example, use below command: +Run C++ example: ```shell # run milvus C++ example @@ -38,7 +38,7 @@ To run C++ example, use below command: ### Make your own C++ client project -Firstly create a project folder. And copy C++ sdk header and library into the folder. +Firstly create a project folder. And copy C++ sdk header and library files into the folder. ```shell # create project folder $ mkdir MyMilvusClient @@ -50,7 +50,7 @@ Firstly create a project folder. And copy C++ sdk header and library into the fo $ cp [Milvus root path]/core/src/sdk/include/Status.h . ``` -Create a main.cpp under the project folder, and include C++ sdk headers: +Create main.cpp under the project folder, and paste the following code into the file: ```shell #include "./MilvusApi.h" #include "./Status.h" @@ -68,7 +68,7 @@ int main() { } ``` -Create a CMakeList.txt under the project folder, and paste the follow code into the file: +Create CMakeList.txt under the project folder, and paste the following code into the file: ```shell cmake_minimum_required(VERSION 3.14) project(test) @@ -79,7 +79,17 @@ Create a CMakeList.txt under the project folder, and paste the follow code into ${PROJECT_SOURCE_DIR}/libmilvus_sdk.so) ``` -Build the client project: +Now there are 5 files in your project: +```shell +MyMilvusClient + |-CMakeList.txt + |-main.cpp + |-libmilvus_sdk.so + |-MilvusApi.h + |-Status.h + ``` + +Build the project: ```shell $ mkdir cmake_build $ cd cmake_build From 5772c3b40058eaeddc6cb515cab995c88a8d2bd9 Mon Sep 17 00:00:00 2001 From: groot Date: Wed, 13 Nov 2019 11:42:20 +0800 Subject: [PATCH 4/4] #260 C++ SDK README --- core/src/sdk/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/sdk/README.md b/core/src/sdk/README.md index 48a047df1f..0f4e20d0e7 100644 --- a/core/src/sdk/README.md +++ b/core/src/sdk/README.md @@ -1,27 +1,27 @@ -### Build C++ sdk +### Build C++ SDK -The C++ sdk source code is under milvus/core/src/sdk. Build entire milvus project will also build the sdk project. -If you don't want to build entire milvus project, you can do the following steps: +The C++ SDK source code is under milvus/core/src/sdk. Build entire milvus project will also build the C++ SDK project. +If you don't want to build the entire milvus project, follow below steps: ```shell # generate make files $ cd [Milvus root path]/core $ ./build.sh -l - # build C++ sdk project + # build C++ SDK project $ cd [Milvus root path]/core/cmake_build $ make -C src/sdk ``` ### Try C++ example -Firstly you need to launch a milvus server. -If you already build entire milvus project, just run: +Firstly, you need to start a Milvus server. +If you've already built the entire milvus project, just start Milvus server with the following command: ```shell # start milvus server $ cd [Milvus root path]/core $ ./start_server.sh ``` -You also can pull milvus release docker image to launch milvus server: +You can also use Docker to start Milvus server: ```shell # pull milvus docker image and start milvus server $ docker pull milvusdb/milvus:latest @@ -38,7 +38,7 @@ Run C++ example: ### Make your own C++ client project -Firstly create a project folder. And copy C++ sdk header and library files into the folder. +Create a folder for the project, and copy C++ SDK header and library files into it. ```shell # create project folder $ mkdir MyMilvusClient @@ -50,7 +50,7 @@ Firstly create a project folder. And copy C++ sdk header and library files into $ cp [Milvus root path]/core/src/sdk/include/Status.h . ``` -Create main.cpp under the project folder, and paste the following code into the file: +Create file main.cpp in the project folder, and copy the following code into it: ```shell #include "./MilvusApi.h" #include "./Status.h" @@ -68,7 +68,7 @@ int main() { } ``` -Create CMakeList.txt under the project folder, and paste the following code into the file: +Create file CMakeList.txt in the project folder, and copy the following code into it: ```shell cmake_minimum_required(VERSION 3.14) project(test)