-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement] support phased schedule
Signed-off-by: stdpain <[email protected]>
- Loading branch information
Showing
54 changed files
with
2,034 additions
and
101 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
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.