getPartitionStatistics()
MilvusClient interface. This method shows the statistical information of a partition.
R<GetPartitionStatisticsResponse> getPartitionStatistics(GetPartitionStatisticsParam requestParam);
GetPartitionStatisticsParam
Use the GetPartitionStatisticsParam.Builder
to construct a GetPartitionStatisticsParam
object.
import io.milvus.param.GetPartitionStatisticsParam;
GetPartitionStatisticsParam.Builder builder = GetPartitionStatisticsParam.newBuilder();
Methods of GetPartitionStatisticsParam.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. |
withPartitionName(String partitionName) |
Sets the partition name. Partition name cannot be empty or null. |
partitionName: The target partition name. |
withFlush(Boolean flush) |
Requires a flush action before retrieving partition statistics. Default value is True. |
flush: Set to True to ask a flush action. |
build() |
Construct a GetPartitionStatisticsParam object. |
N/A |
The GetPartitionStatisticsParam.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<GetPartitionStatisticsResponse>
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
GetPartitionStatisticsResponse
held by theR
template. You can useGetPartStatResponseWrapper
to get statistics easily.
GetPartStatResponseWrapper
A tool class to encapsulate the GetPartitionStatisticsResponse
.
import io.milvus.response.GetPartStatResponseWrapper;
GetPartStatResponseWrapper wrapper = new GetPartStatResponseWrapper(partStatResponse);
Methods of GetPartStatResponseWrapper
:
Method |
Description |
Returns |
---|---|---|
getRowCount() |
Get the row count of a partition.Throw NumberFormatException if the row count string is illegal. |
long |
Example
import io.milvus.param.*;
import io.milvus.grpc.GetPartitionStatisticsResponse;
import io.milvus.response.GetPartStatResponseWrapper;
GetPartitionStatisticsParam param = GetPartitionStatisticsParam.newBuilder()
.withCollectionName(COLLECTION_NAME)
.withPartitionName(PARTITION_NAME)
.build();
R<GetPartitionStatisticsResponse> response = client.getPartitionStatistics(param);
if (response.getStatus() != R.Status.Success.getCode()) {
System.out.println(response.getMessage());
}
GetPartStatResponseWrapper wrapper = new GetPartStatResponseWrapper(response.getData());
System.out.println("Partition row count: " + wrapper.getRowCount());