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/cpp/CHANGELOG.md b/cpp/CHANGELOG.md
index 33d34fcd34cbf02a3d583bab74c4556f150f1ac3..a41bc23484a5c290302d8fe06472dff625b1326f 100644
--- a/cpp/CHANGELOG.md
+++ b/cpp/CHANGELOG.md
@@ -33,6 +33,7 @@ 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
# 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 57f3a85dccd921479cd6be41f3bec7fe1112a057..f5f77d25f8bcd9edb5bba76b354fd2a0fa9bccd4 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -50,10 +50,9 @@ Centos7 :
$ yum install gfortran qt4 flex bison
$ yum install mysql-devel mysql
-Ubuntu16.04 :
+Ubuntu 16.04 or 18.04:
$ sudo apt-get install gfortran qt4-qmake flex bison
$ sudo apt-get install libmysqlclient-dev mysql-client
-
```
Verify the existence of `libmysqlclient_r.so`:
@@ -66,6 +65,10 @@ $ locate libmysqlclient_r.so
If not, you need to create a symbolic link:
```shell
+# Locate libmysqlclient.so
+$ sudo updatedb
+$ locate libmysqlclient.so
+
# Create symbolic link
$ sudo ln -s /path/to/libmysqlclient.so /path/to/libmysqlclient_r.so
```
@@ -90,7 +93,7 @@ please reinstall CMake with curl:
```shell
CentOS 7:
$ yum install curl-devel
- Ubuntu 16.04:
+ Ubuntu 16.04 or 18.04:
$ sudo apt-get install libcurl4-openssl-dev
```
@@ -106,7 +109,7 @@ please reinstall CMake with curl:
```shell
CentOS 7:
$ yum install clang
-Ubuntu 16.04:
+Ubuntu 16.04 or 18.04:
$ sudo apt-get install clang-format clang-tidy
$ ./build.sh -l
@@ -123,7 +126,7 @@ $ ./build.sh -u
```shell
CentOS 7:
$ yum install lcov
-Ubuntu 16.04:
+Ubuntu 16.04 or 18.04:
$ sudo apt-get install lcov
$ ./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..4c7dc4718c8b2f8e1a33314fc04040171b5d9fcf
--- /dev/null
+++ b/cpp/build-support/code_style_clion.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cpp/build-support/lint_exclusions.txt b/cpp/build-support/lint_exclusions.txt
index f08664a1a9b6cf578525a7e7fc3192a7a1085ce4..6888dfa32cc2a592db774451bd85bf7783aa4b71 100644
--- a/cpp/build-support/lint_exclusions.txt
+++ b/cpp/build-support/lint_exclusions.txt
@@ -1,7 +1,8 @@
*cmake-build-debug*
*cmake-build-release*
*cmake_build*
-*src/thirdparty*
*src/core/thirdparty*
-*src/grpc*
-*easylogging++*
\ No newline at end of file
+*thirdparty*
+*easylogging++*
+*SqliteMetaImpl.cpp
+*src/grpc*
\ No newline at end of file
diff --git a/cpp/build.sh b/cpp/build.sh
index 4087db45928118ed23f0cc8caab1100c54abe799..deda35ab275672a83d735c0c5a220dbdce4d4bfa 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
+ 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 d80dfda958ae4abb2c675015a97ffbeb113a445f..3d63cdfafa4479ba92a29e70d407e19e91040f9f 100644
--- a/cpp/conf/server_config.template
+++ b/cpp/conf/server_config.template
@@ -1,4 +1,4 @@
-# All the following configurations are default values.
+# Default values are used when you make no changes to the following parameters.
server_config:
address: 0.0.0.0 # milvus server ip address (IPv4)
@@ -11,25 +11,27 @@ 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
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 kept when cache cleanup triggered
- cache_insert_data: false # whether load inserted data into cache
+ 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 f1c42ede618edeb2e245f503172af515ab6d4e70..84459fcc84e51d504ff6e3d8314600c6eafcc1e8 100755
--- a/cpp/coverage.sh
+++ b/cpp/coverage.sh
@@ -101,6 +101,7 @@ ${LCOV_CMD} -r "${FILE_INFO_OUTPUT}" -o "${FILE_INFO_OUTPUT_NEW}" \
"src/core/cmake_build*" \
"src/core/thirdparty*" \
"src/grpc*"\
+ "src/metrics/MetricBase.h"\
"src/server/Server.cpp"\
"src/server/DBWrapper.cpp"\
"src/server/grpc_impl/GrpcMilvusServer.cpp"\
diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt
index 6ee3966c4ffdab88020a4fab70e345565ea4e61b..9810c6b7d83ddb26ce60b7df0443fbd4cd1eeebf 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,8 +46,6 @@ 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)
@@ -70,9 +63,7 @@ set(scheduler_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 +73,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 +98,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 +115,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 +131,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 +141,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 +173,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 b2a57ebdfb2d8c38e37e04cc01521127cd4de31e..7818a2e6b78b8db3f2da2756ed3f08fd588d2251 100644
--- a/cpp/src/cache/Cache.h
+++ b/cpp/src/cache/Cache.h
@@ -15,47 +15,69 @@
// 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
+ public:
+ // mem_capacity, units:GB
Cache(int64_t capacity_gb, uint64_t cache_max_count);
~Cache() = default;
- int64_t usage() const { return usage_; }
- int64_t capacity() const { return capacity_; } //unit: BYTE
- void set_capacity(int64_t capacity); //unit: BYTE
+ int64_t
+ usage() const {
+ return usage_;
+ }
+
+ int64_t
+ capacity() const {
+ return capacity_;
+ } // unit: BYTE
+ void
+ set_capacity(int64_t capacity); // unit: BYTE
+
+ double
+ freemem_percent() const {
+ return freemem_percent_;
+ }
- double freemem_percent() const { return freemem_percent_; };
- void set_freemem_percent(double percent) { freemem_percent_ = 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();
+ private:
+ void
+ free_memory();
-private:
+ private:
int64_t usage_;
int64_t capacity_;
double freemem_percent_;
@@ -64,8 +86,8 @@ private:
mutable std::mutex mutex_;
};
-} // cache
-} // milvus
-} // zilliz
+} // namespace cache
+} // namespace milvus
+} // namespace zilliz
-#include "cache/Cache.inl"
\ No newline at end of file
+#include "cache/Cache.inl"
diff --git a/cpp/src/cache/Cache.inl b/cpp/src/cache/Cache.inl
index 3eaffc45568debd547fa33810d4ccd4c955e8578..ebd8f3c25d2b23fd5adce6e3d50e36efb26a7e0e 100644
--- a/cpp/src/cache/Cache.inl
+++ b/cpp/src/cache/Cache.inl
@@ -33,29 +33,33 @@ Cache::Cache(int64_t capacity, uint64_t cache_max_count)
}
template
-void Cache::set_capacity(int64_t capacity) {
- if(capacity > 0) {
+void
+Cache::set_capacity(int64_t capacity) {
+ if (capacity > 0) {
capacity_ = capacity;
free_memory();
}
}
template
-size_t Cache::size() const {
+size_t
+Cache::size() const {
std::lock_guard lock(mutex_);
return lru_.size();
}
template
-bool Cache::exists(const std::string& key) {
+bool
+Cache::exists(const std::string &key) {
std::lock_guard lock(mutex_);
return lru_.exists(key);
}
template
-ItemObj Cache::get(const std::string& key) {
+ItemObj
+Cache::get(const std::string &key) {
std::lock_guard lock(mutex_);
- if(!lru_.exists(key)){
+ if (!lru_.exists(key)) {
return nullptr;
}
@@ -63,8 +67,9 @@ ItemObj Cache::get(const std::string& key) {
}
template
-void Cache::insert(const std::string& key, const ItemObj& item) {
- if(item == nullptr) {
+void
+Cache::insert(const std::string &key, const ItemObj &item) {
+ if (item == nullptr) {
return;
}
@@ -80,7 +85,7 @@ void Cache::insert(const std::string& key, const ItemObj& item) {
//if key already exist, subtract old item size
if (lru_.exists(key)) {
- const ItemObj& old_item = lru_.get(key);
+ const ItemObj &old_item = lru_.get(key);
usage_ -= old_item->size();
}
@@ -107,13 +112,14 @@ void Cache::insert(const std::string& key, const ItemObj& item) {
}
template
-void Cache::erase(const std::string& key) {
+void
+Cache::erase(const std::string &key) {
std::lock_guard lock(mutex_);
- if(!lru_.exists(key)){
+ if (!lru_.exists(key)) {
return;
}
- const ItemObj& old_item = lru_.get(key);
+ const ItemObj &old_item = lru_.get(key);
usage_ -= old_item->size();
SERVER_LOG_DEBUG << "Erase " << key << " size: " << old_item->size();
@@ -122,7 +128,8 @@ void Cache::erase(const std::string& key) {
}
template
-void Cache::clear() {
+void
+Cache::clear() {
std::lock_guard lock(mutex_);
lru_.clear();
usage_ = 0;
@@ -131,12 +138,13 @@ void Cache::clear() {
/* free memory space when CACHE occupation exceed its capacity */
template
-void Cache::free_memory() {
+void
+Cache::free_memory() {
if (usage_ <= capacity_) return;
int64_t threshhold = capacity_ * freemem_percent_;
int64_t delta_size = usage_ - threshhold;
- if(delta_size <= 0) {
+ if (delta_size <= 0) {
delta_size = 1;//ensure at least one item erased
}
@@ -148,8 +156,8 @@ void Cache::free_memory() {
auto it = lru_.rbegin();
while (it != lru_.rend() && released_size < delta_size) {
- auto& key = it->first;
- auto& obj_ptr = it->second;
+ auto &key = it->first;
+ auto &obj_ptr = it->second;
key_array.emplace(key);
released_size += obj_ptr->size();
@@ -159,7 +167,7 @@ void Cache::free_memory() {
SERVER_LOG_DEBUG << "to be released memory size: " << released_size;
- for (auto& key : key_array) {
+ for (auto &key : key_array) {
erase(key);
}
@@ -167,7 +175,8 @@ void Cache::free_memory() {
}
template
-void Cache::print() {
+void
+Cache::print() {
size_t cache_count = 0;
{
std::lock_guard lock(mutex_);
@@ -179,7 +188,7 @@ void Cache::print() {
SERVER_LOG_DEBUG << "[Cache capacity]: " << capacity_ << " bytes";
}
-} // cache
-} // milvus
-} // zilliz
+} // namespace cache
+} // namespace milvus
+} // namespace zilliz
diff --git a/cpp/src/cache/CacheMgr.h b/cpp/src/cache/CacheMgr.h
index 1dd630e14dc7a1507b881431f8e620b94e943c1e..11cd742a6aa7052a67e80c64a9f37d37e886f78e 100644
--- a/cpp/src/cache/CacheMgr.h
+++ b/cpp/src/cache/CacheMgr.h
@@ -15,50 +15,61 @@
// 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
namespace zilliz {
namespace milvus {
namespace cache {
-template
+template
class CacheMgr {
-public:
- virtual uint64_t ItemCount() const;
+ public:
+ 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:
+ protected:
CacheMgr();
virtual ~CacheMgr();
-protected:
+ protected:
using CachePtr = std::shared_ptr>;
CachePtr cache_;
};
+} // namespace cache
+} // namespace milvus
+} // namespace zilliz
-}
-}
-}
-
-#include "cache/CacheMgr.inl"
\ No newline at end of file
+#include "cache/CacheMgr.inl"
diff --git a/cpp/src/cache/CacheMgr.inl b/cpp/src/cache/CacheMgr.inl
index 36c3d94642d7372f96522810c40cca93c19ce774..b0c47b3dc37f54b6b336fe26f3b292d45ba5697f 100644
--- a/cpp/src/cache/CacheMgr.inl
+++ b/cpp/src/cache/CacheMgr.inl
@@ -30,18 +30,20 @@ CacheMgr::~CacheMgr() {
}
template
-uint64_t CacheMgr::ItemCount() const {
- if(cache_ == nullptr) {
+uint64_t
+CacheMgr::ItemCount() const {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return 0;
}
- return (uint64_t)(cache_->size());
+ return (uint64_t) (cache_->size());
}
template
-bool CacheMgr::ItemExists(const std::string& key) {
- if(cache_ == nullptr) {
+bool
+CacheMgr::ItemExists(const std::string &key) {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return false;
}
@@ -50,8 +52,9 @@ bool CacheMgr::ItemExists(const std::string& key) {
}
template
-ItemObj CacheMgr::GetItem(const std::string& key) {
- if(cache_ == nullptr) {
+ItemObj
+CacheMgr::GetItem(const std::string &key) {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return nullptr;
}
@@ -60,8 +63,9 @@ ItemObj CacheMgr::GetItem(const std::string& key) {
}
template
-void CacheMgr::InsertItem(const std::string& key, const ItemObj& data) {
- if(cache_ == nullptr) {
+void
+CacheMgr::InsertItem(const std::string &key, const ItemObj &data) {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return;
}
@@ -71,8 +75,9 @@ void CacheMgr::InsertItem(const std::string& key, const ItemObj& data)
}
template
-void CacheMgr::EraseItem(const std::string& key) {
- if(cache_ == nullptr) {
+void
+CacheMgr::EraseItem(const std::string &key) {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return;
}
@@ -82,8 +87,9 @@ void CacheMgr::EraseItem(const std::string& key) {
}
template
-void CacheMgr::PrintInfo() {
- if(cache_ == nullptr) {
+void
+CacheMgr::PrintInfo() {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return;
}
@@ -92,8 +98,9 @@ void CacheMgr::PrintInfo() {
}
template
-void CacheMgr::ClearCache() {
- if(cache_ == nullptr) {
+void
+CacheMgr::ClearCache() {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return;
}
@@ -102,8 +109,9 @@ void CacheMgr::ClearCache() {
}
template
-int64_t CacheMgr::CacheUsage() const {
- if(cache_ == nullptr) {
+int64_t
+CacheMgr::CacheUsage() const {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return 0;
}
@@ -112,8 +120,9 @@ int64_t CacheMgr::CacheUsage() const {
}
template
-int64_t CacheMgr::CacheCapacity() const {
- if(cache_ == nullptr) {
+int64_t
+CacheMgr::CacheCapacity() const {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return 0;
}
@@ -122,14 +131,15 @@ int64_t CacheMgr::CacheCapacity() const {
}
template
-void CacheMgr::SetCapacity(int64_t capacity) {
- if(cache_ == nullptr) {
+void
+CacheMgr::SetCapacity(int64_t capacity) {
+ if (cache_ == nullptr) {
SERVER_LOG_ERROR << "Cache doesn't exist";
return;
}
cache_->set_capacity(capacity);
}
-}
-}
-}
+} // namespace cache
+} // namespace milvus
+} // namespace zilliz
diff --git a/cpp/src/cache/CpuCacheMgr.cpp b/cpp/src/cache/CpuCacheMgr.cpp
index 1f93ec92bdd006d4e445f2308d9fb3e860e5e0e8..99a284f0742ad7071e72275c7a62bfec0aae5cfe 100644
--- a/cpp/src/cache/CpuCacheMgr.cpp
+++ b/cpp/src/cache/CpuCacheMgr.cpp
@@ -15,58 +15,61 @@
// specific language governing permissions and limitations
// under the License.
-
-#include "CpuCacheMgr.h"
+#include "cache/CpuCacheMgr.h"
#include "server/Config.h"
#include "utils/Log.h"
+#include
+
namespace zilliz {
namespace milvus {
namespace cache {
namespace {
- constexpr int64_t unit = 1024 * 1024 * 1024;
+constexpr int64_t unit = 1024 * 1024 * 1024;
}
CpuCacheMgr::CpuCacheMgr() {
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;
- cache_ = std::make_shared>(cap, 1UL<<32);
+ 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::GetInstance() {
+CpuCacheMgr*
+CpuCacheMgr::GetInstance() {
static CpuCacheMgr s_mgr;
return &s_mgr;
}
-engine::VecIndexPtr CpuCacheMgr::GetIndex(const std::string& key) {
+engine::VecIndexPtr
+CpuCacheMgr::GetIndex(const std::string& key) {
DataObjPtr obj = GetItem(key);
- if(obj != nullptr) {
+ if (obj != nullptr) {
return obj->data();
}
return nullptr;
}
-}
-}
-}
\ No newline at end of file
+} // namespace cache
+} // namespace milvus
+} // namespace zilliz
diff --git a/cpp/src/cache/CpuCacheMgr.h b/cpp/src/cache/CpuCacheMgr.h
index 5a2cdb599acdc8a7e846e0251179746ab39f52b0..ad6087de7c42104f36d233d107d5691b603bd630 100644
--- a/cpp/src/cache/CpuCacheMgr.h
+++ b/cpp/src/cache/CpuCacheMgr.h
@@ -20,21 +20,26 @@
#include "CacheMgr.h"
#include "DataObj.h"
+#include
+#include
+
namespace zilliz {
namespace milvus {
namespace cache {
class CpuCacheMgr : public CacheMgr {
-private:
+ private:
CpuCacheMgr();
-public:
- //TODO: use smart pointer instead
- static CpuCacheMgr* GetInstance();
+ public:
+ // 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
diff --git a/cpp/src/cache/DataObj.h b/cpp/src/cache/DataObj.h
index f9215bc152096c1444297a2b954d16351cd54e2e..80cc560e7c5099101ec5c11724e87f51f78cc11e 100644
--- a/cpp/src/cache/DataObj.h
+++ b/cpp/src/cache/DataObj.h
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-
#pragma once
#include "src/wrapper/VecIndex.h"
@@ -27,38 +26,43 @@ namespace milvus {
namespace cache {
class DataObj {
-public:
- DataObj(const engine::VecIndexPtr& index)
- : index_(index)
- {}
+ public:
+ 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() {
+ return index_;
+ }
- engine::VecIndexPtr data() { return index_; }
- const engine::VecIndexPtr& data() const { return index_; }
+ const engine::VecIndexPtr&
+ data() const {
+ return index_;
+ }
- int64_t size() const {
- if(index_ == nullptr) {
+ int64_t
+ size() const {
+ if (index_ == nullptr) {
return 0;
}
- if(size_ > 0) {
+ if (size_ > 0) {
return size_;
}
return index_->Count() * index_->Dimension() * sizeof(float);
}
-private:
+ private:
engine::VecIndexPtr index_ = nullptr;
int64_t size_ = 0;
};
using DataObjPtr = std::shared_ptr;
-}
-}
-}
\ No newline at end of file
+} // namespace cache
+} // namespace milvus
+} // namespace zilliz
diff --git a/cpp/src/cache/GpuCacheMgr.cpp b/cpp/src/cache/GpuCacheMgr.cpp
index 5c104ba0e7452fa9eea6de8c0dc30bf566664d9b..9c9e94eda9d31bf891239dd946dc1baca47581f9 100644
--- a/cpp/src/cache/GpuCacheMgr.cpp
+++ b/cpp/src/cache/GpuCacheMgr.cpp
@@ -15,11 +15,12 @@
// specific language governing permissions and limitations
// under the License.
+#include "cache/GpuCacheMgr.h"
+#include "server/Config.h"
+#include "utils/Log.h"
#include
-#include "utils/Log.h"
-#include "GpuCacheMgr.h"
-#include "server/Config.h"
+#include
namespace zilliz {
namespace milvus {
@@ -29,35 +30,36 @@ std::mutex GpuCacheMgr::mutex_;
std::unordered_map GpuCacheMgr::instance_;
namespace {
- constexpr int64_t G_BYTE = 1024 * 1024 * 1024;
+constexpr int64_t G_BYTE = 1024 * 1024 * 1024;
}
GpuCacheMgr::GpuCacheMgr() {
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;
- cache_ = std::make_shared>(cap, 1UL<<32);
+ 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::GetInstance(uint64_t gpu_id) {
+GpuCacheMgr*
+GpuCacheMgr::GetInstance(uint64_t gpu_id) {
if (instance_.find(gpu_id) == instance_.end()) {
std::lock_guard lock(mutex_);
if (instance_.find(gpu_id) == instance_.end()) {
@@ -70,15 +72,16 @@ GpuCacheMgr* GpuCacheMgr::GetInstance(uint64_t gpu_id) {
}
}
-engine::VecIndexPtr GpuCacheMgr::GetIndex(const std::string& key) {
+engine::VecIndexPtr
+GpuCacheMgr::GetIndex(const std::string& key) {
DataObjPtr obj = GetItem(key);
- if(obj != nullptr) {
+ if (obj != nullptr) {
return obj->data();
}
return nullptr;
}
-}
-}
-}
\ No newline at end of file
+} // namespace cache
+} // namespace milvus
+} // namespace zilliz
diff --git a/cpp/src/cache/GpuCacheMgr.h b/cpp/src/cache/GpuCacheMgr.h
index 57539b698192fc5858633f31040d06d1483a177a..15cdcae28fb7691b01eee6466e0fc5e3a0325516 100644
--- a/cpp/src/cache/GpuCacheMgr.h
+++ b/cpp/src/cache/GpuCacheMgr.h
@@ -15,12 +15,12 @@
// specific language governing permissions and limitations
// under the License.
-
#include "CacheMgr.h"
#include "DataObj.h"
-#include
#include
+#include
+#include
namespace zilliz {
namespace milvus {
@@ -30,18 +30,20 @@ class GpuCacheMgr;
using GpuCacheMgrPtr = std::shared_ptr;
class GpuCacheMgr : public CacheMgr {
-public:
+ 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:
+ private:
static std::mutex mutex_;
static std::unordered_map instance_;
};
-}
-}
-}
+} // namespace cache
+} // namespace milvus
+} // namespace zilliz
diff --git a/cpp/src/cache/LRU.h b/cpp/src/cache/LRU.h
index a4f4dcf5f21106f74de79bb70961a31f53c862ea..d6a5b9ace7079030c8e449fd6c18e33e57cc0a2d 100644
--- a/cpp/src/cache/LRU.h
+++ b/cpp/src/cache/LRU.h
@@ -15,28 +15,30 @@
// 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:
+ public:
typedef typename std::pair key_value_pair_t;
typedef typename std::list::iterator list_iterator_t;
typedef typename std::list::reverse_iterator reverse_list_iterator_t;
- LRU(size_t max_size) : max_size_(max_size) {}
+ 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()) {
@@ -53,7 +55,8 @@ public:
}
}
- 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");
@@ -63,7 +66,8 @@ public:
}
}
- 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);
@@ -71,44 +75,50 @@ public:
}
}
- 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();
}
-private:
+ private:
std::list cache_items_list_;
std::unordered_map cache_items_map_;
size_t max_size_;
list_iterator_t iter_;
};
-} // cache
-} // milvus
-} // zilliz
-
+} // namespace cache
+} // namespace milvus
+} // namespace zilliz
diff --git a/cpp/src/config/ConfigMgr.cpp b/cpp/src/config/ConfigMgr.cpp
index a7cfdc9fdaa9f796e39c2d0412a472b8b812d4f0..e006217fd2023dd958abae327b2e2dab1d52409a 100644
--- a/cpp/src/config/ConfigMgr.cpp
+++ b/cpp/src/config/ConfigMgr.cpp
@@ -22,12 +22,12 @@ 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
+} // namespace zilliz
diff --git a/cpp/src/config/ConfigMgr.h b/cpp/src/config/ConfigMgr.h
index 96a63aa2c8e1a784bf828161a7a5447cba08b280..e5336ee34df858f2810958660f32256224b238c8 100644
--- a/cpp/src/config/ConfigMgr.h
+++ b/cpp/src/config/ConfigMgr.h
@@ -17,8 +17,8 @@
#pragma once
-#include "utils/Error.h"
#include "ConfigNode.h"
+#include "utils/Error.h"
#include
@@ -42,16 +42,22 @@ 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
+} // namespace zilliz
diff --git a/cpp/src/config/ConfigNode.cpp b/cpp/src/config/ConfigNode.cpp
index 87b080d5722e9276dc48359faa4862fbd771d795..ff27a0af751623a4879b7e1de72c129e702a5952 100644
--- a/cpp/src/config/ConfigNode.cpp
+++ b/cpp/src/config/ConfigNode.cpp
@@ -19,51 +19,51 @@
#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 +74,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 +94,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 +104,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 +113,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 +123,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 +140,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 +163,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 +180,7 @@ ConfigNode::GetSequence(const std::string &key) const {
}
}
-const std::map > &
+const std::map >&
ConfigNode::GetSequences() const {
return sequences_;
}
@@ -191,40 +191,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 +232,6 @@ ConfigNode::DumpString(const std::string &prefix) const {
return str_buffer.str();
}
-} // namespace server
-} // namespace milvus
-} // namespace zilliz
+} // namespace server
+} // namespace milvus
+} // namespace zilliz
diff --git a/cpp/src/config/ConfigNode.h b/cpp/src/config/ConfigNode.h
index d3fabc06550295dfeed2afdd582c1f46d9ef1621..937066dbf534a6533ed8d280462c01eb2de01c5f 100644
--- a/cpp/src/config/ConfigNode.h
+++ b/cpp/src/config/ConfigNode.h
@@ -17,9 +17,9 @@
#pragma once
-#include
-#include
#include