milvus-logo
LFAI
< Docs
  • Java

showPartitions()

MilvusClient interface. This method shows all partitions in the specified collection.

R<ShowPartitionsResponse> showPartitions(ShowPartitionsParam requestParam);

ShowPartitionsParam

Use the ShowPartitionsParam.Builder to construct a ShowPartitionsParam object.

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

Methods of ShowPartitionsParam.Builder:

Method

Description

Parameters

withCollectionName(String collectionName)

Set the collection name. Collection name cannot be empty or null.

collectionName: The target collection name.

withDatabaseName(String databaseName)

Sets the database name. database name can be null for default database.

databaseName: The database name.

withPartitionNames(List<String> partitionNames)

Set the partition names list. Partition names list cannot be null or empty.

partitionNames: The name list of partitions to show.

addPartitionName(String partitionName)

Add a partition by name. Partition name cannot be empty or null.

partitionName: A target partition name.

build()

Construct a ShowPartitionsParam object.

N/A

The ShowPartitionsParam.Builder.build() can throw the following exceptions:

  • ParamException: error if the parameter is invalid.

Returns

This method catches all the exceptions and returns an R<ShowPartitionsResponse> 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 ShowPartitionsResponse held by the R template. You can use ShowPartResponseWrapper to get information easily.

ShowPartResponseWrapper

A tool class to encapsulate the ShowPartitionsResponse.

import io.milvus.response.ShowPartResponseWrapper;
ShowPartResponseWrapper wrapper = new ShowPartResponseWrapper(showPartitionsResponse);

Methods of ShowPartitionsResponse:

Method

Description

Parameters

Returns

getPartitionsInfo()

Return a list of PartitionInfo.

N/A

List<PartitionInfo>

getPartitionInfoByName(String partitionName)

Return a PartitionInfo object by a partition name.

partitionName: The target partition name.

PartitionInfo

PartitionInfo

A tool class to hold information of a partition.

Methods of ShowPartitionsResponse.PartitionInfo

Method

Description

Returns

getIndexType()

Get index type.

IndexType

getMetricType()

Get metric type.

MetricType

getExtraParam()

Get index parameters in JSON format.

String

Example

import io.milvus.param.*;
import io.milvus.grpc.ShowPartitionsResponse;
import io.milvus.response.ShowPartResponseWrapper;

ShowPartitionsParam param = ShowPartitionsParam.newBuilder()
        .withCollectionName(COLLECTION_NAME)
        .addPartitionName(PARTITION_NAME)
        .build();
R<ShowPartitionsResponse> response = client.showPartitions(param);
if (response.getStatus() != R.Status.Success.getCode()) {
    System.out.println(response.getMessage());
}

ShowPartResponseWrapper wrapper = new ShowPartResponseWrapper(response.getData());
ShowPartResponseWrapper.PartitionInfo info = wrapper.getPartitionInfoByName("_default");
System.out.println("Partition name: " + info.getName() + ", ID: " + info.getId() + ", in-memory: " + info.getInMemoryPercentage() + "%");

Try Managed Milvus for Free

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

Get Started
Feedback

Was this page helpful?