|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
6
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
7
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
8
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
9
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
10
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
11
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
12
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
13
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
14
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
15
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace Ytake\PrestoClient; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class StatementStats |
|
22
|
|
|
* |
|
23
|
|
|
* @author Yuuki Takezawa <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
final class StatementStats |
|
26
|
|
|
{ |
|
27
|
|
|
/** @var string */ |
|
28
|
|
|
private $state = ''; |
|
29
|
|
|
|
|
30
|
|
|
/** @var bool */ |
|
31
|
|
|
private $queued; |
|
32
|
|
|
|
|
33
|
|
|
/** @var bool */ |
|
34
|
|
|
private $scheduled; |
|
35
|
|
|
|
|
36
|
|
|
/** @var int */ |
|
37
|
|
|
private $nodes; |
|
38
|
|
|
|
|
39
|
|
|
/** @var int */ |
|
40
|
|
|
private $totalSplits; |
|
41
|
|
|
|
|
42
|
|
|
/** @var int */ |
|
43
|
|
|
private $queuedSplits; |
|
44
|
|
|
|
|
45
|
|
|
/** @var int */ |
|
46
|
|
|
private $runningSplits; |
|
47
|
|
|
|
|
48
|
|
|
/** @var int */ |
|
49
|
|
|
private $completedSplits; |
|
50
|
|
|
|
|
51
|
|
|
/** @var int */ |
|
52
|
|
|
private $userTimeMillis; |
|
53
|
|
|
|
|
54
|
|
|
/** @var int */ |
|
55
|
|
|
private $cpuTimeMillis; |
|
56
|
|
|
|
|
57
|
|
|
/** @var int */ |
|
58
|
|
|
private $wallTimeMillis; |
|
59
|
|
|
|
|
60
|
|
|
/** @var int */ |
|
61
|
|
|
private $processedRows; |
|
62
|
|
|
|
|
63
|
|
|
/** @var int */ |
|
64
|
|
|
private $processedBytes; |
|
65
|
|
|
|
|
66
|
|
|
/** @var \stdClass */ |
|
67
|
|
|
private $rootStage; |
|
68
|
|
|
|
|
69
|
|
|
/** @var string[] */ |
|
70
|
|
|
private $primitiveCasts = [ |
|
71
|
|
|
'state' => 'strval', |
|
72
|
|
|
'queued' => 'boolval', |
|
73
|
|
|
'scheduled' => 'boolval', |
|
74
|
|
|
'nodes' => 'intval', |
|
75
|
|
|
'totalSplits' => 'intval', |
|
76
|
|
|
'queuedSplits' => 'intval', |
|
77
|
|
|
'runningSplits' => 'intval', |
|
78
|
|
|
'completedSplits' => 'intval', |
|
79
|
|
|
'userTimeMillis' => 'intval', |
|
80
|
|
|
'cpuTimeMillis' => 'intval', |
|
81
|
|
|
'wallTimeMillis' => 'intval', |
|
82
|
|
|
'processedRows' => 'intval', |
|
83
|
|
|
'processedBytes' => 'intval', |
|
84
|
|
|
]; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* StatementStats constructor. |
|
88
|
|
|
* |
|
89
|
|
|
* @param \stdClass $jsonContent |
|
90
|
|
|
*/ |
|
91
|
|
|
public function __construct(\stdClass $jsonContent) |
|
92
|
|
|
{ |
|
93
|
|
|
$arrayContent = (array)$jsonContent; |
|
94
|
|
|
foreach ($arrayContent as $element => $value) { |
|
95
|
|
|
if (property_exists($this, $element)) { |
|
96
|
|
|
if (isset($this->primitiveCasts[$element])) { |
|
97
|
|
|
$castFunction = $this->primitiveCasts[$element]; |
|
98
|
|
|
$this->$element = $castFunction($value); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
if (isset($jsonContent->rootStage)) { |
|
103
|
|
|
$this->rootStage = $jsonContent->rootStage; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return string |
|
109
|
|
|
*/ |
|
110
|
|
|
public function getState(): string |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->state; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @return bool |
|
117
|
|
|
*/ |
|
118
|
|
|
public function isQueued(): bool |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->queued; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return bool |
|
125
|
|
|
*/ |
|
126
|
|
|
public function isScheduled(): bool |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->scheduled; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return int |
|
133
|
|
|
*/ |
|
134
|
|
|
public function getNodes(): int |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->nodes; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return int |
|
141
|
|
|
*/ |
|
142
|
|
|
public function getTotalSplits(): int |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->totalSplits; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @return int |
|
149
|
|
|
*/ |
|
150
|
|
|
public function getQueuedSplits(): int |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->queuedSplits; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @return int |
|
157
|
|
|
*/ |
|
158
|
|
|
public function getRunningSplits(): int |
|
159
|
|
|
{ |
|
160
|
|
|
return $this->runningSplits; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @return int |
|
165
|
|
|
*/ |
|
166
|
|
|
public function getCompletedSplits(): int |
|
167
|
|
|
{ |
|
168
|
|
|
return $this->completedSplits; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @return int |
|
173
|
|
|
*/ |
|
174
|
|
|
public function getUserTimeMillis(): int |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->userTimeMillis; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @return int |
|
181
|
|
|
*/ |
|
182
|
|
|
public function getCpuTimeMillis(): int |
|
183
|
|
|
{ |
|
184
|
|
|
return $this->cpuTimeMillis; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* @return int |
|
189
|
|
|
*/ |
|
190
|
|
|
public function getWallTimeMillis(): int |
|
191
|
|
|
{ |
|
192
|
|
|
return $this->wallTimeMillis; |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* @return int |
|
197
|
|
|
*/ |
|
198
|
|
|
public function getProcessedRows(): int |
|
199
|
|
|
{ |
|
200
|
|
|
return $this->processedRows; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* @return int |
|
205
|
|
|
*/ |
|
206
|
|
|
public function getProcessedBytes(): int |
|
207
|
|
|
{ |
|
208
|
|
|
return $this->processedBytes; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* @return \stdClass|null |
|
213
|
|
|
*/ |
|
214
|
|
|
public function getRootStage() |
|
215
|
|
|
{ |
|
216
|
|
|
return $this->rootStage; |
|
217
|
|
|
} |
|
218
|
|
|
} |
|
219
|
|
|
|