milvus-logo
LFAI
< Docs
  • Java

manualCompact()

MilvusClient interface. This method triggers a compaction operation on the server side.

notes

Milvus server can automatically trigger compaction operation in certain conditions.

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. Collection name cannot be empty or null.

collectionName: The target collection name.

build()

Construct a ManualCompactParam object.

N/A

The ManualCompactParam.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<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.Unknown and error message of the exception.

  • If the API succeeds, it returns a valid ManualCompactionResponse held by the R template. The ManualCompactionResponse contains an ID of this compaction operation, which you can check the state by getCompactionState() or getCompactionStateWithPlans() 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());
Feedback

Was this page helpful?