MtasDataFull.java.html
18.8 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
<?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>MtasDataFull.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">MtasDataFull.java</span></div><h1>MtasDataFull.java</h1><pre class="source lang-java linenums">package mtas.codec.util.collector;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import mtas.codec.util.CodecUtil;
import mtas.codec.util.DataCollector;
/**
* The Class MtasDataFull.
*
* @param <T1> the generic type
* @param <T2> the generic type
*/
abstract class MtasDataFull<T1 extends Number & Comparable<T1>, T2 extends Number & Comparable<T2>>
extends MtasDataCollector<T1, T2> implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/** The full value list. */
<span class="fc" id="L26"> protected T1[][] fullValueList = null;</span>
/** The new full value list. */
<span class="fc" id="L29"> protected T1[][] newFullValueList = null;</span>
/** The operations. */
protected MtasDataOperations<T1, T2> operations;
/**
* Instantiates a new mtas data full.
*
* @param collectorType the collector type
* @param dataType the data 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 operations the operations
* @param segmentRegistration the segment registration
* @param boundary the boundary
* @throws IOException Signals that an I/O exception has occurred.
*/
public MtasDataFull(String collectorType, String dataType,
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,
MtasDataOperations<T1, T2> operations, String segmentRegistration,
String boundary) throws IOException {
<span class="fc" id="L65"> super(collectorType, dataType, CodecUtil.STATS_FULL, statsItems, sortType,</span>
sortDirection, start, number, subCollectorTypes, subDataTypes,
subStatsTypes, subStatsItems, subSortTypes, subSortDirections, subStart,
subNumber, segmentRegistration, boundary);
<span class="fc" id="L69"> this.operations = operations;</span>
<span class="fc" id="L70"> }</span>
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#error(java.lang.String)
*/
@Override
public final void error(String error) throws IOException {
<span class="nc" id="L80"> add(false);</span>
<span class="nc" id="L81"> setError(newCurrentPosition, error, newCurrentExisting);</span>
<span class="nc" id="L82"> }</span>
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.DataCollector.MtasDataCollector#error(java.lang.String[],
* java.lang.String)
*/
@Override
public final void error(String key, String error) throws IOException {
<span class="nc bnc" id="L93" title="All 2 branches missed."> if (key != null) {</span>
<span class="nc" id="L94"> add(key, false);</span>
<span class="nc" id="L95"> setError(newCurrentPosition, error, newCurrentExisting);</span>
}
<span class="nc" id="L97"> }</span>
/**
* Sets the error.
*
* @param newPosition the new position
* @param error the error
* @param currentExisting the current existing
*/
protected void setError(int newPosition, String error,
boolean currentExisting) {
<span class="nc bnc" id="L108" title="All 2 branches missed."> if (!currentExisting) {</span>
<span class="nc" id="L109"> newFullValueList[newPosition] = operations.createVector1(0);</span>
}
<span class="nc" id="L111"> newErrorNumber[newPosition]++;</span>
<span class="nc bnc" id="L112" title="All 2 branches missed."> if (newErrorList[newPosition].containsKey(error)) {</span>
<span class="nc" id="L113"> newErrorList[newPosition].put(error,</span>
<span class="nc" id="L114"> newErrorList[newPosition].get(error) + 1);</span>
} else {
<span class="nc" id="L116"> newErrorList[newPosition].put(error, 1);</span>
}
<span class="nc" id="L118"> }</span>
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#increaseNewListSize()
*/
@Override
protected final void increaseNewListSize() throws IOException {
// register old situation
<span class="nc" id="L128"> int tmpOldSize = newKeyList.length;</span>
<span class="nc" id="L129"> int tmpNewPosition = newPosition;</span>
// increase
<span class="nc" id="L131"> super.increaseNewListSize();</span>
// reconstruct
<span class="nc" id="L133"> T1[][] tmpNewFullValueList = newFullValueList;</span>
<span class="nc" id="L134"> newFullValueList = operations.createMatrix1(newSize);</span>
<span class="nc" id="L135"> newPosition = tmpNewPosition;</span>
<span class="nc" id="L136"> System.arraycopy(tmpNewFullValueList, 0, newFullValueList, 0, tmpOldSize);</span>
<span class="nc" id="L137"> }</span>
/*
* (non-Javadoc)
*
* @see mtas.codec.util.collector.MtasDataCollector#reduceToSegmentKeys()
*/
@Override
public void reduceToSegmentKeys() {
<span class="nc bnc" id="L146" title="All 4 branches missed."> if (segmentRegistration != null && size > 0) {</span>
<span class="nc" id="L147"> int sizeCopy = size;</span>
<span class="nc" id="L148"> String[] keyListCopy = keyList.clone();</span>
<span class="nc" id="L149"> T1[][] fullValueListCopy = fullValueList.clone();</span>
<span class="nc" id="L150"> size = 0;</span>
<span class="nc bnc" id="L151" title="All 2 branches missed."> for (int i = 0; i < sizeCopy; i++) {</span>
<span class="nc bnc" id="L152" title="All 2 branches missed."> if (segmentKeys.contains(keyListCopy[i])) {</span>
<span class="nc" id="L153"> keyList[size] = keyListCopy[i];</span>
<span class="nc" id="L154"> fullValueList[size] = fullValueListCopy[i];</span>
<span class="nc" id="L155"> size++;</span>
}
}
}
<span class="nc" id="L159"> }</span>
/*
* (non-Javadoc)
*
* @see
* mtas.codec.util.collector.MtasDataCollector#reduceToKeys(java.util.Set)
*/
@SuppressWarnings("unchecked")
public void reduceToKeys(Set<String> keys) {
<span class="nc bnc" id="L169" title="All 2 branches missed."> if (size > 0) {</span>
<span class="nc" id="L170"> int sizeCopy = size;</span>
<span class="nc" id="L171"> String[] keyListCopy = keyList.clone();</span>
<span class="nc" id="L172"> int[] errorNumberCopy = errorNumber.clone();</span>
<span class="nc" id="L173"> HashMap<String, Integer>[] errorListCopy = errorList.clone();</span>
<span class="nc" id="L174"> int[] sourceNumberListCopy = sourceNumberList.clone();</span>
<span class="nc" id="L175"> T1[][] fullValueListCopy = fullValueList.clone();</span>
<span class="nc bnc" id="L176" title="All 2 branches missed."> for (int i = 0; i < fullValueListCopy.length; i++) {</span>
<span class="nc bnc" id="L177" title="All 2 branches missed."> if (fullValueListCopy[i] != null) {</span>
<span class="nc" id="L178"> fullValueListCopy[i] = fullValueListCopy[i].clone();</span>
}
}
<span class="nc" id="L181"> keyList = new String[keys.size()];</span>
<span class="nc" id="L182"> errorNumber = new int[keys.size()];</span>
<span class="nc" id="L183"> errorList = new HashMap[keys.size()];</span>
<span class="nc" id="L184"> sourceNumberList = new int[keys.size()];</span>
<span class="nc" id="L185"> fullValueList = operations.createMatrix1(keys.size());</span>
<span class="nc" id="L186"> size = 0;</span>
<span class="nc bnc" id="L187" title="All 2 branches missed."> for (int i = 0; i < sizeCopy; i++) {</span>
<span class="nc bnc" id="L188" title="All 2 branches missed."> if (keys.contains(keyListCopy[i])) {</span>
<span class="nc" id="L189"> keyList[size] = keyListCopy[i];</span>
<span class="nc" id="L190"> errorNumber[size] = errorNumberCopy[i];</span>
<span class="nc" id="L191"> errorList[size] = errorListCopy[i];</span>
<span class="nc" id="L192"> sourceNumberList[size] = sourceNumberListCopy[i];</span>
<span class="nc" id="L193"> fullValueList[size] = fullValueListCopy[i];</span>
<span class="nc" id="L194"> size++;</span>
}
}
}
<span class="nc" id="L198"> }</span>
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#copyToNew(int, int)
*/
@Override
protected void copyToNew(int position, int newPosition) {
<span class="fc" id="L207"> newFullValueList[newPosition] = fullValueList[position];</span>
<span class="fc" id="L208"> }</span>
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#copyFromNew()
*/
@Override
protected void copyFromNew() {
<span class="fc" id="L217"> fullValueList = newFullValueList;</span>
<span class="fc" id="L218"> }</span>
/**
* Sets the value.
*
* @param newPosition the new position
* @param values the values
* @param number the number
* @param currentExisting the current existing
*/
protected void setValue(int newPosition, T1[] values, int number,
boolean currentExisting) {
<span class="pc bpc" id="L230" title="1 of 2 branches missed."> if (number > 0) {</span>
<span class="fc bfc" id="L231" title="All 2 branches covered."> if (currentExisting) {</span>
<span class="fc" id="L232"> T1[] tmpList = operations</span>
<span class="fc" id="L233"> .createVector1(newFullValueList[newPosition].length + number);</span>
<span class="fc" id="L234"> System.arraycopy(newFullValueList[newPosition], 0, tmpList, 0,</span>
newFullValueList[newPosition].length);
<span class="fc" id="L236"> System.arraycopy(values, 0, tmpList,</span>
newFullValueList[newPosition].length, number);
<span class="fc" id="L238"> newFullValueList[newPosition] = tmpList;</span>
<span class="fc" id="L239"> } else {</span>
<span class="pc bpc" id="L240" title="1 of 2 branches missed."> if (number < values.length) {</span>
<span class="nc" id="L241"> T1[] tmpList = operations.createVector1(number);</span>
<span class="nc" id="L242"> System.arraycopy(values, 0, tmpList, 0, number);</span>
<span class="nc" id="L243"> newFullValueList[newPosition] = tmpList;</span>
<span class="nc" id="L244"> } else {</span>
<span class="fc" id="L245"> newFullValueList[newPosition] = values;</span>
}
}
}
<span class="fc" id="L249"> }</span>
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#remapData(int[][])
*/
@Override
protected void remapData(int[][] mapping) throws IOException {
<span class="nc" id="L258"> super.remapData(mapping);</span>
<span class="nc" id="L259"> T1[][] originalFullValueList = fullValueList.clone();</span>
<span class="nc" id="L260"> fullValueList = operations.createMatrix1(mapping.length);</span>
<span class="nc bnc" id="L261" title="All 2 branches missed."> for (int i = 0; i < mapping.length; i++) {</span>
<span class="nc bnc" id="L262" title="All 2 branches missed."> for (int j = 0; j < mapping[i].length; j++) {</span>
<span class="nc bnc" id="L263" title="All 2 branches missed."> if (j == 0) {</span>
<span class="nc" id="L264"> setValue(i, originalFullValueList[mapping[i][j]],</span>
originalFullValueList[mapping[i][j]].length, false);
} else {
<span class="nc" id="L267"> setValue(i, originalFullValueList[mapping[i][j]],</span>
originalFullValueList[mapping[i][j]].length, true);
}
}
}
<span class="nc" id="L272"> fullValueList = newFullValueList;</span>
<span class="nc" id="L273"> }</span>
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#merge(mtas.codec.util.
* DataCollector.MtasDataCollector)
*/
@Override
public void merge(MtasDataCollector<?, ?> newDataCollector,
Map<MtasDataCollector<?, ?>, MtasDataCollector<?, ?>> map,
boolean increaseSourceNumber) throws IOException {
<span class="nc" id="L285"> closeNewList();</span>
<span class="nc bnc" id="L286" title="All 2 branches missed."> if (!collectorType.equals(newDataCollector.getCollectorType())</span>
<span class="nc bnc" id="L287" title="All 2 branches missed."> || !dataType.equals(newDataCollector.getDataType())</span>
<span class="nc bnc" id="L288" title="All 4 branches missed."> || !statsType.equals(newDataCollector.getStatsType())</span>
|| !(newDataCollector instanceof MtasDataFull)) {
<span class="nc" id="L290"> throw new IOException("cannot merge different dataCollectors");</span>
} else {
<span class="nc" id="L292"> segmentRegistration = null;</span>
@SuppressWarnings("unchecked")
<span class="nc" id="L294"> MtasDataFull<T1, T2> newMtasDataFull = (MtasDataFull<T1, T2>) newDataCollector;</span>
<span class="nc" id="L295"> closeNewList();</span>
<span class="nc" id="L296"> initNewList(newMtasDataFull.getSize());</span>
<span class="nc bnc" id="L297" title="All 2 branches missed."> if (collectorType.equals(DataCollector.COLLECTOR_TYPE_LIST)) {</span>
<span class="nc" id="L298"> map.put(newDataCollector, this);</span>
<span class="nc bnc" id="L299" title="All 2 branches missed."> for (int i = 0; i < newMtasDataFull.getSize(); i++) {</span>
<span class="nc bnc" id="L300" title="All 2 branches missed."> if (newMtasDataFull.fullValueList[i].length > 0) {</span>
<span class="nc" id="L301"> MtasDataCollector<?, ?>[] subCollectors = new MtasDataCollector<?, ?>[1];</span>
<span class="nc" id="L302"> subCollectors[0] = add(newMtasDataFull.keyList[i],</span>
increaseSourceNumber);
<span class="nc" id="L304"> setError(newCurrentPosition, newMtasDataFull.errorNumber[i],</span>
newMtasDataFull.errorList[i], newCurrentExisting);
<span class="nc" id="L306"> setValue(newCurrentPosition, newMtasDataFull.fullValueList[i],</span>
newMtasDataFull.fullValueList[i].length, newCurrentExisting);
<span class="nc bnc" id="L308" title="All 4 branches missed."> if (hasSub() && newMtasDataFull.hasSub()) {</span>
// single key implies exactly one subCollector if hasSub
<span class="nc" id="L310"> subCollectors[0].merge(</span>
newMtasDataFull.subCollectorListNextLevel[i], map,
increaseSourceNumber);
}
}
}
<span class="nc bnc" id="L316" title="All 2 branches missed."> } else if (collectorType.equals(DataCollector.COLLECTOR_TYPE_DATA)) {</span>
<span class="nc" id="L317"> map.put(newDataCollector, this);</span>
<span class="nc bnc" id="L318" title="All 2 branches missed."> if (newMtasDataFull.getSize() > 0) {</span>
<span class="nc" id="L319"> MtasDataCollector<?, ?> subCollector = add(increaseSourceNumber);</span>
<span class="nc" id="L320"> setError(newCurrentPosition, newMtasDataFull.errorNumber[0],</span>
newMtasDataFull.errorList[0], newCurrentExisting);
<span class="nc" id="L322"> setValue(newCurrentPosition, newMtasDataFull.fullValueList[0],</span>
newMtasDataFull.fullValueList[0].length, newCurrentExisting);
<span class="nc bnc" id="L324" title="All 4 branches missed."> if (hasSub() && newMtasDataFull.hasSub()) {</span>
<span class="nc" id="L325"> subCollector.merge(newMtasDataFull.subCollectorNextLevel, map,</span>
increaseSourceNumber);
}
<span class="nc" id="L328"> }</span>
} else {
<span class="nc" id="L330"> throw new IOException("cannot merge " + collectorType);</span>
}
<span class="nc" id="L332"> closeNewList();</span>
}
<span class="nc" id="L334"> }</span>
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#initNewList(int)
*/
@Override
public final void initNewList(int maxNumberOfTerms) throws IOException {
<span class="fc" id="L343"> super.initNewList(maxNumberOfTerms);</span>
<span class="fc" id="L344"> initNewListBasic(maxNumberOfTerms);</span>
<span class="fc" id="L345"> }</span>
/*
* (non-Javadoc)
*
* @see mtas.codec.util.DataCollector.MtasDataCollector#initNewList(int,
* java.lang.String)
*/
@Override
public final void initNewList(int maxNumberOfTerms, String segmentName,
int segmentNumber, String boundary) throws IOException {
<span class="nc" id="L356"> super.initNewList(maxNumberOfTerms, segmentName, segmentNumber, boundary);</span>
<span class="nc" id="L357"> initNewListBasic(maxNumberOfTerms);</span>
<span class="nc" id="L358"> }</span>
/**
* Inits the new list basic.
*
* @param maxNumberOfTerms the max number of terms
*/
private void initNewListBasic(int maxNumberOfTerms) {
<span class="fc" id="L366"> newFullValueList = operations.createMatrix1(newSize);</span>
<span class="fc" id="L367"> }</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>