27
27
import java .io .IOException ;
28
28
import java .util .Objects ;
29
29
30
- import static org .elasticsearch .common .xcontent .ConstructingObjectParser .constructorArg ;
31
30
import static org .elasticsearch .common .xcontent .ConstructingObjectParser .optionalConstructorArg ;
32
31
33
32
public class TransformIndexerStats extends IndexerJobStats {
@@ -39,21 +38,38 @@ public class TransformIndexerStats extends IndexerJobStats {
39
38
public static final ConstructingObjectParser <TransformIndexerStats , Void > LENIENT_PARSER = new ConstructingObjectParser <>(
40
39
NAME ,
41
40
true ,
42
- args -> new TransformIndexerStats ((long ) args [0 ], (long ) args [1 ], (long ) args [2 ],
43
- (long ) args [3 ], (long ) args [4 ], (long ) args [5 ], (long ) args [6 ], (long ) args [7 ], (long ) args [8 ], (long ) args [9 ],
44
- (Double ) args [10 ], (Double ) args [11 ], (Double ) args [12 ]));
41
+ args -> new TransformIndexerStats (
42
+ unboxSafe (args [0 ], 0L ),
43
+ unboxSafe (args [1 ], 0L ),
44
+ unboxSafe (args [2 ], 0L ),
45
+ unboxSafe (args [3 ], 0L ),
46
+ unboxSafe (args [4 ], 0L ),
47
+ unboxSafe (args [5 ], 0L ),
48
+ unboxSafe (args [6 ], 0L ),
49
+ unboxSafe (args [7 ], 0L ),
50
+ unboxSafe (args [8 ], 0L ),
51
+ unboxSafe (args [9 ], 0L ),
52
+ unboxSafe (args [10 ], 0L ),
53
+ unboxSafe (args [11 ], 0L ),
54
+ unboxSafe (args [12 ], 0.0 ),
55
+ unboxSafe (args [13 ], 0.0 ),
56
+ unboxSafe (args [14 ], 0.0 )
57
+ )
58
+ );
45
59
46
60
static {
47
- LENIENT_PARSER .declareLong (constructorArg (), NUM_PAGES );
48
- LENIENT_PARSER .declareLong (constructorArg (), NUM_INPUT_DOCUMENTS );
49
- LENIENT_PARSER .declareLong (constructorArg (), NUM_OUTPUT_DOCUMENTS );
50
- LENIENT_PARSER .declareLong (constructorArg (), NUM_INVOCATIONS );
51
- LENIENT_PARSER .declareLong (constructorArg (), INDEX_TIME_IN_MS );
52
- LENIENT_PARSER .declareLong (constructorArg (), SEARCH_TIME_IN_MS );
53
- LENIENT_PARSER .declareLong (constructorArg (), INDEX_TOTAL );
54
- LENIENT_PARSER .declareLong (constructorArg (), SEARCH_TOTAL );
55
- LENIENT_PARSER .declareLong (constructorArg (), INDEX_FAILURES );
56
- LENIENT_PARSER .declareLong (constructorArg (), SEARCH_FAILURES );
61
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), NUM_PAGES );
62
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), NUM_INPUT_DOCUMENTS );
63
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), NUM_OUTPUT_DOCUMENTS );
64
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), NUM_INVOCATIONS );
65
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), INDEX_TIME_IN_MS );
66
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), SEARCH_TIME_IN_MS );
67
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), PROCESSING_TIME_IN_MS );
68
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), INDEX_TOTAL );
69
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), SEARCH_TOTAL );
70
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), PROCESSING_TOTAL );
71
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), INDEX_FAILURES );
72
+ LENIENT_PARSER .declareLong (optionalConstructorArg (), SEARCH_FAILURES );
57
73
LENIENT_PARSER .declareDouble (optionalConstructorArg (), EXPONENTIAL_AVG_CHECKPOINT_DURATION_MS );
58
74
LENIENT_PARSER .declareDouble (optionalConstructorArg (), EXPONENTIAL_AVG_DOCUMENTS_INDEXED );
59
75
LENIENT_PARSER .declareDouble (optionalConstructorArg (), EXPONENTIAL_AVG_DOCUMENTS_PROCESSED );
@@ -67,16 +83,40 @@ public static TransformIndexerStats fromXContent(XContentParser parser) throws I
67
83
private final double expAvgDocumentsIndexed ;
68
84
private final double expAvgDocumentsProcessed ;
69
85
70
- public TransformIndexerStats (long numPages , long numInputDocuments , long numOuputDocuments ,
71
- long numInvocations , long indexTime , long searchTime ,
72
- long indexTotal , long searchTotal , long indexFailures , long searchFailures ,
73
- Double expAvgCheckpointDurationMs , Double expAvgDocumentsIndexed ,
74
- Double expAvgDocumentsProcessed ) {
75
- super (numPages , numInputDocuments , numOuputDocuments , numInvocations , indexTime , searchTime ,
76
- indexTotal , searchTotal , indexFailures , searchFailures );
77
- this .expAvgCheckpointDurationMs = expAvgCheckpointDurationMs == null ? 0.0 : expAvgCheckpointDurationMs ;
78
- this .expAvgDocumentsIndexed = expAvgDocumentsIndexed == null ? 0.0 : expAvgDocumentsIndexed ;
79
- this .expAvgDocumentsProcessed = expAvgDocumentsProcessed == null ? 0.0 : expAvgDocumentsProcessed ;
86
+ public TransformIndexerStats (
87
+ long numPages ,
88
+ long numInputDocuments ,
89
+ long numOuputDocuments ,
90
+ long numInvocations ,
91
+ long indexTime ,
92
+ long searchTime ,
93
+ long processingTime ,
94
+ long indexTotal ,
95
+ long searchTotal ,
96
+ long processingTotal ,
97
+ long indexFailures ,
98
+ long searchFailures ,
99
+ double expAvgCheckpointDurationMs ,
100
+ double expAvgDocumentsIndexed ,
101
+ double expAvgDocumentsProcessed
102
+ ) {
103
+ super (
104
+ numPages ,
105
+ numInputDocuments ,
106
+ numOuputDocuments ,
107
+ numInvocations ,
108
+ indexTime ,
109
+ searchTime ,
110
+ processingTime ,
111
+ indexTotal ,
112
+ searchTotal ,
113
+ processingTotal ,
114
+ indexFailures ,
115
+ searchFailures
116
+ );
117
+ this .expAvgCheckpointDurationMs = expAvgCheckpointDurationMs ;
118
+ this .expAvgDocumentsIndexed = expAvgDocumentsIndexed ;
119
+ this .expAvgDocumentsProcessed = expAvgDocumentsProcessed ;
80
120
}
81
121
82
122
public double getExpAvgCheckpointDurationMs () {
@@ -109,19 +149,44 @@ public boolean equals(Object other) {
109
149
&& Objects .equals (this .numInvocations , that .numInvocations )
110
150
&& Objects .equals (this .indexTime , that .indexTime )
111
151
&& Objects .equals (this .searchTime , that .searchTime )
152
+ && Objects .equals (this .processingTime , that .processingTime )
112
153
&& Objects .equals (this .indexFailures , that .indexFailures )
113
154
&& Objects .equals (this .searchFailures , that .searchFailures )
114
155
&& Objects .equals (this .indexTotal , that .indexTotal )
115
156
&& Objects .equals (this .searchTotal , that .searchTotal )
157
+ && Objects .equals (this .processingTotal , that .processingTotal )
116
158
&& Objects .equals (this .expAvgCheckpointDurationMs , that .expAvgCheckpointDurationMs )
117
159
&& Objects .equals (this .expAvgDocumentsIndexed , that .expAvgDocumentsIndexed )
118
160
&& Objects .equals (this .expAvgDocumentsProcessed , that .expAvgDocumentsProcessed );
119
161
}
120
162
121
163
@ Override
122
164
public int hashCode () {
123
- return Objects .hash (numPages , numInputDocuments , numOuputDocuments , numInvocations ,
124
- indexTime , searchTime , indexFailures , searchFailures , indexTotal , searchTotal ,
125
- expAvgCheckpointDurationMs , expAvgDocumentsIndexed , expAvgDocumentsProcessed );
165
+ return Objects .hash (
166
+ numPages ,
167
+ numInputDocuments ,
168
+ numOuputDocuments ,
169
+ numInvocations ,
170
+ indexTime ,
171
+ searchTime ,
172
+ processingTime ,
173
+ indexFailures ,
174
+ searchFailures ,
175
+ indexTotal ,
176
+ searchTotal ,
177
+ processingTotal ,
178
+ expAvgCheckpointDurationMs ,
179
+ expAvgDocumentsIndexed ,
180
+ expAvgDocumentsProcessed
181
+ );
182
+ }
183
+
184
+ @ SuppressWarnings ("unchecked" )
185
+ private static <T > T unboxSafe (Object l , T default_value ) {
186
+ if (l == null ) {
187
+ return default_value ;
188
+ } else {
189
+ return (T ) l ;
190
+ }
126
191
}
127
192
}
0 commit comments