-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MPPReceiverSet, which includes ExchangeReceiver and CoprocessorReader #5175
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c2d705
introduce MPPReceiverSet, which includes ExchangeReceiver and Coproce…
windtalker ec38331
fix
windtalker 8211048
address comments
windtalker 32cfe6c
Merge branch 'master' into add_mpp_receiver_set
ti-chi-bot 1f0d151
Merge branch 'master' into add_mpp_receiver_set
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check if exception thrown here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For both exchange receiver and coprocessor read, cancel is just set a flag, it should not throw exception.