Skip to content

Commit 7eac29d

Browse files
committed
use proto for milvus 2.3.5
Signed-off-by: Ji Bin <[email protected]>
1 parent 4d56589 commit 7eac29d

17 files changed

+98
-177
lines changed

.clang-format

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ColumnLimit: 120
2121
IndentWidth: 4
2222
AccessModifierOffset: -3
2323
AlwaysBreakAfterReturnType: All
24-
AllowShortBlocksOnASingleLine: false
25-
AllowShortFunctionsOnASingleLine: false
24+
AllowShortBlocksOnASingleLine: Never
25+
AllowShortFunctionsOnASingleLine: None
2626
AllowShortIfStatementsOnASingleLine: false
2727
AlignTrailingComments: true

.clang-tidy

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# The checks defined here will be run and will display by default as warnings.
1919
Checks: >
2020
-*, clang-diagnostic-*, -clang-diagnostic-error,
21-
clang-analyzer-*, -clang-analyzer-alpha*,
21+
clang-analyzer-*, -clang-analyzer-alpha*, -clang-diagnostic-deprecated*,
2222
google-*, -google-runtime-references, -google-readability-todo, -google-default-arguments,
2323
modernize-*, -modernize-pass-by-value, -modernize-use-equals-default, -modernize-use-trailing-return-type,
2424
performance-faster-string-find, performance-for-range-copy,

.github/workflows/main.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464
CCACHE_COMPRESSLEVEL: 5
6565
CCACHE_MAXSIZE: 2G
6666
steps:
67+
- name: Env
68+
run: echo "${HOME}/.local/bin" >> $GITHUB_PATH
6769
- name: Checkout
6870
uses: actions/checkout@v3
6971
- name: Cache ccache
@@ -98,6 +100,8 @@ jobs:
98100
CCACHE_COMPRESSLEVEL: 5
99101
CCACHE_MAXSIZE: 2G
100102
steps:
103+
- name: Env
104+
run: echo "${HOME}/.local/bin" >> $GITHUB_PATH
101105
- name: Checkout
102106
uses: actions/checkout@v3
103107
- name: Cache ccache

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ project(milvus_sdk LANGUAGES CXX)
1919

2020
set(CMAKE_VERBOSE_MAKEFILE OFF)
2121
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
22+
set(CMAKE_CXX_STANDARD 14)
23+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2224

2325
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2426

cmake/FindClangTools.cmake

+46-103
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,57 @@
1-
# Licensed to the LF AI & Data foundation under one
2-
# or more contributor license agreements. See the NOTICE file
3-
# distributed with this work for additional information
4-
# regarding copyright ownership. The ASF licenses this file
5-
# to you under the Apache License, Version 2.0 (the
6-
# "License"); you may not use this file except in compliance
7-
# with the License. You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
16-
#
17-
# Tries to find the clang-tidy and clang-format modules
18-
#
19-
# Usage of this module as follows:
20-
#
21-
# find_package(ClangTools)
22-
#
23-
# Variables used by this module, they can change the default behaviour and need
24-
# to be set before calling find_package:
25-
#
26-
# ClangToolsBin_HOME -
27-
# When set, this path is inspected instead of standard library binary locations
28-
# to find clang-tidy and clang-format
29-
#
30-
# This module defines
31-
# CLANG_TIDY_BIN, The path to the clang tidy binary
32-
# CLANG_TIDY_FOUND, Whether clang tidy was found
33-
# CLANG_FORMAT_BIN, The path to the clang format binary
34-
# CLANG_TIDY_FOUND, Whether clang format was found
1+
# use pip install clang-tidy & clang-format
352

363
if (CMAKE_HOST_APPLE)
37-
execute_process(
38-
COMMAND brew --prefix llvm
39-
OUTPUT_VARIABLE USER_LLVM_PATH
40-
OUTPUT_STRIP_TRAILING_WHITESPACE
41-
COMMAND_ERROR_IS_FATAL ANY
42-
)
43-
set(USER_CLANG_TOOLS_PATH ${USER_LLVM_PATH}/bin)
44-
message(STATUS ${USER_CLANG_TOOLS_PATH})
4+
execute_process(
5+
COMMAND brew --prefix llvm
6+
OUTPUT_VARIABLE USER_LLVM_PATH
7+
OUTPUT_STRIP_TRAILING_WHITESPACE
8+
COMMAND_ERROR_IS_FATAL ANY
9+
)
10+
set(USER_CLANG_TOOLS_PATH ${USER_LLVM_PATH}/bin)
11+
message(STATUS ${USER_CLANG_TOOLS_PATH})
4512
endif ()
4613

