Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,33 @@ public DescribeReplicasResp describeReplicas(DescribeReplicasReq request) {
return rpcUtils.retry(() -> collectionService.describeReplicas(this.getRpcStub(), request));
}

/**
* Add a function to collection.
*
* @param request add function request
*/
public void addCollectionFunction(AddCollectionFunctionReq request) {
rpcUtils.retry(() -> collectionService.addCollectionFunction(this.getRpcStub(), request));
}

/**
* Alter a function of collection.
*
* @param request alter function request
*/
public void alterCollectionFunction(AlterCollectionFunctionReq request) {
rpcUtils.retry(() -> collectionService.alterCollectionFunction(this.getRpcStub(), request));
}

/**
* Drop a function of collection.
*
* @param request drop function request
*/
public void dropCollectionFunction(DropCollectionFunctionReq request) {
rpcUtils.retry(() -> collectionService.dropCollectionFunction(this.getRpcStub(), request));
}

/////////////////////////////////////////////////////////////////////////////////////////////
// Index Operations
/////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,70 @@ public DescribeReplicasResp describeReplicas(MilvusServiceGrpc.MilvusServiceBloc
.build();
}

public Void addCollectionFunction(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub,
AddCollectionFunctionReq request) {
if (request.getFunction() == null) {
throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Function cannot be null.");
}

String dbName = request.getDatabaseName();
String collectionName = request.getCollectionName();
String title = String.format("Add function to collection: '%s' in database: '%s'", collectionName, dbName);
AddCollectionFunctionRequest.Builder builder = AddCollectionFunctionRequest.newBuilder()
.setCollectionName(collectionName)
.setFunctionSchema(SchemaUtils.convertToGrpcFunction(request.getFunction()));
if (StringUtils.isNotEmpty(dbName)) {
builder.setDbName(dbName);
}
Status status = blockingStub.addCollectionFunction(builder.build());
rpcUtils.handleResponse(title, status);

return null;
}

public Void alterCollectionFunction(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub,
AlterCollectionFunctionReq request) {
if (request.getFunction() == null) {
throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Function cannot be null.");
}

String dbName = request.getDatabaseName();
String collectionName = request.getCollectionName();
String title = String.format("Alter function of collection: '%s' in database: '%s'", collectionName, dbName);
AlterCollectionFunctionRequest.Builder builder = AlterCollectionFunctionRequest.newBuilder()
.setCollectionName(collectionName)
.setFunctionName(request.getFunction().getName())
.setFunctionSchema(SchemaUtils.convertToGrpcFunction(request.getFunction()));
if (StringUtils.isNotEmpty(dbName)) {
builder.setDbName(dbName);
}
Status status = blockingStub.alterCollectionFunction(builder.build());
rpcUtils.handleResponse(title, status);

return null;
}

public Void dropCollectionFunction(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub,
DropCollectionFunctionReq request) {
if (StringUtils.isEmpty(request.getFunctionName())) {
throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Function name cannot be empty.");
}

String dbName = request.getDatabaseName();
String collectionName = request.getCollectionName();
String title = String.format("Drop function to collection: '%s' in database: '%s'", collectionName, dbName);
DropCollectionFunctionRequest.Builder builder = DropCollectionFunctionRequest.newBuilder()
.setCollectionName(collectionName)
.setFunctionName(request.getFunctionName());
if (StringUtils.isNotEmpty(dbName)) {
builder.setDbName(dbName);
}
Status status = blockingStub.dropCollectionFunction(builder.build());
rpcUtils.handleResponse(title, status);

return null;
}

