CPARK 1.0
A light-weighted, distributed computing framework for C++ that offers a fast and general-purpose large data processing solution.
Loading...
Searching...
No Matches
utils.h
1// Contains small utility classes and functions for cpark.
2
3#ifndef CPARK_UTILS_H
4#define CPARK_UTILS_H
5
6#include <ostream>
7
8namespace cpark {
9
10namespace utils {
11
13class NullOStream : public std::ostream {
14private:
15 class NullBuffer : public std::streambuf {
16 public:
17 int overflow(int c) override { return c; }
18 };
19
20 inline static NullBuffer g_null_buffer_;
21
22public:
23 NullOStream() : std::ostream(&g_null_buffer_) {}
24};
25
26inline static NullOStream g_null_ostream;
27
29template <typename R>
30using RddElementType = std::ranges::range_value_t<std::ranges::range_value_t<R>>;
31
32template <typename R>
33using RddKeyType = decltype(std::declval<RddElementType<R>>().first);
34
35template <typename R>
36using RddValueType = decltype(std::declval<RddElementType<R>>().second);
37
38namespace {
39
40template <typename Iterator>
41struct GetIteratorTagImpl {};
42
43template <typename Iterator>
44requires std::forward_iterator<Iterator> struct GetIteratorTagImpl<Iterator> {
45 using type = std::forward_iterator_tag;
46};
47
48template <typename Iterator>
49requires std::bidirectional_iterator<Iterator> struct GetIteratorTagImpl<Iterator> {
50 using type = std::bidirectional_iterator_tag;
51};
52
53template <typename Iterator>
54requires std::random_access_iterator<Iterator> struct GetIteratorTagImpl<Iterator> {
55 using type = std::random_access_iterator_tag;
56};
57
58} // namespace
59
61template <typename Iterator>
62using GetIteratorTagType = typename GetIteratorTagImpl<Iterator>::type;
63
64} // namespace utils
65
66} // namespace cpark
67
68#endif // CPARK_UTILS_H
Definition base_rdd.h:94
Definition utils.h:13