4714
find_program(CLANG_TIDY_BIN
48-
NAMES
49-
clang-tidy-14
50-
clang-tidy-13
51-
clang-tidy-10
52-
clang-tidy
53-
PATHS ${ClangTools_PATH} $ENV{CLANG_TOOLS_PATH} ${USER_CLANG_TOOLS_PATH} /usr/local/bin /usr/bin
15+
NAMES
16+
clang-tidy
17+
PATHS
18+
${USER_CLANG_TOOLS_PATH}
19+
${ClangTools_PATH}
20+
$ENV{CLANG_TOOLS_PATH}
21+
$ENV{HOME}/.local/bin
22+
/usr/local/bin
23+
/usr/bin
5424
NO_DEFAULT_PATH
5525
)
5626

57-
if ( "${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND" )
58-
set(CLANG_TIDY_FOUND 0)
59-
message("clang-tidy not found")
60-
else()
61-
set(CLANG_TIDY_FOUND 1)
62-
message("clang-tidy found at ${CLANG_TIDY_BIN}")
63-
endif()
64-
65-
if (CLANG_FORMAT_VERSION)
66-
find_program(CLANG_FORMAT_BIN
67-
NAMES clang-format-${CLANG_FORMAT_VERSION}
68-
PATHS
69-
${ClangTools_PATH}
70-
$ENV{CLANG_TOOLS_PATH}
71-
${USER_CLANG_TOOLS_PATH}
72-
/usr/local/bin /usr/bin
73-
NO_DEFAULT_PATH
74-
)
27+
if ("${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
28+
set(CLANG_TIDY_FOUND 0)
29+
message("clang-tidy not found")
30+
else ()
31+
set(CLANG_TIDY_FOUND 1)
32+
message("clang-tidy found at ${CLANG_TIDY_BIN}")
33+
endif ()
7534

76-
# If not found yet, search alternative locations
77-
if (("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND") AND APPLE)
78-
# Homebrew ships older LLVM versions in /usr/local/opt/llvm@version/
79-
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" CLANG_FORMAT_MAJOR_VERSION "${CLANG_FORMAT_VERSION}")
80-
STRING(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" CLANG_FORMAT_MINOR_VERSION "${CLANG_FORMAT_VERSION}")
81-
if ("${CLANG_FORMAT_MINOR_VERSION}" STREQUAL "0")
82-
find_program(CLANG_FORMAT_BIN
83-
NAMES clang-format
84-
PATHS /usr/local/opt/llvm@${CLANG_FORMAT_MAJOR_VERSION}/bin
85-
NO_DEFAULT_PATH
86-
)
87-
else()
88-
find_program(CLANG_FORMAT_BIN
89-
NAMES clang-format
90-
PATHS /usr/local/opt/llvm@${CLANG_FORMAT_VERSION}/bin
91-
NO_DEFAULT_PATH
92-
)
93-
endif()
94-
endif()
95-
else()
96-
find_program(CLANG_FORMAT_BIN
97-
NAMES
98-
clang-format-14
99-
clang-format-13
100-
clang-format-10
101-
clang-format
102-
PATHS ${ClangTools_PATH} $ENV{CLANG_TOOLS_PATH} ${USER_CLANG_TOOLS_PATH} /usr/local/bin /usr/bin
103-
NO_DEFAULT_PATH
104-
)
105-
endif()
35+
find_program(CLANG_FORMAT_BIN
36+
NAMES
37+
clang-format
38+
PATHS
39+
clang-tidy
40+
PATHS
41+
${USER_CLANG_TOOLS_PATH}
42+
${ClangTools_PATH}
43+
$ENV{CLANG_TOOLS_PATH}
44+
$ENV{HOME}/.local/bin
45+
/usr/local/bin
46+
/usr/bin
47+
NO_DEFAULT_PATH
48+
)
10649

107-
if ( "${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND" )
108-
set(CLANG_FORMAT_FOUND 0)
109-
message("clang-format not found")
110-
else()
111-
set(CLANG_FORMAT_FOUND 1)
112-
message("clang-format found at ${CLANG_FORMAT_BIN}")
113-
endif()
50+
if ("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND")
51+
set(CLANG_FORMAT_FOUND 0)
52+
message("clang-format not found")
53+
else ()
54+
set(CLANG_FORMAT_FOUND 1)
55+
message("clang-format found at ${CLANG_FORMAT_BIN}")
56+
endif ()
11457

cmake/MilvusProtoGen.cmake

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
include_guard(GLOBAL)
1818

19-
set(PROTO_VERSION v2.2.11)
19+
set(PROTO_VERSION v2.3.5)
2020
set(PROTO_URL https://github.com/milvus-io/milvus-proto/archive/refs/tags/${PROTO_VERSION}.tar.gz)
2121

2222

@@ -75,6 +75,8 @@ endfunction(add_proto_service target name)
7575
function(add_milvus_protos target)
7676
add_proto_source(${target} "schema")
7777
add_proto_source(${target} "common")
78+
add_proto_source(${target} "msg")
79+
add_proto_source(${target} "feder")
7880
add_proto_source(${target} "milvus")
7981
add_proto_service(${target} "milvus")
8082
target_include_directories(${target} PRIVATE ${milvus_proto_BINARY_DIR})

cmake/ThirdPartyPackages.cmake

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ include_guard(GLOBAL)
1919
include(FetchContent)
2020

2121
set(GRPC_VERSION 1.49.1)
22-
set(NLOHMANN_JSON_VERSION 3.11.2)
22+
set(NLOHMANN_JSON_VERSION 3.11.3)
2323
set(GOOGLETEST_VERSION 1.12.1)
2424

2525
# grpc
@@ -62,6 +62,7 @@ else ()
6262
set(gRPC_PROTOBUF_PROVIDER "module" CACHE INTERNAL "")
6363
set(gRPC_BUILD_TESTS OFF CACHE INTERNAL "")
6464
set(RE2_BUILD_TESTING OFF CACHE INTERNAL "")
65+
set(ABSL_ENABLE_INSTALL ON CACHE INTERNAL "")
6566
set(ABSL_PROPAGATE_CXX_STD ON CACHE INTERNAL "")
6667
add_subdirectory(${grpc_SOURCE_DIR} ${grpc_BINARY_DIR} EXCLUDE_FROM_ALL)
6768
add_library(gRPC::grpc++ ALIAS grpc++)

examples/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
cmake_minimum_required(VERSION 3.12)
1818
project(milvus_sdk_example LANGUAGES CXX C)
1919

20-
set(CMAKE_CXX_STANDARD 11)
20+
set(CMAKE_CXX_STANDARD 14)
2121
set(CMAKE_CXX_STANDARD_REQUIRED on)
2222

2323
message(STATUS " CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")

scripts/install_deps.sh

+11-43
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ check_sudo() {
88
fi
99
}
1010

11-
get_cmake_version() {
12-
if [ -x "$(command -v cmake)" ] ; then
13-
expr $(cmake --version | grep version | sed 's/\./ /g' | awk '{printf "%02d%02d", $3, $4}')
14-
else
15-
echo 0
16-
fi
11+
install_linux_cmake_clang_toolchain() {
12+
pip3 install --user -U pip scikit-build wheel
13+
pip3 install --user cmake clang-tidy~=17.0 clang-format~=17.0
1714
}
1815

1916
install_deps_for_ubuntu_common() {
@@ -30,30 +27,8 @@ install_deps_for_ubuntu_common() {
3027
fi
3128

3229
${SUDO} apt-get -y install python2.7 gpg wget gcc g++ ccache make \
33-
libssl-dev iwyu lcov git
34-
35-
# for cmake >= 3.12
36-
current_cmake_version=$(get_cmake_version)
37-
if [ $current_cmake_version -lt 312 ] ; then
38-
${SUDO} rm -f /usr/share/keyrings/kitware-archive-keyring.gpg /etc/apt/sources.list.d/kitware.list
39-
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | ${SUDO} tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
40-
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ${dist} main" | ${SUDO} tee /etc/apt/sources.list.d/kitware.list >/dev/null
41-
${SUDO} apt-get update
42-
${SUDO} apt-get -y install kitware-archive-keyring
43-
${SUDO} apt-get -y install cmake
44-
fi
45-
46-
llvm_version=14
47-
if [ "${dist}" = "bionic" ] ; then
48-
llvm_version=13
49-
fi
50-
51-
# install stable clang-tidy clang-format
52-
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | ${SUDO} apt-key add -
53-
${SUDO} apt-get -y install software-properties-common
54-
${SUDO} add-apt-repository -y "deb http://apt.llvm.org/${dist}/ llvm-toolchain-${dist}-${llvm_version} main"
55-
${SUDO} apt-get update
56-
${SUDO} apt-get install -y clang-format-${llvm_version} clang-tidy-${llvm_version}
30+
libssl-dev iwyu lcov git python3-pip
31+
install_linux_cmake_clang_toolchain
5732
}
5833

5934
install_deps_for_ubuntu_1804() {
@@ -70,41 +45,34 @@ install_deps_for_ubuntu_2204() {
7045

7146
install_deps_for_fedora_common() {
7247
check_sudo
73-
${SUDO} dnf -y install gcc gcc-c++ python2 gpg wget ccache make openssl-devel which lcov git rpm-build
74-
${SUDO} dnf -y install cmake
48+
${SUDO} dnf -y install gcc gcc-c++ python2 gpg wget ccache make openssl-devel which lcov git rpm-build python3-pip
49+
install_linux_cmake_clang_toolchain
7550
}
7651

7752
install_deps_for_centos_8() {
7853
check_sudo
7954
${SUDO} dnf -y install epel-release
80-
${SUDO} dnf -y install gcc gcc-c++ python2 gpg wget ccache make openssl-devel which lcov git rpm-build
55+
${SUDO} dnf -y install gcc gcc-c++ python2 gpg wget ccache make openssl-devel which lcov git rpm-build python3-pip
8156
${SUDO} dnf -y install cmake
8257
}
8358

8459
install_deps_for_centos_7() {
8560
check_sudo
8661
${SUDO} yum -y install epel-release centos-release-scl
87-
${SUDO} yum -y install gcc gcc-c++ python gpg wget ccache make openssl-devel which lcov git rpm-build
62+
${SUDO} yum -y install gcc gcc-c++ python gpg wget ccache make openssl-devel which lcov git rpm-build python3-pip
8863
${SUDO} yum -y install devtoolset-7
8964

9065
scl enable devtoolset-7 bash
91-
92-
# for cmake >= 3.12, using cmake3 from epel
93-
current_cmake_version=$(get_cmake_version)
94-
if [ $current_cmake_version -lt 312 ] ; then
95-
${SUDO} yum -y install cmake3
96-
test -L /usr/local/bin/cmake && ${SUDO} unlink /usr/local/bin/cmake
97-
${SUDO} ln -s /usr/bin/cmake3 /usr/local/bin/cmake
98-
fi
9966
}
10067

10168
install_deps_for_macos() {
10269
if [ -x "$(command -v brew)" ] ; then
103-
brew install wget lcov llvm openssl@3 cmake ccache
70+
brew install wget lcov llvm openssl@3 ccache
10471
else
10572
echo 'Detect using macos but brew seems not installed.'
10673
exit 1
10774
fi
75+
install_linux_cmake_clang_toolchain
10876
}
10977

11078
if uname | grep -wq Linux ; then

src/impl/MilvusClientImpl.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ MilvusClientImpl::LoadCollection(const std::string& collection_name, int replica
147147
CollectionsInfo collections_info;
148148
auto collection_names = std::vector<std::string>{collection_name};
149149
auto status = ShowCollections(collection_names, collections_info);
150-
if (not status.IsOk()) {
150+
if (!status.IsOk()) {
151151
return status;
152152
}
153153
progress.total_ = collections_info.size();
@@ -336,7 +336,7 @@ MilvusClientImpl::LoadPartitions(const std::string& collection_name, const std::
336336
[&collection_name, &partition_names, this](Progress& progress) -> Status {
337337
PartitionsInfo partitions_info;
338338
auto status = ShowPartitions(collection_name, partition_names, partitions_info);
339-
if (not status.IsOk()) {
339+
if (!status.IsOk()) {
340340
return status;
341341
}
342342
progress.total_ = partition_names.size();
@@ -504,7 +504,7 @@ MilvusClientImpl::CreateIndex(const std::string& collection_name, const IndexDes
504504
[&collection_name, &index_desc, this](Progress& progress) -> Status {
505505
IndexState index_state;
506506
auto status = GetIndexState(collection_name, index_desc.FieldName(), index_state);
507-
if (not status.IsOk()) {
507+
if (!status.IsOk()) {
508508
return status;
509509
}
510510

@@ -963,7 +963,7 @@ MilvusClientImpl::Flush(const std::vector<std::string>& collection_names, const
963963
for (auto iter = flush_segments.begin(); iter != flush_segments.end();) {
964964
bool flushed = false;
965965
Status status = GetFlushState(iter->second, flushed);
966-
if (not status.IsOk()) {
966+
if (!status.IsOk()) {
967967
return status;
968968
}
969969

@@ -1240,7 +1240,7 @@ MilvusClientImpl::waitForStatus(std::function<Status(Progress&)> query_function,
12401240
auto status = query_function(current_progress);
12411241

12421242
// if the internal check function failed, return error
1243-
if (not status.IsOk()) {
1243+
if (!status.IsOk()) {
12441244
return status;
12451245
}
12461246

0 commit comments

Comments
 (0)