-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapReduceClient.h
More file actions
88 lines (73 loc) · 1.7 KB
/
MapReduceClient.h
File metadata and controls
88 lines (73 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef MAPREDUCECLIENT_H
#define MAPREDUCECLIENT_H
#include <vector>
#include <utility>
// ======================[ Key/Value Base Classes ]==================
/**
* @brief Base class for input key.
*/
class K1 {
public:
virtual ~K1() {}
virtual bool operator<(const K1& other) const = 0;
};
/**
* @brief Base class for input value.
*/
class V1 {
public:
virtual ~V1() {}
};
/**
* @brief Base class for intermediate key.
*/
class K2 {
public:
virtual ~K2() {}
virtual bool operator<(const K2& other) const = 0;
};
/**
* @brief Base class for intermediate value.
*/
class V2 {
public:
virtual ~V2() {}
};
/**
* @brief Base class for output key.
*/
class K3 {
public:
virtual ~K3() {}
virtual bool operator<(const K3& other) const = 0;
};
/**
* @brief Base class for output value.
*/
class V3 {
public:
virtual ~V3() {}
};
// ======================[ Type Definitions ]========================
typedef std::pair<K1*, V1*> InputPair;
typedef std::pair<K2*, V2*> IntermediatePair;
typedef std::pair<K3*, V3*> OutputPair;
typedef std::vector<InputPair> InputVec;
typedef std::vector<IntermediatePair> IntermediateVec;
typedef std::vector<OutputPair> OutputVec;
// ======================[ MapReduceClient Interface ]===============
/**
* @brief Abstract base class for user MapReduce implementation.
*/
class MapReduceClient {
public:
/**
* @brief Map function: emits (K2, V2) pairs via emit2.
*/
virtual void map(const K1* key, const V1* value, void* context) const = 0;
/**
* @brief Reduce function: emits (K3, V3) pairs via emit3.
*/
virtual void reduce(const IntermediateVec* pairs, void* context) const = 0;
};
#endif // MAPREDUCECLIENT_H