ClickHouse/src/Storages/MergeTree/MutateTask.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
#include <Storages/MergeTree/MergeTreeData.h>
#include <Storages/MergeTree/MergeProgress.h>
#include <Storages/MergeTree/FutureMergedMutatedPart.h>
#include <Storages/MergeTree/IMergedBlockOutputStream.h>
#include <Storages/MutationCommands.h>
#include <Interpreters/MutationsInterpreter.h>
namespace DB
{
class MutateTask;
2022-04-20 19:08:26 +00:00
using MutateTaskPtr = std::shared_ptr<MutateTask>;
class MergeTreeDataMergerMutator;
struct MutationContext;
class MutateTask
{
public:
MutateTask(
FutureMergedMutatedPartPtr future_part_,
StorageMetadataPtr metadata_snapshot_,
MutationCommandsConstPtr commands_,
MergeListEntry * mutate_entry_,
time_t time_of_mutation_,
ContextPtr context_,
ReservationSharedPtr space_reservation_,
TableLockHolder & table_lock_holder_,
2022-02-14 19:50:08 +00:00
const MergeTreeTransactionPtr & txn,
MergeTreeData & data_,
MergeTreeDataMergerMutator & mutator_,
2022-12-22 13:31:42 +00:00
ActionBlocker & merges_blocker_,
bool need_prefix_);
bool execute();
std::future<MergeTreeData::MutableDataPartPtr> getFuture()
{
return promise.get_future();
}
2022-04-19 13:53:10 +00:00
const MergeTreeData::HardlinkedFiles & getHardlinkedFiles() const;
private:
bool prepare();
enum class State
{
NEED_PREPARE,
NEED_EXECUTE
};
State state{State::NEED_PREPARE};
std::promise<MergeTreeData::MutableDataPartPtr> promise;
std::shared_ptr<MutationContext> ctx;
ExecutableTaskPtr task;
};
[[ maybe_unused]] static MergeTreeData::MutableDataPartPtr executeHere(MutateTaskPtr task)
{
while (task->execute()) {}
return task->getFuture().get();
}
}