Commit 7633437e authored by starlord's avatar starlord
Browse files

format wrapper code


Former-commit-id: 75fc82a41b150fbd3f1ddcc9d09c7c4b4e43c93b
parent e9d3f80c
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -7,4 +7,3 @@
*SqliteMetaImpl.cpp
*src/grpc*
*src/core*
 No newline at end of file
*src/wrapper*
 No newline at end of file
+22 −22
Original line number Diff line number Diff line
@@ -15,13 +15,14 @@
// specific language governing permissions and limitations
// under the License.

#include "wrapper/ConfAdapter.h"
#include "knowhere/index/vector_index/helpers/IndexParameter.h"
#include "utils/Log.h"

#include <cmath>
#include "ConfAdapter.h"
#include "src/utils/Log.h"
#include "knowhere/index/vector_index/helpers/IndexParameter.h"
#include <memory>

// TODO: add conf checker
// TODO(lxj): add conf checker

namespace zilliz {
namespace milvus {
@@ -95,10 +96,9 @@ IVFConfAdapter::MatchSearch(const TempMetaConf &metaconf, const IndexType &type)
        case IndexType::FAISS_IVFPQ_GPU:
            if (conf->nprobe > GPU_MAX_NRPOBE) {
                WRAPPER_LOG_WARNING << "When search with GPU, nprobe shoud be no more than " << GPU_MAX_NRPOBE
                                    << ", but you passed " << conf->nprobe
                                    << ". Search with " << GPU_MAX_NRPOBE << " instead";
                                    << ", but you passed " << conf->nprobe << ". Search with " << GPU_MAX_NRPOBE
                                    << " instead";
                conf->nprobe = GPU_MAX_NRPOBE;

            }
    }
    return conf;
@@ -160,6 +160,6 @@ NSGConfAdapter::MatchSearch(const TempMetaConf &metaconf, const IndexType &type)
    return conf;
}

}
}
}
}  // namespace engine
}  // namespace milvus
}  // namespace zilliz
+19 −17
Original line number Diff line number Diff line
@@ -15,12 +15,12 @@
// specific language governing permissions and limitations
// under the License.


#pragma once

#include "knowhere/common/Config.h"
#include "VecIndex.h"
#include "knowhere/common/Config.h"

#include <memory>

namespace zilliz {
namespace milvus {
@@ -51,7 +51,8 @@ class ConfAdapter {
    //    Dump(){}

 protected:
    static void MatchBase(knowhere::Config conf);
    static void
    MatchBase(knowhere::Config conf);
};

using ConfAdapterPtr = std::shared_ptr<ConfAdapter>;
@@ -65,7 +66,8 @@ class IVFConfAdapter : public ConfAdapter {
    MatchSearch(const TempMetaConf& metaconf, const IndexType& type) override;

 protected:
    static int64_t MatchNlist(const int64_t &size, const int64_t &nlist);
    static int64_t
    MatchNlist(const int64_t& size, const int64_t& nlist);
};

class IVFSQConfAdapter : public IVFConfAdapter {
@@ -89,6 +91,6 @@ class NSGConfAdapter : public IVFConfAdapter {
    MatchSearch(const TempMetaConf& metaconf, const IndexType& type) final;
};

}
}
}
}  // namespace engine
}  // namespace milvus
}  // namespace zilliz
+9 −11
Original line number Diff line number Diff line
@@ -15,10 +15,8 @@
// specific language governing permissions and limitations
// under the License.


#include "src/utils/Exception.h"
#include "ConfAdapterMgr.h"

#include "wrapper/ConfAdapterMgr.h"
#include "utils/Exception.h"

namespace zilliz {
namespace milvus {
@@ -26,7 +24,8 @@ namespace engine {

ConfAdapterPtr
AdapterMgr::GetAdapter(const IndexType& indexType) {
    if (!init_) RegisterAdapter();
    if (!init_)
        RegisterAdapter();

    auto it = table_.find(indexType);
    if (it != table_.end()) {
@@ -36,8 +35,8 @@ AdapterMgr::GetAdapter(const IndexType &indexType) {
    }
}


#define REGISTER_CONF_ADAPTER(T, KEY, NAME) static AdapterMgr::register_t<T> reg_##NAME##_(KEY)

void
AdapterMgr::RegisterAdapter() {
    init_ = true;
@@ -58,7 +57,6 @@ AdapterMgr::RegisterAdapter() {
    REGISTER_CONF_ADAPTER(NSGConfAdapter, IndexType::NSG_MIX, nsg_mix);
}

} // engine
} // milvus
} // zilliz
}  // namespace engine
}  // namespace milvus
}  // namespace zilliz
+11 −16
Original line number Diff line number Diff line
@@ -15,12 +15,13 @@
// specific language governing permissions and limitations
// under the License.


#pragma once

#include "VecIndex.h"
#include "ConfAdapter.h"
#include "VecIndex.h"

#include <map>
#include <memory>

namespace zilliz {
namespace milvus {
@@ -31,9 +32,7 @@ class AdapterMgr {
    template <typename T>
    struct register_t {
        explicit register_t(const IndexType& key) {
            AdapterMgr::GetInstance().table_.emplace(key, [] {
                return std::make_shared<T>();
            });
            AdapterMgr::GetInstance().table_.emplace(key, [] { return std::make_shared<T>(); });
        }
    };

@@ -54,10 +53,6 @@ class AdapterMgr {
    std::map<IndexType, std::function<ConfAdapterPtr()> > table_;
};


} // engine
} // milvus
} // zilliz


}  // namespace engine
}  // namespace milvus
}  // namespace zilliz
Loading