CompactionPlan
Describes one compaction task in a compaction response. CompactionPlan also contains the task type and task state enums.
CompactionPlan();
CompactionPlan(const std::vector<int64_t>& segments, int64_t dst_segment);
CompactionPlan(std::vector<int64_t>&& segments, int64_t dst_segment);
METHODS:
const std::vector<int64_t>& SourceSegments() constReturns the source segment IDs.
void SetSourceSegments(const std::vector<int64_t>& segments)Sets the source segment IDs.
void SetSourceSegments(std::vector<int64_t>&& segments)Sets the source segment IDs. The vector is passed by rvalue reference.
int64_t DestinySegemnt() constReturns the single destination segment ID from the legacy compaction API. For detailed tasks, prefer
Targets().void SetDestinySegemnt(int64_t id)Sets the destination segment ID.
int64_t PlanId() constReturns the server-side compaction task identifier.
void SetPlanId(int64_t plan_id)Sets the server-side compaction task identifier.
int64_t TriggerId() constReturns the compaction trigger ID.
void SetTriggerId(int64_t trigger_id)Sets the compaction trigger ID.
int64_t CollectionId() constReturns the collection ID.
void SetCollectionId(int64_t collection_id)Sets the collection ID.
int64_t PartitionId() constReturns the partition ID.
void SetPartitionId(int64_t partition_id)Sets the partition ID.
const std::string& Channel() constReturns the channel handled by this task.
void SetChannel(const std::string& channel)Sets the channel handled by this task.
CompactionType Type() constReturns the compaction type.
void SetType(CompactionType type)Sets the compaction type.
CompactionTaskState State() constReturns the task state.
void SetState(CompactionTaskState state)Sets the task state.
const std::string& FailureReason() constReturns the failure reason, or an empty string when the task has not failed.
void SetFailureReason(const std::string& failure_reason)Sets the failure reason.
const std::vector<int64_t>& Targets() constReturns the complete output segment set.
void SetTargets(const std::vector<int64_t>& targets)Sets the output segment set.
void SetTargets(std::vector<int64_t>&& targets)Sets the output segment set. The vector is passed by rvalue reference.
CompactionType
enum class CompactionType {
UNDEFINED = 0,
MERGE = 2,
MIX = 3,
SINGLE = 4,
MINOR = 5,
MAJOR = 6,
LEVEL0_DELETE = 7,
CLUSTERING = 8,
SORT = 9,
PARTITION_KEY_SORT = 10,
CLUSTERING_PARTITION_KEY_SORT = 11,
BUMP_SCHEMA_VERSION = 12,
};
Constants:
UNDEFINED (0)
The server did not provide a type.
MERGE (2)
Merges segments.
MIX (3)
Performs a mixed compaction.
SINGLE (4)
Compacts one segment.
MINOR (5)
Performs a minor compaction.
MAJOR (6)
Performs a major compaction.
LEVEL0_DELETE (7)
Applies Level-0 delete records.
CLUSTERING (8)
Performs vector clustering compaction.
SORT (9)
Performs data sorting compaction.
PARTITION_KEY_SORT (10)
Sorts data by partition key.
CLUSTERING_PARTITION_KEY_SORT (11)
Combines clustering with partition-key sorting.
BUMP_SCHEMA_VERSION (12)
Bumps the schema version.
CompactionTaskState
enum class CompactionTaskState {
UNKNOWN = 0,
EXECUTING = 1,
PIPELINING = 2,
COMPLETED = 3,
FAILED = 4,
TIMEOUT = 5,
ANALYZING = 6,
INDEXING = 7,
CLEANED = 8,
META_SAVED = 9,
STATISTIC = 10,
};
Constants:
UNKNOWN (0)
The server did not provide a state.
EXECUTING (1)
The task is executing.
PIPELINING (2)
The task is pipelining work.
COMPLETED (3)
The task completed successfully.
FAILED (4)
The task failed. See
FailureReason().TIMEOUT (5)
The task timed out.
ANALYZING (6)
The task is analyzing input data.
INDEXING (7)
The task is building indexes.
CLEANED (8)
Temporary task resources were cleaned.
META_SAVED (9)
Task metadata was saved.
STATISTIC (10)
The task is collecting statistics.
Example
#include "milvus/MilvusClientV2.h"
#include <iostream>
using namespace milvus;
// GetCompactionPlans() returns the compaction plans for the collection
auto client = MilvusClientV2::Create();
client->Connect(ConnectParam("http://localhost:19530").WithToken("root:Milvus"));
GetCompactionPlansResponse response;
auto status = client->GetCompactionPlans(
GetCompactionPlansRequest().WithCompactionID(compaction_id),
response);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
for (const auto& plan : response.Plans()) {
std::cout << "plan " << plan.PlanId()
<< " type=" << static_cast<int>(plan.Type())
<< " state=" << static_cast<int>(plan.State()) << std::endl;
}