milvus/sdk
Cai Yudong a8756559c4 add interface GetConfig()/SetConfig() (#877)
* #665 add interface GetConfig()/SetConfig()

* #665 remove test code
2019-12-31 10:47:52 +08:00
..
build-support Put C++ sdk out of milvus/core (#785) 2019-12-20 14:08:45 +08:00
cmake Remove Jfrog Cache on Jenkins CI (#827) 2019-12-26 10:33:05 +08:00
examples Put C++ sdk out of milvus/core (#785) 2019-12-20 14:08:45 +08:00
grpc add interface GetConfig()/SetConfig() (#877) 2019-12-31 10:47:52 +08:00
grpc-gen Put C++ sdk out of milvus/core (#785) 2019-12-20 14:08:45 +08:00
include add interface GetConfig()/SetConfig() (#877) 2019-12-31 10:47:52 +08:00
interface add interface GetConfig()/SetConfig() (#877) 2019-12-31 10:47:52 +08:00
build.sh Put C++ sdk out of milvus/core (#785) 2019-12-20 14:08:45 +08:00
CMakeLists.txt Put C++ sdk out of milvus/core (#785) 2019-12-20 14:08:45 +08:00
README.md Put C++ sdk out of milvus/core (#785) 2019-12-20 14:08:45 +08:00

Build C++ SDK

The C++ SDK source code is under milvus/sdk. If you want to build sdk project, follow below steps:

 # build project
 $ cd [Milvus root path]/sdk
 $ ./build.sh

Try C++ example

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:

 # start milvus server
 $ cd [Milvus root path]/core
 $ ./start_server.sh

You can also use Docker to start Milvus server:

 # pull milvus docker image and start milvus server
 $ docker pull milvusdb/milvus:latest
 $ docker run --runtime=nvidia -p 19530:19530 -d milvusdb/milvus:latest

Run C++ example:

 # run milvus C++ example
 $ cd [Milvus root path]/sdk/cmake_build/examples/simple
 $ ./sdk_simple

Make your own C++ client project

Create a folder for the project, and copy C++ SDK header and library files into it.

 # create project folder
 $ mkdir MyMilvusClient
 $ cd MyMilvusClient
 
 # copy necessary files
 $ cp [Milvus root path]/sdk/cmake_build/libmilvus_sdk.so .
 $ cp [Milvus root path]/sdk/include/MilvusApi.h .
 $ cp [Milvus root path]/sdk/include/Status.h .

Create file main.cpp in the project folder, and copy the following code into it:

#include "./MilvusApi.h"
#include "./Status.h"

int main() {
  // connect to milvus server
  std::shared_ptr<milvus::Connection> 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 file CMakeList.txt in the project folder, and copy the following code into it:

 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)

Now there are 5 files in your project:

MyMilvusClient
 |-CMakeList.txt
 |-main.cpp
 |-libmilvus_sdk.so
 |-MilvusApi.h
 |-Status.h

Build the project:

 $ mkdir cmake_build
 $ cd cmake_build
 $ cmake ..
 $ make

Run your client program:

 $ ./milvus_client