MtasDataDoubleBasic.java.html
17 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MtasDataDoubleBasic.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">MTAS</a> > <a href="index.source.html" class="el_package">mtas.codec.util.collector</a> > <span class="el_source">MtasDataDoubleBasic.java</span></div><h1>MtasDataDoubleBasic.java</h1><pre class="source lang-java linenums">package mtas.codec.util.collector;
import java.io.IOException;
import java.util.Collections;
import java.util.SortedSet;
import org.apache.commons.lang.ArrayUtils;
import mtas.codec.util.CodecUtil;
/**
* The Class MtasDataDoubleBasic.
*/
public class MtasDataDoubleBasic extends MtasDataBasic<Double, Double> {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* Instantiates a new mtas data double basic.
*
* @param collectorType the collector type
* @param statsItems the stats items
* @param sortType the sort type
* @param sortDirection the sort direction
* @param start the start
* @param number the number
* @param subCollectorTypes the sub collector types
* @param subDataTypes the sub data types
* @param subStatsTypes the sub stats types
* @param subStatsItems the sub stats items
* @param subSortTypes the sub sort types
* @param subSortDirections the sub sort directions
* @param subStart the sub start
* @param subNumber the sub number
* @param segmentRegistration the segment registration
* @param boundary the boundary
* @throws IOException Signals that an I/O exception has occurred.
*/
public MtasDataDoubleBasic(String collectorType, SortedSet<String> statsItems,
String sortType, String sortDirection, Integer start, Integer number,
String[] subCollectorTypes, String[] subDataTypes, String[] subStatsTypes,
SortedSet<String>[] subStatsItems, String[] subSortTypes,
String[] subSortDirections, Integer[] subStart, Integer[] subNumber,
String segmentRegistration, String boundary) throws IOException {
<span class="nc" id="L45"> super(collectorType, CodecUtil.DATA_TYPE_DOUBLE, statsItems, sortType,</span>
sortDirection, start, number, subCollectorTypes, subDataTypes,
subStatsTypes, subStatsItems, subSortTypes, subSortDirections, subStart,
subNumber, new MtasDataDoubleOperations(), segmentRegistration,
boundary);
<span class="nc" id="L50"> }</span>
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#getItem(int)
*/
@Override
protected MtasDataItemDoubleBasic getItem(int i) {
<span class="nc bnc" id="L59" title="All 4 branches missed."> if (i >= 0 && i < size) {</span>
<span class="nc" id="L60"> return new MtasDataItemDoubleBasic(basicValueSumList[i],</span>
<span class="nc bnc" id="L61" title="All 2 branches missed."> basicValueNList[i], hasSub() ? subCollectorListNextLevel[i] : null,</span>
<span class="nc" id="L62"> getStatsItems(), sortType, sortDirection, errorNumber[i],</span>
errorList[i], sourceNumberList[i]);
} else {
<span class="nc" id="L65"> return null;</span>
}
}
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#add(long, long)
*/
@Override
public MtasDataCollector<?, ?> add(long valueSum, long valueN)
throws IOException {
<span class="nc" id="L77"> MtasDataCollector<?, ?> dataCollector = add(false);</span>
<span class="nc" id="L78"> setValue(newCurrentPosition, Double.valueOf(valueSum), valueN,</span>
newCurrentExisting);
<span class="nc" id="L80"> return dataCollector;</span>
}
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#add(long[], int)
*/
@Override
public MtasDataCollector<?, ?> add(long[] values, int number)
throws IOException {
<span class="nc" id="L91"> MtasDataCollector<?, ?> dataCollector = add(false);</span>
<span class="nc" id="L92"> Double[] newValues = new Double[number];</span>
<span class="nc bnc" id="L93" title="All 2 branches missed."> for (int i = 0; i < values.length; i++)</span>
<span class="nc" id="L94"> newValues[i] = Long.valueOf(values[i]).doubleValue();</span>
<span class="nc" id="L95"> setValue(newCurrentPosition, newValues, number, newCurrentExisting);</span>
<span class="nc" id="L96"> return dataCollector;</span>
}
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#add(double, long)
*/
@Override
public MtasDataCollector<?, ?> add(double valueSum, long valueN)
throws IOException {
<span class="nc" id="L107"> MtasDataCollector<?, ?> dataCollector = add(false);</span>
<span class="nc" id="L108"> setValue(newCurrentPosition, valueSum, valueN, newCurrentExisting);</span>
<span class="nc" id="L109"> return dataCollector;</span>
}
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#add(double[], int)
*/
@Override
public MtasDataCollector<?, ?> add(double[] values, int number)
throws IOException {
<span class="nc" id="L120"> MtasDataCollector<?, ?> dataCollector = add(false);</span>
<span class="nc" id="L121"> setValue(newCurrentPosition, ArrayUtils.toObject(values), number,</span>
newCurrentExisting);
<span class="nc" id="L123"> return dataCollector;</span>
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#add(java.lang.String[],
* long, long)
*/
@Override
public MtasDataCollector<?, ?> add(String key, long valueSum, long valueN)
throws IOException {
<span class="nc bnc" id="L136" title="All 2 branches missed."> if (key != null) {</span>
<span class="nc" id="L137"> MtasDataCollector<?, ?> subCollector = add(key, false);</span>
<span class="nc" id="L138"> setValue(newCurrentPosition, Double.valueOf(valueSum), valueN,</span>
newCurrentExisting);
<span class="nc" id="L140"> return subCollector;</span>
} else {
<span class="nc" id="L142"> return null;</span>
}
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#add(java.lang.String[],
* long[], int)
*/
@Override
public MtasDataCollector<?, ?> add(String key, long[] values, int number)
throws IOException {
<span class="nc bnc" id="L156" title="All 2 branches missed."> if (key != null) {</span>
<span class="nc" id="L157"> Double[] newValues = new Double[number];</span>
<span class="nc bnc" id="L158" title="All 2 branches missed."> for (int i = 0; i < values.length; i++)</span>
<span class="nc" id="L159"> newValues[i] = Long.valueOf(values[i]).doubleValue();</span>
<span class="nc" id="L160"> MtasDataCollector<?, ?> subCollector = add(key, false);</span>
<span class="nc" id="L161"> setValue(newCurrentPosition, newValues, number, newCurrentExisting);</span>
<span class="nc" id="L162"> return subCollector;</span>
} else {
<span class="nc" id="L164"> return null;</span>
}
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#add(java.lang.String[],
* double, long)
*/
@Override
public MtasDataCollector<?, ?> add(String key, double valueSum, long valueN)
throws IOException {
<span class="nc bnc" id="L178" title="All 2 branches missed."> if (key != null) {</span>
<span class="nc" id="L179"> MtasDataCollector<?, ?> subCollector = add(key, false);</span>
<span class="nc" id="L180"> setValue(newCurrentPosition, valueSum, valueN, newCurrentExisting);</span>
<span class="nc" id="L181"> return subCollector;</span>
} else {
<span class="nc" id="L183"> return null;</span>
}
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#add(java.lang.String[],
* double[], int)
*/
@Override
public MtasDataCollector<?, ?> add(String key, double[] values, int number)
throws IOException {
<span class="nc bnc" id="L197" title="All 2 branches missed."> if (key != null) {</span>
<span class="nc" id="L198"> MtasDataCollector<?, ?> subCollector = add(key, false);</span>
<span class="nc" id="L199"> setValue(newCurrentPosition, ArrayUtils.toObject(values), number,</span>
newCurrentExisting);
<span class="nc" id="L201"> return subCollector;</span>
} else {
<span class="nc" id="L203"> return null;</span>
}
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#compareForComputingSegment(
* java.lang.Number, java.lang.Number)
*/
@Override
protected boolean compareWithBoundary(Double value, Double boundary)
throws IOException {
<span class="nc bnc" id="L217" title="All 2 branches missed."> if (segmentRegistration.equals(SEGMENT_SORT_ASC)</span>
<span class="nc bnc" id="L218" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_ASC)) {</span>
<span class="nc bnc" id="L219" title="All 2 branches missed."> return value <= boundary;</span>
<span class="nc bnc" id="L220" title="All 2 branches missed."> } else if (segmentRegistration.equals(SEGMENT_SORT_DESC)</span>
<span class="nc bnc" id="L221" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_DESC)) {</span>
<span class="nc bnc" id="L222" title="All 2 branches missed."> return value >= boundary;</span>
} else {
<span class="nc" id="L224"> throw new IOException(</span>
"can't compare for segmentRegistration " + segmentRegistration);
}
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#minimumForComputingSegment(
* java.lang.Number, java.lang.Number)
*/
@Override
protected Double lastForComputingSegment(Double value, Double boundary)
throws IOException {
<span class="nc bnc" id="L239" title="All 2 branches missed."> if (segmentRegistration.equals(SEGMENT_SORT_ASC)) {</span>
<span class="nc" id="L240"> return Math.max(value, boundary);</span>
<span class="nc bnc" id="L241" title="All 2 branches missed."> } else if (segmentRegistration.equals(SEGMENT_SORT_DESC)) {</span>
<span class="nc" id="L242"> return Math.min(value, boundary);</span>
} else {
<span class="nc" id="L244"> throw new IOException(</span>
"can't compute last for segmentRegistration " + segmentRegistration);
}
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#minimumForComputingSegment(
* )
*/
@Override
protected Double lastForComputingSegment() throws IOException {
<span class="nc bnc" id="L258" title="All 2 branches missed."> if (segmentRegistration.equals(SEGMENT_SORT_ASC)</span>
<span class="nc bnc" id="L259" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_ASC)) {</span>
<span class="nc" id="L260"> return Collections.max(segmentValueTopList);</span>
<span class="nc bnc" id="L261" title="All 2 branches missed."> } else if (segmentRegistration.equals(SEGMENT_SORT_DESC)</span>
<span class="nc bnc" id="L262" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_DESC)) {</span>
<span class="nc" id="L263"> return Collections.min(segmentValueTopList);</span>
} else {
<span class="nc" id="L265"> throw new IOException(</span>
"can't compute last for segmentRegistration " + segmentRegistration);
}
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#boundaryForComputingSegment
* ()
*/
@Override
protected Double boundaryForSegmentComputing(String segmentName)
throws IOException {
<span class="nc bnc" id="L280" title="All 2 branches missed."> if (segmentRegistration.equals(SEGMENT_SORT_ASC)</span>
<span class="nc bnc" id="L281" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_SORT_DESC)) {</span>
<span class="nc" id="L282"> Double boundary = boundaryForSegment(segmentName);</span>
<span class="nc bnc" id="L283" title="All 2 branches missed."> if (boundary == null) {</span>
<span class="nc" id="L284"> return null;</span>
} else {
<span class="nc bnc" id="L286" title="All 2 branches missed."> if (segmentRegistration.equals(SEGMENT_SORT_DESC)) {</span>
<span class="nc" id="L287"> long correctionBoundary = 0;</span>
<span class="nc bnc" id="L288" title="All 2 branches missed."> for (String otherSegmentName : segmentValueTopListLast.keySet()) {</span>
<span class="nc bnc" id="L289" title="All 2 branches missed."> if (!otherSegmentName.equals(segmentName)) {</span>
<span class="nc" id="L290"> Double otherBoundary = segmentValuesBoundary</span>
<span class="nc" id="L291"> .get(otherSegmentName);</span>
<span class="nc bnc" id="L292" title="All 2 branches missed."> if (otherBoundary != null) {</span>
<span class="nc" id="L293"> correctionBoundary += Math.max(0, otherBoundary - boundary);</span>
}
}
<span class="nc" id="L296"> }</span>
<span class="nc" id="L297"> return boundary + correctionBoundary;</span>
} else {
<span class="nc" id="L299"> return boundary;</span>
}
}
} else {
<span class="nc" id="L303"> throw new IOException("can't compute boundary for segmentRegistration "</span>
+ segmentRegistration);
}
}
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#boundaryForSegment()
*/
@Override
protected Double boundaryForSegment(String segmentName) throws IOException {
<span class="nc bnc" id="L315" title="All 2 branches missed."> if (segmentRegistration.equals(SEGMENT_SORT_ASC)</span>
<span class="nc bnc" id="L316" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_SORT_DESC)) {</span>
<span class="nc" id="L317"> Double thisLast = segmentValueTopListLast.get(segmentName);</span>
<span class="nc bnc" id="L318" title="All 2 branches missed."> if (thisLast == null) {</span>
<span class="nc" id="L319"> return null;</span>
<span class="nc bnc" id="L320" title="All 2 branches missed."> } else if (segmentRegistration.equals(SEGMENT_SORT_ASC)) {</span>
<span class="nc" id="L321"> return thisLast * segmentNumber;</span>
} else {
<span class="nc" id="L323"> return thisLast / segmentNumber;</span>
}
} else {
<span class="nc" id="L326"> throw new IOException("can't compute boundary for segmentRegistration "</span>
+ segmentRegistration);
}
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.collector.MtasDataCollector#stringToBoundary(java.lang.
* String, java.lang.Integer)
*/
@Override
protected Double stringToBoundary(String boundary, Integer segmentNumber)
throws IOException {
<span class="nc bnc" id="L341" title="All 2 branches missed."> if (segmentRegistration.equals(SEGMENT_BOUNDARY_ASC)</span>
<span class="nc bnc" id="L342" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_DESC)) {</span>
<span class="nc bnc" id="L343" title="All 2 branches missed."> if (segmentNumber == null) {</span>
<span class="nc" id="L344"> return Double.valueOf(boundary);</span>
} else {
<span class="nc" id="L346"> return Double.valueOf(boundary) / segmentNumber;</span>
}
} else {
<span class="nc" id="L349"> throw new IOException(</span>
"not available for segmentRegistration " + segmentRegistration);
}
}
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.collector.MtasDataCollector#validateSegmentBoundary(java.
* lang.Object)
*/
@Override
public boolean validateSegmentBoundary(Object o) throws IOException {
<span class="nc bnc" id="L363" title="All 2 branches missed."> if (o instanceof Double) {</span>
<span class="nc" id="L364"> return validateWithSegmentBoundary((Double) o);</span>
} else {
<span class="nc" id="L366"> throw new IOException("incorrect type");</span>
}
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html>