MCPcopy Create free account
hub / github.com/ByConity/ByConity / executeImpl

Method executeImpl

src/WorkerTasks/CloudMergeTreeReclusterTask.cpp:46–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void CloudMergeTreeReclusterTask::executeImpl()
47{
48 auto lock_holder = storage.lockForShare(RWLockImpl::NO_QUERY, storage.getSettings()->lock_acquire_timeout_for_background_operations);
49
50 MergeTreeDataReclusterMutator mutator(storage);
51
52 auto clustered_tmp_parts = mutator.executeClusterTask(params, *manipulation_entry, getContext());
53
54 if (isCancelled())
55 throw Exception("Recluster task " + params.task_id + " is cancelled", ErrorCodes::ABORTED);
56
57 MergeTreeMutableDataPartsVector parts_to_commit;
58 std::vector<ReservationPtr> reservations;
59 for (auto & part : params.source_data_parts)
60 {
61 MergeTreePartInfo drop_part_info(
62 part->info.partition_id, part->info.min_block, part->info.max_block, part->info.level + 1, part->info.mutation, 0);
63 reservations.emplace_back(storage.reserveSpace(0));
64 auto single_disk_volume = std::make_shared<SingleDiskVolume>("volume_" + part->name, reservations.back()->getDisk(), 0);
65
66 auto drop_part = std::make_shared<MergeTreeDataPartCNCH>(
67 storage, drop_part_info.getPartName(), drop_part_info, single_disk_volume, std::nullopt);
68 drop_part->partition.assign(part->partition);
69 drop_part->deleted = true;
70 /// rows_count and bytes_on_disk is required for parts info statistics.
71 // drop_part->covered_parts_rows = part->rows_count;
72 // drop_part->covered_parts_size = part->bytes_on_disk;
73 parts_to_commit.push_back(std::move(drop_part));
74 }
75
76 parts_to_commit.insert(parts_to_commit.end(), clustered_tmp_parts.begin(), clustered_tmp_parts.end());
77
78 CnchDataWriter cnch_writer(storage, getContext(), ManipulationType::Clustering, params.task_id);
79 auto res = cnch_writer.dumpAndCommitCnchParts(parts_to_commit);
80 getContext()->getCurrentTransaction()->commitV2();
81 if (params.parts_preload_level)
82 cnch_writer.preload(res.parts);
83}
84
85}

Callers

nothing calls this directly

Calls 15

isCancelledFunction · 0.85
lockForShareMethod · 0.80
executeClusterTaskMethod · 0.80
reserveSpaceMethod · 0.80
getPartNameMethod · 0.80
getCurrentTransactionMethod · 0.80
ExceptionClass · 0.50
getSettingsMethod · 0.45
emplace_backMethod · 0.45
getDiskMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected