mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
* #1910 C++ SDK GetIDsInSegment could not work for large dataset (#1911) Signed-off-by: groot <yihua.mo@zilliz.com> * #1903 Fix invalid annoy result (#1912) Signed-off-by: shengjun.li <shengjun.li@zilliz.com> * #1914: Partition max size should be 4096 (#1915) Signed-off-by: jinhai <hai.jin@zilliz.com> * add log (#1913) * add log Signed-off-by: groot <yihua.mo@zilliz.com> * add log Signed-off-by: groot <yihua.mo@zilliz.com> * fix ut Signed-off-by: groot <yihua.mo@zilliz.com> * partition limit 4096 Signed-off-by: groot <yihua.mo@zilliz.com> * fix py test Signed-off-by: groot <yihua.mo@zilliz.com> * update server version (#1916) Signed-off-by: zw <zw@zilliz.com> * Update to 0.8.0 (#1918) * Create new branch 0.8.0 and change preload_table to preload_collection Signed-off-by: jinhai <hai.jin@zilliz.com> * Fix format Signed-off-by: JinHai-CN <hai.jin@zilliz.com> * Update CHANGELOG Signed-off-by: jinhai <hai.jin@zilliz.com> * Update CHANGELOG Signed-off-by: jinhai <hai.jin@zilliz.com> * update helm version Signed-off-by: zw <zw@zilliz.com> * Update CHANGELOG Signed-off-by: jinhai <hai.jin@zilliz.com> Co-authored-by: zw <zw@zilliz.com> * fix issue 1901 (#1920) * fix issue 1901 Signed-off-by: cmli <chengming.li@zilliz.com> * update change log Signed-off-by: cmli <chengming.li@zilliz.com> Co-authored-by: cmli <chengming.li@zilliz.com> * #1900 (#1923) * add log Signed-off-by: yhmo <yihua.mo@zilliz.com> * fix #1900 Signed-off-by: groot <yihua.mo@zilliz.com> * Upgrade mishards to 0.8.0 (#1933) * update grpc server of milvus & rename table name to collection Signed-off-by: Yhz <yinghao.zou@zilliz.com> * update changlog Signed-off-by: Yhz <yinghao.zou@zilliz.com> * [skip ci] Skip CI Signed-off-by: Yhz <yinghao.zou@zilliz.com> * [skip ci] Update changlog Signed-off-by: Yhz <yinghao.zou@zilliz.com> * Caiyd 1883 fix rw (#1926) * #1883 use DiskIO Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * fix logic error Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update changelog Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * retry CI Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * Update CHANGELOG Signed-off-by: JinHai-CN <hai.jin@zilliz.com> * update changelog Signed-off-by: yudong.cai <yudong.cai@zilliz.com> Co-authored-by: JinHai-CN <hai.jin@zilliz.com> * #1928 Too many data and uid copies when loading files (#1931) Signed-off-by: shengjun.li <shengjun.li@zilliz.com> Co-authored-by: Jin Hai <hai.jin@zilliz.com> * Update mishards configure files (#1938) * Update web readme Signed-off-by: Yhz <yinghao.zou@zilliz.com> * [skip ci] update configure files Signed-off-by: Yhz <yinghao.zou@zilliz.com> * [skip ci] rename table to collection Signed-off-by: Yhz <yinghao.zou@zilliz.com> * Update test.groovy Signed-off-by: jinhai <hai.jin@zilliz.com> * Update test.groovy Signed-off-by: jinhai <hai.jin@zilliz.com> * Fix lint Signed-off-by: JinHai-CN <hai.jin@zilliz.com> * Fix compiling error Signed-off-by: jinhai <hai.jin@zilliz.com> Co-authored-by: groot <yhmo@zeronedata.com> Co-authored-by: shengjun.li <49774184+shengjun1985@users.noreply.github.com> Co-authored-by: del-zhenwu <56623710+del-zhenwu@users.noreply.github.com> Co-authored-by: zw <zw@zilliz.com> Co-authored-by: op-hunter <ophunter52@gmail.com> Co-authored-by: cmli <chengming.li@zilliz.com> Co-authored-by: BossZou <40255591+BossZou@users.noreply.github.com> Co-authored-by: Cai Yudong <yudong.cai@zilliz.com>
113 lines
4.6 KiB
C++
113 lines
4.6 KiB
C++
// 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/CreatePartitionRequest.h"
|
|
#include "server/DBWrapper.h"
|
|
#include "utils/Log.h"
|
|
#include "utils/TimeRecorder.h"
|
|
#include "utils/ValidationUtil.h"
|
|
|
|
#include <fiu-local.h>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace milvus {
|
|
namespace server {
|
|
|
|
constexpr uint64_t MAX_PARTITION_LIMIT = 4096;
|
|
|
|
CreatePartitionRequest::CreatePartitionRequest(const std::shared_ptr<milvus::server::Context>& context,
|
|
const std::string& collection_name, const std::string& tag)
|
|
: BaseRequest(context, BaseRequest::kCreatePartition), collection_name_(collection_name), tag_(tag) {
|
|
}
|
|
|
|
BaseRequestPtr
|
|
CreatePartitionRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
|
|
const std::string& collection_name, const std::string& tag) {
|
|
return std::shared_ptr<BaseRequest>(new CreatePartitionRequest(context, collection_name, tag));
|
|
}
|
|
|
|
Status
|
|
CreatePartitionRequest::OnExecute() {
|
|
std::string hdr = "CreatePartitionRequest(collection=" + collection_name_ + ", partition_tag=" + tag_ + ")";
|
|
TimeRecorderAuto rc(hdr);
|
|
|
|
try {
|
|
// step 1: check arguments
|
|
auto status = ValidationUtil::ValidateCollectionName(collection_name_);
|
|
fiu_do_on("CreatePartitionRequest.OnExecute.invalid_collection_name",
|
|
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
|
if (!status.ok()) {
|
|
return status;
|
|
}
|
|
|
|
if (tag_ == milvus::engine::DEFAULT_PARTITON_TAG) {
|
|
return Status(SERVER_INVALID_PARTITION_TAG, "'_default' is built-in partition tag");
|
|
}
|
|
|
|
status = ValidationUtil::ValidatePartitionTags({tag_});
|
|
fiu_do_on("CreatePartitionRequest.OnExecute.invalid_partition_name",
|
|
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
|
if (!status.ok()) {
|
|
return status;
|
|
}
|
|
|
|
// only process root collection, ignore partition collection
|
|
engine::meta::CollectionSchema collection_schema;
|
|
collection_schema.collection_id_ = collection_name_;
|
|
status = DBWrapper::DB()->DescribeCollection(collection_schema);
|
|
fiu_do_on("CreatePartitionRequest.OnExecute.invalid_partition_tags",
|
|
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;
|
|
}
|
|
} else {
|
|
if (!collection_schema.owner_collection_.empty()) {
|
|
return Status(SERVER_INVALID_COLLECTION_NAME, CollectionNotExistMsg(collection_name_));
|
|
}
|
|
}
|
|
|
|
// check partition total count
|
|
std::vector<engine::meta::CollectionSchema> schema_array;
|
|
status = DBWrapper::DB()->ShowPartitions(collection_name_, schema_array);
|
|
if (schema_array.size() >= MAX_PARTITION_LIMIT) {
|
|
return Status(SERVER_UNSUPPORTED_ERROR, "The number of partitions exceeds the upper limit(4096)");
|
|
}
|
|
|
|
rc.RecordSection("check validation");
|
|
|
|
// step 2: create partition
|
|
status = DBWrapper::DB()->CreatePartition(collection_name_, "", tag_);
|
|
fiu_do_on("CreatePartitionRequest.OnExecute.db_already_exist", status = Status(milvus::DB_ALREADY_EXIST, ""));
|
|
fiu_do_on("CreatePartitionRequest.OnExecute.create_partition_fail",
|
|
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
|
fiu_do_on("CreatePartitionRequest.OnExecute.throw_std_exception", throw std::exception());
|
|
if (!status.ok()) {
|
|
// partition could exist
|
|
if (status.code() == DB_ALREADY_EXIST) {
|
|
return Status(SERVER_INVALID_COLLECTION_NAME, status.message());
|
|
}
|
|
return status;
|
|
}
|
|
} catch (std::exception& ex) {
|
|
return Status(SERVER_UNEXPECTED_ERROR, ex.what());
|
|
}
|
|
|
|
return Status::OK();
|
|
}
|
|
|
|
} // namespace server
|
|
} // namespace milvus
|