Skip to content

Commit

Permalink
use proto for milvus 2.3.5
Browse files Browse the repository at this point in the history
Signed-off-by: Ji Bin <[email protected]>
  • Loading branch information
matrixji committed Jan 13, 2024
1 parent 4d56589 commit 3adb81a
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 177 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ColumnLimit: 120
IndentWidth: 4
AccessModifierOffset: -3
AlwaysBreakAfterReturnType: All
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AlignTrailingComments: true
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# The checks defined here will be run and will display by default as warnings.
Checks: >
-*, clang-diagnostic-*, -clang-diagnostic-error,
clang-analyzer-*, -clang-analyzer-alpha*,
clang-analyzer-*, -clang-analyzer-alpha*, -clang-diagnostic-deprecated*,
google-*, -google-runtime-references, -google-readability-todo, -google-default-arguments,
modernize-*, -modernize-pass-by-value, -modernize-use-equals-default, -modernize-use-trailing-return-type,
performance-faster-string-find, performance-for-range-copy,
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ jobs:
CCACHE_COMPRESSLEVEL: 5
CCACHE_MAXSIZE: 2G
steps:
- name: Env
run: echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Checkout
uses: actions/checkout@v3
- name: Cache ccache
Expand Down Expand Up @@ -98,6 +100,8 @@ jobs:
CCACHE_COMPRESSLEVEL: 5
CCACHE_MAXSIZE: 2G
steps:
- name: Env
run: echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Checkout
uses: actions/checkout@v3
- name: Cache ccache
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ project(milvus_sdk LANGUAGES CXX)

set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

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

Expand Down
149 changes: 46 additions & 103 deletions cmake/FindClangTools.cmake
Original file line number Diff line number Diff line change
@@ -1,114 +1,57 @@
# Licensed to the LF AI & Data foundation 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.
#
# Tries to find the clang-tidy and clang-format modules
#
# Usage of this module as follows:
#
# find_package(ClangTools)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# ClangToolsBin_HOME -
# When set, this path is inspected instead of standard library binary locations
# to find clang-tidy and clang-format
#
# This module defines
# CLANG_TIDY_BIN, The path to the clang tidy binary
# CLANG_TIDY_FOUND, Whether clang tidy was found
# CLANG_FORMAT_BIN, The path to the clang format binary
# CLANG_TIDY_FOUND, Whether clang format was found
# use pip install clang-tidy & clang-format

if (CMAKE_HOST_APPLE)
execute_process(
COMMAND brew --prefix llvm
OUTPUT_VARIABLE USER_LLVM_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY
)
set(USER_CLANG_TOOLS_PATH ${USER_LLVM_PATH}/bin)
message(STATUS ${USER_CLANG_TOOLS_PATH})
execute_process(
COMMAND brew --prefix llvm
OUTPUT_VARIABLE USER_LLVM_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY
)
set(USER_CLANG_TOOLS_PATH ${USER_LLVM_PATH}/bin)
message(STATUS ${USER_CLANG_TOOLS_PATH})
endif ()

find_program(CLANG_TIDY_BIN
NAMES
clang-tidy-14
clang-tidy-13
clang-tidy-10
clang-tidy
PATHS ${ClangTools_PATH} $ENV{CLANG_TOOLS_PATH} ${USER_CLANG_TOOLS_PATH} /usr/local/bin /usr/bin
NAMES
clang-tidy
PATHS
${USER_CLANG_TOOLS_PATH}
${ClangTools_PATH}
$ENV{CLANG_TOOLS_PATH}
$ENV{HOME}/.local/bin
/usr/local/bin
/usr/bin
NO_DEFAULT_PATH
)

if ( "${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND" )
set(CLANG_TIDY_FOUND 0)
message("clang-tidy not found")
else()
set(CLANG_TIDY_FOUND 1)
message("clang-tidy found at ${CLANG_TIDY_BIN}")
endif()

