Loading cpp/build.sh +7 −7 Original line number Diff line number Diff line Loading @@ -104,13 +104,13 @@ if [[ ${RUN_CPPLINT} == "ON" ]]; then 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-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 Loading cpp/src/cache/Cache.h +34 −22 Original line number Diff line number Diff line Loading @@ -15,16 +15,15 @@ // specific language governing permissions and limitations // under the License. #pragma once #include "LRU.h" #include "utils/Log.h" #include <string> #include <mutex> #include <atomic> #include <mutex> #include <set> #include <string> namespace zilliz { namespace milvus { Loading @@ -37,33 +36,46 @@ class Cache { 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 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_; Loading cpp/src/cache/CacheMgr.h +26 −17 Original line number Diff line number Diff line Loading @@ -15,15 +15,14 @@ // 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 <string> #include <memory> #include <string> namespace zilliz { namespace milvus { Loading @@ -32,23 +31,33 @@ namespace cache { template <typename ItemObj> 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(); Loading cpp/src/cache/CpuCacheMgr.cpp +8 −9 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. #include "cache/CpuCacheMgr.h" #include "server/Config.h" #include "utils/Log.h" Loading Loading @@ -50,8 +49,8 @@ CpuCacheMgr::CpuCacheMgr() { if (cpu_cache_threshold > 0.0 && cpu_cache_threshold <= 1.0) { cache_->set_freemem_percent(cpu_cache_threshold); } else { SERVER_LOG_ERROR << "Invalid cpu_cache_threshold: " << cpu_cache_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(); } } Loading cpp/src/cache/CpuCacheMgr.h +9 −7 Original line number Diff line number Diff line Loading @@ -20,8 +20,8 @@ #include "CacheMgr.h" #include "DataObj.h" #include <string> #include <memory> #include <string> namespace zilliz { namespace milvus { Loading @@ -33,9 +33,11 @@ class CpuCacheMgr : public CacheMgr<DataObjPtr> { public: // TODO: use smart pointer instead static CpuCacheMgr *GetInstance(); static CpuCacheMgr* GetInstance(); engine::VecIndexPtr GetIndex(const std::string &key); engine::VecIndexPtr GetIndex(const std::string& key); }; } // namespace cache Loading Loading
cpp/build.sh +7 −7 Original line number Diff line number Diff line Loading @@ -104,13 +104,13 @@ if [[ ${RUN_CPPLINT} == "ON" ]]; then 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-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 Loading
cpp/src/cache/Cache.h +34 −22 Original line number Diff line number Diff line Loading @@ -15,16 +15,15 @@ // specific language governing permissions and limitations // under the License. #pragma once #include "LRU.h" #include "utils/Log.h" #include <string> #include <mutex> #include <atomic> #include <mutex> #include <set> #include <string> namespace zilliz { namespace milvus { Loading @@ -37,33 +36,46 @@ class Cache { 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 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_; Loading
cpp/src/cache/CacheMgr.h +26 −17 Original line number Diff line number Diff line Loading @@ -15,15 +15,14 @@ // 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 <string> #include <memory> #include <string> namespace zilliz { namespace milvus { Loading @@ -32,23 +31,33 @@ namespace cache { template <typename ItemObj> 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(); Loading
cpp/src/cache/CpuCacheMgr.cpp +8 −9 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. #include "cache/CpuCacheMgr.h" #include "server/Config.h" #include "utils/Log.h" Loading Loading @@ -50,8 +49,8 @@ CpuCacheMgr::CpuCacheMgr() { if (cpu_cache_threshold > 0.0 && cpu_cache_threshold <= 1.0) { cache_->set_freemem_percent(cpu_cache_threshold); } else { SERVER_LOG_ERROR << "Invalid cpu_cache_threshold: " << cpu_cache_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(); } } Loading
cpp/src/cache/CpuCacheMgr.h +9 −7 Original line number Diff line number Diff line Loading @@ -20,8 +20,8 @@ #include "CacheMgr.h" #include "DataObj.h" #include <string> #include <memory> #include <string> namespace zilliz { namespace milvus { Loading @@ -33,9 +33,11 @@ class CpuCacheMgr : public CacheMgr<DataObjPtr> { public: // TODO: use smart pointer instead static CpuCacheMgr *GetInstance(); static CpuCacheMgr* GetInstance(); engine::VecIndexPtr GetIndex(const std::string &key); engine::VecIndexPtr GetIndex(const std::string& key); }; } // namespace cache Loading