1#ifndef CPARK_SAMPLE_RDD_H
2#define CPARK_SAMPLE_RDD_H
26template <concepts::Rdd R>
27requires std::invocable<std::function<bool(
int)>, utils::RddElementType<R>>&& std::is_convertible_v<
28 std::invoke_result_t<std::function<
bool(
int)>, utils::RddElementType<R>>,
bool>
class SampleRdd
29 :
public BaseRdd<SampleRdd<R>> {
42 "Instance of SampleRdd does not satisfy Rdd concept.");
58 constexpr auto beginImpl()
const {
return std::ranges::begin(splits_); }
60 constexpr auto endImpl()
const {
return std::ranges::end(splits_); }
64 std::function<bool(
int)> func = [
this](
int i) {
65 std::random_device rd;
66 std::mt19937 gen(rd());
67 std::bernoulli_distribution d(fraction_);
70 std::vector<ViewSplit<FilterView<std::ranges::range_value_t<R>, std::function<bool(
int)>>>>
80 template <concepts::Rdd R,
typename T = utils::RddElementType<R>>
81 requires std::invocable<std::function<
bool(
int)>,
T>&&
82 std::is_same_v<std::invoke_result_t<std::function<
bool(
int)>,
T>,
bool>
auto
83 operator()(
const R&
r)
const {
94template <concepts::Rdd R>
Definition base_rdd.h:522
Definition filter_rdd.h:28
Definition sample_rdd.h:77
Definition sample_rdd.h:29
constexpr SampleRdd(const R &prev, double fraction)
Definition sample_rdd.h:40
auto operator|(const R &r, const Collect &collect)
Definition collect.h:48