private void WaitForLoadCollection(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, String databaseName,
String collectionName, long timeoutMs) {
long startTime = System.currentTimeMillis(); // Capture start time/ Timeout in milliseconds (60 seconds)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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.
*/

package io.milvus.v2.service.collection.request;

public class AddCollectionFunctionReq {
private String collectionName;
private String databaseName;
private CreateCollectionReq.Function function;

private AddCollectionFunctionReq(AddCollectionFunctionReqBuilder builder) {
this.collectionName = builder.collectionName;
this.databaseName = builder.databaseName;
this.function = builder.function;
}

public String getCollectionName() {
return collectionName;
}

public void setCollectionName(String collectionName) {
this.collectionName = collectionName;
}

public String getDatabaseName() {
return databaseName;
}

public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}

public CreateCollectionReq.Function getFunction() {
return function;
}

@Override
public String toString() {
return "AddCollectionFunctionReq{" +
"collectionName='" + collectionName + '\'' +
", databaseName='" + databaseName + '\'' +
", function= " + function +
'}';
}

public static AddCollectionFunctionReqBuilder builder() {
return new AddCollectionFunctionReqBuilder();
}

public static class AddCollectionFunctionReqBuilder {
private String collectionName = "";
private String databaseName = "";
private CreateCollectionReq.Function function;

private AddCollectionFunctionReqBuilder() {
}

public AddCollectionFunctionReqBuilder collectionName(String collectionName) {
this.collectionName = collectionName;
return this;
}

public AddCollectionFunctionReqBuilder databaseName(String databaseName) {
this.databaseName = databaseName;
return this;
}

public AddCollectionFunctionReqBuilder function(CreateCollectionReq.Function function) {
this.function = function;
return this;
}

public AddCollectionFunctionReq build() {
return new AddCollectionFunctionReq(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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.
*/

package io.milvus.v2.service.collection.request;

public class AlterCollectionFunctionReq {
private String collectionName;
private String databaseName;
private CreateCollectionReq.Function function;

private AlterCollectionFunctionReq(AlterCollectionFunctionReqBuilder builder) {
this.collectionName = builder.collectionName;
this.databaseName = builder.databaseName;
this.function = builder.function;
}

public String getCollectionName() {
return collectionName;
}

public void setCollectionName(String collectionName) {
this.collectionName = collectionName;
}

public String getDatabaseName() {
return databaseName;
}

public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}

public CreateCollectionReq.Function getFunction() {
return function;
}

@Override
public String toString() {
return "AlterCollectionFunctionReq{" +
"collectionName='" + collectionName + '\'' +
", databaseName='" + databaseName + '\'' +
", function= " + function +
'}';
}

public static AlterCollectionFunctionReqBuilder builder() {
return new AlterCollectionFunctionReqBuilder();
}

public static class AlterCollectionFunctionReqBuilder {
private String collectionName = "";
private String databaseName = "";
private CreateCollectionReq.Function function;

private AlterCollectionFunctionReqBuilder() {
}

public AlterCollectionFunctionReqBuilder collectionName(String collectionName) {
this.collectionName = collectionName;
return this;
}

public AlterCollectionFunctionReqBuilder databaseName(String databaseName) {
this.databaseName = databaseName;
return this;
}

public AlterCollectionFunctionReqBuilder function(CreateCollectionReq.Function function) {
this.function = function;
return this;
}

public AlterCollectionFunctionReq build() {
return new AlterCollectionFunctionReq(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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.
*/

package io.milvus.v2.service.collection.request;

public class DropCollectionFunctionReq {
private String collectionName;
private String databaseName;
private String functionName;

private DropCollectionFunctionReq(DropCollectionFunctionReqBuilder builder) {
this.collectionName = builder.collectionName;
this.databaseName = builder.databaseName;
this.functionName = builder.functionName;
}

public String getCollectionName() {
return collectionName;
}

public void setCollectionName(String collectionName) {
this.collectionName = collectionName;
}

public String getDatabaseName() {
return databaseName;
}

public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}

public String getFunctionName() {
return functionName;
}

@Override
public String toString() {
return "DropCollectionFunctionReq{" +
"collectionName='" + collectionName + '\'' +
", databaseName='" + databaseName + '\'' +
", functionName= '" + functionName + '\'' +
'}';
}

public static DropCollectionFunctionReqBuilder builder() {
return new DropCollectionFunctionReqBuilder();
}

public static class DropCollectionFunctionReqBuilder {
private String collectionName = "";
private String databaseName = "";
private String functionName = "";

private DropCollectionFunctionReqBuilder() {
}

public DropCollectionFunctionReqBuilder collectionName(String collectionName) {
this.collectionName = collectionName;
return this;
}

public DropCollectionFunctionReqBuilder databaseName(String databaseName) {
this.databaseName = databaseName;
return this;
}

public DropCollectionFunctionReqBuilder functionName(String functionName) {
this.functionName = functionName;
return this;
}

public DropCollectionFunctionReq build() {
return new DropCollectionFunctionReq(this);
}
}
}
Loading