LoadPartitions()

This operation loads the data of specific partitions in one collection into query nodes.

Status LoadPartitions(const LoadPartitionsRequest& request)

Request Syntax

auto request = LoadPartitionsRequest()
    .WithDatabaseName(db_name)
    .WithCollectionName(collection_name)
    .WithPartitionNames(partition_names)
    .WithSync(sync)
    .WithReplicaNum(replica_num)
    .WithTimeoutMs(timeout_ms)
    .WithRefresh(refresh)
    .WithLoadFields(load_fields)
    .WithSkipDynamicField(skip_dynamic_field)
    .WithTargetResourceGroups(target_resource_groups);

REQUEST METHODS:

  • WithDatabaseName(const std::string& db_name)

    Sets the target database name. The default database applies if it is empty.

  • WithCollectionName(const std::string& collection_name)

    Sets the name of the collection.

  • WithPartitionNames(const std::set<std::string>& partition_names)

    Sets the names of the partitions.

  • AddPartitionName(const std::string& partition_name)

    Adds a partition to be loaded.

  • WithSync(bool sync)

    Sets the sync mode. The default value is True.

    • True: wait the collection to be fully loaded.

    • False: return immediately no matter the collection is fully loaded or not.

  • WithReplicaNum(int64_t replica_num)

    Sets the number of replicas.

  • WithTimeoutMs(int64_t timeout_ms)

    Sets the timeout in milliseconds. The default value is 60000 ms. This parameter only works when this operation works in sync mode.

    If WaitFlushedMs is set to 0, this operation repeatedly calls GetLoadingProgress() to check the loading state until the collection is fully loaded into memory. If WaitFlushedMs is greater than 0, this operation will break the loop after a specified period of time and return a status indicating a timeout.

  • WithRefresh(bool refresh)

    Sets the refresh option. This parameter takes effect when new segments are generated by the bulk import interface.

    • True: Loads newly generated segments from the bulk import interface.

    • False: Ignores newly generated segments from the bulk import interface.

  • WithLoadFields(const std::set<std::string>& load_fields)

    Sets the names of the fields to load.

  • AddLoadField(const std::string& load_field)

    Adds the name of a field to load.

  • WithSkipDynamicField(bool skip_dynamic_field)

    Sets whether to skip the dynamic field option.

  • WithTargetResourceGroups(const std::set<std::string>& target_resource_groups)

    Sets the target resource groups. If it is empty, the partition data will be loaded into the default resource group.

  • AddTargetResourceGroups(const std::string& target_resource_group)

    Adds a target resource group.

RETURNS:

Status

Check status.IsOk() to confirm success.

EXCEPTIONS:

  • StatusCode

    Check status.Code() and status.Message() for error details.

Example

#include "milvus/MilvusClientV2.h"
auto client = milvus::MilvusClientV2::Create();

milvus::ConnectParam connect_param{"http://localhost:19530", "root:Milvus"};
auto status = client->Connect(connect_param);
if (!status.IsOk()) {
    std::cout << status.Message() << std::endl;
}

status = client->LoadPartitions(
    milvus::LoadPartitionsRequest()
        .WithCollectionName("my_collection")
        .AddPartitionName("partition_1")
        .AddPartitionName("partition_2")
        .WithSync(true));
if (!status.IsOk()) {
    std::cout << status.Message() << std::endl;
}

Try Managed Milvus for Free

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

Get Started
Feedback

Was this page helpful?