milvus-logo
LFAI
< Docs
  • Java
    • v1

alterDatabase()

The MilvusClient interface. This method alters a database.

R<RpcStatus> alterDatabase(AlterDatabaseParam requestParam);

AlterDatabaseParam

Use the AlterDatabaseParam.Builder to construct an AlterDatabaseParam object.

import io.milvus.param.collection.AlterDatabaseParam;
AlterDatabaseParam.Builder builder = AlterDatabaseParam.newBuilder()

Methods of AlterDatabaseParam.Builder:

Method

Description

Parameters

withDatabaseName(String databaseName)

Sets the databaseName name. Database name cannot be empty or null.

databaseName: The database name

withReplicaNumber(int replicaNumber)

Sets the replica number in database level, then if load collection doesn't have replica number, it will use this replica number.

replicaNumber: replica number

WithResourceGroups(List<String> resourceGroups)

Sets the resource groups in database level, then if load collection doesn't have resource groups, it will use this resource groups.

resourceGroups: resource group names

build()

Construct a CreateDatabaseParam object.

N/A

Returns

This method catches all the exceptions and returns an R<RpcStatus> object.

  • If the API fails on the server side, it returns the error code and message from the server.

  • If the API fails by RPC exception, it returns R.Status.Unknown and the error message of the exception.

  • If the API succeeds, it returns R.Status.Success.

Example

import io.milvus.param.collection.AlterDatabaseParam;

AlterDatabaseParam param = AlterDatabaseParam.newBuilder()
        .withDatabaseName("mydnb")
        .withReplicaNumber(3)
        .WithResourceGroups(Arrays.asList("rg1", "rg2", "rg3"))
        .build();
        
R<RpcStatus> response = client.alterDatabase(param);
if (response.getStatus() != R.Status.Success.getCode()) {
    System.out.println(response.getMessage());
}

describeDatabase()

The MilvusClient interface. This method describes a database.

R<DescribeDatabaseResponse> describeDatabase(DescribeDatabaseParam requestParam);

DescribeDatabaseParam

Use the DescribeDatabaseParam.Builder to construct a DescribeDatabaseParam object.

import io.milvus.param.collection.DescribeDatabaseParam;
DescribeDatabaseParam.Builder builder = DescribeDatabaseParam.newBuilder()

Methods of DescribeDatabaseParam.Builder:

Method

Description

Parameters

withDatabaseName(String databaseName)

Sets the databaseName name. Database name cannot be empty or null.

databaseName: The database name

build()

Construct a DescribeDatabaseParam object.

N/A

Returns

This method catches all the exceptions and returns an R<DescribeDatabaseResponse> object.

  • If the API fails on the server side, it returns the error code and message from the server.

  • If the API fails by RPC exception, it returns R.Status.Unknown and error message of the exception.

  • If the API succeeds, it returns a valid DescribeDatabaseResponse held by the R template. You can use DescDBResponseWrapper to get the information.

DescDBResponseWrapper

A tool class to encapsulate the DescribeDatabaseResponse.

import io.milvus.response.DescDBResponseWrapper;
DescDBResponseWrapper wrapper = new DescDBResponseWrapper(describeDBResponse);

Methods of DescDBResponseWrapper:

Method

Description

Parameters

Returns

getDatabaseName()

Returns the name of the database.

N/A

String

getReplicaNumber()

Returns database-level replica number.

N/A

int

getResourceGroups()

Returns resource groups of the database.

N/A

List<String>

getProperties()

Returns all properties of the database, including the replica number and resource groups.

N/A

Map<String, String>

Example

import io.milvus.param.collection.DescribeDatabaseParam;
import io.milvus.response.DescDBResponseWrapper;

DescribeDatabaseParam describeDBParam = DescribeDatabaseParam.newBuilder()
        .withDatabaseName("mydb")
        .build();
R<DescribeDatabaseResponse> response = client.describeDatabase(describeDBParam);
if (response.getStatus() != R.Status.Success.getCode()) {
    System.out.println(response.getMessage());
}
DescDBResponseWrapper describeDBWrapper = new DescDBResponseWrapper(response.getData());
System.out.println(describeDBWrapper.getReplicaNumber());

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?