Skip to content

Commit

Permalink
Add withDatabaseBame for releaseCollection
Browse files Browse the repository at this point in the history
Signed-off-by: yhmo <[email protected]>
  • Loading branch information
yhmo committed Mar 4, 2024
1 parent f8943d5 commit 6a41d40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,7 @@ public R<RpcStatus> loadCollection(@NonNull LoadCollectionParam requestParam) {
builder.setDbName(requestParam.getDatabaseName());
}

LoadCollectionRequest loadCollectionRequest = builder
.build();

Status response = blockingStub().loadCollection(loadCollectionRequest);
Status response = blockingStub().loadCollection(builder.build());
handleResponse(title, response);

// sync load, wait until collection finish loading
Expand Down Expand Up @@ -591,11 +588,13 @@ public R<RpcStatus> releaseCollection(@NonNull ReleaseCollectionParam requestPar
String title = String.format("ReleaseCollectionRequest collectionName:%s", requestParam.getCollectionName());

try {
ReleaseCollectionRequest releaseCollectionRequest = ReleaseCollectionRequest.newBuilder()
.setCollectionName(requestParam.getCollectionName())
.build();
ReleaseCollectionRequest.Builder builder = ReleaseCollectionRequest.newBuilder()
.setCollectionName(requestParam.getCollectionName());
if (StringUtils.isNotEmpty(requestParam.getDatabaseName())) {
builder.setDbName(requestParam.getDatabaseName());
}

Status response = blockingStub().releaseCollection(releaseCollectionRequest);
Status response = blockingStub().releaseCollection(builder.build());
handleResponse(title, response);
return R.success(new RpcStatus(RpcStatus.SUCCESS_MSG));
} catch (StatusRuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
*/
@Getter
public class ReleaseCollectionParam {
private final String databaseName;
private final String collectionName;

private ReleaseCollectionParam(@NonNull Builder builder) {
this.databaseName = builder.databaseName;
this.collectionName = builder.collectionName;
}

Expand All @@ -44,11 +46,23 @@ public static Builder newBuilder() {
* Builder for {@link ReleaseCollectionParam} class.
*/
public static final class Builder {
private String databaseName;
private String collectionName;

private Builder() {
}

/**
* Sets the database name. database name can be nil.
*
* @param databaseName database name
* @return <code>Builder</code>
*/
public Builder withDatabaseName(String databaseName) {
this.databaseName = databaseName;
return this;
}

/**
* Sets the collection name. Collection name cannot be empty or null.
*
Expand Down Expand Up @@ -80,6 +94,7 @@ public ReleaseCollectionParam build() throws ParamException {
@Override
public String toString() {
return "ReleaseCollectionParam{" +
"databaseName='" + databaseName + '\'' +
"collectionName='" + collectionName + '\'' + '}';
}
}

0 comments on commit 6a41d40

Please sign in to comment.