未验证 提交 b12a19df 编写于 作者: Y yukun 提交者: GitHub

Fix bug (#3121)

* Fix Block Format Read bug
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Fix Search crash bug
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Fix CreateCollection bug
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Add db->Query unittest
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Fix index name bug
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>

* Fix test_db error
Signed-off-by: Nfishpenguin <kun.yu@zilliz.com>
Co-authored-by: NWang XiangYu <xy.wang@zilliz.com>
上级 7861da3e
......@@ -289,7 +289,7 @@ ExecutionEngineImpl::Search(ExecutionEngineContext& context) {
auto type = field->GetFtype();
if (field->GetFtype() == (int)engine::DataType::VECTOR_FLOAT ||
field->GetFtype() == (int)engine::DataType::VECTOR_BINARY) {
segment_ptr->GetVectorIndex(field->GetName(), vec_index);
STATUS_CHECK(segment_ptr->GetVectorIndex(field->GetName(), vec_index));
} else {
attr_type.insert(std::make_pair(field->GetName(), (engine::DataType)type));
}
......
......@@ -11,6 +11,7 @@
#include "knowhere/index/vector_index/ConfAdapter.h"
#include <cmath>
#include <limits>
#include <memory>
#include <string>
#include <vector>
......@@ -327,6 +328,8 @@ ANNOYConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
bool
ANNOYConfAdapter::CheckSearch(Config& oricfg, const IndexType type, const IndexMode mode) {
CheckIntByRange(knowhere::IndexParams::search_k, std::numeric_limits<int64_t>::min(),
std::numeric_limits<int64_t>::max());
return ConfAdapter::CheckSearch(oricfg, type, mode);
}
......
......@@ -308,17 +308,17 @@ SegmentReader::LoadVectorIndex(const std::string& field_name, knowhere::VecIndex
engine::snapshot::GetResPath<engine::snapshot::SegmentFile>(dir_collections_, index_visitor->GetFile());
ss_codec.GetVectorIndexFormat()->ReadIndex(fs_ptr_, file_path, index_data);
auto index_name = index_visitor->GetElement()->GetName();
auto index_type = index_visitor->GetElement()->GetTypeName();
// for some kinds index(IVF), read raw file
if (index_name == knowhere::IndexEnum::INDEX_FAISS_IVFFLAT || index_name == knowhere::IndexEnum::INDEX_NSG ||
index_name == knowhere::IndexEnum::INDEX_HNSW) {
if (index_type == knowhere::IndexEnum::INDEX_FAISS_IVFFLAT || index_type == knowhere::IndexEnum::INDEX_NSG ||
index_type == knowhere::IndexEnum::INDEX_HNSW) {
read_raw();
}
// for some kinds index(SQ8), read compress file
if (index_name == knowhere::IndexEnum::INDEX_FAISS_IVFSQ8NR ||
index_name == knowhere::IndexEnum::INDEX_HNSW_SQ8NM) {
if (index_type == knowhere::IndexEnum::INDEX_FAISS_IVFSQ8NR ||
index_type == knowhere::IndexEnum::INDEX_HNSW_SQ8NM) {
if (auto visitor = field_visitor->GetElementVisitor(engine::FieldElementType::FET_COMPRESS_SQ8)) {
file_path =
engine::snapshot::GetResPath<engine::snapshot::SegmentFile>(dir_collections_, visitor->GetFile());
......@@ -326,7 +326,7 @@ SegmentReader::LoadVectorIndex(const std::string& field_name, knowhere::VecIndex
}
}
ss_codec.GetVectorIndexFormat()->ConstructIndex(index_name, index_data, raw_data, compress_data, index_ptr);
ss_codec.GetVectorIndexFormat()->ConstructIndex(index_type, index_data, raw_data, compress_data, index_ptr);
index_ptr->SetUids(uids);
index_ptr->SetBlacklist(concurrent_bitset_ptr);
......
......@@ -52,6 +52,9 @@ SearchReq::OnExecute() {
std::string hdr = "SearchReq(table=" + query_ptr_->collection_id;
TimeRecorder rc(hdr);
STATUS_CHECK(ValidateCollectionName(query_ptr_->collection_id));
STATUS_CHECK(ValidatePartitionTags(query_ptr_->partitions));
// step 2: check table existence
// only process root table, ignore partition table
engine::snapshot::CollectionPtr collection;
......
......@@ -222,9 +222,10 @@ BuildEntities2(uint64_t n, uint64_t batch_index, milvus::engine::DataChunkPtr& d
vectors.id_array_.push_back(n * batch_index + i);
}
milvus::engine::FIXED_FIELD_DATA& raw = data_chunk->fixed_fields_["float_vector"];
raw.resize(vectors.float_data_.size() * sizeof(float));
memcpy(raw.data(), vectors.float_data_.data(), vectors.float_data_.size() * sizeof(float));
milvus::engine::BinaryDataPtr raw = std::make_shared<milvus::engine::BinaryData>();
raw->data_.resize(vectors.float_data_.size() * sizeof(float));
memcpy(raw->data_.data(), vectors.float_data_.data(), vectors.float_data_.size() * sizeof(float));
data_chunk->fixed_fields_["float_vector"] = raw;
std::vector<int64_t> value_1;
value_1.resize(n);
......@@ -234,9 +235,10 @@ BuildEntities2(uint64_t n, uint64_t batch_index, milvus::engine::DataChunkPtr& d
}
{
milvus::engine::FIXED_FIELD_DATA& raw = data_chunk->fixed_fields_["int64"];
raw.resize(value_1.size() * sizeof(int64_t));
memcpy(raw.data(), value_1.data(), value_1.size() * sizeof(int64_t));
milvus::engine::BinaryDataPtr raw = std::make_shared<milvus::engine::BinaryData>();
raw->data_.resize(value_1.size() * sizeof(int64_t));
memcpy(raw->data_.data(), value_1.data(), value_1.size() * sizeof(int64_t));
data_chunk->fixed_fields_["int64"] = raw;
}
}
} // namespace
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册