mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
63 lines
1.6 KiB
C++
63 lines
1.6 KiB
C++
/*******************************************************************************
|
|
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
|
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
|
* Proprietary and confidential.
|
|
******************************************************************************/
|
|
#pragma once
|
|
|
|
#include "db/MetaTypes.h"
|
|
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <condition_variable>
|
|
|
|
namespace zilliz {
|
|
namespace vecwise {
|
|
namespace engine {
|
|
|
|
using TableFileSchemaPtr = std::shared_ptr<meta::TableFileSchema>;
|
|
|
|
class SearchContext {
|
|
public:
|
|
SearchContext(uint64_t topk, uint64_t nq, const float* vectors);
|
|
|
|
bool AddIndexFile(TableFileSchemaPtr& index_file);
|
|
|
|
uint64_t topk() const { return topk_; }
|
|
uint64_t nq() const { return nq_; }
|
|
const float* vectors() const { return vectors_; }
|
|
|
|
using Id2IndexMap = std::unordered_map<size_t, TableFileSchemaPtr>;
|
|
const Id2IndexMap& GetIndexMap() const { return map_index_files_; }
|
|
|
|
using Score2IdMap = std::map<float, int64_t>;
|
|
using ResultSet = std::vector<Score2IdMap>;
|
|
const ResultSet& GetResult() const { return result_; }
|
|
ResultSet& GetResult() { return result_; }
|
|
|
|
void IndexSearchDone(size_t index_id);
|
|
void WaitResult();
|
|
|
|
private:
|
|
uint64_t topk_ = 0;
|
|
uint64_t nq_ = 0;
|
|
const float* vectors_ = nullptr;
|
|
|
|
Id2IndexMap map_index_files_;
|
|
ResultSet result_;
|
|
|
|
std::mutex mtx_;
|
|
std::condition_variable done_cond_;
|
|
|
|
std::string identity_; //for debug
|
|
};
|
|
|
|
using SearchContextPtr = std::shared_ptr<SearchContext>;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|