1#ifndef CPARK_PARTITION_BY_RDD_H
2#define CPARK_PARTITION_BY_RDD_H
9#include "merged_view.h"
29template <concepts::KeyValueRdd R,
typename Partitioner = std::hash<utils::RddKeyType<R>>>
41 for (
size_t i : std::views::iota(0
u, Base::splits_num_)) {
44 splits_.emplace_back(std::move(
split_view), Base::context_);
46 splits_.back().addDependency(
split);
63 constexpr auto beginImpl()
const {
return std::ranges::begin(splits_); }
66 constexpr auto endImpl()
const {
return std::ranges::end(splits_); }
73 class PartitionerHelper {
81 PartitionerHelper(
size_t split_index,
size_t splits_num, Partitioner* partitioner)
82 : split_index_{split_index}, splits_num_{splits_num}, partitioner_{partitioner} {}
87 bool operator()(
const utils::RddElementType<R>& x)
const {
88 return (*partitioner_)(x.first) % splits_num_ == split_index_;
92 size_t split_index_, splits_num_;
93 Partitioner* partitioner_;
97 std::vector<ViewSplit<FilterView<MergedSameView<R>, PartitionerHelper>>> splits_;
98 Partitioner partitioner_;
101template <
typename... Args>
107template <
typename Partitioner>
112 template <concepts::Rdd R,
typename K = utils::RddKeyType<R>>
113 requires std::invocable<Partitioner, K> &&
114 std::convertible_to<std::invoke_result_t<Partitioner, K>,
size_t>
115 auto operator()(
const R&
r)
const {
129 template <concepts::Rdd R>
130 auto operator()(
const R&
r)
const {
136template <cpark::concepts::Rdd R,
typename P>
Definition base_rdd.h:522
Definition filter_rdd.h:28
Definition merged_view.h:22
Definition partition_by_rdd.h:102
Definition partition_by_rdd.h:30
PartitionByRdd(const PartitionByRdd &)=default
PartitionByRdd(const R &prev)
Definition partition_by_rdd.h:55
PartitionByRdd(const R &prev, Partitioner partitioner)
Definition partition_by_rdd.h:39
auto operator|(const R &r, const Collect &collect)
Definition collect.h:48