Commit 8cef5e00 authored by 余昆's avatar 余昆
Browse files

Merge remote-tracking branch 'upstream/branch-0.5.0' into branch-0.5.0-yk


Former-commit-id: 281b50c7f47996d98d972a72a19a4ef600a56ece
parents e64b7edc 9eb09e86
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -18,3 +18,8 @@
BasedOnStyle:  Google
DerivePointerAlignment: false
ColumnLimit: 120
IndentWidth: 4
AccessModifierOffset: -3
AlwaysBreakAfterReturnType: All
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
+39 −0
Original line number Diff line number Diff line
<code_scheme name="Default" version="173">
  <Objective-C>
    <option name="INDENT_NAMESPACE_MEMBERS" value="0" />
    <option name="INDENT_VISIBILITY_KEYWORDS" value="1" />
    <option name="KEEP_STRUCTURES_IN_ONE_LINE" value="true" />
    <option name="KEEP_CASE_EXPRESSIONS_IN_ONE_LINE" value="true" />
    <option name="FUNCTION_NON_TOP_AFTER_RETURN_TYPE_WRAP" value="0" />
    <option name="FUNCTION_TOP_AFTER_RETURN_TYPE_WRAP" value="2" />
    <option name="FUNCTION_PARAMETERS_WRAP" value="5" />
    <option name="FUNCTION_CALL_ARGUMENTS_WRAP" value="5" />
    <option name="TEMPLATE_CALL_ARGUMENTS_WRAP" value="5" />
    <option name="TEMPLATE_CALL_ARGUMENTS_ALIGN_MULTILINE" value="true" />
    <option name="CLASS_CONSTRUCTOR_INIT_LIST_WRAP" value="5" />
    <option name="ALIGN_INIT_LIST_IN_COLUMNS" value="false" />
    <option name="SPACE_BEFORE_PROTOCOLS_BRACKETS" value="false" />
    <option name="SPACE_BEFORE_POINTER_IN_DECLARATION" value="false" />
    <option name="SPACE_AFTER_POINTER_IN_DECLARATION" value="true" />
    <option name="SPACE_BEFORE_REFERENCE_IN_DECLARATION" value="false" />
    <option name="SPACE_AFTER_REFERENCE_IN_DECLARATION" value="true" />
    <option name="KEEP_BLANK_LINES_BEFORE_END" value="1" />
  </Objective-C>
  <codeStyleSettings language="ObjectiveC">
    <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
    <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
    <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
    <option name="BLANK_LINES_AROUND_CLASS" value="0" />
    <option name="BLANK_LINES_AROUND_METHOD_IN_INTERFACE" value="0" />
    <option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
    <option name="ALIGN_MULTILINE_BINARY_OPERATION" value="false" />
    <option name="SPACE_AFTER_TYPE_CAST" value="false" />
    <option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
    <option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="false" />
    <option name="FOR_STATEMENT_WRAP" value="1" />
    <option name="ASSIGNMENT_WRAP" value="1" />
    <indentOptions>
      <option name="CONTINUATION_INDENT_SIZE" value="4" />
    </indentOptions>
  </codeStyleSettings>
</code_scheme>
 No newline at end of file
+7 −7
Original line number Diff line number Diff line
@@ -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
+34 −22
Original line number Diff line number Diff line
@@ -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 {
@@ -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_;
+26 −17
Original line number Diff line number Diff line
@@ -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 {
@@ -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