milvus-logo
LFAI
< Docs
  • Java

getCompactionStateWithPlans()

A MilvusClient interface. This method returns the detailed information of a compaction operation, including the state indicating if the operation is completed or not, its sub tasks (i.e. the plans), and more.

R<GetCompactionPlansResponse> getCompactionStateWithPlans(GetCompactionPlansParam requestParam)

GetCompactionPlansParam

Use the GetCompactionPlansParam.Builder to construct a GetCompactionPlansParam object.

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

Methods of GetCompactionPlansParam.Builder:

MethodDescriptionParameters
withCompactionID(Long compactionID)Sets the ID of the compaction operation.compactionID: The ID of the compaction operation whose detailed information needs to be checked.
build()Constructs a GetCompactionPlansParam object.N/A

The GetCompactionPlansParam.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<GetCompactionPlansResponse> 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.Unknow and the error message of the exception.

  • If the API succeeds, it returns a valid GetCompactionPlansResponse held by the R template.

Example

import io.milvus.param.*;
import io.milvus.grpc.GetCompactionPlansResponse;
import io.milvus.grpc.CompactionMergeInfo;

GetCompactionPlansParam param = GetCompactionPlansParam.newBuilder()
        .withCompactionID(compactionID)
        .build();
R<GetCompactionPlansResponse> response = client.getCompactionStateWithPlans(param);
if (response.getStatus() != R.Status.Success.getCode()) {
    System.out.println(response.getMessage());
}

GetCompactionPlansResponse compactionPlans = response.getData();
System.out.println("Compaction state: " + compactionPlans.getState());

for (int i = 0; i < compactionPlans.getMergeInfosCount(); i++) {
    CompactionMergeInfo info = compactionPlans.getMergeInfos(i);
    System.out.println("Merge segments " + info.getSourcesList().toString() + " into new segment " + info.getTarget());
}
Feedback

Was this page helpful?