mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-02-02 01:06:41 +08:00
update collection sdk (#3037)
* update request enum Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update collection request Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update request Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update request interface Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update request names Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * fix clang-formatg Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * fix clang-format Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * remove DescribeIndex Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update sdk Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update sdk Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * fix unittest Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
This commit is contained in:
parent
fc3839ccc5
commit
32bb441a36
@ -52,25 +52,21 @@ class DB {
|
||||
virtual Status
|
||||
DropCollection(const std::string& name) = 0;
|
||||
|
||||
virtual Status
|
||||
DescribeCollection(const std::string& collection_name, snapshot::CollectionPtr& collection,
|
||||
snapshot::CollectionMappings& fields_schema) = 0;
|
||||
|
||||
virtual Status
|
||||
HasCollection(const std::string& collection_name, bool& has_or_not) = 0;
|
||||
|
||||
virtual Status
|
||||
AllCollections(std::vector<std::string>& names) = 0;
|
||||
ListCollections(std::vector<std::string>& names) = 0;
|
||||
|
||||
virtual Status
|
||||
GetCollectionInfo(const std::string& collection_name, std::string& collection_info) = 0;
|
||||
GetCollectionInfo(const std::string& collection_name, snapshot::CollectionPtr& collection,
|
||||
snapshot::CollectionMappings& fields_schema) = 0;
|
||||
|
||||
virtual Status
|
||||
GetCollectionRowCount(const std::string& collection_name, uint64_t& row_count) = 0;
|
||||
GetCollectionStats(const std::string& collection_name, std::string& collection_stats) = 0;
|
||||
|
||||
virtual Status
|
||||
LoadCollection(const server::ContextPtr& context, const std::string& collection_name,
|
||||
const std::vector<std::string>& field_names, bool force = false) = 0;
|
||||
CountEntities(const std::string& collection_name, int64_t& row_count) = 0;
|
||||
|
||||
virtual Status
|
||||
CreatePartition(const std::string& collection_name, const std::string& partition_name) = 0;
|
||||
@ -78,17 +74,41 @@ class DB {
|
||||
virtual Status
|
||||
DropPartition(const std::string& collection_name, const std::string& partition_name) = 0;
|
||||
|
||||
virtual Status
|
||||
ShowPartitions(const std::string& collection_name, std::vector<std::string>& partition_names) = 0;
|
||||
|
||||
virtual Status
|
||||
HasPartition(const std::string& collection_name, const std::string& partition_tag, bool& exist) = 0;
|
||||
|
||||
virtual Status
|
||||
InsertEntities(const std::string& collection_name, const std::string& partition_name, DataChunkPtr& data_chunk) = 0;
|
||||
ListPartitions(const std::string& collection_name, std::vector<std::string>& partition_names) = 0;
|
||||
|
||||
virtual Status
|
||||
DeleteEntities(const std::string& collection_name, engine::IDNumbers entity_ids) = 0;
|
||||
CreateIndex(const server::ContextPtr& context, const std::string& collection_id, const std::string& field_name,
|
||||
const CollectionIndex& index) = 0;
|
||||
|
||||
virtual Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name) = 0;
|
||||
|
||||
virtual Status
|
||||
DropIndex(const std::string& collection_id) = 0;
|
||||
|
||||
virtual Status
|
||||
Insert(const std::string& collection_name, const std::string& partition_name, DataChunkPtr& data_chunk) = 0;
|
||||
|
||||
virtual Status
|
||||
GetEntityByID(const std::string& collection_name, const IDNumbers& id_array,
|
||||
const std::vector<std::string>& field_names, DataChunkPtr& data_chunk) = 0;
|
||||
|
||||
virtual Status
|
||||
DeleteEntityByID(const std::string& collection_name, const engine::IDNumbers entity_ids) = 0;
|
||||
|
||||
virtual Status
|
||||
ListIDInSegment(const std::string& collection_id, int64_t segment_id, IDNumbers& entity_ids) = 0;
|
||||
|
||||
virtual Status
|
||||
Query(const server::ContextPtr& context, const query::QueryPtr& query_ptr, engine::QueryResultPtr& result) = 0;
|
||||
|
||||
virtual Status
|
||||
LoadCollection(const server::ContextPtr& context, const std::string& collection_name,
|
||||
const std::vector<std::string>& field_names, bool force = false) = 0;
|
||||
|
||||
virtual Status
|
||||
Flush(const std::string& collection_name) = 0;
|
||||
@ -98,29 +118,6 @@ class DB {
|
||||
|
||||
virtual Status
|
||||
Compact(const server::ContextPtr& context, const std::string& collection_name, double threshold = 0.0) = 0;
|
||||
|
||||
virtual Status
|
||||
GetEntityByID(const std::string& collection_name, const IDNumbers& id_array,
|
||||
const std::vector<std::string>& field_names, DataChunkPtr& data_chunk) = 0;
|
||||
|
||||
virtual Status
|
||||
GetEntityIDs(const std::string& collection_id, int64_t segment_id, IDNumbers& entity_ids) = 0;
|
||||
|
||||
virtual Status
|
||||
CreateIndex(const server::ContextPtr& context, const std::string& collection_id, const std::string& field_name,
|
||||
const CollectionIndex& index) = 0;
|
||||
|
||||
virtual Status
|
||||
DescribeIndex(const std::string& collection_id, const std::string& field_name, CollectionIndex& index) = 0;
|
||||
|
||||
virtual Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name) = 0;
|
||||
|
||||
virtual Status
|
||||
DropIndex(const std::string& collection_id) = 0;
|
||||
|
||||
virtual Status
|
||||
Query(const server::ContextPtr& context, const query::QueryPtr& query_ptr, engine::QueryResultPtr& result) = 0;
|
||||
}; // DB
|
||||
|
||||
using DBPtr = std::shared_ptr<DB>;
|
||||
|
||||
@ -228,22 +228,6 @@ DBImpl::CreateCollection(const snapshot::CreateCollectionContext& context) {
|
||||
return op->Push();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::DescribeCollection(const std::string& collection_name, snapshot::CollectionPtr& collection,
|
||||
snapshot::CollectionMappings& fields_schema) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
collection = ss->GetCollection();
|
||||
auto& fields = ss->GetResources<snapshot::Field>();
|
||||
for (auto& kv : fields) {
|
||||
fields_schema[kv.second.Get()] = ss->GetFieldElementsByField(kv.second->GetName());
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::DropCollection(const std::string& name) {
|
||||
CHECK_INITIALIZED;
|
||||
@ -276,7 +260,7 @@ DBImpl::HasCollection(const std::string& collection_name, bool& has_or_not) {
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::AllCollections(std::vector<std::string>& names) {
|
||||
DBImpl::ListCollections(std::vector<std::string>& names) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
names.clear();
|
||||
@ -284,21 +268,34 @@ DBImpl::AllCollections(std::vector<std::string>& names) {
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::GetCollectionInfo(const std::string& collection_name, std::string& collection_info) {
|
||||
DBImpl::GetCollectionInfo(const std::string& collection_name, snapshot::CollectionPtr& collection,
|
||||
snapshot::CollectionMappings& fields_schema) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
nlohmann::json json;
|
||||
auto status = GetSnapshotInfo(collection_name, json);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
collection_info = json.dump();
|
||||
collection = ss->GetCollection();
|
||||
auto& fields = ss->GetResources<snapshot::Field>();
|
||||
for (auto& kv : fields) {
|
||||
fields_schema[kv.second.Get()] = ss->GetFieldElementsByField(kv.second->GetName());
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::GetCollectionRowCount(const std::string& collection_name, uint64_t& row_count) {
|
||||
DBImpl::GetCollectionStats(const std::string& collection_name, std::string& collection_stats) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
nlohmann::json json;
|
||||
STATUS_CHECK(GetSnapshotInfo(collection_name, json));
|
||||
|
||||
collection_stats = json.dump();
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::CountEntities(const std::string& collection_name, int64_t& row_count) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
@ -308,20 +305,6 @@ DBImpl::GetCollectionRowCount(const std::string& collection_name, uint64_t& row_
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::LoadCollection(const server::ContextPtr& context, const std::string& collection_name,
|
||||
const std::vector<std::string>& field_names, bool force) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
auto handler = std::make_shared<LoadVectorFieldHandler>(context, ss);
|
||||
handler->Iterate();
|
||||
|
||||
return handler->GetStatus();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::CreatePartition(const std::string& collection_name, const std::string& partition_name) {
|
||||
CHECK_INITIALIZED;
|
||||
@ -362,17 +345,6 @@ DBImpl::DropPartition(const std::string& collection_name, const std::string& par
|
||||
return op->Push();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::ShowPartitions(const std::string& collection_name, std::vector<std::string>& partition_names) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
partition_names = std::move(ss->GetPartitionNames());
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::HasPartition(const std::string& collection_name, const std::string& partition_tag, bool& exist) {
|
||||
CHECK_INITIALIZED;
|
||||
@ -393,8 +365,108 @@ DBImpl::HasPartition(const std::string& collection_name, const std::string& part
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::InsertEntities(const std::string& collection_name, const std::string& partition_name,
|
||||
DataChunkPtr& data_chunk) {
|
||||
DBImpl::ListPartitions(const std::string& collection_name, std::vector<std::string>& partition_names) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
partition_names = std::move(ss->GetPartitionNames());
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::CreateIndex(const std::shared_ptr<server::Context>& context, const std::string& collection_name,
|
||||
const std::string& field_name, const CollectionIndex& index) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
// step 1: wait merge file thread finished to avoid duplicate data bug
|
||||
auto status = Flush();
|
||||
WaitMergeFileFinish(); // let merge file thread finish
|
||||
|
||||
// step 2: compare old index and new index
|
||||
CollectionIndex new_index = index;
|
||||
CollectionIndex old_index;
|
||||
STATUS_CHECK(GetSnapshotIndex(collection_name, field_name, old_index));
|
||||
|
||||
if (utils::IsSameIndex(old_index, new_index)) {
|
||||
return Status::OK(); // same index
|
||||
}
|
||||
|
||||
// step 3: drop old index
|
||||
DropIndex(collection_name);
|
||||
WaitMergeFileFinish(); // let merge file thread finish since DropIndex start a merge task
|
||||
|
||||
// step 4: create field element for index
|
||||
status = SetSnapshotIndex(collection_name, field_name, new_index);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// step 5: start background build index thread
|
||||
std::vector<std::string> collection_names = {collection_name};
|
||||
WaitBuildIndexFinish();
|
||||
StartBuildIndexTask(collection_names);
|
||||
|
||||
// step 6: iterate segments need to be build index, wait until all segments are built
|
||||
while (true) {
|
||||
SnapshotVisitor ss_visitor(collection_name);
|
||||
snapshot::IDS_TYPE segment_ids;
|
||||
ss_visitor.SegmentsToIndex(field_name, segment_ids);
|
||||
if (segment_ids.empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
index_req_swn_.Wait_For(std::chrono::seconds(1));
|
||||
|
||||
// client break the connection, no need to block, check every 1 second
|
||||
if (context && context->IsConnectionBroken()) {
|
||||
LOG_ENGINE_DEBUG_ << "Client connection broken, build index in background";
|
||||
break; // just break, not return, continue to update partitions files to to_index
|
||||
}
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::DropIndex(const std::string& collection_name, const std::string& field_name) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
LOG_ENGINE_DEBUG_ << "Drop index for collection: " << collection_name;
|
||||
|
||||
STATUS_CHECK(DeleteSnapshotIndex(collection_name, field_name));
|
||||
|
||||
std::set<std::string> merge_collection_names = {collection_name};
|
||||
StartMergeTask(merge_collection_names, true);
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::DropIndex(const std::string& collection_name) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
LOG_ENGINE_DEBUG_ << "Drop index for collection: " << collection_name;
|
||||
|
||||
std::vector<std::string> field_names;
|
||||
{
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
field_names = ss->GetFieldNames();
|
||||
}
|
||||
|
||||
snapshot::OperationContext context;
|
||||
for (auto& field_name : field_names) {
|
||||
STATUS_CHECK(DeleteSnapshotIndex(collection_name, field_name));
|
||||
}
|
||||
|
||||
std::set<std::string> merge_collection_names = {collection_name};
|
||||
StartMergeTask(merge_collection_names, true);
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::Insert(const std::string& collection_name, const std::string& partition_name, DataChunkPtr& data_chunk) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
if (data_chunk == nullptr) {
|
||||
@ -421,17 +493,17 @@ DBImpl::InsertEntities(const std::string& collection_name, const std::string& pa
|
||||
|
||||
if (options_.wal_enable_) {
|
||||
return Status(SERVER_NOT_IMPLEMENT, "Wal not implemented");
|
||||
// auto vector_it = entity.vector_data_.begin();
|
||||
// if (!vector_it->second.binary_data_.empty()) {
|
||||
// wal_mgr_->InsertEntities(collection_name, partition_name, entity.id_array_,
|
||||
// vector_it->second.binary_data_,
|
||||
// attr_nbytes, attr_data);
|
||||
// } else if (!vector_it->second.float_data_.empty()) {
|
||||
// wal_mgr_->InsertEntities(collection_name, partition_name, entity.id_array_,
|
||||
// vector_it->second.float_data_,
|
||||
// attr_nbytes, attr_data);
|
||||
// }
|
||||
// swn_wal_.Notify();
|
||||
// auto vector_it = entity.vector_data_.begin();
|
||||
// if (!vector_it->second.binary_data_.empty()) {
|
||||
// wal_mgr_->InsertEntities(collection_name, partition_name, entity.id_array_,
|
||||
// vector_it->second.binary_data_,
|
||||
// attr_nbytes, attr_data);
|
||||
// } else if (!vector_it->second.float_data_.empty()) {
|
||||
// wal_mgr_->InsertEntities(collection_name, partition_name, entity.id_array_,
|
||||
// vector_it->second.float_data_,
|
||||
// attr_nbytes, attr_data);
|
||||
// }
|
||||
// swn_wal_.Notify();
|
||||
} else {
|
||||
// insert entities: collection_name is field id
|
||||
wal::MXLogRecord record;
|
||||
@ -449,14 +521,31 @@ DBImpl::InsertEntities(const std::string& collection_name, const std::string& pa
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::DeleteEntities(const std::string& collection_name, engine::IDNumbers entity_ids) {
|
||||
DBImpl::GetEntityByID(const std::string& collection_name, const IDNumbers& id_array,
|
||||
const std::vector<std::string>& field_names, DataChunkPtr& data_chunk) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
std::string dir_root = options_.meta_.path_;
|
||||
auto handler = std::make_shared<GetEntityByIdSegmentHandler>(nullptr, ss, dir_root, id_array, field_names);
|
||||
handler->Iterate();
|
||||
STATUS_CHECK(handler->GetStatus());
|
||||
|
||||
data_chunk = handler->data_chunk_;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::DeleteEntityByID(const std::string& collection_name, const engine::IDNumbers entity_ids) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
Status status;
|
||||
if (options_.wal_enable_) {
|
||||
return Status(SERVER_NOT_IMPLEMENT, "Wal not implemented");
|
||||
// wal_mgr_->DeleteById(collection_name, entity_ids);
|
||||
// swn_wal_.Notify();
|
||||
// wal_mgr_->DeleteById(collection_name, entity_ids);
|
||||
// swn_wal_.Notify();
|
||||
} else {
|
||||
wal::MXLogRecord record;
|
||||
record.lsn = 0; // need to get from meta ?
|
||||
@ -471,6 +560,136 @@ DBImpl::DeleteEntities(const std::string& collection_name, engine::IDNumbers ent
|
||||
return status;
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::Query(const server::ContextPtr& context, const query::QueryPtr& query_ptr, engine::QueryResultPtr& result) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
TimeRecorder rc("SSDBImpl::Query");
|
||||
|
||||
scheduler::SSSearchJobPtr job = std::make_shared<scheduler::SearchJob>(nullptr, options_, query_ptr);
|
||||
|
||||
/* put search job to scheduler and wait job finish */
|
||||
scheduler::JobMgrInst::GetInstance()->Put(job);
|
||||
job->WaitFinish();
|
||||
|
||||
if (!job->status().ok()) {
|
||||
return job->status();
|
||||
}
|
||||
|
||||
// snapshot::ScopedSnapshotT ss;
|
||||
// STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
//
|
||||
// /* collect all valid segment */
|
||||
// std::vector<SegmentVisitor::Ptr> segment_visitors;
|
||||
// auto exec = [&] (const snapshot::Segment::Ptr& segment, snapshot::SegmentIterator* handler) -> Status {
|
||||
// auto p_id = segment->GetPartitionId();
|
||||
// auto p_ptr = ss->GetResource<snapshot::Partition>(p_id);
|
||||
// auto& p_name = p_ptr->GetName();
|
||||
//
|
||||
// /* check partition match pattern */
|
||||
// bool match = false;
|
||||
// if (partition_patterns.empty()) {
|
||||
// match = true;
|
||||
// } else {
|
||||
// for (auto &pattern : partition_patterns) {
|
||||
// if (StringHelpFunctions::IsRegexMatch(p_name, pattern)) {
|
||||
// match = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (match) {
|
||||
// auto visitor = SegmentVisitor::Build(ss, segment->GetID());
|
||||
// if (!visitor) {
|
||||
// return Status(milvus::SS_ERROR, "Cannot build segment visitor");
|
||||
// }
|
||||
// segment_visitors.push_back(visitor);
|
||||
// }
|
||||
// return Status::OK();
|
||||
// };
|
||||
//
|
||||
// auto segment_iter = std::make_shared<snapshot::SegmentIterator>(ss, exec);
|
||||
// segment_iter->Iterate();
|
||||
// STATUS_CHECK(segment_iter->GetStatus());
|
||||
//
|
||||
// LOG_ENGINE_DEBUG_ << LogOut("Engine query begin, segment count: %ld", segment_visitors.size());
|
||||
//
|
||||
// VectorsData vectors;
|
||||
// scheduler::SSSearchJobPtr job =
|
||||
// std::make_shared<scheduler::SSSearchJob>(tracer.Context(), general_query, query_ptr, attr_type, vectors);
|
||||
// for (auto& sv : segment_visitors) {
|
||||
// job->AddSegmentVisitor(sv);
|
||||
// }
|
||||
//
|
||||
// // step 2: put search job to scheduler and wait result
|
||||
// scheduler::JobMgrInst::GetInstance()->Put(job);
|
||||
// job->WaitResult();
|
||||
//
|
||||
// if (!job->GetStatus().ok()) {
|
||||
// return job->GetStatus();
|
||||
// }
|
||||
//
|
||||
// // step 3: construct results
|
||||
// result.row_num_ = job->vector_count();
|
||||
// result.result_ids_ = job->GetResultIds();
|
||||
// result.result_distances_ = job->GetResultDistances();
|
||||
|
||||
// step 4: get entities by result ids
|
||||
// STATUS_CHECK(GetEntityByID(collection_name, result.result_ids_, field_names, result.vectors_, result.attrs_));
|
||||
|
||||
// step 5: filter entities by field names
|
||||
// std::vector<engine::AttrsData> filter_attrs;
|
||||
// for (auto attr : result.attrs_) {
|
||||
// AttrsData attrs_data;
|
||||
// attrs_data.attr_type_ = attr.attr_type_;
|
||||
// attrs_data.attr_count_ = attr.attr_count_;
|
||||
// attrs_data.id_array_ = attr.id_array_;
|
||||
// for (auto& name : field_names) {
|
||||
// if (attr.attr_data_.find(name) != attr.attr_data_.end()) {
|
||||
// attrs_data.attr_data_.insert(std::make_pair(name, attr.attr_data_.at(name)));
|
||||
// }
|
||||
// }
|
||||
// filter_attrs.emplace_back(attrs_data);
|
||||
// }
|
||||
|
||||
rc.ElapseFromBegin("Engine query totally cost");
|
||||
|
||||
// tracer.Context()->GetTraceContext()->GetSpan()->Finish();
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::ListIDInSegment(const std::string& collection_name, int64_t segment_id, IDNumbers& entity_ids) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
auto read_visitor = engine::SegmentVisitor::Build(ss, segment_id);
|
||||
segment::SegmentReaderPtr segment_reader =
|
||||
std::make_shared<segment::SegmentReader>(options_.meta_.path_, read_visitor);
|
||||
|
||||
STATUS_CHECK(segment_reader->LoadUids(entity_ids));
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::LoadCollection(const server::ContextPtr& context, const std::string& collection_name,
|
||||
const std::vector<std::string>& field_names, bool force) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
auto handler = std::make_shared<LoadVectorFieldHandler>(context, ss);
|
||||
handler->Iterate();
|
||||
|
||||
return handler->GetStatus();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::Flush(const std::string& collection_name) {
|
||||
if (!initialized_.load(std::memory_order_acquire)) {
|
||||
@ -614,239 +833,6 @@ DBImpl::Compact(const std::shared_ptr<server::Context>& context, const std::stri
|
||||
return status;
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::GetEntityByID(const std::string& collection_name, const IDNumbers& id_array,
|
||||
const std::vector<std::string>& field_names, DataChunkPtr& data_chunk) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
std::string dir_root = options_.meta_.path_;
|
||||
auto handler = std::make_shared<GetEntityByIdSegmentHandler>(nullptr, ss, dir_root, id_array, field_names);
|
||||
handler->Iterate();
|
||||
STATUS_CHECK(handler->GetStatus());
|
||||
|
||||
data_chunk = handler->data_chunk_;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::GetEntityIDs(const std::string& collection_name, int64_t segment_id, IDNumbers& entity_ids) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
|
||||
auto read_visitor = engine::SegmentVisitor::Build(ss, segment_id);
|
||||
segment::SegmentReaderPtr segment_reader =
|
||||
std::make_shared<segment::SegmentReader>(options_.meta_.path_, read_visitor);
|
||||
|
||||
STATUS_CHECK(segment_reader->LoadUids(entity_ids));
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::CreateIndex(const std::shared_ptr<server::Context>& context, const std::string& collection_name,
|
||||
const std::string& field_name, const CollectionIndex& index) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
// step 1: wait merge file thread finished to avoid duplicate data bug
|
||||
auto status = Flush();
|
||||
WaitMergeFileFinish(); // let merge file thread finish
|
||||
|
||||
// step 2: compare old index and new index
|
||||
CollectionIndex new_index = index;
|
||||
CollectionIndex old_index;
|
||||
status = DescribeIndex(collection_name, field_name, old_index);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (utils::IsSameIndex(old_index, new_index)) {
|
||||
return Status::OK(); // same index
|
||||
}
|
||||
|
||||
// step 3: drop old index
|
||||
DropIndex(collection_name);
|
||||
WaitMergeFileFinish(); // let merge file thread finish since DropIndex start a merge task
|
||||
|
||||
// step 4: create field element for index
|
||||
status = SetSnapshotIndex(collection_name, field_name, new_index);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// step 5: start background build index thread
|
||||
std::vector<std::string> collection_names = {collection_name};
|
||||
WaitBuildIndexFinish();
|
||||
StartBuildIndexTask(collection_names);
|
||||
|
||||
// step 6: iterate segments need to be build index, wait until all segments are built
|
||||
while (true) {
|
||||
SnapshotVisitor ss_visitor(collection_name);
|
||||
snapshot::IDS_TYPE segment_ids;
|
||||
ss_visitor.SegmentsToIndex(field_name, segment_ids);
|
||||
if (segment_ids.empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
index_req_swn_.Wait_For(std::chrono::seconds(1));
|
||||
|
||||
// client break the connection, no need to block, check every 1 second
|
||||
if (context && context->IsConnectionBroken()) {
|
||||
LOG_ENGINE_DEBUG_ << "Client connection broken, build index in background";
|
||||
break; // just break, not return, continue to update partitions files to to_index
|
||||
}
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::DescribeIndex(const std::string& collection_name, const std::string& field_name, CollectionIndex& index) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
return GetSnapshotIndex(collection_name, field_name, index);
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::DropIndex(const std::string& collection_name, const std::string& field_name) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
LOG_ENGINE_DEBUG_ << "Drop index for collection: " << collection_name;
|
||||
|
||||
STATUS_CHECK(DeleteSnapshotIndex(collection_name, field_name));
|
||||
|
||||
std::set<std::string> merge_collection_names = {collection_name};
|
||||
StartMergeTask(merge_collection_names, true);
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::DropIndex(const std::string& collection_name) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
LOG_ENGINE_DEBUG_ << "Drop index for collection: " << collection_name;
|
||||
|
||||
std::vector<std::string> field_names;
|
||||
{
|
||||
snapshot::ScopedSnapshotT ss;
|
||||
STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
field_names = ss->GetFieldNames();
|
||||
}
|
||||
|
||||
snapshot::OperationContext context;
|
||||
for (auto& field_name : field_names) {
|
||||
STATUS_CHECK(DeleteSnapshotIndex(collection_name, field_name));
|
||||
}
|
||||
|
||||
std::set<std::string> merge_collection_names = {collection_name};
|
||||
StartMergeTask(merge_collection_names, true);
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
DBImpl::Query(const server::ContextPtr& context, const query::QueryPtr& query_ptr, engine::QueryResultPtr& result) {
|
||||
CHECK_INITIALIZED;
|
||||
|
||||
TimeRecorder rc("SSDBImpl::Query");
|
||||
|
||||
scheduler::SSSearchJobPtr job = std::make_shared<scheduler::SearchJob>(nullptr, options_, query_ptr);
|
||||
|
||||
/* put search job to scheduler and wait job finish */
|
||||
scheduler::JobMgrInst::GetInstance()->Put(job);
|
||||
job->WaitFinish();
|
||||
|
||||
if (!job->status().ok()) {
|
||||
return job->status();
|
||||
}
|
||||
|
||||
// snapshot::ScopedSnapshotT ss;
|
||||
// STATUS_CHECK(snapshot::Snapshots::GetInstance().GetSnapshot(ss, collection_name));
|
||||
//
|
||||
// /* collect all valid segment */
|
||||
// std::vector<SegmentVisitor::Ptr> segment_visitors;
|
||||
// auto exec = [&] (const snapshot::Segment::Ptr& segment, snapshot::SegmentIterator* handler) -> Status {
|
||||
// auto p_id = segment->GetPartitionId();
|
||||
// auto p_ptr = ss->GetResource<snapshot::Partition>(p_id);
|
||||
// auto& p_name = p_ptr->GetName();
|
||||
//
|
||||
// /* check partition match pattern */
|
||||
// bool match = false;
|
||||
// if (partition_patterns.empty()) {
|
||||
// match = true;
|
||||
// } else {
|
||||
// for (auto &pattern : partition_patterns) {
|
||||
// if (StringHelpFunctions::IsRegexMatch(p_name, pattern)) {
|
||||
// match = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (match) {
|
||||
// auto visitor = SegmentVisitor::Build(ss, segment->GetID());
|
||||
// if (!visitor) {
|
||||
// return Status(milvus::SS_ERROR, "Cannot build segment visitor");
|
||||
// }
|
||||
// segment_visitors.push_back(visitor);
|
||||
// }
|
||||
// return Status::OK();
|
||||
// };
|
||||
//
|
||||
// auto segment_iter = std::make_shared<snapshot::SegmentIterator>(ss, exec);
|
||||
// segment_iter->Iterate();
|
||||
// STATUS_CHECK(segment_iter->GetStatus());
|
||||
//
|
||||
// LOG_ENGINE_DEBUG_ << LogOut("Engine query begin, segment count: %ld", segment_visitors.size());
|
||||
//
|
||||
// VectorsData vectors;
|
||||
// scheduler::SSSearchJobPtr job =
|
||||
// std::make_shared<scheduler::SSSearchJob>(tracer.Context(), general_query, query_ptr, attr_type, vectors);
|
||||
// for (auto& sv : segment_visitors) {
|
||||
// job->AddSegmentVisitor(sv);
|
||||
// }
|
||||
//
|
||||
// // step 2: put search job to scheduler and wait result
|
||||
// scheduler::JobMgrInst::GetInstance()->Put(job);
|
||||
// job->WaitResult();
|
||||
//
|
||||
// if (!job->GetStatus().ok()) {
|
||||
// return job->GetStatus();
|
||||
// }
|
||||
//
|
||||
// // step 3: construct results
|
||||
// result.row_num_ = job->vector_count();
|
||||
// result.result_ids_ = job->GetResultIds();
|
||||
// result.result_distances_ = job->GetResultDistances();
|
||||
|
||||
// step 4: get entities by result ids
|
||||
// STATUS_CHECK(GetEntityByID(collection_name, result.result_ids_, field_names, result.vectors_, result.attrs_));
|
||||
|
||||
// step 5: filter entities by field names
|
||||
// std::vector<engine::AttrsData> filter_attrs;
|
||||
// for (auto attr : result.attrs_) {
|
||||
// AttrsData attrs_data;
|
||||
// attrs_data.attr_type_ = attr.attr_type_;
|
||||
// attrs_data.attr_count_ = attr.attr_count_;
|
||||
// attrs_data.id_array_ = attr.id_array_;
|
||||
// for (auto& name : field_names) {
|
||||
// if (attr.attr_data_.find(name) != attr.attr_data_.end()) {
|
||||
// attrs_data.attr_data_.insert(std::make_pair(name, attr.attr_data_.at(name)));
|
||||
// }
|
||||
// }
|
||||
// filter_attrs.emplace_back(attrs_data);
|
||||
// }
|
||||
|
||||
rc.ElapseFromBegin("Engine query totally cost");
|
||||
|
||||
// tracer.Context()->GetTraceContext()->GetSpan()->Finish();
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal APIs
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -47,25 +47,21 @@ class DBImpl : public DB {
|
||||
Status
|
||||
DropCollection(const std::string& name) override;
|
||||
|
||||
Status
|
||||
DescribeCollection(const std::string& collection_name, snapshot::CollectionPtr& collection,
|
||||
snapshot::CollectionMappings& fields_schema) override;
|
||||
|
||||
Status
|
||||
HasCollection(const std::string& collection_name, bool& has_or_not) override;
|
||||
|
||||
Status
|
||||
AllCollections(std::vector<std::string>& names) override;
|
||||
ListCollections(std::vector<std::string>& names) override;
|
||||
|
||||
Status
|
||||
GetCollectionInfo(const std::string& collection_name, std::string& collection_info);
|
||||
GetCollectionInfo(const std::string& collection_name, snapshot::CollectionPtr& collection,
|
||||
snapshot::CollectionMappings& fields_schema) override;
|
||||
|
||||
Status
|
||||
GetCollectionRowCount(const std::string& collection_name, uint64_t& row_count) override;
|
||||
GetCollectionStats(const std::string& collection_name, std::string& collection_stats);
|
||||
|
||||
Status
|
||||
LoadCollection(const server::ContextPtr& context, const std::string& collection_name,
|
||||
const std::vector<std::string>& field_names, bool force = false) override;
|
||||
CountEntities(const std::string& collection_name, int64_t& row_count) override;
|
||||
|
||||
Status
|
||||
CreatePartition(const std::string& collection_name, const std::string& partition_name) override;
|
||||
@ -73,18 +69,41 @@ class DBImpl : public DB {
|
||||
Status
|
||||
DropPartition(const std::string& collection_name, const std::string& partition_name) override;
|
||||
|
||||
Status
|
||||
ShowPartitions(const std::string& collection_name, std::vector<std::string>& partition_names) override;
|
||||
|
||||
Status
|
||||
HasPartition(const std::string& collection_name, const std::string& partition_tag, bool& exist) override;
|
||||
|
||||
Status
|
||||
InsertEntities(const std::string& collection_name, const std::string& partition_name,
|
||||
DataChunkPtr& data_chunk) override;
|
||||
ListPartitions(const std::string& collection_name, std::vector<std::string>& partition_names) override;
|
||||
|
||||
Status
|
||||
DeleteEntities(const std::string& collection_name, engine::IDNumbers entity_ids) override;
|
||||
CreateIndex(const std::shared_ptr<server::Context>& context, const std::string& collection_name,
|
||||
const std::string& field_name, const CollectionIndex& index) override;
|
||||
|
||||
Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name) override;
|
||||
|
||||
Status
|
||||
DropIndex(const std::string& collection_name) override;
|
||||
|
||||
Status
|
||||
Insert(const std::string& collection_name, const std::string& partition_name, DataChunkPtr& data_chunk) override;
|
||||
|
||||
Status
|
||||
GetEntityByID(const std::string& collection_name, const IDNumbers& id_array,
|
||||
const std::vector<std::string>& field_names, DataChunkPtr& data_chunk) override;
|
||||
|
||||
Status
|
||||
DeleteEntityByID(const std::string& collection_name, const engine::IDNumbers entity_ids) override;
|
||||
|
||||
Status
|
||||
Query(const server::ContextPtr& context, const query::QueryPtr& query_ptr, engine::QueryResultPtr& result) override;
|
||||
|
||||
Status
|
||||
ListIDInSegment(const std::string& collection_name, int64_t segment_id, IDNumbers& entity_ids) override;
|
||||
|
||||
Status
|
||||
LoadCollection(const server::ContextPtr& context, const std::string& collection_name,
|
||||
const std::vector<std::string>& field_names, bool force = false) override;
|
||||
|
||||
Status
|
||||
Flush(const std::string& collection_name) override;
|
||||
@ -95,29 +114,6 @@ class DBImpl : public DB {
|
||||
Status
|
||||
Compact(const server::ContextPtr& context, const std::string& collection_name, double threshold = 0.0) override;
|
||||
|
||||
Status
|
||||
GetEntityByID(const std::string& collection_name, const IDNumbers& id_array,
|
||||
const std::vector<std::string>& field_names, DataChunkPtr& data_chunk) override;
|
||||
|
||||
Status
|
||||
GetEntityIDs(const std::string& collection_name, int64_t segment_id, IDNumbers& entity_ids) override;
|
||||
|
||||
Status
|
||||
CreateIndex(const std::shared_ptr<server::Context>& context, const std::string& collection_name,
|
||||
const std::string& field_name, const CollectionIndex& index) override;
|
||||
|
||||
Status
|
||||
DescribeIndex(const std::string& collection_name, const std::string& field_name, CollectionIndex& index) override;
|
||||
|
||||
Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name) override;
|
||||
|
||||
Status
|
||||
DropIndex(const std::string& collection_name) override;
|
||||
|
||||
Status
|
||||
Query(const server::ContextPtr& context, const query::QueryPtr& query_ptr, engine::QueryResultPtr& result) override;
|
||||
|
||||
private:
|
||||
void
|
||||
InternalFlush(const std::string& collection_name = "");
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include <grpcpp/server_context.h>
|
||||
|
||||
#include "server/context/ConnectionContext.h"
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
#include "tracing/TraceContext.h"
|
||||
|
||||
namespace milvus {
|
||||
|
||||
@ -14,30 +14,29 @@
|
||||
#include <set>
|
||||
|
||||
#include "server/delivery/RequestScheduler.h"
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/CmdRequest.h"
|
||||
#include "server/delivery/request/CompactRequest.h"
|
||||
#include "server/delivery/request/CountCollectionRequest.h"
|
||||
#include "server/delivery/request/CreateCollectionRequest.h"
|
||||
#include "server/delivery/request/CreateIndexRequest.h"
|
||||
#include "server/delivery/request/CreatePartitionRequest.h"
|
||||
#include "server/delivery/request/DeleteByIDRequest.h"
|
||||
#include "server/delivery/request/DescribeCollectionRequest.h"
|
||||
#include "server/delivery/request/DescribeIndexRequest.h"
|
||||
#include "server/delivery/request/DropCollectionRequest.h"
|
||||
#include "server/delivery/request/DropIndexRequest.h"
|
||||
#include "server/delivery/request/DropPartitionRequest.h"
|
||||
#include "server/delivery/request/FlushRequest.h"
|
||||
#include "server/delivery/request/GetEntityByIDRequest.h"
|
||||
#include "server/delivery/request/GetEntityIDsRequest.h"
|
||||
#include "server/delivery/request/HasCollectionRequest.h"
|
||||
#include "server/delivery/request/HasPartitionRequest.h"
|
||||
#include "server/delivery/request/InsertEntityRequest.h"
|
||||
#include "server/delivery/request/PreloadCollectionRequest.h"
|
||||
#include "server/delivery/request/SearchRequest.h"
|
||||
#include "server/delivery/request/ShowCollectionInfoRequest.h"
|
||||
#include "server/delivery/request/ShowCollectionsRequest.h"
|
||||
#include "server/delivery/request/ShowPartitionsRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
#include "server/delivery/request/CmdReq.h"
|
||||
#include "server/delivery/request/CompactReq.h"
|
||||
#include "server/delivery/request/CountEntitiesReq.h"
|
||||
#include "server/delivery/request/CreateCollectionReq.h"
|
||||
#include "server/delivery/request/CreateIndexReq.h"
|
||||
#include "server/delivery/request/CreatePartitionReq.h"
|
||||
#include "server/delivery/request/DeleteEntityByIDReq.h"
|
||||
#include "server/delivery/request/DropCollectionReq.h"
|
||||
#include "server/delivery/request/DropIndexReq.h"
|
||||
#include "server/delivery/request/DropPartitionReq.h"
|
||||
#include "server/delivery/request/FlushReq.h"
|
||||
#include "server/delivery/request/GetCollectionInfoReq.h"
|
||||
#include "server/delivery/request/GetCollectionStatsRequest.h"
|
||||
#include "server/delivery/request/GetEntityByIDReq.h"
|
||||
#include "server/delivery/request/HasCollectionReq.h"
|
||||
#include "server/delivery/request/HasPartitionReq.h"
|
||||
#include "server/delivery/request/InsertReq.h"
|
||||
#include "server/delivery/request/ListCollectionsReq.h"
|
||||
#include "server/delivery/request/ListIDInSegmentReq.h"
|
||||
#include "server/delivery/request/ListPartitionsReq.h"
|
||||
#include "server/delivery/request/LoadCollectionReq.h"
|
||||
#include "server/delivery/request/SearchReq.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
@ -49,16 +48,13 @@ RequestHandler::CreateCollection(const std::shared_ptr<Context>& context, const
|
||||
std::unordered_map<std::string, std::string>& field_params, milvus::json& json_param) {
|
||||
BaseRequestPtr request_ptr = CreateCollectionRequest::Create(context, collection_name, field_types,
|
||||
field_index_params, field_params, json_param);
|
||||
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::DescribeCollection(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
HybridCollectionSchema& collection_schema) {
|
||||
BaseRequestPtr request_ptr = DescribeCollectionRequest::Create(context, collection_name, collection_schema);
|
||||
|
||||
RequestHandler::DropCollection(const std::shared_ptr<Context>& context, const std::string& collection_name) {
|
||||
BaseRequestPtr request_ptr = DropCollectionRequest::Create(context, collection_name);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
@ -68,15 +64,69 @@ RequestHandler::HasCollection(const std::shared_ptr<Context>& context, const std
|
||||
bool& has_collection) {
|
||||
BaseRequestPtr request_ptr = HasCollectionRequest::Create(context, collection_name, has_collection);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::DropCollection(const std::shared_ptr<Context>& context, const std::string& collection_name) {
|
||||
BaseRequestPtr request_ptr = DropCollectionRequest::Create(context, collection_name);
|
||||
RequestHandler::ListCollections(const std::shared_ptr<Context>& context, std::vector<std::string>& collections) {
|
||||
BaseRequestPtr request_ptr = ListCollectionsRequest::Create(context, collections);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::GetCollectionInfo(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
CollectionSchema& collection_schema) {
|
||||
BaseRequestPtr request_ptr = GetCollectionInfoRequest::Create(context, collection_name, collection_schema);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::GetCollectionStats(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
std::string& collection_stats) {
|
||||
BaseRequestPtr request_ptr = GetCollectionStatsRequest::Create(context, collection_name, collection_stats);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::CountEntities(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
int64_t& count) {
|
||||
BaseRequestPtr request_ptr = CountEntitiesRequest::Create(context, collection_name, count);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::CreatePartition(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& tag) {
|
||||
BaseRequestPtr request_ptr = CreatePartitionRequest::Create(context, collection_name, tag);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::DropPartition(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& tag) {
|
||||
BaseRequestPtr request_ptr = DropPartitionRequest::Create(context, collection_name, tag);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::HasPartition(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& tag, bool& has_partition) {
|
||||
BaseRequestPtr request_ptr = HasPartitionRequest::Create(context, collection_name, tag, has_partition);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::ListPartitions(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
std::vector<std::string>& partitions) {
|
||||
BaseRequestPtr request_ptr = ListPartitionsRequest::Create(context, collection_name, partitions);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
@ -87,76 +137,6 @@ RequestHandler::CreateIndex(const std::shared_ptr<Context>& context, const std::
|
||||
BaseRequestPtr request_ptr =
|
||||
CreateIndexRequest::Create(context, collection_name, field_name, index_name, json_params);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::GetEntityIDs(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
int64_t segment_id, std::vector<int64_t>& vector_ids) {
|
||||
BaseRequestPtr request_ptr = GetEntityIDsRequest::Create(context, collection_name, segment_id, vector_ids);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::ShowCollections(const std::shared_ptr<Context>& context, std::vector<std::string>& collections) {
|
||||
BaseRequestPtr request_ptr = ShowCollectionsRequest::Create(context, collections);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::ShowCollectionInfo(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
std::string& collection_info) {
|
||||
BaseRequestPtr request_ptr = ShowCollectionInfoRequest::Create(context, collection_name, collection_info);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::CountCollection(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
int64_t& count) {
|
||||
BaseRequestPtr request_ptr = CountCollectionRequest::Create(context, collection_name, count);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::Cmd(const std::shared_ptr<Context>& context, const std::string& cmd, std::string& reply) {
|
||||
BaseRequestPtr request_ptr = CmdRequest::Create(context, cmd, reply);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::DeleteByID(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::vector<int64_t>& vector_ids) {
|
||||
BaseRequestPtr request_ptr = DeleteByIDRequest::Create(context, collection_name, vector_ids);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::PreloadCollection(const std::shared_ptr<Context>& context, const std::string& collection_name) {
|
||||
BaseRequestPtr request_ptr = PreloadCollectionRequest::Create(context, collection_name);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::DescribeIndex(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
IndexParam& param) {
|
||||
BaseRequestPtr request_ptr = DescribeIndexRequest::Create(context, collection_name, param);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
@ -165,70 +145,14 @@ RequestHandler::DropIndex(const std::shared_ptr<Context>& context, const std::st
|
||||
const std::string& field_name, const std::string& index_name) {
|
||||
BaseRequestPtr request_ptr = DropIndexRequest::Create(context, collection_name, index_name, field_name);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::CreatePartition(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& tag) {
|
||||
BaseRequestPtr request_ptr = CreatePartitionRequest::Create(context, collection_name, tag);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::HasPartition(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& tag, bool& has_partition) {
|
||||
BaseRequestPtr request_ptr = HasPartitionRequest::Create(context, collection_name, tag, has_partition);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::ShowPartitions(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
std::vector<std::string>& partitions) {
|
||||
BaseRequestPtr request_ptr = ShowPartitionsRequest::Create(context, collection_name, partitions);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::DropPartition(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& tag) {
|
||||
BaseRequestPtr request_ptr = DropPartitionRequest::Create(context, collection_name, tag);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::Flush(const std::shared_ptr<Context>& context, const std::vector<std::string>& collection_names) {
|
||||
BaseRequestPtr request_ptr = FlushRequest::Create(context, collection_names);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::Compact(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
double compact_threshold) {
|
||||
BaseRequestPtr request_ptr = CompactRequest::Create(context, collection_name, compact_threshold);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::InsertEntity(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& partition_name, const int32_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data) {
|
||||
BaseRequestPtr request_ptr =
|
||||
InsertEntityRequest::Create(context, collection_name, partition_name, row_count, chunk_data);
|
||||
|
||||
RequestHandler::Insert(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& partition_name, const int64_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data) {
|
||||
BaseRequestPtr request_ptr = InsertRequest::Create(context, collection_name, partition_name, row_count, chunk_data);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
@ -239,7 +163,14 @@ RequestHandler::GetEntityByID(const std::shared_ptr<Context>& context, const std
|
||||
engine::snapshot::CollectionMappings& field_mappings, engine::DataChunkPtr& data_chunk) {
|
||||
BaseRequestPtr request_ptr =
|
||||
GetEntityByIDRequest::Create(context, collection_name, ids, field_names, field_mappings, data_chunk);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::DeleteEntityByID(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const engine::IDNumbers& ids) {
|
||||
BaseRequestPtr request_ptr = DeleteEntityByIDRequest::Create(context, collection_name, ids);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
@ -248,11 +179,45 @@ Status
|
||||
RequestHandler::Search(const std::shared_ptr<milvus::server::Context>& context, const query::QueryPtr& query_ptr,
|
||||
const milvus::json& json_params, engine::QueryResultPtr& result) {
|
||||
BaseRequestPtr request_ptr = SearchRequest::Create(context, query_ptr, json_params, result);
|
||||
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::ListIDInSegment(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
int64_t segment_id, engine::IDNumbers& ids) {
|
||||
BaseRequestPtr request_ptr = ListIDInSegmentRequest::Create(context, collection_name, segment_id, ids);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::LoadCollection(const std::shared_ptr<Context>& context, const std::string& collection_name) {
|
||||
BaseRequestPtr request_ptr = LoadCollectionRequest::Create(context, collection_name);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::Flush(const std::shared_ptr<Context>& context, const std::vector<std::string>& collection_names) {
|
||||
BaseRequestPtr request_ptr = FlushRequest::Create(context, collection_names);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::Compact(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
double compact_threshold) {
|
||||
BaseRequestPtr request_ptr = CompactRequest::Create(context, collection_name, compact_threshold);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
|
||||
Status
|
||||
RequestHandler::Cmd(const std::shared_ptr<Context>& context, const std::string& cmd, std::string& reply) {
|
||||
BaseRequestPtr request_ptr = CmdRequest::Create(context, cmd, reply);
|
||||
RequestScheduler::ExecRequest(request_ptr);
|
||||
return request_ptr->status();
|
||||
}
|
||||
} // namespace server
|
||||
} // namespace milvus
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "query/BooleanQuery.h"
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
#include "utils/Status.h"
|
||||
|
||||
namespace milvus {
|
||||
@ -37,67 +37,72 @@ class RequestHandler {
|
||||
std::unordered_map<std::string, std::string>& field_params, milvus::json& json_params);
|
||||
|
||||
Status
|
||||
DescribeCollection(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
HybridCollectionSchema& collection_schema);
|
||||
|
||||
Status
|
||||
DropCollection(const std::shared_ptr<Context>& context, std::string& collection_name);
|
||||
DropCollection(const std::shared_ptr<Context>& context, const std::string& collection_name);
|
||||
|
||||
Status
|
||||
HasCollection(const std::shared_ptr<Context>& context, const std::string& collection_name, bool& has_collection);
|
||||
|
||||
Status
|
||||
DropCollection(const std::shared_ptr<Context>& context, const std::string& collection_name);
|
||||
ListCollections(const std::shared_ptr<Context>& context, std::vector<std::string>& collections);
|
||||
|
||||
Status
|
||||
CreateIndex(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& field_name, const std::string& index_name, const milvus::json& json_params);
|
||||
GetCollectionInfo(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
CollectionSchema& collection_schema);
|
||||
|
||||
Status
|
||||
GetEntityIDs(const std::shared_ptr<Context>& context, const std::string& collection_name, int64_t segment_id,
|
||||
std::vector<int64_t>& vector_ids);
|
||||
GetCollectionStats(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
std::string& collection_stats);
|
||||
|
||||
Status
|
||||
ShowCollections(const std::shared_ptr<Context>& context, std::vector<std::string>& collections);
|
||||
|
||||
Status
|
||||
ShowCollectionInfo(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
std::string& collection_info);
|
||||
|
||||
Status
|
||||
CountCollection(const std::shared_ptr<Context>& context, const std::string& collection_name, int64_t& count);
|
||||
|
||||
Status
|
||||
Cmd(const std::shared_ptr<Context>& context, const std::string& cmd, std::string& reply);
|
||||
|
||||
Status
|
||||
DeleteByID(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::vector<int64_t>& vector_ids);
|
||||
|
||||
Status
|
||||
PreloadCollection(const std::shared_ptr<Context>& context, const std::string& collection_name);
|
||||
|
||||
Status
|
||||
DescribeIndex(const std::shared_ptr<Context>& context, const std::string& collection_name, IndexParam& param);
|
||||
|
||||
Status
|
||||
DropIndex(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& field_name, const std::string& index_name);
|
||||
CountEntities(const std::shared_ptr<Context>& context, const std::string& collection_name, int64_t& count);
|
||||
|
||||
Status
|
||||
CreatePartition(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& tag);
|
||||
|
||||
Status
|
||||
DropPartition(const std::shared_ptr<Context>& context, const std::string& collection_name, const std::string& tag);
|
||||
|
||||
Status
|
||||
HasPartition(const std::shared_ptr<Context>& context, const std::string& collection_name, const std::string& tag,
|
||||
bool& has_partition);
|
||||
|
||||
Status
|
||||
ShowPartitions(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
ListPartitions(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
std::vector<std::string>& partitions);
|
||||
|
||||
Status
|
||||
DropPartition(const std::shared_ptr<Context>& context, const std::string& collection_name, const std::string& tag);
|
||||
CreateIndex(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& field_name, const std::string& index_name, const milvus::json& json_params);
|
||||
|
||||
Status
|
||||
DropIndex(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& field_name, const std::string& index_name);
|
||||
|
||||
Status
|
||||
Insert(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& partition_name, const int64_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data);
|
||||
|
||||
Status
|
||||
GetEntityByID(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const engine::IDNumbers& ids, std::vector<std::string>& field_names,
|
||||
engine::snapshot::CollectionMappings& field_mappings, engine::DataChunkPtr& data_chunk);
|
||||
|
||||
Status
|
||||
DeleteEntityByID(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const engine::IDNumbers& ids);
|
||||
|
||||
Status
|
||||
Search(const std::shared_ptr<milvus::server::Context>& context, const query::QueryPtr& query_ptr,
|
||||
const milvus::json& json_params, engine::QueryResultPtr& result);
|
||||
|
||||
Status
|
||||
ListIDInSegment(const std::shared_ptr<Context>& context, const std::string& collection_name, int64_t segment_id,
|
||||
engine::IDNumbers& ids);
|
||||
|
||||
Status
|
||||
LoadCollection(const std::shared_ptr<Context>& context, const std::string& collection_name);
|
||||
|
||||
Status
|
||||
Flush(const std::shared_ptr<Context>& context, const std::vector<std::string>& collection_names);
|
||||
@ -106,18 +111,7 @@ class RequestHandler {
|
||||
Compact(const std::shared_ptr<Context>& context, const std::string& collection_name, double compact_threshold);
|
||||
|
||||
Status
|
||||
InsertEntity(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const std::string& partition_name, const int32_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data);
|
||||
|
||||
Status
|
||||
GetEntityByID(const std::shared_ptr<Context>& context, const std::string& collection_name,
|
||||
const engine::IDNumbers& ids, std::vector<std::string>& field_names,
|
||||
engine::snapshot::CollectionMappings& field_mappings, engine::DataChunkPtr& data_chunk);
|
||||
|
||||
Status
|
||||
Search(const std::shared_ptr<milvus::server::Context>& context, const query::QueryPtr& query_ptr,
|
||||
const milvus::json& json_params, engine::QueryResultPtr& result);
|
||||
Cmd(const std::shared_ptr<Context>& context, const std::string& cmd, std::string& reply);
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
#include "utils/BlockingQueue.h"
|
||||
#include "utils/Status.h"
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -29,45 +29,39 @@ namespace {
|
||||
std::string
|
||||
RequestGroup(BaseRequest::RequestType type) {
|
||||
static std::map<BaseRequest::RequestType, std::string> s_map_type_group = {
|
||||
// general operations
|
||||
/* general operations */
|
||||
{BaseRequest::kCmd, INFO_REQUEST_GROUP},
|
||||
|
||||
// data operations
|
||||
{BaseRequest::kInsert, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kCompact, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kFlush, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kDeleteByID, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kGetVectorByID, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kGetVectorIDs, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kInsertEntity, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kGetEntityByID, INFO_REQUEST_GROUP},
|
||||
|
||||
// collection operations
|
||||
{BaseRequest::kShowCollections, INFO_REQUEST_GROUP},
|
||||
/* collection operations */
|
||||
{BaseRequest::kCreateCollection, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kHasCollection, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kDescribeCollection, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kCountCollection, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kShowCollectionInfo, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kDropCollection, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kPreloadCollection, DQL_REQUEST_GROUP},
|
||||
{BaseRequest::kCreateHybridCollection, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kDescribeHybridCollection, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kHasCollection, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kListCollections, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kGetCollectionInfo, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kGetCollectionStats, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kCountEntities, INFO_REQUEST_GROUP},
|
||||
|
||||
// partition operations
|
||||
/* partition operations */
|
||||
{BaseRequest::kCreatePartition, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kShowPartitions, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kDropPartition, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kHasPartition, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kListPartitions, INFO_REQUEST_GROUP},
|
||||
|
||||
// index operations
|
||||
/* index operations */
|
||||
{BaseRequest::kCreateIndex, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kDescribeIndex, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kDropIndex, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kCreateHybridIndex, DDL_DML_REQUEST_GROUP},
|
||||
|
||||
// search operations
|
||||
/* data operations */
|
||||
{BaseRequest::kInsert, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kGetEntityByID, INFO_REQUEST_GROUP},
|
||||
{BaseRequest::kDeleteEntityByID, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kSearch, DQL_REQUEST_GROUP},
|
||||
{BaseRequest::kSearchCombine, DQL_REQUEST_GROUP},
|
||||
{BaseRequest::kListIDInSegment, DQL_REQUEST_GROUP},
|
||||
|
||||
/* other operations */
|
||||
{BaseRequest::kLoadCollection, DQL_REQUEST_GROUP},
|
||||
{BaseRequest::kFlush, DDL_DML_REQUEST_GROUP},
|
||||
{BaseRequest::kCompact, DDL_DML_REQUEST_GROUP},
|
||||
};
|
||||
|
||||
auto iter = s_map_type_group.find(type);
|
||||
@ -33,27 +33,6 @@ namespace milvus {
|
||||
namespace server {
|
||||
|
||||
struct CollectionSchema {
|
||||
std::string collection_name_;
|
||||
int64_t dimension_;
|
||||
int64_t index_file_size_;
|
||||
int64_t metric_type_;
|
||||
|
||||
CollectionSchema() {
|
||||
dimension_ = 0;
|
||||
index_file_size_ = 0;
|
||||
metric_type_ = 0;
|
||||
}
|
||||
|
||||
CollectionSchema(const std::string& collection_name, int64_t dimension, int64_t index_file_size,
|
||||
int64_t metric_type) {
|
||||
collection_name_ = collection_name;
|
||||
dimension_ = dimension;
|
||||
index_file_size_ = index_file_size;
|
||||
metric_type_ = metric_type;
|
||||
}
|
||||
};
|
||||
|
||||
struct HybridCollectionSchema {
|
||||
std::string collection_name_;
|
||||
std::unordered_map<std::string, engine::meta::hybrid::DataType> field_types_;
|
||||
std::unordered_map<std::string, milvus::json> index_params_;
|
||||
@ -108,45 +87,38 @@ class BaseRequest {
|
||||
public:
|
||||
enum RequestType {
|
||||
// general operations
|
||||
kCmd = 100,
|
||||
kCmd = 0,
|
||||
|
||||
// data operations
|
||||
kInsert = 200,
|
||||
kCompact,
|
||||
kFlush,
|
||||
kDeleteByID,
|
||||
kGetVectorByID,
|
||||
kGetVectorIDs,
|
||||
kInsertEntity,
|
||||
kGetEntityByID,
|
||||
|
||||
// collection operations
|
||||
kShowCollections = 300,
|
||||
kCreateCollection,
|
||||
kHasCollection,
|
||||
kDescribeCollection,
|
||||
kCountCollection,
|
||||
kShowCollectionInfo,
|
||||
/* collection operations */
|
||||
kCreateCollection = 100,
|
||||
kDropCollection,
|
||||
kPreloadCollection,
|
||||
kCreateHybridCollection,
|
||||
kHasHybridCollection,
|
||||
kDescribeHybridCollection,
|
||||
kHasCollection,
|
||||
kListCollections,
|
||||
kGetCollectionInfo,
|
||||
kGetCollectionStats,
|
||||
kCountEntities,
|
||||
|
||||
// partition operations
|
||||
kCreatePartition = 400,
|
||||
kShowPartitions,
|
||||
/* partition operations */
|
||||
kCreatePartition = 200,
|
||||
kDropPartition,
|
||||
kHasPartition,
|
||||
kListPartitions,
|
||||
|
||||
// index operations
|
||||
kCreateIndex = 500,
|
||||
kDescribeIndex,
|
||||
/* index operations */
|
||||
kCreateIndex = 300,
|
||||
kDropIndex,
|
||||
kCreateHybridIndex,
|
||||
|
||||
// search operations
|
||||
/* data operations */
|
||||
kInsert = 400,
|
||||
kGetEntityByID,
|
||||
kDeleteEntityByID,
|
||||
kSearch,
|
||||
kSearchCombine,
|
||||
kListIDInSegment,
|
||||
|
||||
/* other operations */
|
||||
kLoadCollection = 500,
|
||||
kFlush,
|
||||
kCompact,
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/CmdRequest.h"
|
||||
#include "server/delivery/request/CmdReq.h"
|
||||
#include "config/ConfigMgr.h"
|
||||
#include "metrics/SystemInfo.h"
|
||||
#include "scheduler/SchedInst.h"
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BaseRequest.h"
|
||||
#include "BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -15,7 +15,7 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "server/delivery/request/CompactRequest.h"
|
||||
#include "server/delivery/request/CompactReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
@ -47,31 +47,13 @@ CompactRequest::OnExecute() {
|
||||
std::string hdr = "CompactRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
bool exist = false;
|
||||
auto status = DBWrapper::DB()->HasCollection(collection_name_, exist);
|
||||
if (!exist) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
}
|
||||
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, fields_schema);
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
rc.RecordSection("check validation");
|
||||
|
||||
// step 2: check collection existence
|
||||
status = DBWrapper::DB()->Compact(context_, collection_name_, compact_threshold_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
STATUS_CHECK(DBWrapper::DB()->Compact(context_, collection_name_, compact_threshold_));
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -1,87 +0,0 @@
|
||||
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/CountCollectionRequest.h"
|
||||
#include "BaseRequest.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
|
||||
#include <fiu-local.h>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
CountCollectionRequest::CountCollectionRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, int64_t& row_count)
|
||||
: BaseRequest(context, BaseRequest::kCountCollection), collection_name_(collection_name), row_count_(row_count) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
CountCollectionRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, int64_t& row_count) {
|
||||
return std::shared_ptr<BaseRequest>(new CountCollectionRequest(context, collection_name, row_count));
|
||||
}
|
||||
|
||||
Status
|
||||
CountCollectionRequest::OnExecute() {
|
||||
try {
|
||||
std::string hdr = "CountCollectionRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, fields_schema);
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
rc.RecordSection("check validation");
|
||||
|
||||
// step 2: get row count
|
||||
uint64_t row_count = 0;
|
||||
status = DBWrapper::DB()->GetCollectionRowCount(collection_name_, row_count);
|
||||
fiu_do_on("CountCollectionRequest.OnExecute.db_not_found", status = Status(DB_NOT_FOUND, ""));
|
||||
fiu_do_on("CountCollectionRequest.OnExecute.status_error", status = Status(SERVER_UNEXPECTED_ERROR, ""));
|
||||
fiu_do_on("CountCollectionRequest.OnExecute.throw_std_exception", throw std::exception());
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
row_count_ = static_cast<int64_t>(row_count);
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
} // namespace milvus
|
||||
61
core/src/server/delivery/request/CountEntitiesReq.cpp
Normal file
61
core/src/server/delivery/request/CountEntitiesReq.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/CountEntitiesReq.h"
|
||||
#include "BaseReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
|
||||
#include <fiu-local.h>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
CountEntitiesRequest::CountEntitiesRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, int64_t& row_count)
|
||||
: BaseRequest(context, BaseRequest::kCountEntities), collection_name_(collection_name), row_count_(row_count) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
CountEntitiesRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, int64_t& row_count) {
|
||||
return std::shared_ptr<BaseRequest>(new CountEntitiesRequest(context, collection_name, row_count));
|
||||
}
|
||||
|
||||
Status
|
||||
CountEntitiesRequest::OnExecute() {
|
||||
try {
|
||||
std::string hdr = "CountEntitiesRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
bool exist = false;
|
||||
auto status = DBWrapper::DB()->HasCollection(collection_name_, exist);
|
||||
if (!exist) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
}
|
||||
|
||||
STATUS_CHECK(DBWrapper::DB()->CountEntities(collection_name_, row_count_));
|
||||
|
||||
rc.ElapseFromBegin("done");
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
} // namespace milvus
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -19,15 +19,15 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class CountCollectionRequest : public BaseRequest {
|
||||
class CountEntitiesRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
int64_t& row_count);
|
||||
|
||||
protected:
|
||||
CountCollectionRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
int64_t& row_count);
|
||||
CountEntitiesRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
int64_t& row_count);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
@ -9,11 +9,11 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/CreateCollectionRequest.h"
|
||||
#include "server/delivery/request/CreateCollectionReq.h"
|
||||
#include "db/Utils.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
#include "server/web_impl/Constants.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
@ -33,7 +33,7 @@ CreateCollectionRequest::CreateCollectionRequest(
|
||||
std::unordered_map<std::string, engine::meta::hybrid::DataType>& field_types,
|
||||
std::unordered_map<std::string, milvus::json>& field_index_params,
|
||||
std::unordered_map<std::string, std::string>& field_params, milvus::json& extra_params)
|
||||
: BaseRequest(context, BaseRequest::kCreateHybridCollection),
|
||||
: BaseRequest(context, BaseRequest::kCreateCollection),
|
||||
collection_name_(collection_name),
|
||||
field_types_(field_types),
|
||||
field_index_params_(field_index_params),
|
||||
@ -113,16 +113,12 @@ CreateCollectionRequest::OnExecute() {
|
||||
if (extra_params_.contains(engine::PARAM_SEGMENT_SIZE)) {
|
||||
auto segment_size = extra_params_[engine::PARAM_SEGMENT_SIZE].get<int64_t>();
|
||||
collection_info.index_file_size_ = segment_size;
|
||||
status = ValidateCollectionIndexFileSize(segment_size);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
STATUS_CHECK(ValidateCollectionIndexFileSize(segment_size));
|
||||
}
|
||||
|
||||
if (vector_param.contains(engine::PARAM_INDEX_METRIC_TYPE)) {
|
||||
int32_t metric_type =
|
||||
(int32_t)milvus::engine::s_map_metric_type.at(vector_param[engine::PARAM_INDEX_METRIC_TYPE]);
|
||||
collection_info.metric_type_ = metric_type;
|
||||
auto metric_type = engine::s_map_metric_type.at(vector_param[engine::PARAM_INDEX_METRIC_TYPE]);
|
||||
collection_info.metric_type_ = (int32_t)metric_type;
|
||||
}
|
||||
|
||||
// step 3: create snapshot collection
|
||||
@ -148,6 +144,8 @@ CreateCollectionRequest::OnExecute() {
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
rc.ElapseFromBegin("done");
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
@ -17,7 +17,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/CreateIndexRequest.h"
|
||||
#include "server/delivery/request/CreateIndexReq.h"
|
||||
#include "db/SnapshotUtils.h"
|
||||
#include "db/Utils.h"
|
||||
#include "server/DBWrapper.h"
|
||||
@ -69,7 +69,7 @@ CreateIndexRequest::OnExecute() {
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, fields_schema);
|
||||
status = DBWrapper::DB()->GetCollectionInfo(collection_name_, collection, fields_schema);
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/CreatePartitionRequest.h"
|
||||
#include "server/delivery/request/CreatePartitionReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
@ -54,7 +54,6 @@ CreatePartitionRequest::OnExecute() {
|
||||
return status;
|
||||
}
|
||||
|
||||
// only process root collection, ignore partition collection
|
||||
bool exist = false;
|
||||
status = DBWrapper::DB()->HasCollection(collection_name_, exist);
|
||||
if (!exist) {
|
||||
@ -63,7 +62,7 @@ CreatePartitionRequest::OnExecute() {
|
||||
|
||||
// check partition total count
|
||||
std::vector<std::string> partition_names;
|
||||
status = DBWrapper::DB()->ShowPartitions(collection_name_, partition_names);
|
||||
status = DBWrapper::DB()->ListPartitions(collection_name_, partition_names);
|
||||
if (partition_names.size() >= MAX_PARTITION_LIMIT) {
|
||||
std::stringstream err_ss;
|
||||
err_ss << "The number of partitions exceeds the upper limit (" << MAX_PARTITION_LIMIT << ")";
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
@ -15,7 +15,7 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "server/delivery/request/DeleteByIDRequest.h"
|
||||
#include "server/delivery/request/DeleteEntityByIDReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -30,41 +30,31 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
DeleteByIDRequest::DeleteByIDRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, const std::vector<int64_t>& entity_ids)
|
||||
: BaseRequest(context, BaseRequest::kDeleteByID), collection_name_(collection_name), entity_ids_(entity_ids) {
|
||||
DeleteEntityByIDRequest::DeleteEntityByIDRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name,
|
||||
const engine::IDNumbers& entity_ids)
|
||||
: BaseRequest(context, BaseRequest::kDeleteEntityByID), collection_name_(collection_name), entity_ids_(entity_ids) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
DeleteByIDRequest::Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
const std::vector<int64_t>& entity_ids) {
|
||||
return std::shared_ptr<BaseRequest>(new DeleteByIDRequest(context, collection_name, entity_ids));
|
||||
DeleteEntityByIDRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, const engine::IDNumbers& entity_ids) {
|
||||
return std::shared_ptr<BaseRequest>(new DeleteEntityByIDRequest(context, collection_name, entity_ids));
|
||||
}
|
||||
|
||||
Status
|
||||
DeleteByIDRequest::OnExecute() {
|
||||
DeleteEntityByIDRequest::OnExecute() {
|
||||
try {
|
||||
TimeRecorderAuto rc("DeleteByIDRequest");
|
||||
TimeRecorderAuto rc("DeleteEntityByIDRequest");
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
bool exist = false;
|
||||
auto status = DBWrapper::DB()->HasCollection(collection_name_, exist);
|
||||
if (!exist) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
}
|
||||
|
||||
// step 2: check collection existence
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, fields_schema);
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
// Check collection's index type supports delete
|
||||
#ifdef MILVUS_SUPPORT_SPTAG
|
||||
/* Check collection's index type supports delete */
|
||||
if (collection_schema.engine_type_ == (int32_t)engine::EngineType::SPTAG_BKT ||
|
||||
collection_schema.engine_type_ == (int32_t)engine::EngineType::SPTAG_KDT) {
|
||||
std::string err_msg =
|
||||
@ -74,12 +64,7 @@ DeleteByIDRequest::OnExecute() {
|
||||
}
|
||||
#endif
|
||||
|
||||
rc.RecordSection("check validation");
|
||||
|
||||
status = DBWrapper::DB()->DeleteEntities(collection_name_, entity_ids_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
STATUS_CHECK(DBWrapper::DB()->DeleteEntityByID(collection_name_, entity_ids_));
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
@ -21,20 +21,20 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class DeleteByIDRequest : public BaseRequest {
|
||||
class DeleteEntityByIDRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
const std::vector<int64_t>& entity_ids);
|
||||
const engine::IDNumbers& entity_ids);
|
||||
|
||||
protected:
|
||||
DeleteByIDRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
const std::vector<int64_t>& entity_ids);
|
||||
DeleteEntityByIDRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
const engine::IDNumbers& entity_ids);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
@ -1,113 +0,0 @@
|
||||
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/DescribeIndexRequest.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
|
||||
#include <fiu-local.h>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
DescribeIndexRequest::DescribeIndexRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, IndexParam& index_param)
|
||||
: BaseRequest(context, BaseRequest::kDescribeIndex), collection_name_(collection_name), index_param_(index_param) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
DescribeIndexRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, IndexParam& index_param) {
|
||||
return std::shared_ptr<BaseRequest>(new DescribeIndexRequest(context, collection_name, index_param));
|
||||
}
|
||||
|
||||
Status
|
||||
DescribeIndexRequest::OnExecute() {
|
||||
try {
|
||||
fiu_do_on("DescribeIndexRequest.OnExecute.throw_std_exception", throw std::exception());
|
||||
std::string hdr = "DescribeIndexRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, fields_schema);
|
||||
fiu_do_on("DropIndexRequest.OnExecute.collection_not_exist",
|
||||
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
// // pick up field
|
||||
// engine::snapshot::FieldPtr field;
|
||||
// for (auto field_it = fields_schema.begin(); field_it != fields_schema.end(); field_it++) {
|
||||
// if (field_it->first->GetName() == field_name_) {
|
||||
// field = field_it->first;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (field == nullptr) {
|
||||
// return Status(SERVER_INVALID_FIELD_NAME, "Invalid field name");
|
||||
// }
|
||||
//
|
||||
// // TODO(yukun): Currently field name is vector field name
|
||||
// std::string field_name;
|
||||
// for (auto field_it = fields_schema.begin(); field_it != fields_schema.end(); field_it++) {
|
||||
// auto type = field_it->first->GetFtype();
|
||||
// if (type == (int64_t)engine::meta::hybrid::DataType::VECTOR_FLOAT ||
|
||||
// type == (int64_t)engine::meta::hybrid::DataType::VECTOR_BINARY) {
|
||||
// field_name = field_it->first->GetName();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // step 2: check collection existence
|
||||
// engine::CollectionIndex index;
|
||||
// status = DBWrapper::DB()->DescribeIndex(collection_name_, field_name, index);
|
||||
// if (!status.ok()) {
|
||||
// return status;
|
||||
// }
|
||||
//
|
||||
// // for binary vector, IDMAP and IVFLAT will be treated as BIN_IDMAP and BIN_IVFLAT internally
|
||||
// // return IDMAP and IVFLAT for outside caller
|
||||
// if (index.engine_type_ == (int32_t)engine::EngineType::FAISS_BIN_IDMAP) {
|
||||
// index.engine_type_ = (int32_t)engine::EngineType::FAISS_IDMAP;
|
||||
// } else if (index.engine_type_ == (int32_t)engine::EngineType::FAISS_BIN_IVFFLAT) {
|
||||
// index.engine_type_ = (int32_t)engine::EngineType::FAISS_IVFFLAT;
|
||||
// }
|
||||
//
|
||||
// index_param_.collection_name_ = collection_name_;
|
||||
// index_param_.index_type_ = index.engine_type_;
|
||||
// index_param_.extra_params_ = index.extra_params_.dump();
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
} // namespace milvus
|
||||
@ -1,41 +0,0 @@
|
||||
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class DescribeIndexRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
IndexParam& index_param);
|
||||
|
||||
protected:
|
||||
DescribeIndexRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
IndexParam& index_param);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
|
||||
private:
|
||||
const std::string collection_name_;
|
||||
IndexParam& index_param_;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
} // namespace milvus
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/DropCollectionRequest.h"
|
||||
#include "server/delivery/request/DropCollectionReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
@ -40,44 +40,18 @@ DropCollectionRequest::OnExecute() {
|
||||
std::string hdr = "DropCollectionRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorder rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
bool exist = false;
|
||||
auto status = DBWrapper::DB()->HasCollection(collection_name_, exist);
|
||||
if (!exist) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
}
|
||||
|
||||
// step 2: check collection existence
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
STATUS_CHECK(DBWrapper::DB()->DropCollection(collection_name_));
|
||||
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, fields_schema);
|
||||
fiu_do_on("DropCollectionRequest.OnExecute.db_not_found", status = Status(milvus::DB_NOT_FOUND, ""));
|
||||
fiu_do_on("DropCollectionRequest.OnExecute.describe_collection_fail",
|
||||
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
fiu_do_on("DropCollectionRequest.OnExecute.throw_std_exception", throw std::exception());
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
/* flush to trigger CleanUpFilesWithTTL */
|
||||
STATUS_CHECK(DBWrapper::DB()->Flush());
|
||||
|
||||
rc.RecordSection("check validation");
|
||||
|
||||
// step 3: Drop collection
|
||||
status = DBWrapper::DB()->DropCollection(collection_name_);
|
||||
fiu_do_on("DropCollectionRequest.OnExecute.drop_collection_fail",
|
||||
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// step 4: flush to trigger CleanUpFilesWithTTL
|
||||
status = DBWrapper::DB()->Flush();
|
||||
|
||||
rc.ElapseFromBegin("total cost");
|
||||
rc.ElapseFromBegin("done");
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/DropIndexRequest.h"
|
||||
#include "server/delivery/request/DropIndexReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
@ -45,28 +45,12 @@ DropIndexRequest::OnExecute() {
|
||||
std::string hdr = "DropIndexRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
bool exist = false;
|
||||
auto status = DBWrapper::DB()->HasCollection(collection_name_, exist);
|
||||
if (!exist) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
}
|
||||
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, fields_schema);
|
||||
fiu_do_on("DropIndexRequest.OnExecute.collection_not_exist",
|
||||
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
rc.RecordSection("check validation");
|
||||
|
||||
// step 2: drop index
|
||||
status = DBWrapper::DB()->DropIndex(collection_name_, field_name_);
|
||||
fiu_do_on("DropIndexRequest.OnExecute.drop_index_fail", status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/DropPartitionRequest.h"
|
||||
#include "server/delivery/request/DropPartitionReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
@ -15,7 +15,7 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "server/delivery/request/FlushRequest.h"
|
||||
#include "server/delivery/request/FlushReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
@ -52,31 +52,21 @@ FlushRequest::OnExecute() {
|
||||
|
||||
// flush all collections
|
||||
if (collection_names_.empty()) {
|
||||
status = DBWrapper::DB()->Flush();
|
||||
return status;
|
||||
return DBWrapper::DB()->Flush();
|
||||
}
|
||||
|
||||
// flush specified collections
|
||||
for (auto& name : collection_names_) {
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(name, collection, fields_schema);
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(name));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
bool exist = false;
|
||||
auto status = DBWrapper::DB()->HasCollection(name, exist);
|
||||
if (!exist) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(name));
|
||||
}
|
||||
|
||||
status = DBWrapper::DB()->Flush(name);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
STATUS_CHECK(DBWrapper::DB()->Flush(name));
|
||||
}
|
||||
|
||||
return status;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BaseRequest.h"
|
||||
#include "BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -9,10 +9,10 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/DescribeCollectionRequest.h"
|
||||
#include "server/delivery/request/GetCollectionInfoReq.h"
|
||||
#include "db/Utils.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
#include "server/web_impl/Constants.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
@ -27,29 +27,29 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
DescribeCollectionRequest::DescribeCollectionRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name,
|
||||
HybridCollectionSchema& collection_schema)
|
||||
: BaseRequest(context, BaseRequest::kDescribeHybridCollection),
|
||||
GetCollectionInfoRequest::GetCollectionInfoRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name,
|
||||
CollectionSchema& collection_schema)
|
||||
: BaseRequest(context, BaseRequest::kGetCollectionInfo),
|
||||
collection_name_(collection_name),
|
||||
collection_schema_(collection_schema) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
DescribeCollectionRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, HybridCollectionSchema& collection_schema) {
|
||||
return std::shared_ptr<BaseRequest>(new DescribeCollectionRequest(context, collection_name, collection_schema));
|
||||
GetCollectionInfoRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, CollectionSchema& collection_schema) {
|
||||
return std::shared_ptr<BaseRequest>(new GetCollectionInfoRequest(context, collection_name, collection_schema));
|
||||
}
|
||||
|
||||
Status
|
||||
DescribeCollectionRequest::OnExecute() {
|
||||
std::string hdr = "CreateCollectionRequest(collection=" + collection_name_ + ")";
|
||||
GetCollectionInfoRequest::OnExecute() {
|
||||
std::string hdr = "GetCollectionInfoRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
try {
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings collection_mappings;
|
||||
auto status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, collection_mappings);
|
||||
auto status = DBWrapper::DB()->GetCollectionInfo(collection_name_, collection, collection_mappings);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
@ -85,6 +85,8 @@ DescribeCollectionRequest::OnExecute() {
|
||||
milvus::json json_extra_param = milvus::json::parse(schema.field_params_);
|
||||
collection_schema_.field_params_.insert(std::make_pair(field_name, json_extra_param));
|
||||
}
|
||||
|
||||
rc.ElapseFromBegin("done");
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
@ -17,27 +17,27 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class DescribeCollectionRequest : public BaseRequest {
|
||||
class GetCollectionInfoRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
HybridCollectionSchema& collection_schema);
|
||||
CollectionSchema& collection_schema);
|
||||
|
||||
protected:
|
||||
DescribeCollectionRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, HybridCollectionSchema& collection_schema);
|
||||
GetCollectionInfoRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, CollectionSchema& collection_schema);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
|
||||
private:
|
||||
const std::string collection_name_;
|
||||
HybridCollectionSchema& collection_schema_;
|
||||
CollectionSchema& collection_schema_;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
62
core/src/server/delivery/request/GetCollectionStatsReq.cpp
Normal file
62
core/src/server/delivery/request/GetCollectionStatsReq.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "server/delivery/request/GetCollectionStatsRequest.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
GetCollectionStatsRequest::GetCollectionStatsRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, std::string& collection_stats)
|
||||
: BaseRequest(context, BaseRequest::kGetCollectionStats),
|
||||
collection_name_(collection_name),
|
||||
collection_stats_(collection_stats) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
GetCollectionStatsRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, std::string& collection_stats) {
|
||||
return std::shared_ptr<BaseRequest>(new GetCollectionStatsRequest(context, collection_name, collection_stats));
|
||||
}
|
||||
|
||||
Status
|
||||
GetCollectionStatsRequest::OnExecute() {
|
||||
std::string hdr = "GetCollectionStatsRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
bool exist = false;
|
||||
auto status = DBWrapper::DB()->HasCollection(collection_name_, exist);
|
||||
if (!exist) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
}
|
||||
|
||||
STATUS_CHECK(DBWrapper::DB()->GetCollectionStats(collection_name_, collection_stats_));
|
||||
rc.ElapseFromBegin("done");
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
} // namespace milvus
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -26,22 +26,22 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class ShowCollectionInfoRequest : public BaseRequest {
|
||||
class GetCollectionStatsRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
std::string& collection_info);
|
||||
std::string& collection_stats);
|
||||
|
||||
protected:
|
||||
ShowCollectionInfoRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, std::string& collection_info);
|
||||
GetCollectionStatsRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, std::string& collection_stats);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
|
||||
private:
|
||||
const std::string collection_name_;
|
||||
std::string& collection_info_;
|
||||
std::string& collection_stats_;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
@ -15,7 +15,7 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "server/delivery/request/GetEntityByIDRequest.h"
|
||||
#include "server/delivery/request/GetEntityByIDReq.h"
|
||||
#include "db/meta/MetaTypes.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
@ -34,7 +34,7 @@ GetEntityByIDRequest::GetEntityByIDRequest(const std::shared_ptr<milvus::server:
|
||||
std::vector<std::string>& field_names,
|
||||
engine::snapshot::CollectionMappings& field_mappings,
|
||||
engine::DataChunkPtr& data_chunk)
|
||||
: BaseRequest(context, BaseRequest::kGetVectorByID),
|
||||
: BaseRequest(context, BaseRequest::kGetEntityByID),
|
||||
collection_name_(collection_name),
|
||||
id_array_(id_array),
|
||||
field_names_(field_names),
|
||||
@ -54,7 +54,7 @@ GetEntityByIDRequest::Create(const std::shared_ptr<milvus::server::Context>& con
|
||||
Status
|
||||
GetEntityByIDRequest::OnExecute() {
|
||||
try {
|
||||
std::string hdr = "GetEntitiesByIDRequest(collection=" + collection_name_ + ")";
|
||||
std::string hdr = "GetEntityByIDRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
@ -76,7 +76,7 @@ GetEntityByIDRequest::OnExecute() {
|
||||
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collectionPtr;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collectionPtr, field_mappings_);
|
||||
status = DBWrapper::DB()->GetCollectionInfo(collection_name_, collectionPtr, field_mappings_);
|
||||
if (collectionPtr == nullptr) {
|
||||
return Status(SERVER_INVALID_COLLECTION_NAME, CollectionNotExistMsg(collection_name_));
|
||||
}
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <src/db/snapshot/Context.h>
|
||||
#include <src/db/snapshot/Resources.h>
|
||||
@ -1,81 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "server/delivery/request/GetEntityIDsRequest.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
GetEntityIDsRequest::GetEntityIDsRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, int64_t segment_id,
|
||||
std::vector<int64_t>& vector_ids)
|
||||
: BaseRequest(context, BaseRequest::kGetVectorIDs),
|
||||
collection_name_(collection_name),
|
||||
segment_id_(segment_id),
|
||||
vector_ids_(vector_ids) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
GetEntityIDsRequest::Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
int64_t segment_id, std::vector<int64_t>& vector_ids) {
|
||||
return std::shared_ptr<BaseRequest>(new GetEntityIDsRequest(context, collection_name, segment_id, vector_ids));
|
||||
}
|
||||
|
||||
Status
|
||||
GetEntityIDsRequest::OnExecute() {
|
||||
try {
|
||||
std::string hdr =
|
||||
"GetVectorIDsRequest(collection=" + collection_name_ + " segment=" + std::to_string(segment_id_) + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// step 2: check table existence
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings mappings;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, mappings);
|
||||
if (collection == nullptr) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
// step 2: get vector data, now only support get one id
|
||||
vector_ids_.clear();
|
||||
return DBWrapper::DB()->GetEntityIDs(collection_name_, segment_id_, vector_ids_);
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
} // namespace milvus
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/HasCollectionRequest.h"
|
||||
#include "server/delivery/request/HasCollectionReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
@ -22,16 +22,14 @@ namespace milvus {
|
||||
namespace server {
|
||||
|
||||
HasCollectionRequest::HasCollectionRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, bool& has_collection)
|
||||
: BaseRequest(context, BaseRequest::kHasCollection),
|
||||
collection_name_(collection_name),
|
||||
has_collection_(has_collection) {
|
||||
const std::string& collection_name, bool& exist)
|
||||
: BaseRequest(context, BaseRequest::kHasCollection), collection_name_(collection_name), exist_(exist) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
HasCollectionRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, bool& has_collection) {
|
||||
return std::shared_ptr<BaseRequest>(new HasCollectionRequest(context, collection_name, has_collection));
|
||||
const std::string& collection_name, bool& exist) {
|
||||
return std::shared_ptr<BaseRequest>(new HasCollectionRequest(context, collection_name, exist));
|
||||
}
|
||||
|
||||
Status
|
||||
@ -40,20 +38,14 @@ HasCollectionRequest::OnExecute() {
|
||||
std::string hdr = "HasCollectionRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
STATUS_CHECK(DBWrapper::DB()->HasCollection(collection_name_, exist_));
|
||||
|
||||
// step 2: check collection existence
|
||||
status = DBWrapper::DB()->HasCollection(collection_name_, has_collection_);
|
||||
fiu_do_on("HasCollectionRequest.OnExecute.throw_std_exception", throw std::exception());
|
||||
|
||||
return status;
|
||||
rc.ElapseFromBegin("done");
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -22,19 +22,18 @@ namespace server {
|
||||
class HasCollectionRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
bool& has_collection);
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name, bool& exist);
|
||||
|
||||
protected:
|
||||
HasCollectionRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
bool& has_collection);
|
||||
bool& exist);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
|
||||
private:
|
||||
std::string collection_name_;
|
||||
bool& has_collection_;
|
||||
bool& exist_;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/HasPartitionRequest.h"
|
||||
#include "server/delivery/request/HasPartitionReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/InsertEntityRequest.h"
|
||||
#include "server/delivery/request/InsertReq.h"
|
||||
#include "db/Utils.h"
|
||||
#include "db/snapshot/Context.h"
|
||||
#include "server/DBWrapper.h"
|
||||
@ -32,11 +32,11 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
InsertEntityRequest::InsertEntityRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, const std::string& partition_name,
|
||||
const int32_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data)
|
||||
: BaseRequest(context, BaseRequest::kInsertEntity),
|
||||
InsertRequest::InsertRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, const std::string& partition_name,
|
||||
const int64_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data)
|
||||
: BaseRequest(context, BaseRequest::kInsert),
|
||||
collection_name_(collection_name),
|
||||
partition_name_(partition_name),
|
||||
row_count_(row_count),
|
||||
@ -44,54 +44,42 @@ InsertEntityRequest::InsertEntityRequest(const std::shared_ptr<milvus::server::C
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
InsertEntityRequest::Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
const std::string& partition_name, const int32_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data) {
|
||||
InsertRequest::Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
const std::string& partition_name, const int64_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data) {
|
||||
return std::shared_ptr<BaseRequest>(
|
||||
new InsertEntityRequest(context, collection_name, partition_name, row_count, chunk_data));
|
||||
new InsertRequest(context, collection_name, partition_name, row_count, chunk_data));
|
||||
}
|
||||
|
||||
Status
|
||||
InsertEntityRequest::OnExecute() {
|
||||
InsertRequest::OnExecute() {
|
||||
LOG_SERVER_INFO_ << LogOut("[%s][%ld] ", "insert", 0) << "Execute insert request.";
|
||||
try {
|
||||
std::string hdr = "InsertEntityRequest(table=" + collection_name_ + ", partition_name=" + partition_name_ + ")";
|
||||
std::string hdr = "InsertRequest(table=" + collection_name_ + ", partition_name=" + partition_name_ + ")";
|
||||
TimeRecorder rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (chunk_data_.empty()) {
|
||||
return Status{SERVER_INVALID_ARGUMENT,
|
||||
"The vector field is empty, Make sure you have entered vector records"};
|
||||
}
|
||||
|
||||
// step 2: check table existence
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings mappings;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, mappings);
|
||||
if (collection == nullptr) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
bool exist = false;
|
||||
auto status = DBWrapper::DB()->HasCollection(collection_name_, exist);
|
||||
if (!exist) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
}
|
||||
|
||||
engine::DataChunkPtr data_chunk = std::make_shared<engine::DataChunk>();
|
||||
data_chunk->count_ = row_count_;
|
||||
data_chunk->fixed_fields_.swap(chunk_data_);
|
||||
status = DBWrapper::DB()->InsertEntities(collection_name_, partition_name_, data_chunk);
|
||||
status = DBWrapper::DB()->Insert(collection_name_, partition_name_, data_chunk);
|
||||
if (!status.ok()) {
|
||||
LOG_SERVER_ERROR_ << LogOut("[%s][%ld] %s", "InsertEntities", 0, status.message().c_str());
|
||||
LOG_SERVER_ERROR_ << LogOut("[%s][%ld] %s", "Insert", 0, status.message().c_str());
|
||||
return status;
|
||||
}
|
||||
chunk_data_[engine::DEFAULT_UID_NAME] = data_chunk->fixed_fields_[engine::DEFAULT_UID_NAME];
|
||||
|
||||
rc.RecordSection("add vectors to engine");
|
||||
rc.RecordSection("add entities");
|
||||
rc.ElapseFromBegin("total cost");
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -21,17 +21,17 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class InsertEntityRequest : public BaseRequest {
|
||||
class InsertRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
const std::string& partition_name, const int32_t& row_count,
|
||||
const std::string& partition_name, const int64_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data);
|
||||
|
||||
protected:
|
||||
InsertEntityRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
const std::string& partition_name, const int32_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data);
|
||||
InsertRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
const std::string& partition_name, const int64_t& row_count,
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
@ -39,7 +39,7 @@ class InsertEntityRequest : public BaseRequest {
|
||||
private:
|
||||
const std::string collection_name_;
|
||||
const std::string partition_name_;
|
||||
const int32_t row_count_;
|
||||
const int64_t row_count_;
|
||||
std::unordered_map<std::string, std::vector<uint8_t>>& chunk_data_;
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/ShowCollectionsRequest.h"
|
||||
#include "server/delivery/request/ListCollectionsReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
@ -22,31 +22,31 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
ShowCollectionsRequest::ShowCollectionsRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
std::vector<std::string>& collection_name_list)
|
||||
: BaseRequest(context, BaseRequest::kShowCollections), collection_name_list_(collection_name_list) {
|
||||
ListCollectionsRequest::ListCollectionsRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
std::vector<std::string>& collection_list)
|
||||
: BaseRequest(context, BaseRequest::kListCollections), collection_list_(collection_list) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
ShowCollectionsRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
ListCollectionsRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
std::vector<std::string>& collection_name_list) {
|
||||
return std::shared_ptr<BaseRequest>(new ShowCollectionsRequest(context, collection_name_list));
|
||||
return std::shared_ptr<BaseRequest>(new ListCollectionsRequest(context, collection_name_list));
|
||||
}
|
||||
|
||||
Status
|
||||
ShowCollectionsRequest::OnExecute() {
|
||||
TimeRecorderAuto rc("ShowCollectionsRequest");
|
||||
ListCollectionsRequest::OnExecute() {
|
||||
TimeRecorderAuto rc("ListCollectionsRequest");
|
||||
|
||||
std::vector<std::string> names;
|
||||
auto status = DBWrapper::DB()->AllCollections(names);
|
||||
fiu_do_on("ShowCollectionsRequest.OnExecute.show_collections_fail",
|
||||
auto status = DBWrapper::DB()->ListCollections(names);
|
||||
fiu_do_on("ListCollectionsRequest.OnExecute.show_collections_fail",
|
||||
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
for (auto& name : names) {
|
||||
collection_name_list_.push_back(name);
|
||||
collection_list_.push_back(name);
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
@ -15,25 +15,25 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class ShowCollectionsRequest : public BaseRequest {
|
||||
class ListCollectionsRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, std::vector<std::string>& collection_name_list);
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, std::vector<std::string>& collection_list);
|
||||
|
||||
protected:
|
||||
ShowCollectionsRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
ListCollectionsRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
std::vector<std::string>& collection_name_list);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
|
||||
private:
|
||||
std::vector<std::string>& collection_name_list_;
|
||||
std::vector<std::string>& collection_list_;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
67
core/src/server/delivery/request/ListIDInSegmentReq.cpp
Normal file
67
core/src/server/delivery/request/ListIDInSegmentReq.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "server/delivery/request/ListIDInSegmentReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
ListIDInSegmentRequest::ListIDInSegmentRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, int64_t segment_id,
|
||||
engine::IDNumbers& ids)
|
||||
: BaseRequest(context, BaseRequest::kListIDInSegment),
|
||||
collection_name_(collection_name),
|
||||
segment_id_(segment_id),
|
||||
ids_(ids) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
ListIDInSegmentRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, int64_t segment_id, engine::IDNumbers& ids) {
|
||||
return std::shared_ptr<BaseRequest>(new ListIDInSegmentRequest(context, collection_name, segment_id, ids));
|
||||
}
|
||||
|
||||
Status
|
||||
ListIDInSegmentRequest::OnExecute() {
|
||||
try {
|
||||
std::string hdr =
|
||||
"ListIDInSegmentRequest(collection=" + collection_name_ + " segment=" + std::to_string(segment_id_) + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
bool exist = false;
|
||||
auto status = DBWrapper::DB()->HasCollection(collection_name_, exist);
|
||||
if (!exist) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
}
|
||||
|
||||
// step 2: get vector data, now only support get one id
|
||||
ids_.clear();
|
||||
return DBWrapper::DB()->ListIDInSegment(collection_name_, segment_id_, ids_);
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
} // namespace milvus
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -26,15 +26,15 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class GetEntityIDsRequest : public BaseRequest {
|
||||
class ListIDInSegmentRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
int64_t segment_id, std::vector<int64_t>& vector_ids);
|
||||
int64_t segment_id, engine::IDNumbers& ids);
|
||||
|
||||
protected:
|
||||
GetEntityIDsRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
int64_t segment_id, std::vector<int64_t>& vector_ids);
|
||||
ListIDInSegmentRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
int64_t segment_id, engine::IDNumbers& ids);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
@ -42,7 +42,7 @@ class GetEntityIDsRequest : public BaseRequest {
|
||||
private:
|
||||
std::string collection_name_;
|
||||
int64_t segment_id_;
|
||||
std::vector<int64_t>& vector_ids_;
|
||||
engine::IDNumbers& ids_;
|
||||
};
|
||||
|
||||
} // namespace server
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/ShowPartitionsRequest.h"
|
||||
#include "server/delivery/request/ListPartitionsReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
@ -22,23 +22,23 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
ShowPartitionsRequest::ShowPartitionsRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
ListPartitionsRequest::ListPartitionsRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name,
|
||||
std::vector<std::string>& partition_list)
|
||||
: BaseRequest(context, BaseRequest::kShowPartitions),
|
||||
: BaseRequest(context, BaseRequest::kListPartitions),
|
||||
collection_name_(collection_name),
|
||||
partition_list_(partition_list) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
ShowPartitionsRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
ListPartitionsRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, std::vector<std::string>& partition_list) {
|
||||
return std::shared_ptr<BaseRequest>(new ShowPartitionsRequest(context, collection_name, partition_list));
|
||||
return std::shared_ptr<BaseRequest>(new ListPartitionsRequest(context, collection_name, partition_list));
|
||||
}
|
||||
|
||||
Status
|
||||
ShowPartitionsRequest::OnExecute() {
|
||||
std::string hdr = "ShowPartitionsRequest(collection=" + collection_name_ + ")";
|
||||
ListPartitionsRequest::OnExecute() {
|
||||
std::string hdr = "ListPartitionsRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
/* check collection existence */
|
||||
@ -49,10 +49,7 @@ ShowPartitionsRequest::OnExecute() {
|
||||
}
|
||||
|
||||
/* get partitions */
|
||||
status = DBWrapper::DB()->ShowPartitions(collection_name_, partition_list_);
|
||||
fiu_do_on("ShowPartitionsRequest.OnExecute.show_partition_fail",
|
||||
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
return status;
|
||||
return DBWrapper::DB()->ListPartitions(collection_name_, partition_list_);
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -20,14 +20,14 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class ShowPartitionsRequest : public BaseRequest {
|
||||
class ListPartitionsRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
std::vector<std::string>& partition_list);
|
||||
|
||||
protected:
|
||||
ShowPartitionsRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
ListPartitionsRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name,
|
||||
std::vector<std::string>& partition_list);
|
||||
|
||||
Status
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/PreloadCollectionRequest.h"
|
||||
#include "server/delivery/request/LoadCollectionReq.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
@ -23,33 +23,26 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
PreloadCollectionRequest::PreloadCollectionRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name)
|
||||
: BaseRequest(context, BaseRequest::kPreloadCollection), collection_name_(collection_name) {
|
||||
LoadCollectionRequest::LoadCollectionRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name)
|
||||
: BaseRequest(context, BaseRequest::kLoadCollection), collection_name_(collection_name) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
PreloadCollectionRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name) {
|
||||
return std::shared_ptr<BaseRequest>(new PreloadCollectionRequest(context, collection_name));
|
||||
LoadCollectionRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name) {
|
||||
return std::shared_ptr<BaseRequest>(new LoadCollectionRequest(context, collection_name));
|
||||
}
|
||||
|
||||
Status
|
||||
PreloadCollectionRequest::OnExecute() {
|
||||
LoadCollectionRequest::OnExecute() {
|
||||
try {
|
||||
std::string hdr = "PreloadCollectionRequest(collection=" + collection_name_ + ")";
|
||||
std::string hdr = "LoadCollectionRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
// step 1: check arguments
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, fields_schema);
|
||||
auto status = DBWrapper::DB()->GetCollectionInfo(collection_name_, collection, fields_schema);
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
@ -67,12 +60,14 @@ PreloadCollectionRequest::OnExecute() {
|
||||
// step 2: force load collection data into cache
|
||||
// load each segment and insert into cache even cache capacity is not enough
|
||||
status = DBWrapper::DB()->LoadCollection(context_, collection_name_, field_names, true);
|
||||
fiu_do_on("PreloadCollectionRequest.OnExecute.preload_collection_fail",
|
||||
fiu_do_on("LoadCollectionRequest.OnExecute.preload_collection_fail",
|
||||
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
fiu_do_on("PreloadCollectionRequest.OnExecute.throw_std_exception", throw std::exception());
|
||||
fiu_do_on("LoadCollectionRequest.OnExecute.throw_std_exception", throw std::exception());
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
rc.ElapseFromBegin("done");
|
||||
} catch (std::exception& ex) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
||||
}
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -19,14 +19,13 @@
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
class PreloadCollectionRequest : public BaseRequest {
|
||||
class LoadCollectionRequest : public BaseRequest {
|
||||
public:
|
||||
static BaseRequestPtr
|
||||
Create(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name);
|
||||
|
||||
protected:
|
||||
PreloadCollectionRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name);
|
||||
LoadCollectionRequest(const std::shared_ptr<milvus::server::Context>& context, const std::string& collection_name);
|
||||
|
||||
Status
|
||||
OnExecute() override;
|
||||
@ -9,7 +9,7 @@
|
||||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
#include "server/delivery/request/SearchRequest.h"
|
||||
#include "server/delivery/request/SearchReq.h"
|
||||
#include "db/Utils.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
@ -49,17 +49,11 @@ SearchRequest::OnExecute() {
|
||||
|
||||
TimeRecorder rc(hdr);
|
||||
|
||||
// step 1: check table name
|
||||
auto status = ValidateCollectionName(query_ptr_->collection_id);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// step 2: check table existence
|
||||
// only process root table, ignore partition table
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(query_ptr_->collection_id, collection, fields_schema);
|
||||
auto status = DBWrapper::DB()->GetCollectionInfo(query_ptr_->collection_id, collection, fields_schema);
|
||||
fiu_do_on("SearchRequest.OnExecute.describe_table_fail", status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
@ -71,15 +65,6 @@ SearchRequest::OnExecute() {
|
||||
|
||||
int64_t dimension = collection->GetParams()[engine::DIMENSION].get<int64_t>();
|
||||
|
||||
// step 3: check partition tags
|
||||
status = ValidatePartitionTags(query_ptr_->partitions);
|
||||
fiu_do_on("SearchRequest.OnExecute.invalid_partition_tags",
|
||||
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||
if (!status.ok()) {
|
||||
LOG_SERVER_ERROR_ << LogOut("[%s][%ld] %s", "search", 0, status.message().c_str());
|
||||
return status;
|
||||
}
|
||||
|
||||
// step 4: Get field info
|
||||
std::unordered_map<std::string, engine::meta::hybrid::DataType> field_types;
|
||||
for (auto& schema : fields_schema) {
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -1,78 +0,0 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "server/delivery/request/ShowCollectionInfoRequest.h"
|
||||
#include "server/DBWrapper.h"
|
||||
#include "server/ValidationUtil.h"
|
||||
#include "utils/Log.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
||||
ShowCollectionInfoRequest::ShowCollectionInfoRequest(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, std::string& collection_info)
|
||||
: BaseRequest(context, BaseRequest::kShowCollectionInfo),
|
||||
collection_name_(collection_name),
|
||||
collection_info_(collection_info) {
|
||||
}
|
||||
|
||||
BaseRequestPtr
|
||||
ShowCollectionInfoRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
||||
const std::string& collection_name, std::string& collection_info) {
|
||||
return std::shared_ptr<BaseRequest>(new ShowCollectionInfoRequest(context, collection_name, collection_info));
|
||||
}
|
||||
|
||||
Status
|
||||
ShowCollectionInfoRequest::OnExecute() {
|
||||
std::string hdr = "ShowCollectionInfoRequest(collection=" + collection_name_ + ")";
|
||||
TimeRecorderAuto rc(hdr);
|
||||
|
||||
// step 1: check collection name
|
||||
auto status = ValidateCollectionName(collection_name_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// step 2: check collection existence
|
||||
// only process root collection, ignore partition collection
|
||||
engine::snapshot::CollectionPtr collection;
|
||||
engine::snapshot::CollectionMappings fields_schema;
|
||||
status = DBWrapper::DB()->DescribeCollection(collection_name_, collection, fields_schema);
|
||||
if (!status.ok()) {
|
||||
if (status.code() == DB_NOT_FOUND) {
|
||||
return Status(SERVER_COLLECTION_NOT_EXIST, CollectionNotExistMsg(collection_name_));
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
// step 3: get partitions
|
||||
status = DBWrapper::DB()->GetCollectionInfo(collection_name_, collection_info_);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
} // namespace milvus
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
#include "utils/BlockingQueue.h"
|
||||
#include "utils/Status.h"
|
||||
|
||||
|
||||
@ -856,8 +856,8 @@ GrpcRequestHandler::GetEntityIDs(::grpc::ServerContext* context, const ::milvus:
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
|
||||
std::vector<int64_t> vector_ids;
|
||||
Status status = request_handler_.GetEntityIDs(GetContext(context), request->collection_name(),
|
||||
request->segment_id(), vector_ids);
|
||||
Status status = request_handler_.ListIDInSegment(GetContext(context), request->collection_name(),
|
||||
request->segment_id(), vector_ids);
|
||||
|
||||
if (!vector_ids.empty()) {
|
||||
response->mutable_entity_id_array()->Resize(vector_ids.size(), -1);
|
||||
@ -965,9 +965,9 @@ GrpcRequestHandler::DescribeCollection(::grpc::ServerContext* context, const ::m
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
CHECK_NULLPTR_RETURN(request);
|
||||
try {
|
||||
milvus::server::HybridCollectionSchema collection_schema;
|
||||
milvus::server::CollectionSchema collection_schema;
|
||||
Status status =
|
||||
request_handler_.DescribeCollection(GetContext(context), request->collection_name(), collection_schema);
|
||||
request_handler_.GetCollectionInfo(GetContext(context), request->collection_name(), collection_schema);
|
||||
if (!status.ok()) {
|
||||
SET_RESPONSE(response->mutable_status(), status, context);
|
||||
return ::grpc::Status::OK;
|
||||
@ -1007,7 +1007,7 @@ GrpcRequestHandler::CountCollection(::grpc::ServerContext* context, const ::milv
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
|
||||
int64_t row_count = 0;
|
||||
Status status = request_handler_.CountCollection(GetContext(context), request->collection_name(), row_count);
|
||||
Status status = request_handler_.CountEntities(GetContext(context), request->collection_name(), row_count);
|
||||
response->set_collection_row_count(row_count);
|
||||
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s end.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
@ -1023,7 +1023,7 @@ GrpcRequestHandler::ShowCollections(::grpc::ServerContext* context, const ::milv
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
|
||||
std::vector<std::string> collections;
|
||||
Status status = request_handler_.ShowCollections(GetContext(context), collections);
|
||||
Status status = request_handler_.ListCollections(GetContext(context), collections);
|
||||
for (auto& collection : collections) {
|
||||
response->add_collection_names(collection);
|
||||
}
|
||||
@ -1040,10 +1040,10 @@ GrpcRequestHandler::ShowCollectionInfo(::grpc::ServerContext* context, const ::m
|
||||
CHECK_NULLPTR_RETURN(request);
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
|
||||
std::string collection_info;
|
||||
std::string collection_stats;
|
||||
Status status =
|
||||
request_handler_.ShowCollectionInfo(GetContext(context), request->collection_name(), collection_info);
|
||||
response->set_json_info(collection_info);
|
||||
request_handler_.GetCollectionStats(GetContext(context), request->collection_name(), collection_stats);
|
||||
response->set_json_info(collection_stats);
|
||||
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s end.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
SET_RESPONSE(response->mutable_status(), status, context);
|
||||
@ -1096,13 +1096,13 @@ GrpcRequestHandler::DeleteByID(::grpc::ServerContext* context, const ::milvus::g
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
|
||||
// step 1: prepare id array
|
||||
std::vector<int64_t> vector_ids;
|
||||
engine::IDNumbers ids;
|
||||
for (int i = 0; i < request->id_array_size(); i++) {
|
||||
vector_ids.push_back(request->id_array(i));
|
||||
ids.push_back(request->id_array(i));
|
||||
}
|
||||
|
||||
// step 2: delete vector
|
||||
Status status = request_handler_.DeleteByID(GetContext(context), request->collection_name(), vector_ids);
|
||||
Status status = request_handler_.DeleteEntityByID(GetContext(context), request->collection_name(), ids);
|
||||
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s end.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
SET_RESPONSE(response, status, context);
|
||||
@ -1116,7 +1116,7 @@ GrpcRequestHandler::PreloadCollection(::grpc::ServerContext* context, const ::mi
|
||||
CHECK_NULLPTR_RETURN(request);
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
|
||||
Status status = request_handler_.PreloadCollection(GetContext(context), request->collection_name());
|
||||
Status status = request_handler_.LoadCollection(GetContext(context), request->collection_name());
|
||||
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s end.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
SET_RESPONSE(response, status, context);
|
||||
@ -1127,20 +1127,6 @@ GrpcRequestHandler::PreloadCollection(::grpc::ServerContext* context, const ::mi
|
||||
::grpc::Status
|
||||
GrpcRequestHandler::DescribeIndex(::grpc::ServerContext* context, const ::milvus::grpc::IndexParam* request,
|
||||
::milvus::grpc::IndexParam* response) {
|
||||
CHECK_NULLPTR_RETURN(request);
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
|
||||
IndexParam param;
|
||||
Status status = request_handler_.DescribeIndex(GetContext(context), request->collection_name(), param);
|
||||
response->set_collection_name(param.collection_name_);
|
||||
response->set_index_name(param.index_name_);
|
||||
::milvus::grpc::KeyValuePair* kv = response->add_extra_params();
|
||||
kv->set_key(EXTRA_PARAM_KEY);
|
||||
kv->set_value(param.extra_params_);
|
||||
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s end.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
SET_RESPONSE(response->mutable_status(), status, context);
|
||||
|
||||
return ::grpc::Status::OK;
|
||||
}
|
||||
|
||||
@ -1198,7 +1184,7 @@ GrpcRequestHandler::ShowPartitions(::grpc::ServerContext* context, const ::milvu
|
||||
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->RequestID().c_str(), __func__);
|
||||
|
||||
std::vector<std::string> partition_names;
|
||||
Status status = request_handler_.ShowPartitions(GetContext(context), request->collection_name(), partition_names);
|
||||
Status status = request_handler_.ListPartitions(GetContext(context), request->collection_name(), partition_names);
|
||||
for (auto& pn : partition_names) {
|
||||
response->add_partition_tag_array(pn);
|
||||
}
|
||||
@ -1337,8 +1323,7 @@ GrpcRequestHandler::Insert(::grpc::ServerContext* context, const ::milvus::grpc:
|
||||
|
||||
std::string collection_name = request->collection_name();
|
||||
std::string partition_name = request->partition_tag();
|
||||
Status status =
|
||||
request_handler_.InsertEntity(GetContext(context), collection_name, partition_name, row_num, chunk_data);
|
||||
Status status = request_handler_.Insert(GetContext(context), collection_name, partition_name, row_num, chunk_data);
|
||||
if (!status.ok()) {
|
||||
SET_RESPONSE(response->mutable_status(), status, context);
|
||||
return ::grpc::Status::OK;
|
||||
@ -1694,8 +1679,8 @@ GrpcRequestHandler::Search(::grpc::ServerContext* context, const ::milvus::grpc:
|
||||
|
||||
Status status;
|
||||
|
||||
HybridCollectionSchema collection_schema;
|
||||
status = request_handler_.DescribeCollection(GetContext(context), request->collection_name(), collection_schema);
|
||||
CollectionSchema collection_schema;
|
||||
status = request_handler_.GetCollectionInfo(GetContext(context), request->collection_name(), collection_schema);
|
||||
|
||||
field_type_ = collection_schema.field_types_;
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "config/ServerConfig.h"
|
||||
#include "metrics/SystemInfo.h"
|
||||
#include "query/BinaryQuery.h"
|
||||
#include "server/delivery/request/BaseRequest.h"
|
||||
#include "server/delivery/request/BaseReq.h"
|
||||
#include "server/web_impl/Constants.h"
|
||||
#include "server/web_impl/Types.h"
|
||||
#include "server/web_impl/dto/PartitionDto.hpp"
|
||||
@ -106,13 +106,12 @@ WebRequestHandler::AddStatusToJson(nlohmann::json& json, int64_t code, const std
|
||||
Status
|
||||
WebRequestHandler::IsBinaryCollection(const std::string& collection_name, bool& bin) {
|
||||
CollectionSchema schema;
|
||||
auto status = Status::OK();
|
||||
// status = request_handler_.DescribeCollection(context_ptr_, collection_name, schema);
|
||||
auto status = request_handler_.GetCollectionInfo(context_ptr_, collection_name, schema);
|
||||
if (status.ok()) {
|
||||
auto metric = engine::MetricType(schema.metric_type_);
|
||||
bin = engine::MetricType::HAMMING == metric || engine::MetricType::JACCARD == metric ||
|
||||
engine::MetricType::TANIMOTO == metric || engine::MetricType::SUPERSTRUCTURE == metric ||
|
||||
engine::MetricType::SUBSTRUCTURE == metric;
|
||||
auto metric = engine::MetricType(schema.extra_params_[engine::PARAM_INDEX_METRIC_TYPE].get<int64_t>());
|
||||
bin = (metric == engine::MetricType::HAMMING || metric == engine::MetricType::JACCARD ||
|
||||
metric == engine::MetricType::TANIMOTO || metric == engine::MetricType::SUPERSTRUCTURE ||
|
||||
metric == engine::MetricType::SUBSTRUCTURE);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -153,30 +152,16 @@ WebRequestHandler::CopyRecordsFromJson(const nlohmann::json& json, engine::Vecto
|
||||
Status
|
||||
WebRequestHandler::GetCollectionMetaInfo(const std::string& collection_name, nlohmann::json& json_out) {
|
||||
CollectionSchema schema;
|
||||
auto status = Status::OK();
|
||||
// status = request_handler_.DescribeCollection(context_ptr_, collection_name, schema);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
STATUS_CHECK(request_handler_.GetCollectionInfo(context_ptr_, collection_name, schema));
|
||||
|
||||
int64_t count;
|
||||
status = request_handler_.CountCollection(context_ptr_, collection_name, count);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
|
||||
IndexParam index_param;
|
||||
status = request_handler_.DescribeIndex(context_ptr_, collection_name, index_param);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
STATUS_CHECK(request_handler_.CountEntities(context_ptr_, collection_name, count));
|
||||
|
||||
json_out["collection_name"] = schema.collection_name_;
|
||||
json_out["dimension"] = schema.dimension_;
|
||||
json_out["index_file_size"] = schema.index_file_size_;
|
||||
json_out["index"] = index_param.index_type_;
|
||||
json_out["index_params"] = index_param.extra_params_;
|
||||
json_out["metric_type"] = schema.metric_type_;
|
||||
json_out["dimension"] = schema.extra_params_[engine::PARAM_COLLECTION_DIMENSION].get<int64_t>();
|
||||
json_out["index_file_size"] = schema.extra_params_[engine::PARAM_SEGMENT_SIZE].get<int64_t>();
|
||||
json_out["metric_type"] = schema.extra_params_[engine::PARAM_INDEX_METRIC_TYPE].get<int64_t>();
|
||||
json_out["index_params"] = schema.extra_params_[engine::PARAM_INDEX_EXTRA_PARAMS].get<std::string>();
|
||||
json_out["count"] = count;
|
||||
|
||||
return Status::OK();
|
||||
@ -184,12 +169,12 @@ WebRequestHandler::GetCollectionMetaInfo(const std::string& collection_name, nlo
|
||||
|
||||
Status
|
||||
WebRequestHandler::GetCollectionStat(const std::string& collection_name, nlohmann::json& json_out) {
|
||||
std::string collection_info;
|
||||
auto status = request_handler_.ShowCollectionInfo(context_ptr_, collection_name, collection_info);
|
||||
std::string collection_stats;
|
||||
auto status = request_handler_.GetCollectionStats(context_ptr_, collection_name, collection_stats);
|
||||
|
||||
if (status.ok()) {
|
||||
try {
|
||||
json_out = nlohmann::json::parse(collection_info);
|
||||
json_out = nlohmann::json::parse(collection_stats);
|
||||
} catch (std::exception& e) {
|
||||
return Status(SERVER_UNEXPECTED_ERROR,
|
||||
"Error occurred when parsing collection stat information: " + std::string(e.what()));
|
||||
@ -202,8 +187,8 @@ WebRequestHandler::GetCollectionStat(const std::string& collection_name, nlohman
|
||||
Status
|
||||
WebRequestHandler::GetSegmentVectors(const std::string& collection_name, int64_t segment_id, int64_t page_size,
|
||||
int64_t offset, nlohmann::json& json_out) {
|
||||
std::vector<int64_t> vector_ids;
|
||||
auto status = request_handler_.GetEntityIDs(context_ptr_, 0, segment_id, vector_ids);
|
||||
engine::IDNumbers vector_ids;
|
||||
auto status = request_handler_.ListIDInSegment(context_ptr_, 0, segment_id, vector_ids);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
@ -211,9 +196,9 @@ WebRequestHandler::GetSegmentVectors(const std::string& collection_name, int64_t
|
||||
auto ids_begin = std::min(vector_ids.size(), (size_t)offset);
|
||||
auto ids_end = std::min(vector_ids.size(), (size_t)(offset + page_size));
|
||||
|
||||
auto ids = std::vector<int64_t>(vector_ids.begin() + ids_begin, vector_ids.begin() + ids_end);
|
||||
auto new_ids = std::vector<int64_t>(vector_ids.begin() + ids_begin, vector_ids.begin() + ids_end);
|
||||
nlohmann::json vectors_json;
|
||||
status = GetVectorsByIDs(collection_name, ids, vectors_json);
|
||||
status = GetVectorsByIDs(collection_name, new_ids, vectors_json);
|
||||
|
||||
nlohmann::json result_json;
|
||||
if (vectors_json.empty()) {
|
||||
@ -231,20 +216,20 @@ WebRequestHandler::GetSegmentVectors(const std::string& collection_name, int64_t
|
||||
Status
|
||||
WebRequestHandler::GetSegmentIds(const std::string& collection_name, int64_t segment_id, int64_t page_size,
|
||||
int64_t offset, nlohmann::json& json_out) {
|
||||
std::vector<int64_t> vector_ids;
|
||||
auto status = request_handler_.GetEntityIDs(context_ptr_, collection_name, segment_id, vector_ids);
|
||||
std::vector<int64_t> ids;
|
||||
auto status = request_handler_.ListIDInSegment(context_ptr_, collection_name, segment_id, ids);
|
||||
if (status.ok()) {
|
||||
auto ids_begin = std::min(vector_ids.size(), (size_t)offset);
|
||||
auto ids_end = std::min(vector_ids.size(), (size_t)(offset + page_size));
|
||||
auto ids_begin = std::min(ids.size(), (size_t)offset);
|
||||
auto ids_end = std::min(ids.size(), (size_t)(offset + page_size));
|
||||
|
||||
if (ids_begin >= ids_end) {
|
||||
json_out["ids"] = std::vector<int64_t>();
|
||||
} else {
|
||||
for (size_t i = ids_begin; i < ids_end; i++) {
|
||||
json_out["ids"].push_back(std::to_string(vector_ids.at(i)));
|
||||
json_out["ids"].push_back(std::to_string(ids.at(i)));
|
||||
}
|
||||
}
|
||||
json_out["count"] = vector_ids.size();
|
||||
json_out["count"] = ids.size();
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -277,7 +262,7 @@ WebRequestHandler::PreLoadCollection(const nlohmann::json& json, std::string& re
|
||||
}
|
||||
|
||||
auto collection_name = json["collection_name"];
|
||||
auto status = request_handler_.PreloadCollection(context_ptr_, collection_name.get<std::string>());
|
||||
auto status = request_handler_.LoadCollection(context_ptr_, collection_name.get<std::string>());
|
||||
if (status.ok()) {
|
||||
nlohmann::json result;
|
||||
AddStatusToJson(result, status.code(), status.message());
|
||||
@ -712,8 +697,8 @@ Status
|
||||
WebRequestHandler::Search(const std::string& collection_name, const nlohmann::json& json, std::string& result_str) {
|
||||
Status status;
|
||||
|
||||
milvus::server::HybridCollectionSchema collection_schema;
|
||||
status = request_handler_.DescribeCollection(context_ptr_, collection_name, collection_schema);
|
||||
milvus::server::CollectionSchema collection_schema;
|
||||
status = request_handler_.GetCollectionInfo(context_ptr_, collection_name, collection_schema);
|
||||
if (!status.ok()) {
|
||||
return Status{UNEXPECTED_ERROR, "DescribeHybridCollection failed"};
|
||||
}
|
||||
@ -810,7 +795,7 @@ WebRequestHandler::DeleteByIDs(const std::string& collection_name, const nlohman
|
||||
vector_ids.emplace_back(std::stol(id_str));
|
||||
}
|
||||
|
||||
auto status = request_handler_.DeleteByID(context_ptr_, collection_name, vector_ids);
|
||||
auto status = request_handler_.DeleteEntityByID(context_ptr_, collection_name, vector_ids);
|
||||
|
||||
nlohmann::json result_json;
|
||||
AddStatusToJson(result_json, status.code(), status.message());
|
||||
@ -1280,7 +1265,7 @@ WebRequestHandler::ShowCollections(const OQueryParams& query_params, OString& re
|
||||
}
|
||||
|
||||
std::vector<std::string> collections;
|
||||
status = request_handler_.ShowCollections(context_ptr_, collections);
|
||||
status = request_handler_.ListCollections(context_ptr_, collections);
|
||||
if (!status.ok()) {
|
||||
ASSIGN_RETURN_STATUS_DTO(status)
|
||||
}
|
||||
@ -1376,22 +1361,6 @@ WebRequestHandler::CreateIndex(const OString& collection_name, const OString& bo
|
||||
ASSIGN_RETURN_STATUS_DTO(Status::OK())
|
||||
}
|
||||
|
||||
StatusDto::ObjectWrapper
|
||||
WebRequestHandler::GetIndex(const OString& collection_name, OString& result) {
|
||||
IndexParam param;
|
||||
auto status = request_handler_.DescribeIndex(context_ptr_, collection_name->std_str(), param);
|
||||
|
||||
if (status.ok()) {
|
||||
nlohmann::json json_out;
|
||||
auto index_type = engine::EngineType(param.index_type_);
|
||||
json_out["index_type"] = index_type;
|
||||
json_out["params"] = nlohmann::json::parse(param.extra_params_);
|
||||
result = json_out.dump().c_str();
|
||||
}
|
||||
|
||||
ASSIGN_RETURN_STATUS_DTO(status)
|
||||
}
|
||||
|
||||
StatusDto::ObjectWrapper
|
||||
WebRequestHandler::DropIndex(const OString& collection_name) {
|
||||
auto status = Status::OK();
|
||||
@ -1443,7 +1412,7 @@ WebRequestHandler::ShowPartitions(const OString& collection_name, const OQueryPa
|
||||
}
|
||||
|
||||
std::vector<std::string> partition_names;
|
||||
status = request_handler_.ShowPartitions(context_ptr_, collection_name->std_str(), partition_names);
|
||||
status = request_handler_.ListPartitions(context_ptr_, collection_name->std_str(), partition_names);
|
||||
if (!status.ok()) {
|
||||
ASSIGN_RETURN_STATUS_DTO(status)
|
||||
}
|
||||
@ -1523,13 +1492,13 @@ WebRequestHandler::ShowSegments(const OString& collection_name, const OQueryPara
|
||||
tag = query_params.get("partition_tag")->std_str();
|
||||
}
|
||||
|
||||
std::string info;
|
||||
status = request_handler_.ShowCollectionInfo(context_ptr_, collection_name->std_str(), info);
|
||||
std::string stats;
|
||||
status = request_handler_.GetCollectionStats(context_ptr_, collection_name->std_str(), stats);
|
||||
if (!status.ok()) {
|
||||
ASSIGN_RETURN_STATUS_DTO(status)
|
||||
}
|
||||
|
||||
nlohmann::json info_json = nlohmann::json::parse(info);
|
||||
nlohmann::json info_json = nlohmann::json::parse(stats);
|
||||
nlohmann::json segments_json = nlohmann::json::array();
|
||||
for (auto& par : info_json["partitions"]) {
|
||||
if (!(all_required || tag.empty() || tag == par["tag"])) {
|
||||
@ -1619,7 +1588,7 @@ WebRequestHandler::InsertEntity(const OString& collection_name, const milvus::se
|
||||
|
||||
std::unordered_map<std::string, engine::meta::hybrid::DataType> field_types;
|
||||
auto status = Status::OK();
|
||||
// auto status = request_handler_.DescribeHybridCollection(context_ptr_, collection_name->c_str(), field_types);
|
||||
// auto status = request_handler_.DescribeHybridCollection(context_ptr_, collection_name->c_str(), field_types);
|
||||
|
||||
auto entities = body_json["entity"];
|
||||
if (!entities.is_array()) {
|
||||
@ -1661,9 +1630,9 @@ WebRequestHandler::InsertEntity(const OString& collection_name, const milvus::se
|
||||
ASSIGN_RETURN_STATUS_DTO(status)
|
||||
}
|
||||
|
||||
// engine::VectorsData vectors;
|
||||
// CopyRecordsFromJson(field_value, vectors, bin_flag);
|
||||
// vector_datas.insert(std::make_pair(field_name, vectors));
|
||||
// engine::VectorsData vectors;
|
||||
// CopyRecordsFromJson(field_value, vectors, bin_flag);
|
||||
// vector_datas.insert(std::make_pair(field_name, vectors));
|
||||
}
|
||||
default: {}
|
||||
}
|
||||
@ -1671,7 +1640,7 @@ WebRequestHandler::InsertEntity(const OString& collection_name, const milvus::se
|
||||
chunk_data.insert(std::make_pair(field_name, temp_data));
|
||||
}
|
||||
|
||||
status = request_handler_.InsertEntity(context_ptr_, collection_name->c_str(), partition_name, row_num, chunk_data);
|
||||
status = request_handler_.Insert(context_ptr_, collection_name->c_str(), partition_name, row_num, chunk_data);
|
||||
if (!status.ok()) {
|
||||
RETURN_STATUS_DTO(UNEXPECTED_ERROR, "Failed to insert data");
|
||||
}
|
||||
|
||||
@ -183,9 +183,6 @@ class WebRequestHandler {
|
||||
StatusDto::ObjectWrapper
|
||||
CreateIndex(const OString& collection_name, const OString& body);
|
||||
|
||||
StatusDto::ObjectWrapper
|
||||
GetIndex(const OString& collection_name, OString& result);
|
||||
|
||||
StatusDto::ObjectWrapper
|
||||
DropIndex(const OString& collection_name);
|
||||
|
||||
|
||||
@ -150,13 +150,13 @@ TEST_F(DBTest, CollectionTest) {
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
ASSERT_EQ(ss->GetCollectionCommit()->GetRowCount(), 0);
|
||||
milvus::engine::snapshot::SIZE_TYPE row_cnt = 0;
|
||||
status = db_->GetCollectionRowCount(c1, row_cnt);
|
||||
int64_t row_cnt = 0;
|
||||
status = db_->CountEntities(c1, row_cnt);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(row_cnt, 0);
|
||||
|
||||
std::vector<std::string> names;
|
||||
status = db_->AllCollections(names);
|
||||
status = db_->ListCollections(names);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(names.size(), 1);
|
||||
ASSERT_EQ(names[0], c1);
|
||||
@ -169,14 +169,14 @@ TEST_F(DBTest, CollectionTest) {
|
||||
status = CreateCollection(db_, c2, next_lsn());
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
status = db_->AllCollections(names);
|
||||
status = db_->ListCollections(names);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(names.size(), 2);
|
||||
|
||||
status = db_->DropCollection(c1);
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
status = db_->AllCollections(names);
|
||||
status = db_->ListCollections(names);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(names.size(), 1);
|
||||
ASSERT_EQ(names[0], c2);
|
||||
@ -195,7 +195,7 @@ TEST_F(DBTest, PartitionTest) {
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
std::vector<std::string> partition_names;
|
||||
status = db_->ShowPartitions(c1, partition_names);
|
||||
status = db_->ListPartitions(c1, partition_names);
|
||||
ASSERT_EQ(partition_names.size(), 1);
|
||||
ASSERT_EQ(partition_names[0], "_default");
|
||||
|
||||
@ -207,7 +207,7 @@ TEST_F(DBTest, PartitionTest) {
|
||||
status = db_->CreatePartition(c1, p1);
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
status = db_->ShowPartitions(c1, partition_names);
|
||||
status = db_->ListPartitions(c1, partition_names);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(partition_names.size(), 2);
|
||||
|
||||
@ -219,7 +219,7 @@ TEST_F(DBTest, PartitionTest) {
|
||||
|
||||
status = db_->DropPartition(c1, p1);
|
||||
ASSERT_TRUE(status.ok());
|
||||
status = db_->ShowPartitions(c1, partition_names);
|
||||
status = db_->ListPartitions(c1, partition_names);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(partition_names.size(), 1);
|
||||
}
|
||||
@ -461,14 +461,14 @@ TEST_F(DBTest, InsertTest) {
|
||||
milvus::engine::DataChunkPtr data_chunk;
|
||||
BuildEntities(entity_count, 0, data_chunk);
|
||||
|
||||
status = db_->InsertEntities(collection_name, "", data_chunk);
|
||||
status = db_->Insert(collection_name, "", data_chunk);
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
status = db_->Flush();
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
uint64_t row_count = 0;
|
||||
status = db_->GetCollectionRowCount(collection_name, row_count);
|
||||
int64_t row_count = 0;
|
||||
status = db_->CountEntities(collection_name, row_count);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(row_count, entity_count);
|
||||
}
|
||||
@ -484,7 +484,7 @@ TEST_F(DBTest, MergeTest) {
|
||||
|
||||
int64_t repeat = 2;
|
||||
for (int32_t i = 0; i < repeat; i++) {
|
||||
status = db_->InsertEntities(collection_name, "", data_chunk);
|
||||
status = db_->Insert(collection_name, "", data_chunk);
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
status = db_->Flush();
|
||||
@ -493,8 +493,8 @@ TEST_F(DBTest, MergeTest) {
|
||||
|
||||
sleep(2); // wait to merge
|
||||
|
||||
uint64_t row_count = 0;
|
||||
status = db_->GetCollectionRowCount(collection_name, row_count);
|
||||
int64_t row_count = 0;
|
||||
status = db_->CountEntities(collection_name, row_count);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(row_count, entity_count * repeat);
|
||||
}
|
||||
|
||||
@ -67,26 +67,14 @@ ClientTest::~ClientTest() {
|
||||
}
|
||||
|
||||
void
|
||||
ClientTest::ShowServerVersion() {
|
||||
std::string version = conn_->ServerVersion();
|
||||
std::cout << "Server version: " << version << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
ClientTest::ShowSdkVersion() {
|
||||
std::string version = conn_->ClientVersion();
|
||||
std::cout << "SDK version: " << version << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
ClientTest::ShowCollections(std::vector<std::string>& collection_array) {
|
||||
ClientTest::ListCollections(std::vector<std::string>& collection_array) {
|
||||
milvus::Status stat = conn_->ListCollections(collection_array);
|
||||
std::cout << "ShowCollections function call status: " << stat.message() << std::endl;
|
||||
std::cout << "All collections: " << std::endl;
|
||||
std::cout << "ListCollections function call status: " << stat.message() << std::endl;
|
||||
std::cout << "Collection list: " << std::endl;
|
||||
for (auto& collection : collection_array) {
|
||||
int64_t entity_count = 0;
|
||||
stat = conn_->CountEntities(collection, entity_count);
|
||||
std::cout << "\t" << collection << "(" << entity_count << " entities)" << std::endl;
|
||||
std::cout << "\t" << collection << " (" << entity_count << " entities)" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,11 +269,7 @@ ClientTest::CreateIndex(const std::string& collection_name, int64_t nlist) {
|
||||
milvus_sdk::Utils::PrintIndexParam(index1);
|
||||
milvus::Status stat = conn_->CreateIndex(index1);
|
||||
std::cout << "CreateIndex function call status: " << stat.message() << std::endl;
|
||||
|
||||
milvus::IndexParam index2;
|
||||
stat = conn_->GetIndexInfo(collection_name, index2);
|
||||
std::cout << "GetIndexInfo function call status: " << stat.message() << std::endl;
|
||||
milvus_sdk::Utils::PrintIndexParam(index2);
|
||||
milvus_sdk::Utils::PrintIndexParam(index1);
|
||||
}
|
||||
|
||||
void
|
||||
@ -339,18 +323,18 @@ ClientTest::Test() {
|
||||
int64_t dim = COLLECTION_DIMENSION;
|
||||
milvus::MetricType metric_type = COLLECTION_METRIC_TYPE;
|
||||
|
||||
ShowServerVersion();
|
||||
ShowSdkVersion();
|
||||
|
||||
std::vector<std::string> table_array;
|
||||
// ShowCollections(table_array);
|
||||
ListCollections(table_array);
|
||||
|
||||
CreateCollection(collection_name);
|
||||
GetCollectionInfo(collection_name);
|
||||
|
||||
InsertEntities(collection_name);
|
||||
Flush(collection_name);
|
||||
ListCollections(table_array);
|
||||
CountEntities(collection_name);
|
||||
|
||||
// InsertEntities(collection_name);
|
||||
// Flush(collection_name);
|
||||
// CountEntities(collection_name);
|
||||
// GetCollectionStats(collection_name);
|
||||
//
|
||||
// BuildVectors(NQ, COLLECTION_DIMENSION);
|
||||
@ -367,5 +351,5 @@ ClientTest::Test() {
|
||||
// SearchEntities(collection_name, TOP_K, NPROBE); // this line get two search error since we delete two entities
|
||||
//
|
||||
// DropIndex(collection_name, "field_vec", "index_3");
|
||||
// DropCollection(collection_name);
|
||||
DropCollection(collection_name);
|
||||
}
|
||||
|
||||
@ -28,13 +28,7 @@ class ClientTest {
|
||||
|
||||
private:
|
||||
void
|
||||
ShowServerVersion();
|
||||
|
||||
void
|
||||
ShowSdkVersion();
|
||||
|
||||
void
|
||||
ShowCollections(std::vector<std::string>&);
|
||||
ListCollections(std::vector<std::string>&);
|
||||
|
||||
void
|
||||
CreateCollection(const std::string& collection_name);
|
||||
|
||||
@ -426,57 +426,6 @@ ClientProxy::Disconnect() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
ClientProxy::ClientVersion() const {
|
||||
return MILVUS_SDK_VERSION;
|
||||
}
|
||||
|
||||
std::string
|
||||
ClientProxy::ServerVersion() const {
|
||||
Status status = Status::OK();
|
||||
try {
|
||||
std::string version;
|
||||
Status status = client_ptr_->Cmd("version", version);
|
||||
return version;
|
||||
} catch (std::exception& ex) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
ClientProxy::ServerStatus() const {
|
||||
if (channel_ == nullptr) {
|
||||
return "not connected to server";
|
||||
}
|
||||
|
||||
try {
|
||||
std::string dummy;
|
||||
Status status = client_ptr_->Cmd("", dummy);
|
||||
return "server alive";
|
||||
} catch (std::exception& ex) {
|
||||
return "connection lost";
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::GetConfig(const std::string& node_name, std::string& value) const {
|
||||
try {
|
||||
return client_ptr_->Cmd("get_config " + node_name, value);
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to get config: " + node_name);
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::SetConfig(const std::string& node_name, const std::string& value) const {
|
||||
try {
|
||||
std::string dummy;
|
||||
return client_ptr_->Cmd("set_config " + node_name + " " + value, dummy);
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to set config: " + node_name);
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::CreateCollection(const Mapping& mapping, const std::string& extra_params) {
|
||||
try {
|
||||
@ -507,6 +456,17 @@ ClientProxy::CreateCollection(const Mapping& mapping, const std::string& extra_p
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::DropCollection(const std::string& collection_name) {
|
||||
try {
|
||||
::milvus::grpc::CollectionName grpc_collection_name;
|
||||
grpc_collection_name.set_collection_name(collection_name);
|
||||
return client_ptr_->DropCollection(grpc_collection_name);
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to drop collection: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ClientProxy::HasCollection(const std::string& collection_name) {
|
||||
try {
|
||||
@ -520,13 +480,143 @@ ClientProxy::HasCollection(const std::string& collection_name) {
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::DropCollection(const std::string& collection_name) {
|
||||
ClientProxy::ListCollections(std::vector<std::string>& collection_array) {
|
||||
try {
|
||||
Status status;
|
||||
milvus::grpc::CollectionNameList collection_name_list;
|
||||
status = client_ptr_->ListCollections(collection_name_list);
|
||||
|
||||
collection_array.resize(collection_name_list.collection_names_size());
|
||||
for (uint64_t i = 0; i < collection_name_list.collection_names_size(); ++i) {
|
||||
collection_array[i] = collection_name_list.collection_names(i);
|
||||
}
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to list collections: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::GetCollectionInfo(const std::string& collection_name, Mapping& mapping) {
|
||||
try {
|
||||
::milvus::grpc::Mapping grpc_mapping;
|
||||
|
||||
Status status = client_ptr_->GetCollectionInfo(collection_name, grpc_mapping);
|
||||
|
||||
mapping.collection_name = collection_name;
|
||||
for (int64_t i = 0; i < grpc_mapping.fields_size(); i++) {
|
||||
auto grpc_field = grpc_mapping.fields(i);
|
||||
FieldPtr field_ptr = std::make_shared<Field>();
|
||||
field_ptr->field_name = grpc_field.name();
|
||||
JSON json_index_params;
|
||||
for (int64_t j = 0; j < grpc_field.index_params_size(); j++) {
|
||||
JSON json_param;
|
||||
json_param[grpc_field.index_params(j).key()] = grpc_field.index_params(j).value();
|
||||
json_index_params.emplace_back(json_param);
|
||||
}
|
||||
field_ptr->index_params = json_index_params.dump();
|
||||
JSON json_extra_params;
|
||||
for (int64_t j = 0; j < grpc_field.extra_params_size(); j++) {
|
||||
JSON json_param;
|
||||
json_param = JSON::parse(grpc_field.extra_params(j).value());
|
||||
json_extra_params.emplace_back(json_param);
|
||||
}
|
||||
field_ptr->extra_params = json_extra_params.dump();
|
||||
field_ptr->field_type = (DataType)grpc_field.type();
|
||||
mapping.fields.emplace_back(field_ptr);
|
||||
}
|
||||
if (!grpc_mapping.extra_params().empty()) {
|
||||
mapping.extra_params = grpc_mapping.extra_params(0).value();
|
||||
}
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to get collection info: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::GetCollectionStats(const std::string& collection_name, std::string& collection_stats) {
|
||||
try {
|
||||
Status status;
|
||||
::milvus::grpc::CollectionName grpc_collection_name;
|
||||
grpc_collection_name.set_collection_name(collection_name);
|
||||
milvus::grpc::CollectionInfo grpc_collection_stats;
|
||||
status = client_ptr_->GetCollectionStats(grpc_collection_name, grpc_collection_stats);
|
||||
|
||||
collection_stats = grpc_collection_stats.json_info();
|
||||
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to get collection stats: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::CountEntities(const std::string& collection_name, int64_t& row_count) {
|
||||
try {
|
||||
Status status;
|
||||
::milvus::grpc::CollectionName grpc_collection_name;
|
||||
grpc_collection_name.set_collection_name(collection_name);
|
||||
row_count = client_ptr_->CountEntities(grpc_collection_name, status);
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to count collection: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::CreatePartition(const PartitionParam& partition_param) {
|
||||
try {
|
||||
::milvus::grpc::PartitionParam grpc_partition_param;
|
||||
grpc_partition_param.set_collection_name(partition_param.collection_name);
|
||||
grpc_partition_param.set_tag(partition_param.partition_tag);
|
||||
Status status = client_ptr_->CreatePartition(grpc_partition_param);
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to create partition: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::DropPartition(const PartitionParam& partition_param) {
|
||||
try {
|
||||
::milvus::grpc::PartitionParam grpc_partition_param;
|
||||
grpc_partition_param.set_collection_name(partition_param.collection_name);
|
||||
grpc_partition_param.set_tag(partition_param.partition_tag);
|
||||
Status status = client_ptr_->DropPartition(grpc_partition_param);
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to drop partition: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ClientProxy::HasPartition(const std::string& collection_name, const std::string& partition_tag) const {
|
||||
try {
|
||||
Status status = Status::OK();
|
||||
::milvus::grpc::PartitionParam grpc_partition_param;
|
||||
grpc_partition_param.set_collection_name(collection_name);
|
||||
grpc_partition_param.set_tag(partition_tag);
|
||||
return client_ptr_->HasPartition(grpc_partition_param, status);
|
||||
} catch (std::exception& ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::ListPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const {
|
||||
try {
|
||||
::milvus::grpc::CollectionName grpc_collection_name;
|
||||
grpc_collection_name.set_collection_name(collection_name);
|
||||
return client_ptr_->DropCollection(grpc_collection_name);
|
||||
::milvus::grpc::PartitionList grpc_partition_list;
|
||||
Status status = client_ptr_->ListPartitions(grpc_collection_name, grpc_partition_list);
|
||||
partition_tag_array.resize(grpc_partition_list.partition_tag_array_size());
|
||||
for (uint64_t i = 0; i < grpc_partition_list.partition_tag_array_size(); ++i) {
|
||||
partition_tag_array[i] = grpc_partition_list.partition_tag_array(i);
|
||||
}
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to drop collection: " + std::string(ex.what()));
|
||||
return Status(StatusCode::UnknownError, "Failed to show partitions: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,6 +636,21 @@ ClientProxy::CreateIndex(const IndexParam& index_param) {
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const {
|
||||
try {
|
||||
::milvus::grpc::IndexParam grpc_index_param;
|
||||
grpc_index_param.set_collection_name(collection_name);
|
||||
grpc_index_param.set_field_name(field_name);
|
||||
grpc_index_param.set_index_name(index_name);
|
||||
Status status = client_ptr_->DropIndex(grpc_index_param);
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to drop index: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::Insert(const std::string& collection_name, const std::string& partition_tag, const FieldValue& field_value,
|
||||
std::vector<int64_t>& id_array) {
|
||||
@ -603,22 +708,17 @@ ClientProxy::GetEntityByID(const std::string& collection_name, const std::vector
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) {
|
||||
ClientProxy::DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) {
|
||||
try {
|
||||
::milvus::grpc::GetEntityIDsParam param;
|
||||
param.set_collection_name(collection_name);
|
||||
param.set_segment_name(segment_name);
|
||||
|
||||
::milvus::grpc::EntityIds entity_ids;
|
||||
Status status = client_ptr_->ListIDInSegment(param, entity_ids);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
::milvus::grpc::DeleteByIDParam delete_by_id_param;
|
||||
delete_by_id_param.set_collection_name(collection_name);
|
||||
for (auto id : id_array) {
|
||||
delete_by_id_param.add_id_array(id);
|
||||
}
|
||||
id_array.insert(id_array.end(), entity_ids.entity_id_array().begin(), entity_ids.entity_id_array().end());
|
||||
return status;
|
||||
|
||||
return client_ptr_->DeleteEntityByID(delete_by_id_param);
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to get ids from segment: " + std::string(ex.what()));
|
||||
return Status(StatusCode::UnknownError, "Failed to delete entity id: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -651,102 +751,22 @@ ClientProxy::Search(const std::string& collection_name, const std::vector<std::s
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::GetCollectionInfo(const std::string& collection_name, Mapping& mapping) {
|
||||
ClientProxy::ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) {
|
||||
try {
|
||||
::milvus::grpc::Mapping grpc_mapping;
|
||||
::milvus::grpc::GetEntityIDsParam param;
|
||||
param.set_collection_name(collection_name);
|
||||
param.set_segment_name(segment_name);
|
||||
|
||||
Status status = client_ptr_->GetCollectionInfo(collection_name, grpc_mapping);
|
||||
|
||||
mapping.collection_name = collection_name;
|
||||
for (int64_t i = 0; i < grpc_mapping.fields_size(); i++) {
|
||||
auto grpc_field = grpc_mapping.fields(i);
|
||||
FieldPtr field_ptr = std::make_shared<Field>();
|
||||
field_ptr->field_name = grpc_field.name();
|
||||
JSON json_index_params;
|
||||
for (int64_t j = 0; j < grpc_field.index_params_size(); j++) {
|
||||
JSON json_param;
|
||||
json_param[grpc_field.index_params(j).key()] = grpc_field.index_params(j).value();
|
||||
json_index_params.emplace_back(json_param);
|
||||
}
|
||||
field_ptr->index_params = json_index_params.dump();
|
||||
JSON json_extra_params;
|
||||
for (int64_t j = 0; j < grpc_field.extra_params_size(); j++) {
|
||||
JSON json_param;
|
||||
json_param = JSON::parse(grpc_field.extra_params(j).value());
|
||||
json_extra_params.emplace_back(json_param);
|
||||
}
|
||||
field_ptr->extra_params = json_extra_params.dump();
|
||||
field_ptr->field_type = (DataType)grpc_field.type();
|
||||
mapping.fields.emplace_back(field_ptr);
|
||||
}
|
||||
if (!grpc_mapping.extra_params().empty()) {
|
||||
mapping.extra_params = grpc_mapping.extra_params(0).value();
|
||||
::milvus::grpc::EntityIds entity_ids;
|
||||
Status status = client_ptr_->ListIDInSegment(param, entity_ids);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
id_array.insert(id_array.end(), entity_ids.entity_id_array().begin(), entity_ids.entity_id_array().end());
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to describe collection: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::CountEntities(const std::string& collection_name, int64_t& row_count) {
|
||||
try {
|
||||
Status status;
|
||||
::milvus::grpc::CollectionName grpc_collection_name;
|
||||
grpc_collection_name.set_collection_name(collection_name);
|
||||
row_count = client_ptr_->CountEntities(grpc_collection_name, status);
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to count collection: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::ListCollections(std::vector<std::string>& collection_array) {
|
||||
try {
|
||||
Status status;
|
||||
milvus::grpc::CollectionNameList collection_name_list;
|
||||
status = client_ptr_->ListCollections(collection_name_list);
|
||||
|
||||
collection_array.resize(collection_name_list.collection_names_size());
|
||||
for (uint64_t i = 0; i < collection_name_list.collection_names_size(); ++i) {
|
||||
collection_array[i] = collection_name_list.collection_names(i);
|
||||
}
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to show collections: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::GetCollectionStats(const std::string& collection_name, std::string& collection_stats) {
|
||||
try {
|
||||
Status status;
|
||||
::milvus::grpc::CollectionName grpc_collection_name;
|
||||
grpc_collection_name.set_collection_name(collection_name);
|
||||
milvus::grpc::CollectionInfo grpc_collection_stats;
|
||||
status = client_ptr_->GetCollectionStats(grpc_collection_name, grpc_collection_stats);
|
||||
|
||||
collection_stats = grpc_collection_stats.json_info();
|
||||
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to show collection info: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) {
|
||||
try {
|
||||
::milvus::grpc::DeleteByIDParam delete_by_id_param;
|
||||
delete_by_id_param.set_collection_name(collection_name);
|
||||
for (auto id : id_array) {
|
||||
delete_by_id_param.add_id_array(id);
|
||||
}
|
||||
|
||||
return client_ptr_->DeleteEntityByID(delete_by_id_param);
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to delete entity id: " + std::string(ex.what()));
|
||||
return Status(StatusCode::UnknownError, "Failed to get ids from segment: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -762,100 +782,6 @@ ClientProxy::LoadCollection(const std::string& collection_name) const {
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::GetIndexInfo(const std::string& collection_name, IndexParam& index_param) const {
|
||||
try {
|
||||
::milvus::grpc::CollectionName grpc_collection_name;
|
||||
grpc_collection_name.set_collection_name(collection_name);
|
||||
|
||||
::milvus::grpc::IndexParam grpc_index_param;
|
||||
Status status = client_ptr_->GetIndexInfo(grpc_collection_name, grpc_index_param);
|
||||
index_param.index_name = grpc_index_param.index_name();
|
||||
|
||||
for (int i = 0; i < grpc_index_param.extra_params_size(); i++) {
|
||||
const milvus::grpc::KeyValuePair& kv = grpc_index_param.extra_params(i);
|
||||
if (kv.key() == EXTRA_PARAM_KEY) {
|
||||
index_param.extra_params = kv.value();
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to describe index: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const {
|
||||
try {
|
||||
::milvus::grpc::IndexParam grpc_index_param;
|
||||
grpc_index_param.set_collection_name(collection_name);
|
||||
grpc_index_param.set_field_name(field_name);
|
||||
grpc_index_param.set_index_name(index_name);
|
||||
Status status = client_ptr_->DropIndex(grpc_index_param);
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to drop index: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::CreatePartition(const PartitionParam& partition_param) {
|
||||
try {
|
||||
::milvus::grpc::PartitionParam grpc_partition_param;
|
||||
grpc_partition_param.set_collection_name(partition_param.collection_name);
|
||||
grpc_partition_param.set_tag(partition_param.partition_tag);
|
||||
Status status = client_ptr_->CreatePartition(grpc_partition_param);
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to create partition: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ClientProxy::HasPartition(const std::string& collection_name, const std::string& partition_tag) const {
|
||||
try {
|
||||
Status status = Status::OK();
|
||||
::milvus::grpc::PartitionParam grpc_partition_param;
|
||||
grpc_partition_param.set_collection_name(collection_name);
|
||||
grpc_partition_param.set_tag(partition_tag);
|
||||
return client_ptr_->HasPartition(grpc_partition_param, status);
|
||||
} catch (std::exception& ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::ListPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const {
|
||||
try {
|
||||
::milvus::grpc::CollectionName grpc_collection_name;
|
||||
grpc_collection_name.set_collection_name(collection_name);
|
||||
::milvus::grpc::PartitionList grpc_partition_list;
|
||||
Status status = client_ptr_->ListPartitions(grpc_collection_name, grpc_partition_list);
|
||||
partition_tag_array.resize(grpc_partition_list.partition_tag_array_size());
|
||||
for (uint64_t i = 0; i < grpc_partition_list.partition_tag_array_size(); ++i) {
|
||||
partition_tag_array[i] = grpc_partition_list.partition_tag_array(i);
|
||||
}
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to show partitions: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::DropPartition(const PartitionParam& partition_param) {
|
||||
try {
|
||||
::milvus::grpc::PartitionParam grpc_partition_param;
|
||||
grpc_partition_param.set_collection_name(partition_param.collection_name);
|
||||
grpc_partition_param.set_tag(partition_param.partition_tag);
|
||||
Status status = client_ptr_->DropPartition(grpc_partition_param);
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to drop partition: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::Flush(const std::vector<std::string>& collection_name_array) {
|
||||
try {
|
||||
|
||||
@ -35,33 +35,46 @@ class ClientProxy : public Connection {
|
||||
Status
|
||||
Disconnect() override;
|
||||
|
||||
std::string
|
||||
ClientVersion() const override;
|
||||
|
||||
std::string
|
||||
ServerVersion() const override;
|
||||
|
||||
std::string
|
||||
ServerStatus() const override;
|
||||
|
||||
Status
|
||||
GetConfig(const std::string& node_name, std::string& value) const override;
|
||||
|
||||
Status
|
||||
SetConfig(const std::string& node_name, const std::string& value) const override;
|
||||
|
||||
Status
|
||||
CreateCollection(const Mapping& mapping, const std::string& extra_params) override;
|
||||
|
||||
Status
|
||||
DropCollection(const std::string& collection_name) override;
|
||||
|
||||
bool
|
||||
HasCollection(const std::string& collection_name) override;
|
||||
|
||||
Status
|
||||
DropCollection(const std::string& collection_name) override;
|
||||
ListCollections(std::vector<std::string>& collection_array) override;
|
||||
|
||||
Status
|
||||
GetCollectionInfo(const std::string& collection_name, Mapping& mapping) override;
|
||||
|
||||
Status
|
||||
GetCollectionStats(const std::string& collection_name, std::string& collection_stats) override;
|
||||
|
||||
Status
|
||||
CountEntities(const std::string& collection_name, int64_t& entity_count) override;
|
||||
|
||||
Status
|
||||
CreatePartition(const PartitionParam& partition_param) override;
|
||||
|
||||
Status
|
||||
DropPartition(const PartitionParam& partition_param) override;
|
||||
|
||||
bool
|
||||
HasPartition(const std::string& collection_name, const std::string& partition_tag) const override;
|
||||
|
||||
Status
|
||||
ListPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const override;
|
||||
|
||||
Status
|
||||
CreateIndex(const IndexParam& index_param) override;
|
||||
|
||||
Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const override;
|
||||
|
||||
Status
|
||||
Insert(const std::string& collection_name, const std::string& partition_tag, const FieldValue& entity_array,
|
||||
std::vector<int64_t>& id_array) override;
|
||||
@ -71,8 +84,7 @@ class ClientProxy : public Connection {
|
||||
std::string& entities) override;
|
||||
|
||||
Status
|
||||
ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) override;
|
||||
DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) override;
|
||||
|
||||
Status
|
||||
Search(const std::string& collection_name, const std::vector<std::string>& partition_list, const std::string& dsl,
|
||||
@ -83,42 +95,12 @@ class ClientProxy : public Connection {
|
||||
BooleanQueryPtr& boolean_query, const std::string& extra_params, TopKQueryResult& query_result) override;
|
||||
|
||||
Status
|
||||
GetCollectionInfo(const std::string& collection_name, Mapping& mapping) override;
|
||||
|
||||
Status
|
||||
CountEntities(const std::string& collection_name, int64_t& entity_count) override;
|
||||
|
||||
Status
|
||||
ListCollections(std::vector<std::string>& collection_array) override;
|
||||
|
||||
Status
|
||||
GetCollectionStats(const std::string& collection_name, std::string& collection_stats) override;
|
||||
|
||||
Status
|
||||
DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) override;
|
||||
ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) override;
|
||||
|
||||
Status
|
||||
LoadCollection(const std::string& collection_name) const override;
|
||||
|
||||
Status
|
||||
GetIndexInfo(const std::string& collection_name, IndexParam& index_param) const override;
|
||||
|
||||
Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const override;
|
||||
|
||||
Status
|
||||
CreatePartition(const PartitionParam& partition_param) override;
|
||||
|
||||
bool
|
||||
HasPartition(const std::string& collection_name, const std::string& partition_tag) const override;
|
||||
|
||||
Status
|
||||
ListPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const override;
|
||||
|
||||
Status
|
||||
DropPartition(const PartitionParam& partition_param) override;
|
||||
|
||||
Status
|
||||
Flush(const std::vector<std::string>& collection_name_array) override;
|
||||
|
||||
|
||||
@ -149,9 +149,9 @@ struct Mapping {
|
||||
class Connection {
|
||||
public:
|
||||
/**
|
||||
* @brief Create connection
|
||||
* @brief Create connection instance
|
||||
*
|
||||
* Create a connection instance and return it's shared pointer
|
||||
* Create a connection instance and return its shared pointer
|
||||
*
|
||||
* @return connection instance pointer
|
||||
*/
|
||||
@ -160,13 +160,13 @@ class Connection {
|
||||
Create();
|
||||
|
||||
/**
|
||||
* @brief Destroy connection
|
||||
* @brief Destroy connection instance
|
||||
*
|
||||
* Destroy the connection instance
|
||||
*
|
||||
* @param connection, the shared pointer to the instance to be destroyed
|
||||
*
|
||||
* @return if destroy is successful
|
||||
* @return Indicate if destroy successfully
|
||||
*/
|
||||
|
||||
static Status
|
||||
@ -175,12 +175,12 @@ class Connection {
|
||||
/**
|
||||
* @brief Connect
|
||||
*
|
||||
* This method is used to connect server.
|
||||
* Connect function should be called before any operations.
|
||||
* This method is used to connect to Milvus server.
|
||||
* Connect function must be called before all other operations.
|
||||
*
|
||||
* @param param, use to provide server information
|
||||
* @param param, used to provide server information
|
||||
*
|
||||
* @return Indicate if connect is successful
|
||||
* @return Indicate if connect successfully
|
||||
*/
|
||||
|
||||
virtual Status
|
||||
@ -189,20 +189,20 @@ class Connection {
|
||||
/**
|
||||
* @brief Connect
|
||||
*
|
||||
* This method is used to connect server.
|
||||
* Connect function should be called before any operations.
|
||||
* This method is used to connect to Milvus server.
|
||||
* Connect function must be called before all other operations.
|
||||
*
|
||||
* @param uri, use to provide server uri, example: milvus://ipaddress:port
|
||||
* @param uri, used to provide server uri, example: milvus://ipaddress:port
|
||||
*
|
||||
* @return Indicate if connect is successful
|
||||
* @return Indicate if connect successfully
|
||||
*/
|
||||
virtual Status
|
||||
Connect(const std::string& uri) = 0;
|
||||
|
||||
/**
|
||||
* @brief Connected
|
||||
* @brief Check connection
|
||||
*
|
||||
* This method is used to test whether server is connected.
|
||||
* This method is used to check whether Milvus server is connected.
|
||||
*
|
||||
* @return Indicate if connection status
|
||||
*/
|
||||
@ -212,81 +212,37 @@ class Connection {
|
||||
/**
|
||||
* @brief Disconnect
|
||||
*
|
||||
* This method is used to disconnect server.
|
||||
* This method is used to disconnect from Milvus server.
|
||||
*
|
||||
* @return Indicate if disconnect is successful
|
||||
* @return Indicate if disconnect successfully
|
||||
*/
|
||||
virtual Status
|
||||
Disconnect() = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the client version
|
||||
*
|
||||
* This method is used to give the client version.
|
||||
*
|
||||
* @return Client version.
|
||||
*/
|
||||
virtual std::string
|
||||
ClientVersion() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the server version
|
||||
*
|
||||
* This method is used to give the server version.
|
||||
*
|
||||
* @return Server version.
|
||||
*/
|
||||
virtual std::string
|
||||
ServerVersion() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the server status
|
||||
*
|
||||
* This method is used to give the server status.
|
||||
*
|
||||
* @return Server status.
|
||||
*/
|
||||
virtual std::string
|
||||
ServerStatus() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get config method
|
||||
*
|
||||
* This method is used to set config.
|
||||
*
|
||||
* @param node_name, config node name.
|
||||
* @param value, config value.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
GetConfig(const std::string& node_name, std::string& value) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Set config method
|
||||
*
|
||||
* This method is used to set config.
|
||||
*
|
||||
* @param node_name, config node name.
|
||||
* @param value, config value.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
SetConfig(const std::string& node_name, const std::string& value) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Create collection method
|
||||
*
|
||||
* This method is used to create collection.
|
||||
*
|
||||
* @param param, use to provide collection information to be created.
|
||||
* @param param, used to provide collection information to be created.
|
||||
*
|
||||
* @return Indicate if collection is created successfully
|
||||
*/
|
||||
virtual Status
|
||||
CreateCollection(const Mapping& mapping, const std::string& extra_params) = 0;
|
||||
|
||||
/**
|
||||
* @brief Drop collection method
|
||||
*
|
||||
* This method is used to drop collection (and its partitions).
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
*
|
||||
* @return Indicate if collection is dropped successfully.
|
||||
*/
|
||||
virtual Status
|
||||
DropCollection(const std::string& collection_name) = 0;
|
||||
|
||||
/**
|
||||
* @brief Test collection existence method
|
||||
*
|
||||
@ -294,27 +250,116 @@ class Connection {
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
*
|
||||
* @return Indicate if collection is cexist
|
||||
* @return Indicate if the collection exists
|
||||
*/
|
||||
virtual bool
|
||||
HasCollection(const std::string& collection_name) = 0;
|
||||
|
||||
/**
|
||||
* @brief Drop collection method
|
||||
* @brief List all collections in database
|
||||
*
|
||||
* This method is used to drop collection(and its partitions).
|
||||
* This method is used to list all collections.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param collection_array, all collections in database.
|
||||
*
|
||||
* @return Indicate if collection is drop successfully.
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
DropCollection(const std::string& collection_name) = 0;
|
||||
ListCollections(std::vector<std::string>& collection_array) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get collection information
|
||||
*
|
||||
* This method is used to get collection information.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param collection_param, collection_param is given when operation is successful.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
GetCollectionInfo(const std::string& collection_name, Mapping& mapping) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get collection statistics
|
||||
*
|
||||
* This method is used to get statistics of a collection.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param collection_stats, target collection's statistics in json format
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
GetCollectionStats(const std::string& collection_name, std::string& collection_stats) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get collection entity count
|
||||
*
|
||||
* This method is used to get collection entity count.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param entity_count, total entity count in collection.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
CountEntities(const std::string& collection_name, int64_t& entity_count) = 0;
|
||||
|
||||
/**
|
||||
* @brief Create partition method
|
||||
*
|
||||
* This method is used to create collection's partition
|
||||
*
|
||||
* @param partition_param, use to provide partition information to be created.
|
||||
*
|
||||
* @return Indicate if partition is created successfully
|
||||
*/
|
||||
virtual Status
|
||||
CreatePartition(const PartitionParam& partition_param) = 0;
|
||||
|
||||
/**
|
||||
* @brief Delete partition method
|
||||
*
|
||||
* This method is used to delete collection's partition.
|
||||
*
|
||||
* @param partition_param, target partition to be deleted.
|
||||
*
|
||||
* @return Indicate if partition is delete successfully.
|
||||
*/
|
||||
virtual Status
|
||||
DropPartition(const PartitionParam& partition_param) = 0;
|
||||
|
||||
/**
|
||||
* @brief Has partition method
|
||||
*
|
||||
* This method is used to test existence of collection's partition
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param partition_tag, target partition's tag.
|
||||
*
|
||||
* @return Indicate if partition is created successfully
|
||||
*/
|
||||
virtual bool
|
||||
HasPartition(const std::string& collection_name, const std::string& partition_tag) const = 0;
|
||||
|
||||
/**
|
||||
* @brief List all partitions method
|
||||
*
|
||||
* This method is used to list all partitions(return their tags)
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param partition_tag_array, partition tag array of the collection.
|
||||
*
|
||||
* @return Indicate if this operation is successful
|
||||
*/
|
||||
virtual Status
|
||||
ListPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Create index method
|
||||
*
|
||||
* This method is used to create index for whole collection(and its partitions).
|
||||
* This method is used to create index for collection.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param field_name, target field name.
|
||||
@ -326,6 +371,19 @@ class Connection {
|
||||
virtual Status
|
||||
CreateIndex(const IndexParam& index_param) = 0;
|
||||
|
||||
/**
|
||||
* @brief Drop index method
|
||||
*
|
||||
* This method is used to drop index of collection.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Insert entity to collection
|
||||
*
|
||||
@ -361,20 +419,17 @@ class Connection {
|
||||
GetEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array, std::string& entities) = 0;
|
||||
|
||||
/**
|
||||
* @brief List entity ids from a segment
|
||||
* @brief Delete entity by id
|
||||
*
|
||||
* This method is used to get entity ids from a segment
|
||||
* Return all entity(not deleted) ids
|
||||
* This method is used to delete entity by id.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param segment_name, target segment name.
|
||||
* @param id_array, returned entity id array.
|
||||
* @param id_array, entity id array to be deleted.
|
||||
*
|
||||
* @return Indicate if the operation is succeed.
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) = 0;
|
||||
DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) = 0;
|
||||
|
||||
/**
|
||||
* @brief Search entities in a collection
|
||||
@ -407,71 +462,23 @@ class Connection {
|
||||
BooleanQueryPtr& boolean_query, const std::string& extra_params, TopKQueryResult& query_result) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get collection information
|
||||
* @brief List entity ids from a segment
|
||||
*
|
||||
* This method is used to get collection information.
|
||||
* This method is used to get entity ids from a segment
|
||||
* Return all entity(not deleted) ids
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param collection_param, collection_param is given when operation is successful.
|
||||
* @param segment_name, target segment name.
|
||||
* @param id_array, returned entity id array.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
* @return Indicate if the operation is succeed.
|
||||
*/
|
||||
virtual Status
|
||||
GetCollectionInfo(const std::string& collection_name, Mapping& mapping) = 0;
|
||||
ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get collection entity count
|
||||
*
|
||||
* This method is used to get collection entity count.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param entity_count, collection total entity count(including partitions).
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
CountEntities(const std::string& collection_name, int64_t& entity_count) = 0;
|
||||
|
||||
/**
|
||||
* @brief List all collections in database
|
||||
*
|
||||
* This method is used to list all collections.
|
||||
*
|
||||
* @param collection_array, all collections in database.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
ListCollections(std::vector<std::string>& collection_array) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get collection statistics
|
||||
*
|
||||
* This method is used to get statistics of a collection.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param collection_stats, target collection's statistics in json format
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
GetCollectionStats(const std::string& collection_name, std::string& collection_stats) = 0;
|
||||
|
||||
/**
|
||||
* @brief Delete entity by id
|
||||
*
|
||||
* This method is used to delete entity by id.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param id_array, entity id array to be deleted.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) = 0;
|
||||
|
||||
/**
|
||||
* @brief Load collection from disk to memory
|
||||
* @brief Load collection into memory
|
||||
*
|
||||
* This method is used to load collection data into memory
|
||||
*
|
||||
@ -482,82 +489,6 @@ class Connection {
|
||||
virtual Status
|
||||
LoadCollection(const std::string& collection_name) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get index information
|
||||
*
|
||||
* This method is used to get index information
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param index_param, returned index information.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
GetIndexInfo(const std::string& collection_name, IndexParam& index_param) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Drop index
|
||||
*
|
||||
* This method is used to drop index of collection(and its partitions)
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
*
|
||||
* @return Indicate if this operation is successful.
|
||||
*/
|
||||
virtual Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Create partition method
|
||||
*
|
||||
* This method is used to create collection's partition
|
||||
*
|
||||
* @param partition_param, use to provide partition information to be created.
|
||||
*
|
||||
* @return Indicate if partition is created successfully
|
||||
*/
|
||||
virtual Status
|
||||
CreatePartition(const PartitionParam& partition_param) = 0;
|
||||
|
||||
/**
|
||||
* @brief Has partition method
|
||||
*
|
||||
* This method is used to test existence of collection's partition
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param partition_tag, target partition's tag.
|
||||
*
|
||||
* @return Indicate if partition is created successfully
|
||||
*/
|
||||
virtual bool
|
||||
HasPartition(const std::string& collection_name, const std::string& partition_tag) const = 0;
|
||||
|
||||
/**
|
||||
* @brief List all partitions method
|
||||
*
|
||||
* This method is used to list all partitions(return their tags)
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param partition_tag_array, partition tag array of the collection.
|
||||
*
|
||||
* @return Indicate if this operation is successful
|
||||
*/
|
||||
virtual Status
|
||||
ListPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Delete partition method
|
||||
*
|
||||
* This method is used to delete collection's partition.
|
||||
*
|
||||
* @param partition_param, target partition to be deleted.
|
||||
*
|
||||
* @return Indicate if partition is delete successfully.
|
||||
*/
|
||||
virtual Status
|
||||
DropPartition(const PartitionParam& partition_param) = 0;
|
||||
|
||||
/**
|
||||
* @brief Flush collections insert buffer into storage
|
||||
*
|
||||
@ -581,8 +512,6 @@ class Connection {
|
||||
*/
|
||||
virtual Status
|
||||
Compact(const std::string& collection_name) = 0;
|
||||
|
||||
/*******************************New Interface**********************************/
|
||||
};
|
||||
|
||||
} // namespace milvus
|
||||
|
||||
@ -51,44 +51,58 @@ ConnectionImpl::Disconnect() {
|
||||
return client_proxy_->Disconnect();
|
||||
}
|
||||
|
||||
std::string
|
||||
ConnectionImpl::ClientVersion() const {
|
||||
return client_proxy_->ClientVersion();
|
||||
}
|
||||
|
||||
std::string
|
||||
ConnectionImpl::ServerVersion() const {
|
||||
return client_proxy_->ServerVersion();
|
||||
}
|
||||
|
||||
std::string
|
||||
ConnectionImpl::ServerStatus() const {
|
||||
return client_proxy_->ServerStatus();
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::GetConfig(const std::string& node_name, std::string& value) const {
|
||||
return client_proxy_->GetConfig(node_name, value);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::SetConfig(const std::string& node_name, const std::string& value) const {
|
||||
return client_proxy_->SetConfig(node_name, value);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::CreateCollection(const Mapping& mapping, const std::string& extra_params) {
|
||||
return client_proxy_->CreateCollection(mapping, extra_params);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::DropCollection(const std::string& collection_name) {
|
||||
return client_proxy_->DropCollection(collection_name);
|
||||
}
|
||||
|
||||
bool
|
||||
ConnectionImpl::HasCollection(const std::string& collection_name) {
|
||||
return client_proxy_->HasCollection(collection_name);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::DropCollection(const std::string& collection_name) {
|
||||
return client_proxy_->DropCollection(collection_name);
|
||||
ConnectionImpl::ListCollections(std::vector<std::string>& collection_array) {
|
||||
return client_proxy_->ListCollections(collection_array);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::GetCollectionInfo(const std::string& collection_name, Mapping& mapping) {
|
||||
return client_proxy_->GetCollectionInfo(collection_name, mapping);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::GetCollectionStats(const std::string& collection_name, std::string& collection_stats) {
|
||||
return client_proxy_->GetCollectionStats(collection_name, collection_stats);
|
||||
}
|
||||
Status
|
||||
ConnectionImpl::CountEntities(const std::string& collection_name, int64_t& row_count) {
|
||||
return client_proxy_->CountEntities(collection_name, row_count);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::CreatePartition(const PartitionParam& partition_param) {
|
||||
return client_proxy_->CreatePartition(partition_param);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::DropPartition(const PartitionParam& partition_param) {
|
||||
return client_proxy_->DropPartition(partition_param);
|
||||
}
|
||||
|
||||
bool
|
||||
ConnectionImpl::HasPartition(const std::string& collection_name, const std::string& partition_tag) const {
|
||||
return client_proxy_->HasPartition(collection_name, partition_tag);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::ListPartitions(const std::string& collection_name, PartitionTagList& partition_array) const {
|
||||
return client_proxy_->ListPartitions(collection_name, partition_array);
|
||||
}
|
||||
|
||||
Status
|
||||
@ -96,6 +110,12 @@ ConnectionImpl::CreateIndex(const IndexParam& index_param) {
|
||||
return client_proxy_->CreateIndex(index_param);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const {
|
||||
return client_proxy_->DropIndex(collection_name, field_name, index_name);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::Insert(const std::string& collection_name, const std::string& partition_tag,
|
||||
const FieldValue& entity_array, std::vector<int64_t>& id_array) {
|
||||
@ -109,9 +129,8 @@ ConnectionImpl::GetEntityByID(const std::string& collection_name, const std::vec
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) {
|
||||
return client_proxy_->ListIDInSegment(collection_name, segment_name, id_array);
|
||||
ConnectionImpl::DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) {
|
||||
return client_proxy_->DeleteEntityByID(collection_name, id_array);
|
||||
}
|
||||
|
||||
Status
|
||||
@ -127,28 +146,9 @@ ConnectionImpl::SearchPB(const std::string& collection_name, const std::vector<s
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::GetCollectionInfo(const std::string& collection_name, Mapping& mapping) {
|
||||
return client_proxy_->GetCollectionInfo(collection_name, mapping);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::CountEntities(const std::string& collection_name, int64_t& row_count) {
|
||||
return client_proxy_->CountEntities(collection_name, row_count);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::ListCollections(std::vector<std::string>& collection_array) {
|
||||
return client_proxy_->ListCollections(collection_array);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::GetCollectionStats(const std::string& collection_name, std::string& collection_stats) {
|
||||
return client_proxy_->GetCollectionStats(collection_name, collection_stats);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) {
|
||||
return client_proxy_->DeleteEntityByID(collection_name, id_array);
|
||||
ConnectionImpl::ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) {
|
||||
return client_proxy_->ListIDInSegment(collection_name, segment_name, id_array);
|
||||
}
|
||||
|
||||
Status
|
||||
@ -156,37 +156,6 @@ ConnectionImpl::LoadCollection(const std::string& collection_name) const {
|
||||
return client_proxy_->LoadCollection(collection_name);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::GetIndexInfo(const std::string& collection_name, IndexParam& index_param) const {
|
||||
return client_proxy_->GetIndexInfo(collection_name, index_param);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const {
|
||||
return client_proxy_->DropIndex(collection_name, field_name, index_name);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::CreatePartition(const PartitionParam& partition_param) {
|
||||
return client_proxy_->CreatePartition(partition_param);
|
||||
}
|
||||
|
||||
bool
|
||||
ConnectionImpl::HasPartition(const std::string& collection_name, const std::string& partition_tag) const {
|
||||
return client_proxy_->HasPartition(collection_name, partition_tag);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::ListPartitions(const std::string& collection_name, PartitionTagList& partition_array) const {
|
||||
return client_proxy_->ListPartitions(collection_name, partition_array);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::DropPartition(const PartitionParam& partition_param) {
|
||||
return client_proxy_->DropPartition(partition_param);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::Flush(const std::vector<std::string>& collection_name_array) {
|
||||
return client_proxy_->Flush(collection_name_array);
|
||||
|
||||
@ -37,33 +37,61 @@ class ConnectionImpl : public Connection {
|
||||
Status
|
||||
Disconnect() override;
|
||||
|
||||
std::string
|
||||
ClientVersion() const override;
|
||||
|
||||
std::string
|
||||
ServerVersion() const override;
|
||||
|
||||
std::string
|
||||
ServerStatus() const override;
|
||||
|
||||
Status
|
||||
GetConfig(const std::string& node_name, std::string& value) const override;
|
||||
|
||||
Status
|
||||
SetConfig(const std::string& node_name, const std::string& value) const override;
|
||||
// std::string
|
||||
// ClientVersion() const override;
|
||||
//
|
||||
// std::string
|
||||
// ServerVersion() const override;
|
||||
//
|
||||
// std::string
|
||||
// ServerStatus() const override;
|
||||
//
|
||||
// Status
|
||||
// GetConfig(const std::string& node_name, std::string& value) const override;
|
||||
//
|
||||
// Status
|
||||
// SetConfig(const std::string& node_name, const std::string& value) const override;
|
||||
|
||||
Status
|
||||
CreateCollection(const Mapping& mapping, const std::string& extra_params) override;
|
||||
|
||||
Status
|
||||
DropCollection(const std::string& collection_name) override;
|
||||
|
||||
bool
|
||||
HasCollection(const std::string& collection_name) override;
|
||||
|
||||
Status
|
||||
DropCollection(const std::string& collection_name) override;
|
||||
ListCollections(std::vector<std::string>& collection_array) override;
|
||||
|
||||
Status
|
||||
GetCollectionInfo(const std::string& collection_name, Mapping& mapping) override;
|
||||
|
||||
Status
|
||||
GetCollectionStats(const std::string& collection_name, std::string& collection_stats) override;
|
||||
|
||||
Status
|
||||
CountEntities(const std::string& collection_name, int64_t& entity_count) override;
|
||||
|
||||
Status
|
||||
CreatePartition(const PartitionParam& partition_param) override;
|
||||
|
||||
Status
|
||||
DropPartition(const PartitionParam& partition_param) override;
|
||||
|
||||
bool
|
||||
HasPartition(const std::string& collection_name, const std::string& partition_tag) const override;
|
||||
|
||||
Status
|
||||
ListPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const override;
|
||||
|
||||
Status
|
||||
CreateIndex(const IndexParam& index_param) override;
|
||||
|
||||
Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const override;
|
||||
|
||||
Status
|
||||
Insert(const std::string& collection_name, const std::string& partition_tag, const FieldValue& entity_array,
|
||||
std::vector<int64_t>& id_array) override;
|
||||
@ -73,8 +101,7 @@ class ConnectionImpl : public Connection {
|
||||
std::string& entities) override;
|
||||
|
||||
Status
|
||||
ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) override;
|
||||
DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) override;
|
||||
|
||||
Status
|
||||
Search(const std::string& collection_name, const std::vector<std::string>& partition_list, const std::string& dsl,
|
||||
@ -85,42 +112,12 @@ class ConnectionImpl : public Connection {
|
||||
BooleanQueryPtr& boolean_query, const std::string& extra_params, TopKQueryResult& query_result) override;
|
||||
|
||||
Status
|
||||
GetCollectionInfo(const std::string& collection_name, Mapping& mapping) override;
|
||||
|
||||
Status
|
||||
CountEntities(const std::string& collection_name, int64_t& entity_count) override;
|
||||
|
||||
Status
|
||||
ListCollections(std::vector<std::string>& collection_array) override;
|
||||
|
||||
Status
|
||||
GetCollectionStats(const std::string& collection_name, std::string& collection_stats) override;
|
||||
|
||||
Status
|
||||
DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) override;
|
||||
ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
||||
std::vector<int64_t>& id_array) override;
|
||||
|
||||
Status
|
||||
LoadCollection(const std::string& collection_name) const override;
|
||||
|
||||
Status
|
||||
GetIndexInfo(const std::string& collection_name, IndexParam& index_param) const override;
|
||||
|
||||
Status
|
||||
DropIndex(const std::string& collection_name, const std::string& field_name,
|
||||
const std::string& index_name) const override;
|
||||
|
||||
Status
|
||||
CreatePartition(const PartitionParam& partition_param) override;
|
||||
|
||||
bool
|
||||
HasPartition(const std::string& collection_name, const std::string& partition_tag) const override;
|
||||
|
||||
Status
|
||||
ListPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const override;
|
||||
|
||||
Status
|
||||
DropPartition(const PartitionParam& partition_param) override;
|
||||
|
||||
Status
|
||||
Flush(const std::vector<std::string>& collection_name_array) override;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user