manualCompact()
A MilvusClient interface. This method manually triggers a compaction operation on the server side.
R<ManualCompactionResponse> manualCompact(ManualCompactParam requestParam);
ManualCompactParam
Use the ManualCompactParam.Builder
to construct a ManualCompactParam
object.
import io.milvus.param.ManualCompactParam;
ManualCompactParam.Builder builder = ManualCompactParam.newBuilder();
Methods of ManualCompactParam.Builder
:
Method | Description | Parameters |
---|---|---|
withCollectionName(String collectionName) | Sets the collection name. The collection name cannot be empty or null. | collectionName: The name of the collection that needs to be manually compacted. |
build() | Constructs a ManualCompactParam object. | N/A |
The ManualCompactParam.Builder.build()
could throw the following exceptions:
ParamException
: error if the parameter is invalid.
Returns
This method catches all the exceptions and returns an R<ManualCompactionResponse>
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 error message of the exception.If the API succeeds, it returns a valid
ManualCompactionResponse
held by the R template. TheManualCompactionResponse
contains an ID of this compaction operation, of which you can check the state bygetCompactionState()
orgetCompactionStateWithPlans()
method.
Example
import io.milvus.param.*;
ManualCompactParam param = ManualCompactParam.newBuilder()
.withSegmentIDs(segmentIDs)
.withDestinationNodeID(destNodeID)
.withSourceNodeID(srcNodeID)
.build();
R<ManualCompactionResponse> response = client.manualCompact(param);
if (response.getStatus() != R.Status.Success.getCode()) {
System.out.println(response.getMessage());
}
System.out.println("Compaction ID: " + response.getData().getCompactionID());