-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Enhancement] support phased schedule #47868
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// 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 | ||
// | ||
// https://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 "exec/capture_version_node.h" | ||
|
||
#include "exec/pipeline/capture_version_operator.h" | ||
#include "exec/pipeline/pipeline_builder.h" | ||
|
||
namespace starrocks { | ||
|
||
pipeline::OpFactories CaptureVersionNode::decompose_to_pipeline(pipeline::PipelineBuilderContext* context) { | ||
return OpFactories{std::make_shared<pipeline::CaptureVersionOpFactory>(context->next_operator_id(), id())}; | ||
} | ||
|
||
StatusOr<pipeline::MorselQueueFactoryPtr> CaptureVersionNode::scan_range_to_morsel_queue_factory( | ||
const std::vector<TScanRangeParams>& scan_ranges) { | ||
pipeline::Morsels morsels; | ||
for (const auto& scan_range : scan_ranges) { | ||
morsels.emplace_back(std::make_unique<pipeline::ScanMorsel>(id(), scan_range)); | ||
} | ||
auto morsel_queue = std::make_unique<pipeline::FixedMorselQueue>(std::move(morsels)); | ||
return std::make_unique<pipeline::SharedMorselQueueFactory>(std::move(morsel_queue), 1); | ||
} | ||
|
||
} // namespace starrocks |
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,32 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// 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 | ||
// | ||
// https://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 "exec/exec_node.h" | ||
#include "exec/scan_node.h" | ||
|
||
namespace starrocks { | ||
class CaptureVersionNode final : public ExecNode { | ||
public: | ||
CaptureVersionNode(ObjectPool* pool, const TPlanNode& tnode, const DescriptorTbl& descs) | ||
: ExecNode(pool, tnode, descs) {} | ||
~CaptureVersionNode() override = default; | ||
|
||
StatusOr<pipeline::MorselQueueFactoryPtr> scan_range_to_morsel_queue_factory( | ||
const std::vector<TScanRangeParams>& global_scan_ranges); | ||
|
||
pipeline::OpFactories decompose_to_pipeline(pipeline::PipelineBuilderContext* context) override; | ||
}; | ||
} // namespace starrocks |
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,52 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// 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 | ||
// | ||
// https://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 "exec/pipeline/capture_version_operator.h" | ||
|
||
#include "common/logging.h" | ||
#include "exec/olap_scan_node.h" | ||
#include "runtime/runtime_state.h" | ||
#include "storage/rowset/rowset.h" | ||
#include "util/defer_op.h" | ||
|
||
namespace starrocks::pipeline { | ||
Status CaptureVersionOperator::prepare(RuntimeState* state) { | ||
RETURN_IF_ERROR(SourceOperator::prepare(state)); | ||
_capture_tablet_rowsets_timer = ADD_TIMER(_unique_metrics, "CaptureTabletRowsetsTime"); | ||
|
||
return Status::OK(); | ||
} | ||
|
||
StatusOr<ChunkPtr> CaptureVersionOperator::pull_chunk(RuntimeState* state) { | ||
// do capture rowset here | ||
auto defer = DeferOp([this]() { _is_finished = true; }); | ||
std::vector<std::vector<RowsetSharedPtr>> tablet_rowsets; | ||
|
||
{ | ||
SCOPED_TIMER(_capture_tablet_rowsets_timer); | ||
auto scan_rages = _morsel_queue->prepare_olap_scan_ranges(); | ||
std::vector<std::vector<RowsetSharedPtr>> tablet_rowsets; | ||
VLOG_QUERY << "capture rowset scan_ranges nums:" << scan_rages.size(); | ||
for (auto& scan_range : scan_rages) { | ||
ASSIGN_OR_RETURN(TabletSharedPtr tablet, OlapScanNode::get_tablet(scan_range)); | ||
ASSIGN_OR_RETURN(auto rowset, OlapScanNode::capture_tablet_rowsets(tablet, scan_range)); | ||
tablet_rowsets.emplace_back(std::move(rowset)); | ||
} | ||
// | ||
_rowset_release_guard = MultiRowsetReleaseGuard(std::move(tablet_rowsets), adopt_acquire_t{}); | ||
} | ||
return nullptr; | ||
} | ||
|
||
} // namespace starrocks::pipeline |
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,60 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// 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 | ||
// | ||
// https://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 "exec/pipeline/source_operator.h" | ||
#include "util/runtime_profile.h" | ||
|
||
namespace starrocks::pipeline { | ||
|
||
// CaptureVersion returns an empty result set. | ||
class CaptureVersionOperator final : public SourceOperator { | ||
public: | ||
CaptureVersionOperator(OperatorFactory* factory, int32_t id, int32_t plan_node_id, int32_t driver_sequence) | ||
: SourceOperator(factory, id, "capture_version", plan_node_id, false, driver_sequence) {} | ||
|
||
~CaptureVersionOperator() override = default; | ||
|
||
Status prepare(RuntimeState* state) override; | ||
|
||
bool has_output() const override { return !_is_finished; } | ||
|
||
bool is_finished() const override { return _is_finished; } | ||
|
||
StatusOr<ChunkPtr> pull_chunk(RuntimeState* state) override; | ||
|
||
private: | ||
MultiRowsetReleaseGuard _rowset_release_guard; | ||
RuntimeProfile::Counter* _capture_tablet_rowsets_timer = nullptr; | ||
bool _is_finished{}; | ||
}; | ||
|
||
class CaptureVersionOpFactory final : public SourceOperatorFactory { | ||
public: | ||
CaptureVersionOpFactory(int32_t id, int32_t plan_node_id) | ||
: SourceOperatorFactory(id, "capture_version", plan_node_id) {} | ||
|
||
~CaptureVersionOpFactory() override = default; | ||
|
||
OperatorPtr create(int32_t degree_of_parallelism, int32_t driver_sequence) override { | ||
return std::make_shared<CaptureVersionOperator>(this, _id, _plan_node_id, driver_sequence); | ||
} | ||
|
||
bool with_morsels() const override { return true; } | ||
|
||
SourceOperatorFactory::AdaptiveState adaptive_initial_state() const override { return AdaptiveState::ACTIVE; } | ||
}; | ||
|
||
} // namespace starrocks::pipeline |
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
Oops, something went wrong.
Oops, something went wrong.
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.
suggest to move RpcRunnable outerside of this function, or use a lambda instead?
although it is a legal syntax, however, it looks some weird.
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.
I will refator here after #48233 merged