-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MPPReceiverSet, which includes ExchangeReceiver and CoprocessorRe…
- Loading branch information
1 parent
bfceb28
commit e14c677
Showing
8 changed files
with
131 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2022 PingCAP, Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <Flash/Mpp/ExchangeReceiver.h> | ||
#include <Flash/Mpp/MPPReceiverSet.h> | ||
|
||
namespace DB | ||
{ | ||
void MPPReceiverSet::addExchangeReceiver(const String & executor_id, const ExchangeReceiverPtr & exchange_receiver) | ||
{ | ||
RUNTIME_ASSERT(exchange_receiver_map.find(executor_id) == exchange_receiver_map.end(), log, "Duplicate executor_id: {} in DAGRequest", executor_id); | ||
exchange_receiver_map[executor_id] = exchange_receiver; | ||
} | ||
|
||
void MPPReceiverSet::addCoprocessorReader(const CoprocessorReaderPtr & coprocessor_reader) | ||
{ | ||
coprocessor_readers.push_back(coprocessor_reader); | ||
} | ||
|
||
ExchangeReceiverPtr MPPReceiverSet::getExchangeReceiver(const String & executor_id) const | ||
{ | ||
auto it = exchange_receiver_map.find(executor_id); | ||
if (unlikely(it == exchange_receiver_map.end())) | ||
return nullptr; | ||
return it->second; | ||
} | ||
|
||
void MPPReceiverSet::cancel() | ||
{ | ||
for (auto & it : exchange_receiver_map) | ||
{ | ||
it.second->cancel(); | ||
} | ||
for (auto & cop_reader : coprocessor_readers) | ||
cop_reader->cancel(); | ||
} | ||
} // namespace DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2022 PingCAP, Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <Flash/Coprocessor/CoprocessorReader.h> | ||
#include <Flash/Coprocessor/DAGContext.h> | ||
|
||
namespace DB | ||
{ | ||
class MPPReceiverSet | ||
{ | ||
public: | ||
explicit MPPReceiverSet(const String & req_id) | ||
: log(Logger::get("MPPReceiverSet", req_id)) | ||
{} | ||
void addExchangeReceiver(const String & executor_id, const ExchangeReceiverPtr & exchange_receiver); | ||
void addCoprocessorReader(const CoprocessorReaderPtr & coprocessor_reader); | ||
ExchangeReceiverPtr getExchangeReceiver(const String & executor_id) const; | ||
void cancel(); | ||
|
||
private: | ||
/// two kinds of receiver in MPP | ||
/// ExchangeReceiver: receiver data from other MPPTask | ||
/// CoprocessorReader: used in remote read | ||
ExchangeReceiverMap exchange_receiver_map; | ||
std::vector<CoprocessorReaderPtr> coprocessor_readers; | ||
const LoggerPtr log; | ||
}; | ||
|
||
using MPPReceiverSetPtr = std::shared_ptr<MPPReceiverSet>; | ||
|
||
} // namespace DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters