milvus-logo
LFAI
< Docs
  • Java

manualCompact()

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

Compaction is automatically triggerd by the Milvus server under 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:

MethodDescriptionParameters
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. The ManualCompactionResponse contains an ID of this compaction operation, of 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());

Try Managed Milvus for Free

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

Get Started
Feedback

Was this page helpful?