ListCompactionTasks()
Lists detailed server-side compaction tasks for a collection.
Status ListCompactionTasks(const ListCompactionTasksRequest& request, GetCompactionPlansResponse& response)
Request Syntax
auto request = ListCompactionTasksRequest()
.WithDatabaseName(db_name)
.WithCollectionName(collection_name);
REQUEST METHODS:
WithDatabaseName(const std::string& db_name)Sets the database name. Use the default database when it is empty.
SetDatabaseName(const std::string& db_name)Sets the database name. Use the default database when it is empty.
WithCollectionName(const std::string& collection_name)Sets the collection whose compaction tasks are listed.
SetCollectionName(const std::string& collection_name)Sets the collection whose compaction tasks are listed.
RETURNS:
Returns a Status indicating whether the operation succeeded. The response is the same GetCompactionPlansResponse envelope used by GetCompactionPlans(); its Plans() members are documented on CompactionPlan.
response (GetCompactionPlansResponse) -
Plans (const CompactionPlans&) -
Get the compaction plans. See CompactionPlan.
CompactionID (int64_t) -
Get the id of the compaction.
State (CompactionStateCode) -
Get the state of the compaction. See CompactionStateCode.
CollectionName (const std::string&) -
Returns the collection name to which the tasks belong.
ERROR HANDLING:
-
Failures are reported through the returned Status. The SDK converts internal exceptions into a non-OK Status; public API calls do not throw. Inspect
status.IsOk()andstatus.Message()for failure details. See Status.
Example
#include "milvus/MilvusClientV2.h"
#include <iostream>
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;
}
auto request = milvus::ListCompactionTasksRequest().WithCollectionName("demo");
milvus::GetCompactionPlansResponse response;
status = client->ListCompactionTasks(request, response);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
for (const auto& task : response.Plans()) {
std::cout << "task " << task.PlanId() << " state "
<< static_cast<int>(task.State()) << '\n';
}