-
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.
Migrate table scan related code to
DAGStorageInterpreter
(#4783)
ref #4118
- Loading branch information
Showing
12 changed files
with
529 additions
and
372 deletions.
There are no files selected for viewing
298 changes: 4 additions & 294 deletions
298
dbms/src/Flash/Coprocessor/DAGQueryBlockInterpreter.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,65 @@ | ||
// 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 <Common/TiFlashException.h> | ||
#include <Flash/Coprocessor/PushDownFilter.h> | ||
#include <common/likely.h> | ||
|
||
namespace DB | ||
{ | ||
PushDownFilter::PushDownFilter( | ||
const String & executor_id_, | ||
const std::vector<const tipb::Expr *> & conditions_) | ||
: executor_id(executor_id_) | ||
, conditions(conditions_) | ||
{ | ||
if (unlikely(conditions.empty() != executor_id.empty())) | ||
{ | ||
throw TiFlashException( | ||
"for PushDownFilter, conditions and executor_id should both be empty or neither should be empty", | ||
Errors::Coprocessor::BadRequest); | ||
} | ||
} | ||
|
||
tipb::Executor * PushDownFilter::constructSelectionForRemoteRead(tipb::Executor * mutable_executor) const | ||
{ | ||
if (hasValue()) | ||
{ | ||
mutable_executor->set_tp(tipb::ExecType::TypeSelection); | ||
mutable_executor->set_executor_id(executor_id); | ||
auto * new_selection = mutable_executor->mutable_selection(); | ||
for (const auto & condition : conditions) | ||
*new_selection->add_conditions() = *condition; | ||
return new_selection->mutable_child(); | ||
} | ||
else | ||
{ | ||
return mutable_executor; | ||
} | ||
} | ||
|
||
PushDownFilter PushDownFilter::toPushDownFilter(const tipb::Executor * filter_executor) | ||
{ | ||
if (!filter_executor || !filter_executor->has_selection()) | ||
{ | ||
return {"", {}}; | ||
} | ||
|
||
std::vector<const tipb::Expr *> conditions; | ||
for (const auto & condition : filter_executor->selection().conditions()) | ||
conditions.push_back(&condition); | ||
|
||
return {filter_executor->executor_id(), conditions}; | ||
} | ||
} // 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,39 @@ | ||
// 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 <common/types.h> | ||
#include <tipb/executor.pb.h> | ||
|
||
#include <vector> | ||
|
||
namespace DB | ||
{ | ||
struct PushDownFilter | ||
{ | ||
static PushDownFilter toPushDownFilter(const tipb::Executor * filter_executor); | ||
|
||
PushDownFilter( | ||
const String & executor_id_, | ||
const std::vector<const tipb::Expr *> & conditions_); | ||
|
||
bool hasValue() const { return !conditions.empty(); } | ||
|
||
tipb::Executor * constructSelectionForRemoteRead(tipb::Executor * mutable_executor) const; | ||
|
||
String executor_id; | ||
std::vector<const tipb::Expr *> conditions; | ||
}; | ||
} // 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
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