Get all the even numbers from 0 to 50.
#include <iostream>
#include "filter_rdd.h"
#include "generator_rdd.h"
#include "sample_rdd.h"
template <cpark::concepts::Rdd R>
void printRdd(R rdd) {
for (const auto& x : split)
std::cout << x << "\t";
std::cout << std::endl;
}
std::cout << std::endl;
}
int main() {
using namespace cpark;
std::cout << "Generator rdd : " << std::endl;
0, 50 + 1, [](auto x) { return x; }, &default_context);
printRdd(generator_rdd);
auto even = [](int i) {
return 0 == i % 2;
};
std::cout << "Filter rdd (basic): " << std::endl;
auto filter_rdd_1 =
FilterRdd(generator_rdd, even);
printRdd(filter_rdd_1);
std::cout << "Filter rdd (operators): " << std::endl;
auto filter_rdd_2 = generator_rdd |
Filter(even);
printRdd(filter_rdd_2);
std::cout << "Sample rdd: " << std::endl;
auto sample_rdd =
SampleRdd(generator_rdd, 0.5);
printRdd(sample_rdd);
std::cout << "Sample rdd (operators): " << std::endl;
auto sample_rdd_2 = generator_rdd |
Sample(0.5);
printRdd(sample_rdd_2);
return 0;
}
Definition filter_rdd.h:161
Definition filter_rdd.h:120
Definition generator_rdd.h:27
Definition sample_rdd.h:77
Definition sample_rdd.h:29