diff --git a/.clang-format b/.clang-format
index 819c2d361ed02883dd895ad4a5caa7706d460257..73dc2aeb8ff1d339d0f4c72513e1f421806a2d36 100644
--- a/.clang-format
+++ b/.clang-format
@@ -18,3 +18,10 @@
BasedOnStyle: Google
DerivePointerAlignment: false
ColumnLimit: 120
+IndentWidth: 4
+AccessModifierOffset: -3
+AlwaysBreakAfterReturnType: All
+AllowShortBlocksOnASingleLine: false
+AllowShortFunctionsOnASingleLine: false
+AllowShortIfStatementsOnASingleLine: false
+AlignTrailingComments: true
diff --git a/.clang-tidy b/.clang-tidy
index 1f7850efe7c624ae8a22700f247c10126f160d10..1695fa668541bf56dbed074b8860347985116218 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -18,8 +18,10 @@
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,modernize-*,readability-*'
# produce HeaderFilterRegex from cpp/build-support/lint_exclusions.txt with:
# echo -n '^('; sed -e 's/*/\.*/g' cpp/build-support/lint_exclusions.txt | tr '\n' '|'; echo ')$'
-HeaderFilterRegex: '^(.*cmake-build-debug.*|.*cmake-build-release.*|.*cmake_build.*|.*src/thirdparty.*|.*src/core/thirdparty.*|.*src/grpc.*|)$'
+HeaderFilterRegex: '^(.*cmake-build-debug.*|.*cmake-build-release.*|.*cmake_build.*|.*src/core/thirdparty.*|.*thirdparty.*|.*easylogging++.*|.*SqliteMetaImpl.cpp|.*src/grpc.*|.*src/core.*|.*src/wrapper.*)$'
AnalyzeTemporaryDtors: true
+ChainedConditionalReturn: 1
+ChainedConditionalAssignment: 1
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
diff --git a/ci/jenkinsfile/milvus_build.groovy b/ci/jenkinsfile/milvus_build.groovy
index 44895ed5c95a43104bc91112b53cd5abb24160c6..61307664006028b1969f04fac82bad41a1df8652 100644
--- a/ci/jenkinsfile/milvus_build.groovy
+++ b/ci/jenkinsfile/milvus_build.groovy
@@ -9,6 +9,7 @@ container('milvus-build-env') {
sh "git config --global user.email \"test@zilliz.com\""
sh "git config --global user.name \"test\""
withCredentials([usernamePassword(credentialsId: "${params.JFROG_USER}", usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
+ sh "./build.sh -l"
sh "export JFROG_ARTFACTORY_URL='${params.JFROG_ARTFACTORY_URL}' && export JFROG_USER_NAME='${USERNAME}' && export JFROG_PASSWORD='${PASSWORD}' && ./build.sh -t ${params.BUILD_TYPE} -j -u -c"
}
}
diff --git a/ci/jenkinsfile/milvus_build_no_ut.groovy b/ci/jenkinsfile/milvus_build_no_ut.groovy
index a807ec7ad450b1f15ef4a2cfeb0f84bf7e2023c3..f72089e8c3994ed0543f7d3e567d57d54b50d190 100644
--- a/ci/jenkinsfile/milvus_build_no_ut.groovy
+++ b/ci/jenkinsfile/milvus_build_no_ut.groovy
@@ -9,6 +9,7 @@ container('milvus-build-env') {
sh "git config --global user.email \"test@zilliz.com\""
sh "git config --global user.name \"test\""
withCredentials([usernamePassword(credentialsId: "${params.JFROG_USER}", usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
+ sh "./build.sh -l"
sh "export JFROG_ARTFACTORY_URL='${params.JFROG_ARTFACTORY_URL}' && export JFROG_USER_NAME='${USERNAME}' && export JFROG_PASSWORD='${PASSWORD}' && ./build.sh -t ${params.BUILD_TYPE} -j"
}
}
diff --git a/ci/main_jenkinsfile b/ci/main_jenkinsfile
index 40224fe89467b2a8d590431c989708492d11bfe6..12c6c81cfda6bc5c9d2b2b426dd1f801723b0233 100644
--- a/ci/main_jenkinsfile
+++ b/ci/main_jenkinsfile
@@ -33,12 +33,30 @@ pipeline {
cloud 'build-kubernetes'
label 'build'
defaultContainer 'jnlp'
- containerTemplate {
- name 'milvus-build-env'
- image 'registry.zilliz.com/milvus/milvus-build-env:v0.12'
- ttyEnabled true
- command 'cat'
- }
+ yaml """
+apiVersion: v1
+kind: Pod
+metadata:
+ name: milvus-build-env
+ labels:
+ app: milvus
+ componet: build-env
+spec:
+ containers:
+ - name: milvus-build-env
+ image: registry.zilliz.com/milvus/milvus-build-env:v0.13
+ command:
+ - cat
+ tty: true
+ resources:
+ limits:
+ memory: "28Gi"
+ cpu: "10.0"
+ nvidia.com/gpu: 1
+ requests:
+ memory: "14Gi"
+ cpu: "5.0"
+"""
}
}
stages {
diff --git a/ci/main_jenkinsfile_no_ut b/ci/main_jenkinsfile_no_ut
index 9948322c3f2964406e895b4b9db860586743ff92..e7382bd1fd2f324c2b31d35e55b64fb3b78f0578 100644
--- a/ci/main_jenkinsfile_no_ut
+++ b/ci/main_jenkinsfile_no_ut
@@ -33,12 +33,30 @@ pipeline {
cloud 'build-kubernetes'
label 'build'
defaultContainer 'jnlp'
- containerTemplate {
- name 'milvus-build-env'
- image 'registry.zilliz.com/milvus/milvus-build-env:v0.12'
- ttyEnabled true
- command 'cat'
- }
+ yaml """
+apiVersion: v1
+kind: Pod
+metadata:
+ name: milvus-build-env
+ labels:
+ app: milvus
+ componet: build-env
+spec:
+ containers:
+ - name: milvus-build-env
+ image: registry.zilliz.com/milvus/milvus-build-env:v0.13
+ command:
+ - cat
+ tty: true
+ resources:
+ limits:
+ memory: "28Gi"
+ cpu: "10.0"
+ nvidia.com/gpu: 1
+ requests:
+ memory: "14Gi"
+ cpu: "5.0"
+"""
}
}
stages {
diff --git a/ci/nightly_main_jenkinsfile b/ci/nightly_main_jenkinsfile
index 28352e0c83a8ecfd7eeba31a38099353624f8332..add9e00fb4b75bd32c0ec74c645c8b94a2e57a01 100644
--- a/ci/nightly_main_jenkinsfile
+++ b/ci/nightly_main_jenkinsfile
@@ -33,12 +33,30 @@ pipeline {
cloud 'build-kubernetes'
label 'build'
defaultContainer 'jnlp'
- containerTemplate {
- name 'milvus-build-env'
- image 'registry.zilliz.com/milvus/milvus-build-env:v0.12'
- ttyEnabled true
- command 'cat'
- }
+ yaml """
+apiVersion: v1
+kind: Pod
+metadata:
+ name: milvus-build-env
+ labels:
+ app: milvus
+ componet: build-env
+spec:
+ containers:
+ - name: milvus-build-env
+ image: registry.zilliz.com/milvus/milvus-build-env:v0.13
+ command:
+ - cat
+ tty: true
+ resources:
+ limits:
+ memory: "28Gi"
+ cpu: "10.0"
+ nvidia.com/gpu: 1
+ requests:
+ memory: "14Gi"
+ cpu: "5.0"
+"""
}
}
stages {
diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md
index 33d34fcd34cbf02a3d583bab74c4556f150f1ac3..ea4298152b09af183b8ac69551a8c621fb130f8d 100644
--- a/cpp/CHANGELOG.md
+++ b/cpp/CHANGELOG.md
@@ -9,21 +9,32 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-572 - Milvus crash when get SIGINT
- MS-577 - Unittest Query randomly hung
- MS-587 - Count get wrong result after adding vectors and index built immediately
+- MS-599 - search wrong result when table created with metric_type: IP
+- MS-601 - Docker logs error caused by get CPUTemperature error
+- MS-622 - Delete vectors should be failed if date range is invalid
+- MS-620 - Get table row counts display wrong error code
## Improvement
- MS-552 - Add and change the easylogging library
- MS-553 - Refine cache code
-- MS-557 - Merge Log.h
+- MS-555 - Remove old scheduler
- MS-556 - Add Job Definition in Scheduler
+- MS-557 - Merge Log.h
- MS-558 - Refine status code
- MS-562 - Add JobMgr and TaskCreator in Scheduler
- MS-566 - Refactor cmake
-- MS-555 - Remove old scheduler
- MS-574 - Milvus configuration refactor
- MS-578 - Make sure milvus5.0 don't crack 0.3.1 data
- MS-585 - Update namespace in scheduler
+- MS-606 - Speed up result reduce
+- MS-608 - Update TODO names
+- MS-609 - Update task construct function
+- MS-611 - Add resources validity check in ResourceMgr
+- MS-619 - Add optimizer class in scheduler
+- MS-614 - Preload table at startup
## New Feature
+- MS-627 - Integrate new index: IVFSQHybrid
## Task
- MS-554 - Change license to Apache 2.0
@@ -33,6 +44,9 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-575 - Add Clang-format & Clang-tidy & Cpplint
- MS-586 - Remove BUILD_FAISS_WITH_MKL option
- MS-590 - Refine cmake code to support cpplint
+- MS-600 - Reconstruct unittest code
+- MS-602 - Remove zilliz namespace
+- MS-610 - Change error code base value from hex to decimal
# Milvus 0.4.0 (2019-09-12)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index cc807d43ed4cfa238283566f8a8fb9bf7f1c12b8..d2092eb018444d3e207b42596d5903bc11ced4dc 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -189,7 +189,7 @@ add_custom_target(lint
--exclude_globs
${LINT_EXCLUSIONS_FILE}
--source_dir
- ${CMAKE_CURRENT_SOURCE_DIR}/src
+ ${CMAKE_CURRENT_SOURCE_DIR}
${MILVUS_LINT_QUIET})
#
diff --git a/cpp/README.md b/cpp/README.md
index f5f77d25f8bcd9edb5bba76b354fd2a0fa9bccd4..6e81b567ffd15b94fb6cd61b3a162723f933703d 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -105,15 +105,31 @@ please reinstall CMake with curl:
```
##### code format and linting
-
+Install clang-format and clang-tidy
```shell
CentOS 7:
$ yum install clang
-Ubuntu 16.04 or 18.04:
-$ sudo apt-get install clang-format clang-tidy
-
+Ubuntu 16.04:
+$ sudo apt-get install clang-tidy
+$ sudo su
+$ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
+$ apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main"
+$ apt-get update
+$ apt-get install clang-format-6.0
+Ubuntu 18.04:
+$ sudo apt-get install clang-tidy clang-format
+
+$ rm cmake_build/CMakeCache.txt
+```
+Check code style
+```shell
$ ./build.sh -l
```
+To format the code
+```shell
+$ cd cmake_build
+$ make clang-format
+```
##### Run unit test
@@ -122,13 +138,14 @@ $ ./build.sh -u
```
##### Run code coverage
-
+Install lcov
```shell
CentOS 7:
$ yum install lcov
Ubuntu 16.04 or 18.04:
$ sudo apt-get install lcov
-
+```
+```shell
$ ./build.sh -u -c
```
diff --git a/cpp/build-support/code_style_clion.xml b/cpp/build-support/code_style_clion.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f2edeec3b640cb4f7d29cf065185e690ea1e9c11
--- /dev/null
+++ b/cpp/build-support/code_style_clion.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cpp/build-support/lint_exclusions.txt b/cpp/build-support/lint_exclusions.txt
index 27bd780f42c9261f14129cc23836a365c60fdcdd..6ac690f661f56473d28d1bf476ccef9d7a944c81 100644
--- a/cpp/build-support/lint_exclusions.txt
+++ b/cpp/build-support/lint_exclusions.txt
@@ -1,8 +1,9 @@
*cmake-build-debug*
*cmake-build-release*
*cmake_build*
-*src/thirdparty*
*src/core/thirdparty*
-*src/grpc*
+*thirdparty*
*easylogging++*
-*SqliteMetaImpl.cpp
\ No newline at end of file
+*SqliteMetaImpl.cpp
+*src/grpc*
+*milvus/include*
\ No newline at end of file
diff --git a/cpp/build.sh b/cpp/build.sh
index 4087db45928118ed23f0cc8caab1100c54abe799..648206f9ae62c77b2e98338769904ee17f9516f4 100755
--- a/cpp/build.sh
+++ b/cpp/build.sh
@@ -99,21 +99,26 @@ if [[ ${RUN_CPPLINT} == "ON" ]]; then
# cpplint check
make lint
if [ $? -ne 0 ]; then
- echo "ERROR! cpplint check not pass"
+ echo "ERROR! cpplint check failed"
exit 1
fi
+ echo "cpplint check passed!"
+
# clang-format check
make check-clang-format
if [ $? -ne 0 ]; then
echo "ERROR! clang-format check failed"
exit 1
fi
- # clang-tidy check
- make check-clang-tidy
- if [ $? -ne 0 ]; then
- echo "ERROR! clang-tidy check failed"
- exit 1
- fi
+ echo "clang-format check passed!"
+
+# # clang-tidy check
+# make check-clang-tidy
+# if [ $? -ne 0 ]; then
+# echo "ERROR! clang-tidy check failed"
+# exit 1
+# fi
+# echo "clang-tidy check passed!"
else
# compile and build
make -j 4 || exit 1
diff --git a/cpp/conf/server_config.template b/cpp/conf/server_config.template
index b49b5855f5c97b3dad15ed9499a8cc318a2c6389..2f2f699e09fcee5b4f585b874d5e0f8a24c03913 100644
--- a/cpp/conf/server_config.template
+++ b/cpp/conf/server_config.template
@@ -11,25 +11,30 @@ db_config:
secondary_path: # path used to store data only, split by semicolon
backend_url: sqlite://:@:/ # URI format: dialect://username:password@host:port/database
- # Keep 'dialect://:@:/', and replace other texts with real values.
+ # Keep 'dialect://:@:/', and replace other texts with real values
# Replace 'dialect' with 'mysql' or 'sqlite'
insert_buffer_size: 4 # GB, maximum insert buffer size allowed
+ # sum of insert_buffer_size and cpu_cache_capacity cannot exceed total memory
build_index_gpu: 0 # gpu id used for building index
+ preload_table: # preload data at startup, '*' means load all tables, empty value means no preload
+ # you can specify preload tables like this: table1,table2,table3
+
metric_config:
enable_monitor: false # enable monitoring or not
collector: prometheus # prometheus
prometheus_config:
- port: 8080 # port prometheus used to fetch metrics
+ port: 8080 # port prometheus uses to fetch metrics
cache_config:
- cpu_mem_capacity: 16 # GB, CPU memory used for cache
- cpu_mem_threshold: 0.85 # percentage of data that will be kept when cache cleanup is triggered
+ cpu_cache_capacity: 16 # GB, CPU memory used for cache
+ cpu_cache_threshold: 0.85 # percentage of data that will be kept when cache cleanup is triggered
cache_insert_data: false # whether to load inserted data into cache
engine_config:
- blas_threshold: 20
+ use_blas_threshold: 20 # if nq < use_blas_threshold, use SSE, faster with fluctuated response times
+ # if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
resource_config:
resource_pool:
diff --git a/cpp/coverage.sh b/cpp/coverage.sh
index 84459fcc84e51d504ff6e3d8314600c6eafcc1e8..8a7e5f52a16a7f3204f40bcf04cde274ac7562be 100755
--- a/cpp/coverage.sh
+++ b/cpp/coverage.sh
@@ -70,11 +70,11 @@ fi
for test in `ls ${DIR_UNITTEST}`; do
echo $test
case ${test} in
- db_test)
- # set run args for db_test
+ test_db)
+ # set run args for test_db
args="mysql://${MYSQL_USER_NAME}:${MYSQL_PASSWORD}@${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DB_NAME}"
;;
- *_test)
+ *test_*)
args=""
;;
esac
@@ -104,7 +104,7 @@ ${LCOV_CMD} -r "${FILE_INFO_OUTPUT}" -o "${FILE_INFO_OUTPUT_NEW}" \
"src/metrics/MetricBase.h"\
"src/server/Server.cpp"\
"src/server/DBWrapper.cpp"\
- "src/server/grpc_impl/GrpcMilvusServer.cpp"\
+ "src/server/grpc_impl/GrpcServer.cpp"\
"src/utils/easylogging++.h"\
"src/utils/easylogging++.cc"\
diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt
index 6ee3966c4ffdab88020a4fab70e345565ea4e61b..0005edbaf7daec85fae4f0026c0d61c3eb256e3c 100644
--- a/cpp/src/CMakeLists.txt
+++ b/cpp/src/CMakeLists.txt
@@ -20,29 +20,24 @@
include_directories(${MILVUS_SOURCE_DIR})
include_directories(${MILVUS_ENGINE_SRC})
-add_subdirectory(core)
+include_directories(${CUDA_TOOLKIT_ROOT_DIR}/include)
+include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-status)
+include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-milvus)
+#this statement must put here, since the CORE_INCLUDE_DIRS is defined in code/CMakeList.txt
+add_subdirectory(core)
set(CORE_INCLUDE_DIRS ${CORE_INCLUDE_DIRS} PARENT_SCOPE)
foreach (dir ${CORE_INCLUDE_DIRS})
include_directories(${dir})
endforeach ()
aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_files)
-
aux_source_directory(${MILVUS_ENGINE_SRC}/config config_files)
-
+aux_source_directory(${MILVUS_ENGINE_SRC}/metrics metrics_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db db_main_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/engine db_engine_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/insert db_insert_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/meta db_meta_files)
-aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler db_scheduler_files)
-aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler/context db_scheduler_context_files)
-aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler/task db_scheduler_task_files)
-set(db_scheduler_files
- ${db_scheduler_files}
- ${db_scheduler_context_files}
- ${db_scheduler_task_files}
- )
set(grpc_service_files
${MILVUS_ENGINE_SRC}/grpc/gen-milvus/milvus.grpc.pb.cc
@@ -51,12 +46,11 @@ set(grpc_service_files
${MILVUS_ENGINE_SRC}/grpc/gen-status/status.pb.cc
)
-aux_source_directory(${MILVUS_ENGINE_SRC}/metrics metrics_files)
-
aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler scheduler_main_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/action scheduler_action_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/event scheduler_event_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/job scheduler_job_files)
+aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/optimizer scheduler_optimizer_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/resource scheduler_resource_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/task scheduler_task_files)
set(scheduler_files
@@ -64,15 +58,14 @@ set(scheduler_files
${scheduler_action_files}
${scheduler_event_files}
${scheduler_job_files}
+ ${scheduler_optimizer_files}
${scheduler_resource_files}
${scheduler_task_files}
)
aux_source_directory(${MILVUS_ENGINE_SRC}/server server_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/server/grpc_impl grpc_server_files)
-
aux_source_directory(${MILVUS_ENGINE_SRC}/utils utils_files)
-
aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper wrapper_files)
set(engine_files
@@ -82,16 +75,11 @@ set(engine_files
${db_engine_files}
${db_insert_files}
${db_meta_files}
- ${db_scheduler_files}
${metrics_files}
${utils_files}
${wrapper_files}
)
-include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include")
-include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-status)
-include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-milvus)
-
set(client_grpc_lib
grpcpp_channelz
grpc++
@@ -112,6 +100,12 @@ set(boost_lib
boost_serialization_static
)
+set(cuda_lib
+ ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs/libnvidia-ml.so
+ cudart
+ cublas
+ )
+
set(third_party_libs
sqlite
${client_grpc_lib}
@@ -123,17 +117,15 @@ set(third_party_libs
snappy
zlib
zstd
- cudart
- cublas
+ ${cuda_lib}
mysqlpp
- ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs/libnvidia-ml.so
- cudart
)
+
if (MILVUS_ENABLE_PROFILING STREQUAL "ON")
set(third_party_libs ${third_party_libs}
- gperftools
- libunwind
- )
+ gperftools
+ libunwind
+ )
endif ()
link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64")
@@ -141,7 +133,6 @@ set(engine_libs
pthread
libgomp.a
libgfortran.a
- ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs/libnvidia-ml.so
)
if (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
@@ -152,7 +143,11 @@ if (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
endif ()
cuda_add_library(milvus_engine STATIC ${engine_files})
-target_link_libraries(milvus_engine ${engine_libs} knowhere ${third_party_libs})
+target_link_libraries(milvus_engine
+ knowhere
+ ${engine_libs}
+ ${third_party_libs}
+ )
add_library(metrics STATIC ${metrics_files})
@@ -180,7 +175,9 @@ add_executable(milvus_server
${utils_files}
)
-target_link_libraries(milvus_server ${server_libs})
+target_link_libraries(milvus_server
+ ${server_libs}
+ )
install(TARGETS milvus_server DESTINATION bin)
diff --git a/cpp/src/cache/Cache.h b/cpp/src/cache/Cache.h
index b526e9339f7197ddc7f75d1c0384c48b23878c6c..62a7f13ca854f8b55664a1b72079d3aea5f057b9 100644
--- a/cpp/src/cache/Cache.h
+++ b/cpp/src/cache/Cache.h
@@ -15,55 +15,66 @@
// specific language governing permissions and limitations
// under the License.
-
#pragma once
#include "LRU.h"
#include "utils/Log.h"
-#include
-#include
#include
+#include
#include
+#include
-namespace zilliz {
namespace milvus {
namespace cache {
-template
+template
class Cache {
public:
- //mem_capacity, units:GB
+ // mem_capacity, units:GB
Cache(int64_t capacity_gb, uint64_t cache_max_count);
~Cache() = default;
- int64_t usage() const {
+ int64_t
+ usage() const {
return usage_;
}
- int64_t capacity() const {
+ int64_t
+ capacity() const {
return capacity_;
- } //unit: BYTE
- void set_capacity(int64_t capacity); //unit: BYTE
+ } // unit: BYTE
+ void
+ set_capacity(int64_t capacity); // unit: BYTE
- double freemem_percent() const {
+ double
+ freemem_percent() const {
return freemem_percent_;
}
- void set_freemem_percent(double percent) {
+ void
+ set_freemem_percent(double percent) {
freemem_percent_ = percent;
}
- size_t size() const;
- bool exists(const std::string &key);
- ItemObj get(const std::string &key);
- void insert(const std::string &key, const ItemObj &item);
- void erase(const std::string &key);
- void print();
- void clear();
+ size_t
+ size() const;
+ bool
+ exists(const std::string& key);
+ ItemObj
+ get(const std::string& key);
+ void
+ insert(const std::string& key, const ItemObj& item);
+ void
+ erase(const std::string& key);
+ void
+ print();
+ void
+ clear();
private:
- void free_memory();
+ void
+ free_memory();
private:
int64_t usage_;
@@ -74,8 +85,7 @@ class Cache {
mutable std::mutex mutex_;
};
-} // namespace cache
-} // namespace milvus
-} // namespace zilliz
+} // namespace cache
+} // namespace milvus
#include "cache/Cache.inl"
diff --git a/cpp/src/cache/Cache.inl b/cpp/src/cache/Cache.inl
index ebd8f3c25d2b23fd5adce6e3d50e36efb26a7e0e..2ab6b3ffa66480612e92056d62eefbe03eb809c7 100644
--- a/cpp/src/cache/Cache.inl
+++ b/cpp/src/cache/Cache.inl
@@ -17,7 +17,7 @@
-namespace zilliz {
+
namespace milvus {
namespace cache {
@@ -190,5 +190,5 @@ Cache::print() {
} // namespace cache
} // namespace milvus
-} // namespace zilliz
+
diff --git a/cpp/src/cache/CacheMgr.h b/cpp/src/cache/CacheMgr.h
index 53004d10b23b41a90a7090a114f2ad730e05bff9..f5e04f650968552c01664139b8442b56fddf3868 100644
--- a/cpp/src/cache/CacheMgr.h
+++ b/cpp/src/cache/CacheMgr.h
@@ -15,40 +15,48 @@
// specific language governing permissions and limitations
// under the License.
-
#pragma once
#include "Cache.h"
-#include "utils/Log.h"
#include "metrics/Metrics.h"
+#include "utils/Log.h"
-#include
#include
+#include
-namespace zilliz {
namespace milvus {
namespace cache {
-template
+template
class CacheMgr {
public:
- virtual uint64_t ItemCount() const;
+ virtual uint64_t
+ ItemCount() const;
- virtual bool ItemExists(const std::string &key);
+ virtual bool
+ ItemExists(const std::string& key);
- virtual ItemObj GetItem(const std::string &key);
+ virtual ItemObj
+ GetItem(const std::string& key);
- virtual void InsertItem(const std::string &key, const ItemObj &data);
+ virtual void
+ InsertItem(const std::string& key, const ItemObj& data);
- virtual void EraseItem(const std::string &key);
+ virtual void
+ EraseItem(const std::string& key);
- virtual void PrintInfo();
+ virtual void
+ PrintInfo();
- virtual void ClearCache();
+ virtual void
+ ClearCache();
- int64_t CacheUsage() const;
- int64_t CacheCapacity() const;
- void SetCapacity(int64_t capacity);
+ int64_t
+ CacheUsage() const;
+ int64_t
+ CacheCapacity() const;
+ void
+ SetCapacity(int64_t capacity);
protected:
CacheMgr();
@@ -59,8 +67,7 @@ class CacheMgr {
CachePtr cache_;
};
-} // namespace cache
-} // namespace milvus
-} // namespace zilliz
+} // namespace cache
+} // namespace milvus
#include "cache/CacheMgr.inl"
diff --git a/cpp/src/cache/CacheMgr.inl b/cpp/src/cache/CacheMgr.inl
index b0c47b3dc37f54b6b336fe26f3b292d45ba5697f..23b2f0df743b7b237887fec8d322b413fd34f34f 100644
--- a/cpp/src/cache/CacheMgr.inl
+++ b/cpp/src/cache/CacheMgr.inl
@@ -16,7 +16,7 @@
// under the License.
-namespace zilliz {
+
namespace milvus {
namespace cache {
@@ -142,4 +142,4 @@ CacheMgr::SetCapacity(int64_t capacity) {
} // namespace cache
} // namespace milvus
-} // namespace zilliz
+
diff --git a/cpp/src/cache/CpuCacheMgr.cpp b/cpp/src/cache/CpuCacheMgr.cpp
index d26004b2bef5a843700a288075f825022f5db565..7cfe59e72e58b3bcd91b75a00df87e8f4e030878 100644
--- a/cpp/src/cache/CpuCacheMgr.cpp
+++ b/cpp/src/cache/CpuCacheMgr.cpp
@@ -15,14 +15,12 @@
// specific language governing permissions and limitations
// under the License.
-
#include "cache/CpuCacheMgr.h"
#include "server/Config.h"
#include "utils/Log.h"
#include
-namespace zilliz {
namespace milvus {
namespace cache {
@@ -31,38 +29,38 @@ constexpr int64_t unit = 1024 * 1024 * 1024;
}
CpuCacheMgr::CpuCacheMgr() {
- server::Config &config = server::Config::GetInstance();
+ server::Config& config = server::Config::GetInstance();
Status s;
- int32_t cpu_mem_cap;
- s = config.GetCacheConfigCpuMemCapacity(cpu_mem_cap);
+ int32_t cpu_cache_cap;
+ s = config.GetCacheConfigCpuCacheCapacity(cpu_cache_cap);
if (!s.ok()) {
SERVER_LOG_ERROR << s.message();
}
- int64_t cap = cpu_mem_cap * unit;
+ int64_t cap = cpu_cache_cap * unit;
cache_ = std::make_shared>(cap, 1UL << 32);
- float cpu_mem_threshold;
- s = config.GetCacheConfigCpuMemThreshold(cpu_mem_threshold);
+ float cpu_cache_threshold;
+ s = config.GetCacheConfigCpuCacheThreshold(cpu_cache_threshold);
if (!s.ok()) {
SERVER_LOG_ERROR << s.message();
}
- if (cpu_mem_threshold > 0.0 && cpu_mem_threshold <= 1.0) {
- cache_->set_freemem_percent(cpu_mem_threshold);
+ if (cpu_cache_threshold > 0.0 && cpu_cache_threshold <= 1.0) {
+ cache_->set_freemem_percent(cpu_cache_threshold);
} else {
- SERVER_LOG_ERROR << "Invalid cpu_mem_threshold: " << cpu_mem_threshold
- << ", by default set to " << cache_->freemem_percent();
+ SERVER_LOG_ERROR << "Invalid cpu_cache_threshold: " << cpu_cache_threshold << ", by default set to "
+ << cache_->freemem_percent();
}
}
-CpuCacheMgr *
+CpuCacheMgr*
CpuCacheMgr::GetInstance() {
static CpuCacheMgr s_mgr;
return &s_mgr;
}
engine::VecIndexPtr
-CpuCacheMgr::GetIndex(const std::string &key) {
+CpuCacheMgr::GetIndex(const std::string& key) {
DataObjPtr obj = GetItem(key);
if (obj != nullptr) {
return obj->data();
@@ -71,6 +69,5 @@ CpuCacheMgr::GetIndex(const std::string &key) {
return nullptr;
}
-} // namespace cache
-} // namespace milvus
-} // namespace zilliz
+} // namespace cache
+} // namespace milvus
diff --git a/cpp/src/cache/CpuCacheMgr.h b/cpp/src/cache/CpuCacheMgr.h
index 32a83c4cc0dd6a510f3d9386e410db5651951d8b..2f8c50991a9e50eadf60935bbcc40d3d78de3d4d 100644
--- a/cpp/src/cache/CpuCacheMgr.h
+++ b/cpp/src/cache/CpuCacheMgr.h
@@ -20,10 +20,9 @@
#include "CacheMgr.h"
#include "DataObj.h"
-#include
#include
+#include
-namespace zilliz {
namespace milvus {
namespace cache {
@@ -32,12 +31,13 @@ class CpuCacheMgr : public CacheMgr {
CpuCacheMgr();
public:
- //TODO: use smart pointer instead
- static CpuCacheMgr *GetInstance();
+ // TODO(myh): use smart pointer instead
+ static CpuCacheMgr*
+ GetInstance();
- engine::VecIndexPtr GetIndex(const std::string &key);
+ engine::VecIndexPtr
+ GetIndex(const std::string& key);
};
-} // namespace cache
-} // namespace milvus
-} // namespace zilliz
+} // namespace cache
+} // namespace milvus
diff --git a/cpp/src/cache/DataObj.h b/cpp/src/cache/DataObj.h
index 6ed3256eee1bb22f7a9535af666deceab4509a9b..eb58b708250cbc221361f2b782ac8042a9a8d8a4 100644
--- a/cpp/src/cache/DataObj.h
+++ b/cpp/src/cache/DataObj.h
@@ -15,37 +15,35 @@
// specific language governing permissions and limitations
// under the License.
-
#pragma once
#include "src/wrapper/VecIndex.h"
#include
-namespace zilliz {
namespace milvus {
namespace cache {
class DataObj {
public:
- explicit DataObj(const engine::VecIndexPtr &index)
- : index_(index) {
+ explicit DataObj(const engine::VecIndexPtr& index) : index_(index) {
}
- DataObj(const engine::VecIndexPtr &index, int64_t size)
- : index_(index),
- size_(size) {
+ DataObj(const engine::VecIndexPtr& index, int64_t size) : index_(index), size_(size) {
}
- engine::VecIndexPtr data() {
+ engine::VecIndexPtr
+ data() {
return index_;
}
- const engine::VecIndexPtr &data() const {
+ const engine::VecIndexPtr&
+ data() const {
return index_;
}
- int64_t size() const {
+ int64_t
+ size() const {
if (index_ == nullptr) {
return 0;
}
@@ -64,6 +62,5 @@ class DataObj {
using DataObjPtr = std::shared_ptr;
-} // namespace cache
-} // namespace milvus
-} // namespace zilliz
+} // namespace cache
+} // namespace milvus
diff --git a/cpp/src/cache/GpuCacheMgr.cpp b/cpp/src/cache/GpuCacheMgr.cpp
index ad68a6ebef47ee903e954796abbb05affd4c3192..a9eff6d3c3ceb295675ff3ce35d6be000dceb308 100644
--- a/cpp/src/cache/GpuCacheMgr.cpp
+++ b/cpp/src/cache/GpuCacheMgr.cpp
@@ -15,15 +15,13 @@
// specific language governing permissions and limitations
// under the License.
-
#include "cache/GpuCacheMgr.h"
-#include "utils/Log.h"
#include "server/Config.h"
+#include "utils/Log.h"
#include
#include
-namespace zilliz {
namespace milvus {
namespace cache {
@@ -35,31 +33,31 @@ constexpr int64_t G_BYTE = 1024 * 1024 * 1024;
}
GpuCacheMgr::GpuCacheMgr() {
- server::Config &config = server::Config::GetInstance();
+ server::Config& config = server::Config::GetInstance();
Status s;
- int32_t gpu_mem_cap;
- s = config.GetCacheConfigGpuMemCapacity(gpu_mem_cap);
+ int32_t gpu_cache_cap;
+ s = config.GetCacheConfigGpuCacheCapacity(gpu_cache_cap);
if (!s.ok()) {
SERVER_LOG_ERROR << s.message();
}
- int32_t cap = gpu_mem_cap * G_BYTE;
+ int32_t cap = gpu_cache_cap * G_BYTE;
cache_ = std::make_shared>(cap, 1UL << 32);
float gpu_mem_threshold;
- s = config.GetCacheConfigGpuMemThreshold(gpu_mem_threshold);
+ s = config.GetCacheConfigGpuCacheThreshold(gpu_mem_threshold);
if (!s.ok()) {
SERVER_LOG_ERROR << s.message();
}
if (gpu_mem_threshold > 0.0 && gpu_mem_threshold <= 1.0) {
cache_->set_freemem_percent(gpu_mem_threshold);
} else {
- SERVER_LOG_ERROR << "Invalid gpu_mem_threshold: " << gpu_mem_threshold
- << ", by default set to " << cache_->freemem_percent();
+ SERVER_LOG_ERROR << "Invalid gpu_mem_threshold: " << gpu_mem_threshold << ", by default set to "
+ << cache_->freemem_percent();
}
}
-GpuCacheMgr *
+GpuCacheMgr*
GpuCacheMgr::GetInstance(uint64_t gpu_id) {
if (instance_.find(gpu_id) == instance_.end()) {
std::lock_guard lock(mutex_);
@@ -74,7 +72,7 @@ GpuCacheMgr::GetInstance(uint64_t gpu_id) {
}
engine::VecIndexPtr
-GpuCacheMgr::GetIndex(const std::string &key) {
+GpuCacheMgr::GetIndex(const std::string& key) {
DataObjPtr obj = GetItem(key);
if (obj != nullptr) {
return obj->data();
@@ -83,6 +81,5 @@ GpuCacheMgr::GetIndex(const std::string &key) {
return nullptr;
}
-} // namespace cache
-} // namespace milvus
-} // namespace zilliz
+} // namespace cache
+} // namespace milvus
diff --git a/cpp/src/cache/GpuCacheMgr.h b/cpp/src/cache/GpuCacheMgr.h
index 843a5ff67d7a5479c9c54e677345701ae7125fee..8c0d4b95026ab4aea4684b55d593b2d8b3c20b4c 100644
--- a/cpp/src/cache/GpuCacheMgr.h
+++ b/cpp/src/cache/GpuCacheMgr.h
@@ -15,15 +15,13 @@
// specific language governing permissions and limitations
// under the License.
-
#include "CacheMgr.h"
#include "DataObj.h"
-#include
#include
#include
+#include
-namespace zilliz {
namespace milvus {
namespace cache {
@@ -34,15 +32,16 @@ class GpuCacheMgr : public CacheMgr {
public:
GpuCacheMgr();
- static GpuCacheMgr *GetInstance(uint64_t gpu_id);
+ static GpuCacheMgr*
+ GetInstance(uint64_t gpu_id);
- engine::VecIndexPtr GetIndex(const std::string &key);
+ engine::VecIndexPtr
+ GetIndex(const std::string& key);
private:
static std::mutex mutex_;
static std::unordered_map instance_;
};
-} // namespace cache
-} // namespace milvus
-} // namespace zilliz
+} // namespace cache
+} // namespace milvus
diff --git a/cpp/src/cache/LRU.h b/cpp/src/cache/LRU.h
index 5446dd0f14ec909c761f05f125fcc13d3d4bfcaa..9b0eac060854e5d24871c8217308224b71b39b72 100644
--- a/cpp/src/cache/LRU.h
+++ b/cpp/src/cache/LRU.h
@@ -15,20 +15,18 @@
// specific language governing permissions and limitations
// under the License.
-
#pragma once
-#include
-#include
#include
+#include
#include
+#include
#include
-namespace zilliz {
namespace milvus {
namespace cache {
-template
+template
class LRU {
public:
typedef typename std::pair key_value_pair_t;
@@ -38,7 +36,8 @@ class LRU {
explicit LRU(size_t max_size) : max_size_(max_size) {
}
- void put(const key_t &key, const value_t &value) {
+ void
+ put(const key_t& key, const value_t& value) {
auto it = cache_items_map_.find(key);
cache_items_list_.push_front(key_value_pair_t(key, value));
if (it != cache_items_map_.end()) {
@@ -55,7 +54,8 @@ class LRU {
}
}
- const value_t &get(const key_t &key) {
+ const value_t&
+ get(const key_t& key) {
auto it = cache_items_map_.find(key);
if (it == cache_items_map_.end()) {
throw std::range_error("There is no such key in cache");
@@ -65,7 +65,8 @@ class LRU {
}
}
- void erase(const key_t &key) {
+ void
+ erase(const key_t& key) {
auto it = cache_items_map_.find(key);
if (it != cache_items_map_.end()) {
cache_items_list_.erase(it->second);
@@ -73,32 +74,39 @@ class LRU {
}
}
- bool exists(const key_t &key) const {
+ bool
+ exists(const key_t& key) const {
return cache_items_map_.find(key) != cache_items_map_.end();
}
- size_t size() const {
+ size_t
+ size() const {
return cache_items_map_.size();
}
- list_iterator_t begin() {
+ list_iterator_t
+ begin() {
iter_ = cache_items_list_.begin();
return iter_;
}
- list_iterator_t end() {
+ list_iterator_t
+ end() {
return cache_items_list_.end();
}
- reverse_list_iterator_t rbegin() {
+ reverse_list_iterator_t
+ rbegin() {
return cache_items_list_.rbegin();
}
- reverse_list_iterator_t rend() {
+ reverse_list_iterator_t
+ rend() {
return cache_items_list_.rend();
}
- void clear() {
+ void
+ clear() {
cache_items_list_.clear();
cache_items_map_.clear();
}
@@ -110,7 +118,5 @@ class LRU {
list_iterator_t iter_;
};
-} // namespace cache
-} // namespace milvus
-} // namespace zilliz
-
+} // namespace cache
+} // namespace milvus
diff --git a/cpp/src/config/ConfigMgr.cpp b/cpp/src/config/ConfigMgr.cpp
index a7cfdc9fdaa9f796e39c2d0412a472b8b812d4f0..5889f52fac2987ab7a8c7830c176acdf2d0417c6 100644
--- a/cpp/src/config/ConfigMgr.cpp
+++ b/cpp/src/config/ConfigMgr.cpp
@@ -18,16 +18,14 @@
#include "config/ConfigMgr.h"
#include "YamlConfigMgr.h"
-namespace zilliz {
namespace milvus {
namespace server {
-ConfigMgr *
+ConfigMgr*
ConfigMgr::GetInstance() {
static YamlConfigMgr mgr;
return &mgr;
}
-} // namespace server
-} // namespace milvus
-} // namespace zilliz
+} // namespace server
+} // namespace milvus
diff --git a/cpp/src/config/ConfigMgr.h b/cpp/src/config/ConfigMgr.h
index 96a63aa2c8e1a784bf828161a7a5447cba08b280..40753beaa9766e536fb2c34cecfd7166022add49 100644
--- a/cpp/src/config/ConfigMgr.h
+++ b/cpp/src/config/ConfigMgr.h
@@ -17,12 +17,11 @@
#pragma once
-#include "utils/Error.h"
#include "ConfigNode.h"
+#include "utils/Error.h"
#include
-namespace zilliz {
namespace milvus {
namespace server {
@@ -42,16 +41,21 @@ namespace server {
class ConfigMgr {
public:
- static ConfigMgr *GetInstance();
-
- virtual ErrorCode LoadConfigFile(const std::string &filename) = 0;
- virtual void Print() const = 0;//will be deleted
- virtual std::string DumpString() const = 0;
-
- virtual const ConfigNode &GetRootNode() const = 0;
- virtual ConfigNode &GetRootNode() = 0;
+ static ConfigMgr*
+ GetInstance();
+
+ virtual ErrorCode
+ LoadConfigFile(const std::string& filename) = 0;
+ virtual void
+ Print() const = 0; // will be deleted
+ virtual std::string
+ DumpString() const = 0;
+
+ virtual const ConfigNode&
+ GetRootNode() const = 0;
+ virtual ConfigNode&
+ GetRootNode() = 0;
};
-} // namespace server
-} // namespace milvus
-} // namespace zilliz
+} // namespace server
+} // namespace milvus
diff --git a/cpp/src/config/ConfigNode.cpp b/cpp/src/config/ConfigNode.cpp
index 87b080d5722e9276dc48359faa4862fbd771d795..cf148e4d29e57341276d1e1a95df99f320046995 100644
--- a/cpp/src/config/ConfigNode.cpp
+++ b/cpp/src/config/ConfigNode.cpp
@@ -19,51 +19,50 @@
#include "utils/Error.h"
#include "utils/Log.h"
+#include
#include
#include
-#include
-namespace zilliz {
namespace milvus {
namespace server {
void
-ConfigNode::Combine(const ConfigNode &target) {
- const std::map &kv = target.GetConfig();
+ConfigNode::Combine(const ConfigNode& target) {
+ const std::map& kv = target.GetConfig();
for (auto itr = kv.begin(); itr != kv.end(); ++itr) {
config_[itr->first] = itr->second;
}
- const std::map > &sequences = target.GetSequences();
+ const std::map >& sequences = target.GetSequences();
for (auto itr = sequences.begin(); itr != sequences.end(); ++itr) {
sequences_[itr->first] = itr->second;
}
- const std::map &children = target.GetChildren();
+ const std::map& children = target.GetChildren();
for (auto itr = children.begin(); itr != children.end(); ++itr) {
children_[itr->first] = itr->second;
}
}
-//key/value pair config
+// key/value pair config
void
-ConfigNode::SetValue(const std::string &key, const std::string &value) {
+ConfigNode::SetValue(const std::string& key, const std::string& value) {
config_[key] = value;
}
std::string
-ConfigNode::GetValue(const std::string ¶m_key, const std::string &default_val) const {
+ConfigNode::GetValue(const std::string& param_key, const std::string& default_val) const {
auto ref = config_.find(param_key);
if (ref != config_.end()) {
return ref->second;
}
- //THROW_UNEXPECTED_ERROR("Can't find parameter key: " + param_key);
+ // THROW_UNEXPECTED_ERROR("Can't find parameter key: " + param_key);
return default_val;
}
bool
-ConfigNode::GetBoolValue(const std::string ¶m_key, bool default_val) const {
+ConfigNode::GetBoolValue(const std::string& param_key, bool default_val) const {
std::string val = GetValue(param_key);
if (!val.empty()) {
std::transform(val.begin(), val.end(), val.begin(), ::tolower);
@@ -74,17 +73,17 @@ ConfigNode::GetBoolValue(const std::string ¶m_key, bool default_val) const {
}
int32_t
-ConfigNode::GetInt32Value(const std::string ¶m_key, int32_t default_val) const {
+ConfigNode::GetInt32Value(const std::string& param_key, int32_t default_val) const {
std::string val = GetValue(param_key);
if (!val.empty()) {
- return (int32_t) std::strtol(val.c_str(), nullptr, 10);
+ return (int32_t)std::strtol(val.c_str(), nullptr, 10);
} else {
return default_val;
}
}
int64_t
-ConfigNode::GetInt64Value(const std::string ¶m_key, int64_t default_val) const {
+ConfigNode::GetInt64Value(const std::string& param_key, int64_t default_val) const {
std::string val = GetValue(param_key);
if (!val.empty()) {
return std::strtol(val.c_str(), nullptr, 10);
@@ -94,7 +93,7 @@ ConfigNode::GetInt64Value(const std::string ¶m_key, int64_t default_val) con
}
float
-ConfigNode::GetFloatValue(const std::string ¶m_key, float default_val) const {
+ConfigNode::GetFloatValue(const std::string& param_key, float default_val) const {
std::string val = GetValue(param_key);
if (!val.empty()) {
return std::strtof(val.c_str(), nullptr);
@@ -104,7 +103,7 @@ ConfigNode::GetFloatValue(const std::string ¶m_key, float default_val) const
}
double
-ConfigNode::GetDoubleValue(const std::string ¶m_key, double default_val) const {
+ConfigNode::GetDoubleValue(const std::string& param_key, double default_val) const {
std::string val = GetValue(param_key);
if (!val.empty()) {
return std::strtod(val.c_str(), nullptr);
@@ -113,7 +112,7 @@ ConfigNode::GetDoubleValue(const std::string ¶m_key, double default_val) con
}
}
-const std::map &
+const std::map&
ConfigNode::GetConfig() const {
return config_;
}
@@ -123,14 +122,14 @@ ConfigNode::ClearConfig() {
config_.clear();
}
-//key/object config
+// key/object config
void
-ConfigNode::AddChild(const std::string &type_name, const ConfigNode &config) {
+ConfigNode::AddChild(const std::string& type_name, const ConfigNode& config) {
children_[type_name] = config;
}
ConfigNode
-ConfigNode::GetChild(const std::string &type_name) const {
+ConfigNode::GetChild(const std::string& type_name) const {
auto ref = children_.find(type_name);
if (ref != children_.end()) {
return ref->second;
@@ -140,20 +139,20 @@ ConfigNode::GetChild(const std::string &type_name) const {
return nc;
}
-ConfigNode &
-ConfigNode::GetChild(const std::string &type_name) {
+ConfigNode&
+ConfigNode::GetChild(const std::string& type_name) {
return children_[type_name];
}
void
-ConfigNode::GetChildren(ConfigNodeArr &arr) const {
+ConfigNode::GetChildren(ConfigNodeArr& arr) const {
arr.clear();
for (auto ref : children_) {
arr.push_back(ref.second);
}
}
-const std::map &
+const std::map&
ConfigNode::GetChildren() const {
return children_;
}
@@ -163,14 +162,14 @@ ConfigNode::ClearChildren() {
children_.clear();
}
-//key/sequence config
+// key/sequence config
void
-ConfigNode::AddSequenceItem(const std::string &key, const std::string &item) {
+ConfigNode::AddSequenceItem(const std::string& key, const std::string& item) {
sequences_[key].push_back(item);
}
std::vector
-ConfigNode::GetSequence(const std::string &key) const {
+ConfigNode::GetSequence(const std::string& key) const {
auto itr = sequences_.find(key);
if (itr != sequences_.end()) {
return itr->second;
@@ -180,7 +179,7 @@ ConfigNode::GetSequence(const std::string &key) const {
}
}
-const std::map > &
+const std::map >&
ConfigNode::GetSequences() const {
return sequences_;
}
@@ -191,40 +190,40 @@ ConfigNode::ClearSequences() {
}
void
-ConfigNode::PrintAll(const std::string &prefix) const {
- for (auto &elem : config_) {
+ConfigNode::PrintAll(const std::string& prefix) const {
+ for (auto& elem : config_) {
SERVER_LOG_INFO << prefix << elem.first + ": " << elem.second;
}
- for (auto &elem : sequences_) {
+ for (auto& elem : sequences_) {
SERVER_LOG_INFO << prefix << elem.first << ": ";
- for (auto &str : elem.second) {
+ for (auto& str : elem.second) {
SERVER_LOG_INFO << prefix << " - " << str;
}
}
- for (auto &elem : children_) {
+ for (auto& elem : children_) {
SERVER_LOG_INFO << prefix << elem.first << ": ";
elem.second.PrintAll(prefix + " ");
}
}
std::string
-ConfigNode::DumpString(const std::string &prefix) const {
+ConfigNode::DumpString(const std::string& prefix) const {
std::stringstream str_buffer;
const std::string endl = "\n";
- for (auto &elem : config_) {
+ for (auto& elem : config_) {
str_buffer << prefix << elem.first << ": " << elem.second << endl;
}
- for (auto &elem : sequences_) {
+ for (auto& elem : sequences_) {
str_buffer << prefix << elem.first << ": " << endl;
- for (auto &str : elem.second) {
+ for (auto& str : elem.second) {
str_buffer << prefix + " - " << str << endl;
}
}
- for (auto &elem : children_) {
+ for (auto& elem : children_) {
str_buffer << prefix << elem.first << ": " << endl;
str_buffer << elem.second.DumpString(prefix + " ") << endl;
}
@@ -232,6 +231,5 @@ ConfigNode::DumpString(const std::string &prefix) const {
return str_buffer.str();
}
-} // namespace server
-} // namespace milvus
-} // namespace zilliz
+} // namespace server
+} // namespace milvus
diff --git a/cpp/src/config/ConfigNode.h b/cpp/src/config/ConfigNode.h
index d3fabc06550295dfeed2afdd582c1f46d9ef1621..b7bf2c3af14607246e8ffab10afd47ca2ba32c4a 100644
--- a/cpp/src/config/ConfigNode.h
+++ b/cpp/src/config/ConfigNode.h
@@ -17,11 +17,10 @@
#pragma once
-#include
-#include
#include