if (CLANG_FORMAT_VERSION)
find_program(CLANG_FORMAT_BIN
NAMES clang-format-${CLANG_FORMAT_VERSION}
PATHS
${ClangTools_PATH}
$ENV{CLANG_TOOLS_PATH}
${USER_CLANG_TOOLS_PATH}
/usr/local/bin /usr/bin
NO_DEFAULT_PATH
)
if ("${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
set(CLANG_TIDY_FOUND 0)
message("clang-tidy not found")
else ()
set(CLANG_TIDY_FOUND 1)
message("clang-tidy found at ${CLANG_TIDY_BIN}")
endif ()

# If not found yet, search alternative locations
if (("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND") AND APPLE)
# Homebrew ships older LLVM versions in /usr/local/opt/llvm@version/
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" CLANG_FORMAT_MAJOR_VERSION "${CLANG_FORMAT_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" CLANG_FORMAT_MINOR_VERSION "${CLANG_FORMAT_VERSION}")
if ("${CLANG_FORMAT_MINOR_VERSION}" STREQUAL "0")
find_program(CLANG_FORMAT_BIN
NAMES clang-format
PATHS /usr/local/opt/llvm@${CLANG_FORMAT_MAJOR_VERSION}/bin
NO_DEFAULT_PATH
)
else()
find_program(CLANG_FORMAT_BIN
NAMES clang-format
PATHS /usr/local/opt/llvm@${CLANG_FORMAT_VERSION}/bin
NO_DEFAULT_PATH
)
endif()
endif()
else()
find_program(CLANG_FORMAT_BIN
NAMES
clang-format-14
clang-format-13
clang-format-10
clang-format
PATHS ${ClangTools_PATH} $ENV{CLANG_TOOLS_PATH} ${USER_CLANG_TOOLS_PATH} /usr/local/bin /usr/bin
NO_DEFAULT_PATH
)
endif()
find_program(CLANG_FORMAT_BIN
NAMES
clang-format
PATHS
clang-tidy
PATHS
${USER_CLANG_TOOLS_PATH}
${ClangTools_PATH}
$ENV{CLANG_TOOLS_PATH}
$ENV{HOME}/.local/bin
/usr/local/bin
/usr/bin
NO_DEFAULT_PATH
)

if ( "${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND" )
set(CLANG_FORMAT_FOUND 0)
message("clang-format not found")
else()
set(CLANG_FORMAT_FOUND 1)
message("clang-format found at ${CLANG_FORMAT_BIN}")
endif()
if ("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND")
set(CLANG_FORMAT_FOUND 0)
message("clang-format not found")
else ()
set(CLANG_FORMAT_FOUND 1)
message("clang-format found at ${CLANG_FORMAT_BIN}")
endif ()

4 changes: 3 additions & 1 deletion cmake/MilvusProtoGen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

include_guard(GLOBAL)

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


Expand Down Expand Up @@ -75,6 +75,8 @@ endfunction(add_proto_service target name)
function(add_milvus_protos target)
add_proto_source(${target} "schema")
add_proto_source(${target} "common")
add_proto_source(${target} "msg")
add_proto_source(${target} "feder")
add_proto_source(${target} "milvus")
add_proto_service(${target} "milvus")
target_include_directories(${target} PRIVATE ${milvus_proto_BINARY_DIR})
Expand Down
3 changes: 2 additions & 1 deletion cmake/ThirdPartyPackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include_guard(GLOBAL)
include(FetchContent)

set(GRPC_VERSION 1.49.1)
set(NLOHMANN_JSON_VERSION 3.11.2)
set(NLOHMANN_JSON_VERSION 3.11.3)
set(GOOGLETEST_VERSION 1.12.1)

# grpc
Expand Down Expand Up @@ -62,6 +62,7 @@ else ()
set(gRPC_PROTOBUF_PROVIDER "module" CACHE INTERNAL "")
set(gRPC_BUILD_TESTS OFF CACHE INTERNAL "")
set(RE2_BUILD_TESTING OFF CACHE INTERNAL "")
set(ABSL_ENABLE_INSTALL ON CACHE INTERNAL "")
set(ABSL_PROPAGATE_CXX_STD ON CACHE INTERNAL "")
add_subdirectory(${grpc_SOURCE_DIR} ${grpc_BINARY_DIR} EXCLUDE_FROM_ALL)
add_library(gRPC::grpc++ ALIAS grpc++)
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
cmake_minimum_required(VERSION 3.12)
project(milvus_sdk_example LANGUAGES CXX C)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED on)

message(STATUS " CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
Expand Down
57 changes: 13 additions & 44 deletions scripts/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ check_sudo() {
fi
}

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

install_deps_for_ubuntu_common() {
Expand All @@ -30,30 +27,8 @@ install_deps_for_ubuntu_common() {
fi

${SUDO} apt-get -y install python2.7 gpg wget gcc g++ ccache make \
libssl-dev iwyu lcov git

# for cmake >= 3.12
current_cmake_version=$(get_cmake_version)
if [ $current_cmake_version -lt 312 ] ; then
${SUDO} rm -f /usr/share/keyrings/kitware-archive-keyring.gpg /etc/apt/sources.list.d/kitware.list
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
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
${SUDO} apt-get update
${SUDO} apt-get -y install kitware-archive-keyring
${SUDO} apt-get -y install cmake
fi

llvm_version=14
if [ "${dist}" = "bionic" ] ; then
llvm_version=13
fi

# install stable clang-tidy clang-format
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | ${SUDO} apt-key add -
${SUDO} apt-get -y install software-properties-common
${SUDO} add-apt-repository -y "deb http://apt.llvm.org/${dist}/ llvm-toolchain-${dist}-${llvm_version} main"
${SUDO} apt-get update
${SUDO} apt-get install -y clang-format-${llvm_version} clang-tidy-${llvm_version}
libssl-dev iwyu lcov git python3-pip
install_linux_cmake_clang_toolchain
}

install_deps_for_ubuntu_1804() {
Expand All @@ -70,41 +45,35 @@ install_deps_for_ubuntu_2204() {

install_deps_for_fedora_common() {
check_sudo
${SUDO} dnf -y install gcc gcc-c++ python2 gpg wget ccache make openssl-devel which lcov git rpm-build
${SUDO} dnf -y install cmake
${SUDO} dnf -y install gcc gcc-c++ python2 gpg wget ccache make openssl-devel which lcov git rpm-build python3-pip
install_linux_cmake_clang_toolchain
}

install_deps_for_centos_8() {
check_sudo
${SUDO} dnf -y install epel-release
${SUDO} dnf -y install gcc gcc-c++ python2 gpg wget ccache make openssl-devel which lcov git rpm-build
${SUDO} dnf -y install cmake
${SUDO} dnf -y install gcc gcc-c++ python2 gpg wget ccache make openssl-devel which lcov git rpm-build python3-pip
install_linux_cmake_clang_toolchain
}

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

scl enable devtoolset-7 bash

# for cmake >= 3.12, using cmake3 from epel
current_cmake_version=$(get_cmake_version)
if [ $current_cmake_version -lt 312 ] ; then
${SUDO} yum -y install cmake3
test -L /usr/local/bin/cmake && ${SUDO} unlink /usr/local/bin/cmake
${SUDO} ln -s /usr/bin/cmake3 /usr/local/bin/cmake
fi
install_linux_cmake_clang_toolchain
}

install_deps_for_macos() {
if [ -x "$(command -v brew)" ] ; then
brew install wget lcov llvm openssl@3 cmake ccache
brew install wget lcov llvm openssl@3 ccache
else
echo 'Detect using macos but brew seems not installed.'
exit 1
fi
install_linux_cmake_clang_toolchain
}

if uname | grep -wq Linux ; then
Expand Down
10 changes: 5 additions & 5 deletions src/impl/MilvusClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ MilvusClientImpl::LoadCollection(const std::string& collection_name, int replica
CollectionsInfo collections_info;
auto collection_names = std::vector<std::string>{collection_name};
auto status = ShowCollections(collection_names, collections_info);
if (not status.IsOk()) {
if (!status.IsOk()) {
return status;
}
progress.total_ = collections_info.size();
Expand Down Expand Up @@ -336,7 +336,7 @@ MilvusClientImpl::LoadPartitions(const std::string& collection_name, const std::
[&collection_name, &partition_names, this](Progress& progress) -> Status {
PartitionsInfo partitions_info;
auto status = ShowPartitions(collection_name, partition_names, partitions_info);
if (not status.IsOk()) {
if (!status.IsOk()) {
return status;
}
progress.total_ = partition_names.size();
Expand Down Expand Up @@ -504,7 +504,7 @@ MilvusClientImpl::CreateIndex(const std::string& collection_name, const IndexDes
[&collection_name, &index_desc, this](Progress& progress) -> Status {
IndexState index_state;
auto status = GetIndexState(collection_name, index_desc.FieldName(), index_state);
if (not status.IsOk()) {
if (!status.IsOk()) {
return status;
}

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

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

// if the internal check function failed, return error
if (not status.IsOk()) {
if (!status.IsOk()) {
return status;
}

Expand Down
Loading

0 comments on commit 3adb81a

Please sign in to comment.