mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
add unittest
Former-commit-id: 89139a24caab971fa16b27b814ca4731efd0ea20
This commit is contained in:
parent
fabcbe9172
commit
5b26d194f3
@ -42,9 +42,11 @@ Status MemManagerImpl::InsertVectorsNoLock(const std::string &table_id,
|
||||
MemTablePtr mem = GetMemByTable(table_id);
|
||||
VectorSource::Ptr source = std::make_shared<VectorSource>(n, vectors);
|
||||
|
||||
auto status = mem->Add(source);
|
||||
auto status = mem->Add(source, vector_ids);
|
||||
if (status.ok()) {
|
||||
vector_ids = source->GetVectorIds();
|
||||
if (vector_ids.empty()) {
|
||||
vector_ids = source->GetVectorIds();
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ MemTable::MemTable(const std::string &table_id,
|
||||
|
||||
}
|
||||
|
||||
Status MemTable::Add(VectorSource::Ptr &source) {
|
||||
Status MemTable::Add(VectorSource::Ptr &source, IDNumbers &vector_ids) {
|
||||
|
||||
while (!source->AllAdded()) {
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ class MemTable {
|
||||
|
||||
MemTable(const std::string &table_id, const std::shared_ptr<meta::Meta> &meta, const Options &options);
|
||||
|
||||
Status Add(VectorSource::Ptr &source);
|
||||
Status Add(VectorSource::Ptr &source, IDNumbers &vector_ids);
|
||||
|
||||
void GetCurrentMemTableFile(MemTableFile::Ptr &mem_table_file);
|
||||
|
||||
|
||||
@ -12,9 +12,9 @@ namespace engine {
|
||||
|
||||
VectorSource::VectorSource(const size_t &n,
|
||||
const float *vectors) :
|
||||
n_(n),
|
||||
vectors_(vectors),
|
||||
id_generator_(new SimpleIDGenerator()) {
|
||||
n_(n),
|
||||
vectors_(vectors),
|
||||
id_generator_(std::make_shared<SimpleIDGenerator>()) {
|
||||
current_num_vectors_added = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ class VectorSource {
|
||||
|
||||
size_t current_num_vectors_added;
|
||||
|
||||
IDGenerator *id_generator_;
|
||||
std::shared_ptr<IDGenerator> id_generator_;
|
||||
|
||||
}; //VectorSource
|
||||
|
||||
|
||||
@ -381,9 +381,9 @@ InsertTask::InsertTask(const ::milvus::grpc::InsertParam &insert_param,
|
||||
}
|
||||
|
||||
BaseTaskPtr
|
||||
InsertTask::Create(const ::milvus::grpc::InsertParam &insert_infos,
|
||||
InsertTask::Create(const ::milvus::grpc::InsertParam &insert_param,
|
||||
::milvus::grpc::VectorIds &record_ids) {
|
||||
return std::shared_ptr<GrpcBaseTask>(new InsertTask(insert_infos, record_ids));
|
||||
return std::shared_ptr<GrpcBaseTask>(new InsertTask(insert_param, record_ids));
|
||||
}
|
||||
|
||||
ServerError
|
||||
@ -400,6 +400,13 @@ InsertTask::OnExecute() {
|
||||
return SetError(SERVER_INVALID_ROWRECORD_ARRAY, "Row record array is empty");
|
||||
}
|
||||
|
||||
if (!record_ids_.vector_id_array().empty()) {
|
||||
if (record_ids_.vector_id_array().size() != insert_param_.row_record_array_size()) {
|
||||
return SetError(SERVER_ILLEGAL_VECTOR_ID,
|
||||
"Size of vector ids is not equal to row record array size");
|
||||
}
|
||||
}
|
||||
|
||||
//step 2: check table existence
|
||||
engine::meta::TableSchema table_info;
|
||||
table_info.table_id_ = insert_param_.table_name();
|
||||
|
||||
@ -54,4 +54,7 @@ TEST(PrometheusTest, PROMETHEUS_TEST){
|
||||
instance.ConnectionGaugeDecrement();
|
||||
instance.KeepingAliveCounterIncrement();
|
||||
instance.OctetsSet();
|
||||
instance.CPUCoreUsagePercentSet();
|
||||
instance.GPUTemperature();
|
||||
instance.CPUTemperature();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user