From c9bb9d7e58a06a9db2301076b3926c4bc2cfb028 Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 12 Nov 2019 15:30:19 +0800 Subject: [PATCH 1/5] fix typo --- CHANGELOG.md | 2 +- core/src/config.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 core/src/config.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 1087c1b0e0..92167c3922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Please mark all change in change log and use the ticket from JIRA. - \#204 - improve grpc performance in search - \#207 - Add more unittest for config set/get - \#208 - optimize unittest to support run single test more easily -- \#284 - Change C++ SDK to shread library +- \#284 - Change C++ SDK to shared library ## Task diff --git a/core/src/config.h b/core/src/config.h new file mode 100644 index 0000000000..d935c36faf --- /dev/null +++ b/core/src/config.h @@ -0,0 +1,20 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#define MILVUS_VERSION "0.6.0" +#define BUILD_TYPE "Debug" +#define BUILD_TIME "2019-11-12 14:06.18" From 06ae349fe249aa7f7b7868c6ab33879c1e6d4366 Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 12 Nov 2019 19:14:20 +0800 Subject: [PATCH 2/5] #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 92167c3922..3f78e72192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Please mark all change in change log and use the ticket from JIRA. - \#207 - Add more unittest for config set/get - \#208 - optimize unittest to support run single test more easily - \#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 0442ec7900d1dd62a203b91819be20b92fa6aff1 Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 12 Nov 2019 19:22:27 +0800 Subject: [PATCH 3/5] #260 C++ SDK README --- core/src/config.h | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 core/src/config.h diff --git a/core/src/config.h b/core/src/config.h deleted file mode 100644 index d935c36faf..0000000000 --- a/core/src/config.h +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#define MILVUS_VERSION "0.6.0" -#define BUILD_TYPE "Debug" -#define BUILD_TIME "2019-11-12 14:06.18" From 5a74558f0d674a9e815faa33113ed2348a7083b5 Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 12 Nov 2019 19:45:21 +0800 Subject: [PATCH 4/5] #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 be733f1e5d493d41ff967d07a2f2ab0577c62044 Mon Sep 17 00:00:00 2001 From: groot Date: Wed, 13 Nov 2019 11:43:23 +0800 Subject: [PATCH 5/5] #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)