EngineFactory.cpp 1.6 KB
Newer Older
G
groot 已提交
1 2 3 4 5 6 7 8 9
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/
#include "EngineFactory.h"
#include "FaissExecutionEngine.h"
#include "Log.h"

Y
yu yunfeng 已提交
10

G
groot 已提交
11
namespace zilliz {
J
jinhai 已提交
12
namespace milvus {
G
groot 已提交
13 14 15 16
namespace engine {

ExecutionEnginePtr
EngineFactory::Build(uint16_t dimension,
Y
yu yunfeng 已提交
17 18 19 20 21 22 23 24
                     const std::string &location,
                     EngineType type) {

    ExecutionEnginePtr execution_engine_ptr;

    switch (type) {
        case EngineType::FAISS_IDMAP: {
            execution_engine_ptr =
25
                ExecutionEnginePtr(new FaissExecutionEngine(dimension, location, BUILD_INDEX_TYPE_IDMAP, "IDMap,Flat"));
Y
yu yunfeng 已提交
26 27 28 29 30
            break;
        }

        case EngineType::FAISS_IVFFLAT: {
            execution_engine_ptr =
31
                ExecutionEnginePtr(new FaissExecutionEngine(dimension, location, BUILD_INDEX_TYPE_IVF, "IDMap,Flat"));
Y
yu yunfeng 已提交
32 33 34
            break;
        }

S
starlord 已提交
35 36
        case EngineType::FAISS_IVFSQ8: {
            execution_engine_ptr =
37
                    ExecutionEnginePtr(new FaissExecutionEngine(dimension, location, BUILD_INDEX_TYPE_IVFSQ8, "IDMap,Flat"));
S
starlord 已提交
38 39 40
            break;
        }

Y
yu yunfeng 已提交
41 42
        default: {
            ENGINE_LOG_ERROR << "Unsupported engine type";
G
groot 已提交
43
            return nullptr;
Y
yu yunfeng 已提交
44
        }
G
groot 已提交
45
    }
Y
yu yunfeng 已提交
46 47 48

    execution_engine_ptr->Init();
    return execution_engine_ptr;
G
groot 已提交
49 50 51 52 53
}

}
}
}