Skip to main content

loadPartitions()

MilvusClient interface. This method loads partitions' data into query nodes' memory before the search or query.

R<RpcStatus> loadPartitions(LoadPartitionsParam requestParam);

LoadPartitionsParam

Use the LoadPartitionsParam.Builder to construct a LoadPartitionsParam object.

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

Methods of LoadPartitionsParam.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.

withPartitionNames(List<String> partitionNames)

Set the partition names list. Partition names list cannot be null or empty.

partitionNames:
The name list of partitions to be loaded.

addPartitionName(String partitionName)

Add a partition by name. Partition name cannot be empty or null.

partitionName: A target partition name.

withSyncLoad(Boolean syncLoad)

Enable sync mode for load action. With sync mode enabled, the client keeps waiting until all segments of the partition are successfully loaded.If sync mode is disabled, client returns instantly after the loadPartitions() is called.
By default sync mode is enabled.

syncLoad: set to True is sync mode

withSyncLoadWaitingInterval(Long milliseconds)

Set the waiting interval for sync mode. In sync mode, the client constantly checks partition load state by interval.
Interval must be greater than zero, and cannot be greater than Constant.MAX_WAITING_LOADING_INTERVAL.
Default value is 500 milliseconds

milliseconds: interval value(units: millisecond)

withSyncLoadWaitingTimeout(Long seconds)

Set the timeout value for sync mode.
Timeout value must be greater than zero, and cannot be greater than Constant.MAX_WAITING_LOADING_TIMEOUT.
Default value is 60 seconds.

seconds: timeout value(units: second)

withReplicaNumber(Integer replicaNumber)

Specify replica number to load.
Default value is 1.

replicaNumber: replica number

withRefresh(Boolean refresh)

Whether to renew the segment list of this partition before loading. This flag must be set to FALSE when first time call the loadPartitions(). After loading a partition, call loadPartitions() again with refresh=TRUE, the server will look for new segments that are not loaded yet and tries to load them up.
This method is mainly for bulkinsert() interface.

refresh: The flag whether to renew segment list.

build()

Construct a LoadPartitionsParam object.

N/A

The LoadPartitionsParam.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<RpcStatus> 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 R.Status.Success.

Example

import io.milvus.param.*;

LoadPartitionsParam param = LoadPartitionsParam.newBuilder()
.withCollectionName(COLLECTION_NAME)
.addPartitionName(PARTITION_NAME)
.build();
R<RpcStatus> response = client.loadPartitions(param);
if (response.getStatus() != R.Status.Success.getCode()) {
System.out.println(response.getMessage());
}