| 127 | } |
| 128 | |
| 129 | void RemoteExchangeSourceStep::initializePipeline(QueryPipeline & pipeline, const BuildQueryPipelineSettings & settings) |
| 130 | { |
| 131 | auto current_tx_id = context->getCurrentTransactionID().toUInt64(); |
| 132 | if (!plan_segment) |
| 133 | throw Exception("Should setPlanSegment before initializePipeline!", ErrorCodes::LOGICAL_ERROR); |
| 134 | |
| 135 | Pipe pipe; |
| 136 | |
| 137 | size_t source_num = 0; |
| 138 | bool keep_order = context->getSettingsRef().exchange_enable_force_keep_order || context->getSettingsRef().enable_shuffle_with_order; |
| 139 | if (!keep_order) |
| 140 | { |
| 141 | for (const auto & input : inputs) |
| 142 | { |
| 143 | if (input->needKeepOrder()) |
| 144 | { |
| 145 | keep_order = input->needKeepOrder(); |
| 146 | break; |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | const Block & exchange_header = getOutputStream().header; |
| 152 | Block source_header; |
| 153 | if (keep_order) |
| 154 | source_header = exchange_header; |
| 155 | |
| 156 | ExchangeTotalsSourcePtr totals_source; |
| 157 | if (is_add_totals) |
| 158 | totals_source = std::make_shared<ExchangeTotalsSource>(source_header); |
| 159 | ExchangeExtremesSourcePtr extremes_source; |
| 160 | if (is_add_extremes) |
| 161 | extremes_source = std::make_shared<ExchangeExtremesSource>(source_header); |
| 162 | auto enable_metrics = context->getSettingsRef().log_query_exchange; |
| 163 | auto query_exchange_log = enable_metrics ? context->getQueryExchangeLog(): nullptr; |
| 164 | auto register_mode |
| 165 | = context->getSettingsRef().bsp_mode ? BrpcExchangeReceiverRegistryService::DISK_READER : BrpcExchangeReceiverRegistryService::BRPC; |
| 166 | auto disk_exchange_mgr = context->getSettingsRef().bsp_mode ? context->getDiskExchangeDataManager() : nullptr; |
| 167 | size_t local_queue_size = context->getSettingsRef().exchange_local_receiver_queue_size; |
| 168 | size_t remote_queue_size = context->getSettingsRef().exchange_remote_receiver_queue_size; |
| 169 | size_t multi_path_queue_size = context->getSettingsRef().exchange_multi_path_receiver_queue_size; |
| 170 | std::shared_ptr<MemoryController> memory_controller; |
| 171 | auto weak_segment_process_list_entry = context->getPlanSegmentProcessListEntry().lock(); |
| 172 | if (weak_segment_process_list_entry) |
| 173 | memory_controller = weak_segment_process_list_entry->getMemoryController(); |
| 174 | |
| 175 | for (const auto & input : inputs) |
| 176 | { |
| 177 | size_t write_plan_segment_id = input->getPlanSegmentId(); |
| 178 | size_t exchange_parallel_size = input->getExchangeParallelSize(); |
| 179 | UInt32 exchange_id = input->getExchangeId(); |
| 180 | UInt32 parallel_id = context->getPlanSegmentInstanceId().parallel_id; |
| 181 | auto exchange_mode = input->getExchangeMode(); |
| 182 | //TODO: hack logic for BROADCAST/LOCAL_NO_NEED_REPARTITION/LOCAL_MAY_NEED_REPARTITION, we should remove this logic |
| 183 | if (exchange_mode == ExchangeMode::LOCAL_NO_NEED_REPARTITION || exchange_mode == ExchangeMode::LOCAL_MAY_NEED_REPARTITION) |
| 184 | parallel_id = 0; |
| 185 | else if (exchange_mode == ExchangeMode::BROADCAST) |
| 186 | exchange_parallel_size = 1; |
nothing calls this directly
no test coverage detected