Skip to content

Commit

Permalink
fix: fix linting errors
Browse files Browse the repository at this point in the history
Signed-off-by: Ruichen Bao <ruichen.bao@zju.edu.cn>
  • Loading branch information
brcarry committed Jan 20, 2025
1 parent a88cdf9 commit d3d3668
Show file tree
Hide file tree
Showing 29 changed files with 638 additions and 180 deletions.
131 changes: 79 additions & 52 deletions src/impl/MilvusClientImplV2.cpp

Large diffs are not rendered by default.

46 changes: 28 additions & 18 deletions src/impl/MilvusClientImplV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ class MilvusClientImplV2 : public MilvusClientV2 {
ShowCollections(const std::vector<std::string>& collection_names, CollectionsInfo& collections_info) final;

Status
AlterCollectionProperties(const std::string& collection_name, const std::vector<std::pair<std::string, std::string>>& properties, int timeout) final;
AlterCollectionProperties(const std::string& collection_name,
const std::vector<std::pair<std::string, std::string>>& properties, int timeout) final;

Status
DropCollectionProperties(const std::string& collection_name, const std::vector<std::string>& delete_keys, int timeout) final;
DropCollectionProperties(const std::string& collection_name, const std::vector<std::string>& delete_keys,
int timeout) final;

Status
AlterCollectionField(const std::string& collection_name, const std::string& field_name,
Expand Down Expand Up @@ -111,8 +113,8 @@ class MilvusClientImplV2 : public MilvusClientV2 {
PartitionsInfo& partitions_info) final;

Status
GetLoadState(const std::string& collection_name, LoadState& state,
const std::string& partition_name, int timeout) final;
GetLoadState(const std::string& collection_name, LoadState& state, const std::string& partition_name,
int timeout) final;

Status
RefreshLoad(const std::string& collection_name, int timeout) final;
Expand All @@ -133,7 +135,8 @@ class MilvusClientImplV2 : public MilvusClientV2 {
DescribeAlias(const std::string& alias, AliasDesc& alias_desc, int timeout) final;

Status
CreateDatabase(const std::string& db_name, const std::vector<std::pair<std::string, std::string>>& properties, int timeout) final;
CreateDatabase(const std::string& db_name, const std::vector<std::pair<std::string, std::string>>& properties,
int timeout) final;

Status
DropDatabase(const std::string& db_name, int timeout) final;
Expand All @@ -145,7 +148,8 @@ class MilvusClientImplV2 : public MilvusClientV2 {
DescribeDatabase(const std::string& db_name, DatabaseDesc& database_desc, int timeout) final;

Status
AlterDatabaseProperties(const std::string& db_name, const std::vector<std::pair<std::string, std::string>>& properties, int timeout) final;
AlterDatabaseProperties(const std::string& db_name,
const std::vector<std::pair<std::string, std::string>>& properties, int timeout) final;

Status
DropDatabaseProperties(const std::string& db_name, const std::vector<std::string>& delete_keys, int timeout) final;
Expand All @@ -168,7 +172,8 @@ class MilvusClientImplV2 : public MilvusClientV2 {
DropIndex(const std::string& collection_name, const std::string& field_name) final;

Status
ListIndexes(const std::string& collection_name, std::vector<std::string>& results, std::vector<std::string> field_names) final;
ListIndexes(const std::string& collection_name, std::vector<std::string>& results,
std::vector<std::string> field_names) final;

Status
Insert(const std::string& collection_name, const std::string& partition_name,
Expand All @@ -177,7 +182,7 @@ class MilvusClientImplV2 : public MilvusClientV2 {
Status
Upsert(const std::string& collection_name, const std::string& partition_name,
const std::vector<FieldDataPtr>& fields, DmlResults& results) final;

Status
Delete(const std::string& collection_name, const std::string& partition_name, const std::string& expression,
DmlResults& results) final;
Expand All @@ -201,7 +206,8 @@ class MilvusClientImplV2 : public MilvusClientV2 {
CreateUser(const std::string& username, const std::string& password, int timeout) final;

Status
UpdatePassword(const std::string& username, const std::string& old_password, const std::string& new_password, bool reset_connection, int timeout) final;
UpdatePassword(const std::string& username, const std::string& old_password, const std::string& new_password,
bool reset_connection, int timeout) final;

Status
DropUser(const std::string& username, int timeout) final;
Expand All @@ -221,7 +227,7 @@ class MilvusClientImplV2 : public MilvusClientV2 {
Status
DescribeRole(const std::string& role_name, RoleDesc& role_desc, int timeout) final;

Status
Status
ListRoles(std::vector<std::string>& roles, int timeout) final;

Status
Expand All @@ -245,15 +251,18 @@ class MilvusClientImplV2 : public MilvusClientV2 {

Status
AddPrivilegesToGroup(const std::string& group_name, const std::vector<std::string>& privileges, int timeout) final;

Status
RemovePrivilegesFromGroup(const std::string& group_name, const std::vector<std::string>& privileges, int timeout) final;
RemovePrivilegesFromGroup(const std::string& group_name, const std::vector<std::string>& privileges,
int timeout) final;

Status
GrantPrivilegeV2(const std::string& role_name, const std::string& privilege, const std::string& collection_name, const std::string& db_name, int timeout) final;
GrantPrivilegeV2(const std::string& role_name, const std::string& privilege, const std::string& collection_name,
const std::string& db_name, int timeout) final;

Status
RevokePrivilegeV2(const std::string& role_name, const std::string& privilege, const std::string& collection_name, const std::string& db_name, int timeout) final;
RevokePrivilegeV2(const std::string& role_name, const std::string& privilege, const std::string& collection_name,
const std::string& db_name, int timeout) final;

Status
CreateResourceGroup(const std::string& resource_group, const ResourceGroupConfig& config, int timeout) final;
Expand All @@ -262,7 +271,8 @@ class MilvusClientImplV2 : public MilvusClientV2 {
DropResourceGroup(const std::string& resource_group, int timeout) final;

Status
DescribeResourceGroup(const std::string& resource_group, ResourceGroupDesc& resource_group_desc, int timeout = 0) final;
DescribeResourceGroup(const std::string& resource_group, ResourceGroupDesc& resource_group_desc,
int timeout = 0) final;

Status
ListResourceGroups(std::vector<std::string>& resource_groups, int timeout) final;
Expand Down Expand Up @@ -417,7 +427,7 @@ class MilvusClientImplV2 : public MilvusClientV2 {
}


const FieldSchema*
const FieldSchema*
ExtractPrimaryField(const CollectionSchema& schema) {
const auto& fields = schema.Fields();
for (const auto& field : fields) {
Expand All @@ -436,7 +446,7 @@ class MilvusClientImplV2 : public MilvusClientV2 {
}

std::string expr = primary_field->Name() + " in [";

if (primary_field->FieldDataType() == DataType::VARCHAR) {
for (size_t i = 0; i < pks.size(); i++) {
if (i > 0) {
Expand All @@ -452,7 +462,7 @@ class MilvusClientImplV2 : public MilvusClientV2 {
expr += std::to_string(pks[i]);
}
}

expr += "]";
return expr;
}
Expand Down
42 changes: 26 additions & 16 deletions src/impl/MilvusConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ MilvusConnection::AlterCollection(const proto::milvus::AlterCollectionRequest& r
}

Status
MilvusConnection::AlterCollectionField(const proto::milvus::AlterCollectionFieldRequest& request, proto::common::Status& response,
const GrpcContextOptions& options) {
MilvusConnection::AlterCollectionField(const proto::milvus::AlterCollectionFieldRequest& request,
proto::common::Status& response, const GrpcContextOptions& options) {
return grpcCall("AlterCollectionField", &Stub::AlterCollectionField, request, response, options);
}

Expand Down Expand Up @@ -255,14 +255,14 @@ MilvusConnection::AlterAlias(const proto::milvus::AlterAliasRequest& request, pr
}

Status
MilvusConnection::ListAliases(const proto::milvus::ListAliasesRequest& request, proto::milvus::ListAliasesResponse& response,
const GrpcContextOptions& options) {
MilvusConnection::ListAliases(const proto::milvus::ListAliasesRequest& request,
proto::milvus::ListAliasesResponse& response, const GrpcContextOptions& options) {
return grpcCall("ListAliases", &Stub::ListAliases, request, response, options);
}

Status
MilvusConnection::DescribeAlias(const proto::milvus::DescribeAliasRequest& request, proto::milvus::DescribeAliasResponse& response,
const GrpcContextOptions& options) {
MilvusConnection::DescribeAlias(const proto::milvus::DescribeAliasRequest& request,
proto::milvus::DescribeAliasResponse& response, const GrpcContextOptions& options) {
return grpcCall("DescribeAlias", &Stub::DescribeAlias, request, response, options);
}

Expand All @@ -279,13 +279,14 @@ MilvusConnection::DropDatabase(const proto::milvus::DropDatabaseRequest& request
}

Status
MilvusConnection::ListDatabases(const proto::milvus::ListDatabasesRequest& request, proto::milvus::ListDatabasesResponse& response,
const GrpcContextOptions& options) {
MilvusConnection::ListDatabases(const proto::milvus::ListDatabasesRequest& request,
proto::milvus::ListDatabasesResponse& response, const GrpcContextOptions& options) {
return grpcCall("ListDatabases", &Stub::ListDatabases, request, response, options);
}

Status
MilvusConnection::DescribeDatabase(const proto::milvus::DescribeDatabaseRequest& request, proto::milvus::DescribeDatabaseResponse& response,
MilvusConnection::DescribeDatabase(const proto::milvus::DescribeDatabaseRequest& request,
proto::milvus::DescribeDatabaseResponse& response,
const GrpcContextOptions& options) {
return grpcCall("DescribeDatabase", &Stub::DescribeDatabase, request, response, options);
}
Expand Down Expand Up @@ -502,7 +503,8 @@ MilvusConnection::DropPrivilegeGroup(const proto::milvus::DropPrivilegeGroupRequ

Status
MilvusConnection::ListPrivilegeGroups(const proto::milvus::ListPrivilegeGroupsRequest& request,
proto::milvus::ListPrivilegeGroupsResponse& response, const GrpcContextOptions& options) {
proto::milvus::ListPrivilegeGroupsResponse& response,
const GrpcContextOptions& options) {
return grpcCall("ListPrivilegeGroups", &Stub::ListPrivilegeGroups, request, response, options);
}

Expand All @@ -513,32 +515,40 @@ MilvusConnection::OperatePrivilegeGroup(const proto::milvus::OperatePrivilegeGro
}

Status
MilvusConnection::OperatePrivilegeV2(const proto::milvus::OperatePrivilegeV2Request& request, proto::common::Status& response, const GrpcContextOptions& options) {
MilvusConnection::OperatePrivilegeV2(const proto::milvus::OperatePrivilegeV2Request& request,
proto::common::Status& response, const GrpcContextOptions& options) {
return grpcCall("OperatePrivilegeV2", &Stub::OperatePrivilegeV2, request, response, options);
}

Status
MilvusConnection::CreateResourceGroup(const proto::milvus::CreateResourceGroupRequest& request, proto::common::Status& response, const GrpcContextOptions& options) {
MilvusConnection::CreateResourceGroup(const proto::milvus::CreateResourceGroupRequest& request,
proto::common::Status& response, const GrpcContextOptions& options) {
return grpcCall("CreateResourceGroup", &Stub::CreateResourceGroup, request, response, options);
}

Status
MilvusConnection::DropResourceGroup(const proto::milvus::DropResourceGroupRequest& request, proto::common::Status& response, const GrpcContextOptions& options) {
MilvusConnection::DropResourceGroup(const proto::milvus::DropResourceGroupRequest& request,
proto::common::Status& response, const GrpcContextOptions& options) {
return grpcCall("DropResourceGroup", &Stub::DropResourceGroup, request, response, options);
}

Status
MilvusConnection::DescribeResourceGroup(const proto::milvus::DescribeResourceGroupRequest& request, proto::milvus::DescribeResourceGroupResponse& response, const GrpcContextOptions& options) {
MilvusConnection::DescribeResourceGroup(const proto::milvus::DescribeResourceGroupRequest& request,
proto::milvus::DescribeResourceGroupResponse& response,
const GrpcContextOptions& options) {
return grpcCall("DescribeResourceGroup", &Stub::DescribeResourceGroup, request, response, options);
}

Status
MilvusConnection::ListResourceGroups(const proto::milvus::ListResourceGroupsRequest& request, proto::milvus::ListResourceGroupsResponse& response, const GrpcContextOptions& options) {
MilvusConnection::ListResourceGroups(const proto::milvus::ListResourceGroupsRequest& request,
proto::milvus::ListResourceGroupsResponse& response,
const GrpcContextOptions& options) {
return grpcCall("ListResourceGroups", &Stub::ListResourceGroups, request, response, options);
}

Status
MilvusConnection::UpdateResourceGroups(const proto::milvus::UpdateResourceGroupsRequest& request, proto::common::Status& response, const GrpcContextOptions& options) {
MilvusConnection::UpdateResourceGroups(const proto::milvus::UpdateResourceGroupsRequest& request,
proto::common::Status& response, const GrpcContextOptions& options) {
return grpcCall("UpdateResourceGroups", &Stub::UpdateResourceGroups, request, response, options);
}

Expand Down
47 changes: 27 additions & 20 deletions src/impl/MilvusConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ class MilvusConnection {
const GrpcContextOptions& options);

Status
DescribeDatabase(const proto::milvus::DescribeDatabaseRequest& request, proto::milvus::DescribeDatabaseResponse& response,
const GrpcContextOptions& options);
DescribeDatabase(const proto::milvus::DescribeDatabaseRequest& request,
proto::milvus::DescribeDatabaseResponse& response, const GrpcContextOptions& options);

Status
AlterDatabase(const proto::milvus::AlterDatabaseRequest& request, proto::common::Status& response,
Expand Down Expand Up @@ -314,69 +314,76 @@ class MilvusConnection {
const GrpcContextOptions& options);

Status
ListPrivilegeGroups(const proto::milvus::ListPrivilegeGroupsRequest& request, proto::milvus::ListPrivilegeGroupsResponse& response,
const GrpcContextOptions& options);
ListPrivilegeGroups(const proto::milvus::ListPrivilegeGroupsRequest& request,
proto::milvus::ListPrivilegeGroupsResponse& response, const GrpcContextOptions& options);

Status
OperatePrivilegeGroup(const proto::milvus::OperatePrivilegeGroupRequest& request, proto::common::Status& response, const GrpcContextOptions& options);
OperatePrivilegeGroup(const proto::milvus::OperatePrivilegeGroupRequest& request, proto::common::Status& response,
const GrpcContextOptions& options);

Status
OperatePrivilegeV2(const proto::milvus::OperatePrivilegeV2Request& request, proto::common::Status& response, const GrpcContextOptions& options);
OperatePrivilegeV2(const proto::milvus::OperatePrivilegeV2Request& request, proto::common::Status& response,
const GrpcContextOptions& options);

Status
CreateResourceGroup(const proto::milvus::CreateResourceGroupRequest& request, proto::common::Status& response, const GrpcContextOptions& options);
CreateResourceGroup(const proto::milvus::CreateResourceGroupRequest& request, proto::common::Status& response,
const GrpcContextOptions& options);

Status
DropResourceGroup(const proto::milvus::DropResourceGroupRequest& request, proto::common::Status& response, const GrpcContextOptions& options);
DropResourceGroup(const proto::milvus::DropResourceGroupRequest& request, proto::common::Status& response,
const GrpcContextOptions& options);

Status
DescribeResourceGroup(const proto::milvus::DescribeResourceGroupRequest& request, proto::milvus::DescribeResourceGroupResponse& response,const GrpcContextOptions& options);
DescribeResourceGroup(const proto::milvus::DescribeResourceGroupRequest& request,
proto::milvus::DescribeResourceGroupResponse& response, const GrpcContextOptions& options);

Status
ListResourceGroups(const proto::milvus::ListResourceGroupsRequest& request, proto::milvus::ListResourceGroupsResponse& response, const GrpcContextOptions& options);
ListResourceGroups(const proto::milvus::ListResourceGroupsRequest& request,
proto::milvus::ListResourceGroupsResponse& response, const GrpcContextOptions& options);

Status
UpdateResourceGroups(const proto::milvus::UpdateResourceGroupsRequest& request, proto::common::Status& response, const GrpcContextOptions& options);
UpdateResourceGroups(const proto::milvus::UpdateResourceGroupsRequest& request, proto::common::Status& response,
const GrpcContextOptions& options);

void
SetHeader(const std::string& key, const std::string& value);

void
RemoveHeader(const std::string& key);

std::string
GetHeader(const std::string& key) const;

std::vector<std::pair<std::string, std::string>>
GetAllHeaders() const;

const
std::string& Host() const;

void
SetHost(const std::string& host);

uint16_t
Port() const;

void
SetPort(uint16_t port);

const std::string&
const std::string&
User() const;

void
SetUser(const std::string& user);

const std::string&
Password() const;

void
SetPassword(const std::string& password);

const std::string&
Token() const;

void
SetToken(const std::string& token);

Expand Down
22 changes: 20 additions & 2 deletions src/impl/MilvusInterceptor.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Licensed to the LF AI & Data foundation 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 "MilvusInterceptor.h"

HeaderAdderInterceptor::HeaderAdderInterceptor(const std::vector<std::pair<std::string, std::string>>& headers)
Expand All @@ -13,7 +29,8 @@ void HeaderAdderInterceptor::Intercept(grpc::experimental::InterceptorBatchMetho
methods->Proceed();
}

HeaderAdderInterceptorFactory::HeaderAdderInterceptorFactory(const std::vector<std::pair<std::string, std::string>>& headers)
HeaderAdderInterceptorFactory::HeaderAdderInterceptorFactory(
const std::vector<std::pair<std::string, std::string>>& headers)
: headers_(headers) {}

grpc::experimental::Interceptor* HeaderAdderInterceptorFactory::CreateClientInterceptor(
Expand All @@ -30,5 +47,6 @@ std::shared_ptr<grpc::Channel> CreateChannelWithHeaderInterceptor(
std::vector<std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> interceptor_creators;
interceptor_creators.push_back(std::make_unique<HeaderAdderInterceptorFactory>(headers));

return grpc::experimental::CreateCustomChannelWithInterceptors(target, creds, args, std::move(interceptor_creators));
return grpc::experimental::CreateCustomChannelWithInterceptors(target, creds, args,
std::move(interceptor_creators));
}
Loading

0 comments on commit d3d3668

Please sign in to comment.