-
Notifications
You must be signed in to change notification settings - Fork 4
/
mapreduceresult.h
113 lines (96 loc) · 2.39 KB
/
mapreduceresult.h
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
* mapreduceresult.h
*
* PHP results class to retrieve the results from a map/reduce job
*
* @author Aljar Meesters <[email protected]>
* @copyright 2015 Copernica BV
*/
/**
* include guard
*/
#pragma once
/**
* Dependencies
*/
#include "stats.h"
/**
* Class definition
*/
class MapReduceResult : public Php::Base
{
protected:
/**
* JSON object holding all properties
* @var JSON::Object
*/
JSON::Object _json;
public:
/**
* Constructor
* @param output
*/
MapReduceResult(const JSON::Object &output) : _json(output) {}
/**
* Destructor
*/
virtual ~MapReduceResult() = default;
/**
* Get the time when the job is started
* @return Php::Value
*/
Php::Value started() const
{
return _json.decimal("started");
}
/**
* Get the time when the job is finished
*
* @return Value-wrapped decimal value (unix timestamp with sub-second precision)
*/
Php::Value finished() const
{
return _json.decimal("finished");
}
/**
* Get the total runtime
* @return Php::Value
*/
Php::Value runtime() const
{
return _json.decimal("runtime");
}
/**
* Get the stats of mapper
* @return Php::Value
*/
Php::Value mappers() const
{
// return nullptr in case we don't have a mappers json object
if (!_json.isObject("mappers")) return nullptr;
// construct and return a Yothalot\Stats object
return Php::Object("Yothalot\\Stats", new Stats(_json.object("mappers")));
}
/**
* Get the stats of the reducer
* @return Php::Value
*/
Php::Value reducers() const
{
// return nullptr in case we don't have a reducers json object
if (!_json.isObject("reducers")) return nullptr;
// construct and return a Yothalot\Stats object
return Php::Object("Yothalot\\Stats", new Stats(_json.object("reducers")));
}
/**
* Get the stats of the finalizer
* @return Php::Value
*/
Php::Value finalizers() const
{
// return nullptr in case we don't have a finalizers json object
if (!_json.isObject("finalizers")) return nullptr;
// construct and return a Yothalot\Stats object
return Php::Object("Yothalot\\Stats", new Stats(_json.object("finalizers")));
}
};