-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapReduceClient.h
More file actions
77 lines (62 loc) · 1.74 KB
/
Copy pathMapReduceClient.h
File metadata and controls
77 lines (62 loc) · 1.74 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
#ifndef MAPREDUCECLIENT_H
#define MAPREDUCECLIENT_H
#include <vector> //std::vector
#include <map> //std::map
#include <utility> //std::pair
// input key and value.
// the key, value for the map function and the MapReduceFramework
class K1 {
public:
virtual ~K1(){}
virtual bool operator<(const K1 &other) const = 0;
};
class V1 {
public:
virtual ~V1() {}
};
// intermediate key and value.
// the key, value for the Reduce function created by the Map function
class K2 {
public:
virtual ~K2(){}
virtual bool operator<(const K2 &other) const = 0;
};
class V2 {
public:
virtual ~V2(){}
};
// output key and value
// the key,value for the Reduce function created by the Map function
class K3 {
public:
virtual ~K3() {}
virtual bool operator<(const K3 &other) const = 0;
};
class V3 {
public:
virtual ~V3() {}
};
struct K2PointerComp {
bool operator()(const K2* first, const K2* second) const
{
return (*first < *second);
}
};
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::map<K2*, std::vector<V2 *>, K2PointerComp> IntermediateMap;
typedef std::vector<OutputPair> OutputVec;
class MapReduceClient {
public:
// gets a single pair (K1, V1) and calls emit2(K2,V2, context) any
// number of times to output (K2, V2) pairs.
virtual void map(const K1* key, const V1* value, void* context) const = 0;
// gets a single K2 key and a vector of all its respective V2 values
// calls emit3(K3, V3, context) any number of times (usually once)
// to output (K3, V3) pairs.
virtual void reduce(const K2* key, const std::vector<V2 *> &values, void*
context) const = 0;
};
#endif //MAPREDUCECLIENT_H