MtasDataCollector.java.html
72.1 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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
<?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>MtasDataCollector.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">MtasDataCollector.java</span></div><h1>MtasDataCollector.java</h1><pre class="source lang-java linenums">package mtas.codec.util.collector;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.Map.Entry;
import mtas.codec.util.DataCollector;
/**
* The Class MtasDataCollector.
*
* @param <T1> the generic type
* @param <T2> the generic type
*/
public abstract class MtasDataCollector<T1 extends Number & Comparable<T1>, T2 extends Number & Comparable<T2>>
implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/** The Constant SEGMENT_SORT_ASC. */
public static final String SEGMENT_SORT_ASC = "segment_asc";
/** The Constant SEGMENT_SORT_DESC. */
public static final String SEGMENT_SORT_DESC = "segment_desc";
/** The Constant SEGMENT_BOUNDARY_ASC. */
public static final String SEGMENT_BOUNDARY_ASC = "segment_boundary_asc";
/** The Constant SEGMENT_BOUNDARY_DESC. */
public static final String SEGMENT_BOUNDARY_DESC = "segment_boundary_desc";
/** The Constant SEGMENT_KEY. */
public static final String SEGMENT_KEY = "key";
/** The Constant SEGMENT_NEW. */
public static final String SEGMENT_NEW = "new";
/** The Constant SEGMENT_KEY_OR_NEW. */
public static final String SEGMENT_KEY_OR_NEW = "key_or_new";
/** The Constant SEGMENT_POSSIBLE_KEY. */
public static final String SEGMENT_POSSIBLE_KEY = "possible_key";
/** The size. */
protected int size;
/** The position. */
protected int position;
/** The collector type. */
// properties collector
protected String collectorType;
/** The stats type. */
protected String statsType;
/** The data type. */
protected String dataType;
/** The stats items. */
private SortedSet<String> statsItems;
/** The sort type. */
protected String sortType;
/** The sort direction. */
protected String sortDirection;
/** The start. */
protected Integer start;
/** The number. */
protected Integer number;
/** The error number. */
// error
protected int[] errorNumber;
/** The error list. */
protected HashMap<String, Integer>[] errorList;
/** The key list. */
protected String[] keyList;
/** The source number list. */
protected int[] sourceNumberList;
/** The with total. */
private boolean withTotal;
/** The segment registration. */
public transient String segmentRegistration;
/** The segment key value list. */
protected transient LinkedHashMap<String, Map<String, T1>> segmentKeyValueList;
/** The segment recompute key list. */
public transient Map<String, Set<String>> segmentRecomputeKeyList;
/** The segment keys. */
public transient Set<String> segmentKeys;
/** The segment values boundary. */
protected transient Map<String, T1> segmentValuesBoundary;
/** The segment value boundary. */
protected transient T1 segmentValueBoundary;
/** The segment value top list last. */
protected transient Map<String, T1> segmentValueTopListLast;
/** The segment value top list. */
protected transient ArrayList<T1> segmentValueTopList;
/** The segment name. */
protected transient String segmentName;
/** The segment number. */
protected transient int segmentNumber;
/** The has sub. */
private boolean hasSub;
/** The sub collector types. */
private String[] subCollectorTypes;
/** The sub data types. */
private String[] subDataTypes;
/** The sub stats types. */
private String[] subStatsTypes;
/** The sub stats items. */
private SortedSet<String>[] subStatsItems;
/** The sub sort types. */
private String[] subSortTypes;
/** The sub sort directions. */
private String[] subSortDirections;
/** The sub start. */
private Integer[] subStart;
/** The sub number. */
private Integer[] subNumber;
/** The sub collector list next level. */
<span class="fc" id="L161"> protected MtasDataCollector<?, ?>[] subCollectorListNextLevel = null;</span>
/** The sub collector next level. */
<span class="fc" id="L164"> protected MtasDataCollector<?, ?> subCollectorNextLevel = null;</span>
/** The new size. */
protected transient int newSize;
/** The new position. */
protected transient int newPosition;
/** The new current position. */
protected transient int newCurrentPosition;
/** The new current existing. */
protected transient boolean newCurrentExisting;
/** The new key list. */
<span class="fc" id="L179"> protected transient String[] newKeyList = null;</span>
/** The new source number list. */
<span class="fc" id="L182"> protected transient int[] newSourceNumberList = null;</span>
/** The new error number. */
protected transient int[] newErrorNumber;
/** The new error list. */
protected transient HashMap<String, Integer>[] newErrorList;
/** The new known key found in segment. */
public transient Set<String> newKnownKeyFoundInSegment;
/** The new sub collector types. */
private transient String[] newSubCollectorTypes;
/** The new sub data types. */
private transient String[] newSubDataTypes;
/** The new sub stats types. */
private transient String[] newSubStatsTypes;
/** The new sub stats items. */
private transient SortedSet<String>[] newSubStatsItems;
/** The new sub sort types. */
private transient String[] newSubSortTypes;
/** The new sub sort directions. */
private transient String[] newSubSortDirections;
/** The new sub start. */
private transient Integer[] newSubStart;
/** The new sub number. */
private transient Integer[] newSubNumber;
/** The new sub collector list next level. */
// subcollectors next level for adding
<span class="fc" id="L219"> protected transient MtasDataCollector<?, ?>[] newSubCollectorListNextLevel = null;</span>
/** The new sub collector next level. */
<span class="fc" id="L222"> protected transient MtasDataCollector<?, ?> newSubCollectorNextLevel = null;</span>
/** The closed. */
<span class="fc" id="L225"> protected transient boolean closed = false;</span>
/** The result. */
<span class="fc" id="L228"> private transient MtasDataCollectorResult<T1, T2> result = null;</span>
/**
* Instantiates a new mtas data collector.
*
* @param collectorType the collector type
* @param dataType the data type
* @param statsType the stats 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 segmentRegistration the segment registration
* @param boundary the boundary
* @throws IOException Signals that an I/O exception has occurred.
*/
@SuppressWarnings("unchecked")
protected MtasDataCollector(String collectorType, String dataType,
String statsType, SortedSet<String> statsItems, String sortType,
String sortDirection, Integer start, Integer number,
<span class="fc" id="L249"> String segmentRegistration, String boundary) throws IOException {</span>
// set properties
<span class="fc" id="L251"> this.closed = false;</span>
<span class="fc" id="L252"> this.collectorType = collectorType; // data or list</span>
<span class="fc" id="L253"> this.dataType = dataType; // long or double</span>
<span class="fc" id="L254"> this.statsType = statsType; // basic, advanced or full</span>
<span class="fc" id="L255"> this.statsItems = statsItems; // sum, n, all, ...</span>
<span class="fc" id="L256"> this.sortType = sortType;</span>
<span class="fc" id="L257"> this.sortDirection = sortDirection;</span>
<span class="fc" id="L258"> this.start = start;</span>
<span class="fc" id="L259"> this.number = number;</span>
<span class="fc" id="L260"> this.segmentRegistration = segmentRegistration;</span>
<span class="fc" id="L261"> this.withTotal = false;</span>
<span class="fc bfc" id="L262" title="All 2 branches covered."> if (segmentRegistration != null) {</span>
<span class="fc" id="L263"> segmentKeys = new HashSet<>();</span>
<span class="fc" id="L264"> segmentKeyValueList = new LinkedHashMap<>();</span>
<span class="fc" id="L265"> segmentValuesBoundary = new LinkedHashMap<>();</span>
<span class="fc" id="L266"> segmentValueTopListLast = new LinkedHashMap<>();</span>
<span class="pc bpc" id="L267" title="1 of 2 branches missed."> if (segmentRegistration.equals(SEGMENT_BOUNDARY_ASC)</span>
<span class="pc bpc" id="L268" title="1 of 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_DESC)) {</span>
<span class="nc bnc" id="L269" title="All 2 branches missed."> if (boundary != null) {</span>
<span class="nc" id="L270"> segmentValueBoundary = stringToBoundary(boundary);</span>
} else {
<span class="nc" id="L272"> throw new IOException("did expect boundary with segmentRegistration "</span>
+ segmentRegistration);
}
<span class="pc bpc" id="L275" title="1 of 2 branches missed."> } else if (boundary != null) {</span>
<span class="nc" id="L276"> throw new IOException("didn't expect boundary with segmentRegistration "</span>
+ segmentRegistration);
}
}
// initialize administration
<span class="fc" id="L281"> keyList = new String[0];</span>
<span class="fc" id="L282"> sourceNumberList = new int[0];</span>
<span class="fc" id="L283"> errorNumber = new int[0];</span>
<span class="fc" id="L284"> errorList = (HashMap<String, Integer>[]) new HashMap<?, ?>[0];</span>
<span class="fc" id="L285"> size = 0;</span>
<span class="fc" id="L286"> position = 0;</span>
// subCollectors properties
<span class="fc" id="L288"> hasSub = false;</span>
<span class="fc" id="L289"> subCollectorTypes = null;</span>
<span class="fc" id="L290"> subDataTypes = null;</span>
<span class="fc" id="L291"> subStatsTypes = null;</span>
<span class="fc" id="L292"> subStatsItems = null;</span>
<span class="fc" id="L293"> subSortTypes = null;</span>
<span class="fc" id="L294"> subSortDirections = null;</span>
<span class="fc" id="L295"> subStart = null;</span>
<span class="fc" id="L296"> subNumber = null;</span>
<span class="fc" id="L297"> subCollectorListNextLevel = null;</span>
<span class="fc" id="L298"> subCollectorNextLevel = null;</span>
<span class="fc" id="L299"> }</span>
/**
* Instantiates a new mtas data collector.
*
* @param collectorType the collector type
* @param dataType the data type
* @param statsType the stats 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.
*/
protected MtasDataCollector(String collectorType, String dataType,
String statsType, 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 {
// initialize
<span class="fc" id="L332"> this(collectorType, dataType, statsType, statsItems, sortType,</span>
sortDirection, start, number, segmentRegistration, boundary);
// initialize subCollectors
<span class="pc bpc" id="L335" title="1 of 2 branches missed."> if (subCollectorTypes != null) {</span>
<span class="nc" id="L336"> hasSub = true;</span>
<span class="nc" id="L337"> this.subCollectorTypes = subCollectorTypes;</span>
<span class="nc" id="L338"> this.subDataTypes = subDataTypes;</span>
<span class="nc" id="L339"> this.subStatsTypes = subStatsTypes;</span>
<span class="nc" id="L340"> this.subStatsItems = subStatsItems;</span>
<span class="nc" id="L341"> this.subSortTypes = subSortTypes;</span>
<span class="nc" id="L342"> this.subSortDirections = subSortDirections;</span>
<span class="nc" id="L343"> this.subStart = subStart;</span>
<span class="nc" id="L344"> this.subNumber = subNumber;</span>
<span class="nc bnc" id="L345" title="All 2 branches missed."> if (subCollectorTypes.length > 1) {</span>
<span class="nc" id="L346"> newSubCollectorTypes = Arrays.copyOfRange(subCollectorTypes, 1,</span>
subCollectorTypes.length);
<span class="nc" id="L348"> newSubDataTypes = Arrays.copyOfRange(subDataTypes, 1,</span>
subStatsTypes.length);
<span class="nc" id="L350"> newSubStatsTypes = Arrays.copyOfRange(subStatsTypes, 1,</span>
subStatsTypes.length);
<span class="nc" id="L352"> newSubStatsItems = Arrays.copyOfRange(subStatsItems, 1,</span>
subStatsItems.length);
<span class="nc" id="L354"> newSubSortTypes = Arrays.copyOfRange(subSortTypes, 1,</span>
subSortTypes.length);
<span class="nc" id="L356"> newSubSortDirections = Arrays.copyOfRange(subSortDirections, 1,</span>
subSortDirections.length);
<span class="nc" id="L358"> newSubStart = Arrays.copyOfRange(subStart, 1, subStart.length);</span>
<span class="nc" id="L359"> newSubNumber = Arrays.copyOfRange(subNumber, 1, subNumber.length);</span>
}
<span class="nc" id="L361"> newSubCollectorListNextLevel = new MtasDataCollector[0];</span>
}
<span class="fc" id="L363"> }</span>
/**
* Merge.
*
* @param newDataCollector the new data collector
* @param map the map
* @param increaseSourceNumber the increase source number
* @throws IOException Signals that an I/O exception has occurred.
*/
abstract public void merge(MtasDataCollector<?, ?> newDataCollector,
Map<MtasDataCollector<?, ?>, MtasDataCollector<?, ?>> map,
boolean increaseSourceNumber) throws IOException;
/**
* Inits the new list.
*
* @param maxNumberOfTerms the max number of terms
* @param segmentName the segment name
* @param segmentNumber the segment number
* @param boundary the boundary
* @throws IOException Signals that an I/O exception has occurred.
*/
public void initNewList(int maxNumberOfTerms, String segmentName,
int segmentNumber, String boundary) throws IOException {
<span class="pc bpc" id="L388" title="1 of 2 branches missed."> if (closed) {</span>
<span class="nc" id="L389"> result = null;</span>
<span class="nc" id="L390"> closed = false;</span>
}
<span class="fc" id="L392"> initNewListBasic(maxNumberOfTerms);</span>
<span class="fc bfc" id="L393" title="All 2 branches covered."> if (segmentRegistration != null) {</span>
<span class="fc" id="L394"> this.segmentName = segmentName;</span>
<span class="fc" id="L395"> this.segmentNumber = segmentNumber;</span>
<span class="fc bfc" id="L396" title="All 2 branches covered."> if (!segmentKeyValueList.containsKey(segmentName)) {</span>
<span class="fc" id="L397"> segmentKeyValueList.put(segmentName, new HashMap<String, T1>());</span>
<span class="pc bpc" id="L398" title="1 of 2 branches missed."> if (segmentRegistration.equals(SEGMENT_BOUNDARY_ASC)</span>
<span class="pc bpc" id="L399" title="1 of 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_DESC)) {</span>
<span class="nc bnc" id="L400" title="All 2 branches missed."> if (boundary != null) {</span>
<span class="nc" id="L401"> segmentValuesBoundary.put(segmentName,</span>
<span class="nc" id="L402"> stringToBoundary(boundary, segmentNumber));</span>
} else {
<span class="nc" id="L404"> throw new IOException("expected boundary");</span>
}
} else {
<span class="fc" id="L407"> segmentValuesBoundary.put(segmentName, null);</span>
}
<span class="fc" id="L409"> segmentValueTopListLast.put(segmentName, null);</span>
}
<span class="fc" id="L411"> this.segmentValueTopList = new ArrayList<>();</span>
}
<span class="fc" id="L413"> }</span>
/**
* Inits the new list.
*
* @param maxNumberOfTerms the max number of terms
* @throws IOException Signals that an I/O exception has occurred.
*/
public void initNewList(int maxNumberOfTerms) throws IOException {
<span class="fc bfc" id="L422" title="All 2 branches covered."> if (closed) {</span>
<span class="fc" id="L423"> result = null;</span>
<span class="fc" id="L424"> closed = false;</span>
}
<span class="pc bpc" id="L426" title="1 of 2 branches missed."> if (segmentRegistration != null) {</span>
<span class="nc" id="L427"> throw new IOException("missing segment name");</span>
} else {
<span class="fc" id="L429"> initNewListBasic(maxNumberOfTerms);</span>
}
<span class="fc" id="L431"> }</span>
/**
* Inits the new list basic.
*
* @param maxNumberOfTerms the max number of terms
* @throws IOException Signals that an I/O exception has occurred.
*/
@SuppressWarnings("unchecked")
private void initNewListBasic(int maxNumberOfTerms) throws IOException {
<span class="pc bpc" id="L441" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="fc" id="L442"> position = 0;</span>
<span class="fc" id="L443"> newPosition = 0;</span>
<span class="fc" id="L444"> newCurrentPosition = 0;</span>
<span class="fc" id="L445"> newSize = maxNumberOfTerms + size;</span>
<span class="fc" id="L446"> newKeyList = new String[newSize];</span>
<span class="fc" id="L447"> newSourceNumberList = new int[newSize];</span>
<span class="fc" id="L448"> newErrorNumber = new int[newSize];</span>
<span class="fc" id="L449"> newErrorList = (HashMap<String, Integer>[]) new HashMap<?, ?>[newSize];</span>
<span class="fc" id="L450"> newKnownKeyFoundInSegment = new HashSet<>();</span>
<span class="pc bpc" id="L451" title="1 of 2 branches missed."> if (hasSub) {</span>
<span class="nc" id="L452"> newSubCollectorListNextLevel = new MtasDataCollector[newSize];</span>
}
} else {
<span class="nc" id="L455"> throw new IOException("already closed");</span>
}
<span class="fc" id="L457"> }</span>
/**
* Increase new list size.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
@SuppressWarnings("unchecked")
protected void increaseNewListSize() throws IOException {
<span class="pc bpc" id="L466" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="fc" id="L467"> String[] tmpNewKeyList = newKeyList;</span>
<span class="fc" id="L468"> int[] tmpNewSourceNumberList = newSourceNumberList;</span>
<span class="fc" id="L469"> int[] tmpNewErrorNumber = newErrorNumber;</span>
<span class="fc" id="L470"> HashMap<String, Integer>[] tmpNewErrorList = newErrorList;</span>
<span class="fc" id="L471"> int tmpNewSize = newSize;</span>
<span class="fc" id="L472"> newSize = 2 * newSize;</span>
<span class="fc" id="L473"> newKeyList = new String[newSize];</span>
<span class="fc" id="L474"> newSourceNumberList = new int[newSize];</span>
<span class="fc" id="L475"> newErrorNumber = new int[newSize];</span>
<span class="fc" id="L476"> newErrorList = (HashMap<String, Integer>[]) new HashMap<?, ?>[newSize];</span>
<span class="fc" id="L477"> System.arraycopy(tmpNewKeyList, 0, newKeyList, 0, tmpNewSize);</span>
<span class="fc" id="L478"> System.arraycopy(tmpNewSourceNumberList, 0, newSourceNumberList, 0,</span>
tmpNewSize);
<span class="fc" id="L480"> System.arraycopy(tmpNewErrorNumber, 0, newErrorNumber, 0, tmpNewSize);</span>
<span class="fc" id="L481"> System.arraycopy(tmpNewErrorList, 0, newErrorList, 0, tmpNewSize);</span>
<span class="pc bpc" id="L482" title="1 of 2 branches missed."> if (hasSub) {</span>
<span class="nc" id="L483"> MtasDataCollector<?, ?>[] tmpNewSubCollectorListNextLevel = newSubCollectorListNextLevel;</span>
<span class="nc" id="L484"> newSubCollectorListNextLevel = new MtasDataCollector[newSize];</span>
<span class="nc" id="L485"> System.arraycopy(tmpNewSubCollectorListNextLevel, 0,</span>
newSubCollectorListNextLevel, 0, tmpNewSize);
}
<span class="fc" id="L488"> } else {</span>
<span class="nc" id="L489"> throw new IOException("already closed");</span>
}
<span class="fc" id="L491"> }</span>
/**
* Adds the.
*
* @param increaseSourceNumber the increase source number
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
protected final MtasDataCollector add(boolean increaseSourceNumber)
throws IOException {
<span class="pc bpc" id="L502" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="pc bpc" id="L503" title="1 of 2 branches missed."> if (!collectorType.equals(DataCollector.COLLECTOR_TYPE_DATA)) {</span>
<span class="nc" id="L504"> throw new IOException(</span>
"collector should be " + DataCollector.COLLECTOR_TYPE_DATA);
} else {
<span class="pc bpc" id="L507" title="1 of 2 branches missed."> if (newPosition > 0) {</span>
<span class="nc" id="L508"> newCurrentExisting = true;</span>
<span class="fc bfc" id="L509" title="All 2 branches covered."> } else if (position < getSize()) {</span>
// copy
<span class="fc" id="L511"> newKeyList[0] = keyList[0];</span>
<span class="fc" id="L512"> newSourceNumberList[0] = sourceNumberList[0];</span>
<span class="fc bfc" id="L513" title="All 2 branches covered."> if (increaseSourceNumber) {</span>
<span class="fc" id="L514"> newSourceNumberList[0]++;</span>
}
<span class="fc" id="L516"> newErrorNumber[0] = errorNumber[0];</span>
<span class="fc" id="L517"> newErrorList[0] = errorList[0];</span>
<span class="pc bpc" id="L518" title="1 of 2 branches missed."> if (hasSub) {</span>
<span class="nc" id="L519"> newSubCollectorNextLevel = subCollectorNextLevel;</span>
}
<span class="fc" id="L521"> copyToNew(0, 0);</span>
<span class="fc" id="L522"> newPosition = 1;</span>
<span class="fc" id="L523"> position = 1;</span>
<span class="fc" id="L524"> newCurrentExisting = true;</span>
} else {
// add key
<span class="fc" id="L527"> newKeyList[0] = DataCollector.COLLECTOR_TYPE_DATA;</span>
<span class="fc" id="L528"> newSourceNumberList[0] = 1;</span>
<span class="fc" id="L529"> newErrorNumber[0] = 0;</span>
<span class="fc" id="L530"> newErrorList[0] = new HashMap<>();</span>
<span class="fc" id="L531"> newPosition = 1;</span>
<span class="fc" id="L532"> newCurrentPosition = newPosition - 1;</span>
<span class="fc" id="L533"> newCurrentExisting = false;</span>
// ready, only handle sub
<span class="pc bpc" id="L535" title="1 of 2 branches missed."> if (hasSub) {</span>
<span class="nc" id="L536"> newSubCollectorNextLevel = DataCollector.getCollector(</span>
subCollectorTypes[0], subDataTypes[0], subStatsTypes[0],
subStatsItems[0], subSortTypes[0], subSortDirections[0],
subStart[0], subNumber[0], newSubCollectorTypes,
newSubDataTypes, newSubStatsTypes, newSubStatsItems,
newSubSortTypes, newSubSortDirections, newSubStart,
newSubNumber, segmentRegistration, null);
} else {
<span class="fc" id="L544"> newSubCollectorNextLevel = null;</span>
}
}
<span class="fc" id="L547"> return newSubCollectorNextLevel;</span>
}
} else {
<span class="nc" id="L550"> throw new IOException("already closed");</span>
}
}
/**
* Adds the.
*
* @param key the key
* @param increaseSourceNumber the increase source number
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
protected final MtasDataCollector add(String key,
boolean increaseSourceNumber) throws IOException {
<span class="pc bpc" id="L564" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="pc bpc" id="L565" title="1 of 2 branches missed."> if (collectorType.equals(DataCollector.COLLECTOR_TYPE_DATA)) {</span>
<span class="nc" id="L566"> throw new IOException(</span>
"collector should be " + DataCollector.COLLECTOR_TYPE_LIST);
<span class="pc bpc" id="L568" title="1 of 2 branches missed."> } else if (key == null) {</span>
<span class="nc" id="L569"> throw new IOException("key shouldn't be null");</span>
} else {
// check previous added
<span class="fc bfc" id="L572" title="All 2 branches covered."> if ((newPosition > 0)</span>
<span class="fc bfc" id="L573" title="All 2 branches covered."> && newKeyList[(newPosition - 1)].compareTo(key) >= 0) {</span>
<span class="fc" id="L574"> int i = newPosition;</span>
do {
<span class="fc" id="L576"> i--;</span>
<span class="fc bfc" id="L577" title="All 2 branches covered."> if (newKeyList[i].equals(key)) {</span>
<span class="fc" id="L578"> newCurrentPosition = i;</span>
<span class="fc" id="L579"> newCurrentExisting = true;</span>
<span class="pc bpc" id="L580" title="1 of 2 branches missed."> if (subDataTypes != null) {</span>
<span class="nc" id="L581"> return newSubCollectorListNextLevel[newCurrentPosition];</span>
} else {
<span class="fc" id="L583"> return null;</span>
}
}
<span class="fc bfc" id="L586" title="All 4 branches covered."> } while ((i > 0) && (newKeyList[i].compareTo(key) > 0));</span>
}
// move position in old list
<span class="fc bfc" id="L589" title="All 2 branches covered."> if (position < getSize()) {</span>
// just add smaller or equal items
<span class="fc bfc" id="L591" title="All 2 branches covered."> while (keyList[position].compareTo(key) <= 0) {</span>
<span class="fc bfc" id="L592" title="All 2 branches covered."> if (newPosition == newSize) {</span>
<span class="fc" id="L593"> increaseNewListSize();</span>
}
// copy
<span class="fc" id="L596"> newKeyList[newPosition] = keyList[position];</span>
<span class="fc" id="L597"> newSourceNumberList[newPosition] = sourceNumberList[position];</span>
<span class="fc" id="L598"> newErrorNumber[newPosition] = errorNumber[position];</span>
<span class="fc" id="L599"> newErrorList[newPosition] = errorList[position];</span>
<span class="pc bpc" id="L600" title="1 of 2 branches missed."> if (hasSub) {</span>
<span class="nc" id="L601"> newSubCollectorListNextLevel[newPosition] = subCollectorListNextLevel[position];</span>
}
<span class="fc" id="L603"> copyToNew(position, newPosition);</span>
<span class="fc" id="L604"> newPosition++;</span>
<span class="fc" id="L605"> position++;</span>
// check if added key from list is right key
<span class="fc bfc" id="L607" title="All 2 branches covered."> if (newKeyList[(newPosition - 1)].equals(key)) {</span>
<span class="fc bfc" id="L608" title="All 2 branches covered."> if (increaseSourceNumber) {</span>
<span class="fc" id="L609"> newSourceNumberList[(newPosition - 1)]++;</span>
}
<span class="fc" id="L611"> newCurrentPosition = newPosition - 1;</span>
<span class="fc" id="L612"> newCurrentExisting = true;</span>
// register known key found again in segment
<span class="fc" id="L614"> newKnownKeyFoundInSegment.add(key);</span>
// ready
<span class="pc bpc" id="L616" title="1 of 2 branches missed."> if (hasSub) {</span>
<span class="nc" id="L617"> return newSubCollectorListNextLevel[newCurrentPosition];</span>
} else {
<span class="fc" id="L619"> return null;</span>
}
// stop if position exceeds size
<span class="fc bfc" id="L622" title="All 2 branches covered."> } else if (position == getSize()) {</span>
<span class="fc" id="L623"> break;</span>
}
}
}
// check size
<span class="fc bfc" id="L628" title="All 2 branches covered."> if (newPosition == newSize) {</span>
<span class="fc" id="L629"> increaseNewListSize();</span>
}
// add key
<span class="fc" id="L632"> newKeyList[newPosition] = key;</span>
<span class="fc" id="L633"> newSourceNumberList[newPosition] = 1;</span>
<span class="fc" id="L634"> newErrorNumber[newPosition] = 0;</span>
<span class="fc" id="L635"> newErrorList[newPosition] = new HashMap<>();</span>
<span class="fc" id="L636"> newPosition++;</span>
<span class="fc" id="L637"> newCurrentPosition = newPosition - 1;</span>
<span class="fc" id="L638"> newCurrentExisting = false;</span>
// ready, only handle sub
<span class="pc bpc" id="L640" title="1 of 2 branches missed."> if (hasSub) {</span>
<span class="nc" id="L641"> newSubCollectorListNextLevel[newCurrentPosition] = DataCollector</span>
<span class="nc" id="L642"> .getCollector(subCollectorTypes[0], subDataTypes[0],</span>
subStatsTypes[0], subStatsItems[0], subSortTypes[0],
subSortDirections[0], subStart[0], subNumber[0],
newSubCollectorTypes, newSubDataTypes, newSubStatsTypes,
newSubStatsItems, newSubSortTypes, newSubSortDirections,
newSubStart, newSubNumber, segmentRegistration, null);
<span class="nc" id="L648"> return newSubCollectorListNextLevel[newCurrentPosition];</span>
} else {
<span class="fc" id="L650"> return null;</span>
}
}
} else {
<span class="nc" id="L654"> throw new IOException("already closed");</span>
}
}
/**
* Copy to new.
*
* @param position the position
* @param newPosition the new position
*/
protected abstract void copyToNew(int position, int newPosition);
/**
* Copy from new.
*/
protected abstract void copyFromNew();
/**
* Compare with boundary.
*
* @param value the value
* @param boundary the boundary
* @return true, if successful
* @throws IOException Signals that an I/O exception has occurred.
*/
protected abstract boolean compareWithBoundary(T1 value, T1 boundary)
throws IOException;
/**
* Last for computing segment.
*
* @param value the value
* @param boundary the boundary
* @return the t1
* @throws IOException Signals that an I/O exception has occurred.
*/
protected abstract T1 lastForComputingSegment(T1 value, T1 boundary)
throws IOException;
/**
* Last for computing segment.
*
* @return the t1
* @throws IOException Signals that an I/O exception has occurred.
*/
protected abstract T1 lastForComputingSegment() throws IOException;
/**
* Boundary for segment.
*
* @param segmentName the segment name
* @return the t1
* @throws IOException Signals that an I/O exception has occurred.
*/
protected abstract T1 boundaryForSegment(String segmentName)
throws IOException;
/**
* Boundary for segment computing.
*
* @param segmentName the segment name
* @return the t1
* @throws IOException Signals that an I/O exception has occurred.
*/
protected abstract T1 boundaryForSegmentComputing(String segmentName)
throws IOException;
/**
* String to boundary.
*
* @param boundary the boundary
* @param segmentNumber the segment number
* @return the t1
* @throws IOException Signals that an I/O exception has occurred.
*/
protected abstract T1 stringToBoundary(String boundary, Integer segmentNumber)
throws IOException;
/**
* String to boundary.
*
* @param boundary the boundary
* @return the t1
* @throws IOException Signals that an I/O exception has occurred.
*/
protected T1 stringToBoundary(String boundary) throws IOException {
<span class="nc" id="L740"> return stringToBoundary(boundary, null);</span>
}
/**
* Close segment key value registration.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public void closeSegmentKeyValueRegistration() throws IOException {
<span class="pc bpc" id="L749" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="fc bfc" id="L750" title="All 2 branches covered."> if (segmentRegistration != null) {</span>
<span class="fc" id="L751"> Map<String, T1> keyValueList = segmentKeyValueList.get(segmentName);</span>
<span class="fc" id="L752"> T1 tmpSegmentValueBoundary = segmentValuesBoundary.get(segmentName);</span>
<span class="fc bfc" id="L753" title="All 2 branches covered."> for (Entry<String, T1> entry : keyValueList.entrySet()) {</span>
<span class="pc bpc" id="L754" title="1 of 4 branches missed."> if (tmpSegmentValueBoundary == null || compareWithBoundary(</span>
<span class="fc" id="L755"> entry.getValue(), tmpSegmentValueBoundary)) {</span>
<span class="fc" id="L756"> segmentKeys.add(entry.getKey());</span>
}
<span class="fc" id="L758"> }</span>
<span class="fc" id="L759"> }</span>
} else {
<span class="nc" id="L761"> throw new IOException("already closed");</span>
}
<span class="fc" id="L763"> }</span>
/**
* Recompute segment keys.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public void recomputeSegmentKeys() throws IOException {
<span class="pc bpc" id="L771" title="2 of 4 branches missed."> if (!closed && segmentRegistration != null) {</span>
<span class="fc bfc" id="L772" title="All 2 branches covered."> if (segmentRegistration.equals(SEGMENT_SORT_ASC)</span>
<span class="pc bpc" id="L773" title="1 of 2 branches missed."> || segmentRegistration.equals(SEGMENT_SORT_DESC)</span>
<span class="nc bnc" id="L774" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_ASC)</span>
<span class="nc bnc" id="L775" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_DESC)) {</span>
<span class="fc bfc" id="L777" title="All 2 branches covered."> if (segmentRegistration.equals(SEGMENT_SORT_ASC)</span>
<span class="pc bpc" id="L778" title="1 of 2 branches missed."> || segmentRegistration.equals(SEGMENT_SORT_DESC)) {</span>
<span class="fc" id="L779"> segmentKeys.clear();</span>
// recompute boundaries
<span class="fc bfc" id="L781" title="All 2 branches covered."> for (Entry<String, Map<String, T1>> entry : segmentKeyValueList</span>
<span class="fc" id="L782"> .entrySet()) {</span>
<span class="fc" id="L783"> T1 tmpSegmentValueBoundary = boundaryForSegment(entry.getKey());</span>
<span class="fc" id="L784"> segmentValuesBoundary.put(entry.getKey(), tmpSegmentValueBoundary);</span>
<span class="fc" id="L785"> }</span>
// compute adjusted boundaries and compute keys
<span class="fc bfc" id="L787" title="All 2 branches covered."> for (Entry<String, Map<String, T1>> entry : segmentKeyValueList</span>
<span class="fc" id="L788"> .entrySet()) {</span>
<span class="fc" id="L789"> this.segmentName = entry.getKey();</span>
<span class="fc" id="L790"> Map<String, T1> keyValueList = entry.getValue();</span>
<span class="fc" id="L791"> T1 tmpSegmentValueBoundaryForComputing = boundaryForSegmentComputing(</span>
<span class="fc" id="L792"> entry.getKey());</span>
<span class="fc bfc" id="L793" title="All 2 branches covered."> for (Entry<String, T1> subEntry : keyValueList.entrySet()) {</span>
<span class="pc bpc" id="L794" title="1 of 2 branches missed."> if (tmpSegmentValueBoundaryForComputing == null</span>
<span class="fc bfc" id="L795" title="All 2 branches covered."> || compareWithBoundary(subEntry.getValue(),</span>
tmpSegmentValueBoundaryForComputing)) {
<span class="fc bfc" id="L797" title="All 2 branches covered."> if (!segmentKeys.contains(subEntry.getKey())) {</span>
<span class="fc" id="L798"> segmentKeys.add(subEntry.getKey());</span>
}
}
<span class="fc" id="L801"> }</span>
<span class="fc" id="L802"> }</span>
}
Map<String, T1> keyValueList;
Set<String> recomputeKeyList;
<span class="fc" id="L807"> segmentRecomputeKeyList = new LinkedHashMap<>();</span>
<span class="fc bfc" id="L808" title="All 2 branches covered."> for (String key : segmentKeys) {</span>
<span class="fc bfc" id="L809" title="All 2 branches covered."> for (Entry<String, Map<String, T1>> entry : segmentKeyValueList</span>
<span class="fc" id="L810"> .entrySet()) {</span>
<span class="fc" id="L811"> keyValueList = entry.getValue();</span>
<span class="fc bfc" id="L812" title="All 2 branches covered."> if (!keyValueList.containsKey(key)) {</span>
<span class="fc bfc" id="L813" title="All 2 branches covered."> if (!segmentRecomputeKeyList.containsKey(entry.getKey())) {</span>
<span class="fc" id="L814"> recomputeKeyList = new HashSet<>();</span>
<span class="fc" id="L815"> segmentRecomputeKeyList.put(entry.getKey(), recomputeKeyList);</span>
} else {
<span class="fc" id="L817"> recomputeKeyList = segmentRecomputeKeyList.get(entry.getKey());</span>
}
<span class="fc" id="L819"> recomputeKeyList.add(key);</span>
}
<span class="fc" id="L821"> }</span>
<span class="fc" id="L822"> }</span>
<span class="fc" id="L823"> this.segmentName = null;</span>
} else {
<span class="nc" id="L825"> throw new IOException(</span>
"not for segmentRegistration " + segmentRegistration);
}
} else {
<span class="nc" id="L829"> throw new IOException("already closed or no segmentRegistration ("</span>
+ segmentRegistration + ")");
}
<span class="fc" id="L832"> }</span>
/**
* Reduce to keys.
*
* @param keys the keys
*/
public abstract void reduceToKeys(Set<String> keys);
/**
* Reduce to segment keys.
*/
public void reduceToSegmentKeys() {
<span class="nc bnc" id="L845" title="All 2 branches missed."> if (segmentRegistration != null) {</span>
<span class="nc" id="L846"> reduceToKeys(segmentKeys);</span>
}
<span class="nc" id="L848"> }</span>
/**
* Check existence necessary keys.
*
* @return true, if successful
* @throws IOException Signals that an I/O exception has occurred.
*/
public boolean checkExistenceNecessaryKeys() throws IOException {
<span class="pc bpc" id="L857" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="pc bpc" id="L858" title="1 of 2 branches missed."> if (segmentRegistration != null) {</span>
<span class="fc bfc" id="L859" title="All 2 branches covered."> return segmentRecomputeKeyList.size() == 0;</span>
} else {
<span class="nc" id="L861"> return true;</span>
}
} else {
<span class="nc" id="L864"> throw new IOException("already closed");</span>
}
}
/**
* Validate segment boundary.
*
* @param o the o
* @return true, if successful
* @throws IOException Signals that an I/O exception has occurred.
*/
abstract public boolean validateSegmentBoundary(Object o) throws IOException;
/**
* Validate with segment boundary.
*
* @param value the value
* @return true, if successful
* @throws IOException Signals that an I/O exception has occurred.
*/
protected boolean validateWithSegmentBoundary(T1 value) throws IOException {
<span class="pc bpc" id="L885" title="1 of 4 branches missed."> if (!closed && segmentRegistration != null) {</span>
<span class="fc" id="L886"> T1 tmpSegmentValueBoundary = segmentValuesBoundary.get(segmentName);</span>
<span class="pc bpc" id="L887" title="1 of 2 branches missed."> if (tmpSegmentValueBoundary == null</span>
<span class="fc bfc" id="L888" title="All 2 branches covered."> || compareWithBoundary(value, tmpSegmentValueBoundary)) {</span>
<span class="fc" id="L889"> return true;</span>
}
}
<span class="fc" id="L892"> return false;</span>
}
/**
* Validate segment value.
*
* @param value the value
* @param maximumNumber the maximum number
* @param segmentNumber the segment number
* @return the string
* @throws IOException Signals that an I/O exception has occurred.
*/
public String validateSegmentValue(T1 value, int maximumNumber,
int segmentNumber) throws IOException {
<span class="pc bpc" id="L906" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="pc bpc" id="L907" title="1 of 2 branches missed."> if (segmentRegistration != null) {</span>
<span class="pc bpc" id="L908" title="1 of 2 branches missed."> if (maximumNumber > 0) {</span>
<span class="fc" id="L909"> T1 tmpSegmentValueBoundary = segmentValuesBoundary.get(segmentName);</span>
<span class="fc bfc" id="L910" title="All 2 branches covered."> if (segmentValueTopList.size() < maximumNumber</span>
<span class="fc bfc" id="L911" title="All 2 branches covered."> || compareWithBoundary(value, tmpSegmentValueBoundary)) {</span>
<span class="fc" id="L912"> return SEGMENT_KEY_OR_NEW;</span>
<span class="fc bfc" id="L913" title="All 2 branches covered."> } else if (segmentKeys.size() > newKnownKeyFoundInSegment.size()) {</span>
<span class="fc" id="L914"> return SEGMENT_POSSIBLE_KEY;</span>
} else {
<span class="fc" id="L916"> return null;</span>
}
} else {
<span class="nc" id="L919"> return null;</span>
}
} else {
<span class="nc" id="L922"> return null;</span>
}
} else {
<span class="nc" id="L925"> throw new IOException("already closed");</span>
}
}
/**
* Validate segment value.
*
* @param key the key
* @param value the value
* @param maximumNumber the maximum number
* @param segmentNumber the segment number
* @param test the test
* @return the string
* @throws IOException Signals that an I/O exception has occurred.
*/
public String validateSegmentValue(String key, T1 value, int maximumNumber,
int segmentNumber, boolean test) throws IOException {
<span class="pc bpc" id="L942" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="pc bpc" id="L943" title="1 of 2 branches missed."> if (segmentRegistration != null) {</span>
<span class="pc bpc" id="L944" title="1 of 2 branches missed."> if (maximumNumber > 0) {</span>
<span class="fc" id="L945"> T1 tmpSegmentValueMaxListMin = segmentValueTopListLast</span>
<span class="fc" id="L946"> .get(segmentName);</span>
<span class="fc" id="L947"> T1 tmpSegmentValueBoundary = segmentValuesBoundary.get(segmentName);</span>
<span class="fc bfc" id="L948" title="All 2 branches covered."> if (segmentValueTopList.size() < maximumNumber) {</span>
<span class="pc bpc" id="L949" title="1 of 2 branches missed."> if (!test) {</span>
<span class="fc" id="L950"> segmentKeyValueList.get(segmentName).put(key, value);</span>
<span class="fc" id="L951"> segmentValueTopList.add(value);</span>
<span class="fc bfc" id="L952" title="All 2 branches covered."> segmentValueTopListLast.put(segmentName,</span>
(tmpSegmentValueMaxListMin == null) ? value
<span class="fc" id="L954"> : lastForComputingSegment(tmpSegmentValueMaxListMin,</span>
value));
<span class="fc bfc" id="L956" title="All 2 branches covered."> if (segmentValueTopList.size() == maximumNumber) {</span>
<span class="fc" id="L957"> tmpSegmentValueMaxListMin = segmentValueTopListLast</span>
<span class="fc" id="L958"> .get(segmentName);</span>
<span class="fc" id="L959"> segmentValueTopListLast.put(segmentName,</span>
tmpSegmentValueMaxListMin);
<span class="fc" id="L961"> segmentValuesBoundary.put(segmentName,</span>
<span class="fc" id="L962"> boundaryForSegmentComputing(segmentName));</span>
}
}
<span class="fc bfc" id="L965" title="All 2 branches covered."> return segmentKeys.contains(key) ? SEGMENT_KEY : SEGMENT_NEW;</span>
<span class="fc bfc" id="L966" title="All 2 branches covered."> } else if (compareWithBoundary(value, tmpSegmentValueBoundary)) {</span>
// System.out.println(key+" "+value+" "+tmpSegmentValueBoundary);
<span class="pc bpc" id="L968" title="1 of 2 branches missed."> if (!test) {</span>
<span class="fc" id="L969"> segmentKeyValueList.get(segmentName).put(key, value);</span>
<span class="fc bfc" id="L970" title="All 2 branches covered."> if (compareWithBoundary(value, tmpSegmentValueMaxListMin)) {</span>
<span class="fc" id="L971"> segmentValueTopList.add(value);</span>
<span class="fc" id="L972"> segmentValueTopList.remove(tmpSegmentValueMaxListMin);</span>
<span class="fc" id="L973"> tmpSegmentValueMaxListMin = lastForComputingSegment();</span>
<span class="fc" id="L974"> segmentValueTopListLast.put(segmentName,</span>
tmpSegmentValueMaxListMin);
<span class="fc" id="L976"> segmentValuesBoundary.put(segmentName,</span>
<span class="fc" id="L977"> boundaryForSegmentComputing(segmentName));</span>
}
}
<span class="fc bfc" id="L980" title="All 2 branches covered."> return segmentKeys.contains(key) ? SEGMENT_KEY : SEGMENT_NEW;</span>
<span class="fc bfc" id="L981" title="All 2 branches covered."> } else if (segmentKeys.contains(key)) {</span>
<span class="fc bfc" id="L982" title="All 2 branches covered."> if (!test) {</span>
<span class="fc" id="L983"> segmentKeyValueList.get(segmentName).put(key, value);</span>
}
<span class="fc" id="L985"> return SEGMENT_KEY;</span>
} else {
<span class="fc" id="L987"> return null;</span>
}
} else {
<span class="nc" id="L990"> return null;</span>
}
} else {
<span class="nc" id="L993"> return null;</span>
}
} else {
<span class="nc" id="L996"> throw new IOException("already closed");</span>
}
}
/**
* Sets the error.
*
* @param newPosition the new position
* @param errorNumberItem the error number item
* @param errorListItem the error list item
* @param currentExisting the current existing
* @throws IOException Signals that an I/O exception has occurred.
*/
protected final void setError(int newPosition, int errorNumberItem,
HashMap<String, Integer> errorListItem, boolean currentExisting)
throws IOException {
<span class="pc bpc" id="L1012" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="fc bfc" id="L1013" title="All 2 branches covered."> if (currentExisting) {</span>
<span class="fc" id="L1014"> newErrorNumber[newPosition] += errorNumberItem;</span>
<span class="fc" id="L1015"> HashMap<String, Integer> item = newErrorList[newPosition];</span>
<span class="pc bpc" id="L1016" title="1 of 2 branches missed."> for (Entry<String, Integer> entry : errorListItem.entrySet()) {</span>
<span class="nc bnc" id="L1017" title="All 2 branches missed."> if (item.containsKey(entry.getKey())) {</span>
<span class="nc" id="L1018"> item.put(entry.getKey(),</span>
<span class="nc" id="L1019"> item.get(entry.getKey()) + entry.getValue());</span>
} else {
<span class="nc" id="L1021"> item.put(entry.getKey(), entry.getValue());</span>
}
<span class="nc" id="L1023"> }</span>
<span class="fc" id="L1024"> } else {</span>
<span class="fc" id="L1025"> newErrorNumber[newPosition] = errorNumberItem;</span>
<span class="fc" id="L1026"> newErrorList[newPosition] = errorListItem;</span>
}
} else {
<span class="nc" id="L1029"> throw new IOException("already closed");</span>
}
<span class="fc" id="L1031"> }</span>
/**
* Sorted and unique.
*
* @param keyList the key list
* @param size the size
* @return true, if successful
* @throws IOException Signals that an I/O exception has occurred.
*/
private boolean sortedAndUnique(String[] keyList, int size)
throws IOException {
<span class="pc bpc" id="L1043" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="fc bfc" id="L1044" title="All 2 branches covered."> for (int i = 1; i < size; i++) {</span>
<span class="fc bfc" id="L1045" title="All 2 branches covered."> if (keyList[(i - 1)].compareTo(keyList[i]) >= 0) {</span>
<span class="fc" id="L1046"> return false;</span>
}
}
<span class="fc" id="L1049"> return true;</span>
} else {
<span class="nc" id="L1051"> throw new IOException("already closed");</span>
}
}
/**
* Compute sort and unique mapping.
*
* @param keyList the key list
* @param size the size
* @return the int[][]
* @throws IOException Signals that an I/O exception has occurred.
*/
private int[][] computeSortAndUniqueMapping(String[] keyList, int size)
throws IOException {
<span class="pc bpc" id="L1065" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="pc bpc" id="L1066" title="1 of 2 branches missed."> if (size > 0) {</span>
<span class="fc" id="L1067"> SortedMap<String, int[]> sortedMap = new TreeMap<>();</span>
<span class="fc bfc" id="L1068" title="All 2 branches covered."> for (int i = 0; i < size; i++) {</span>
<span class="fc bfc" id="L1069" title="All 2 branches covered."> if (sortedMap.containsKey(keyList[i])) {</span>
<span class="fc" id="L1070"> int[] previousList = sortedMap.get(keyList[i]);</span>
<span class="fc" id="L1071"> int[] newList = new int[previousList.length + 1];</span>
<span class="fc" id="L1072"> System.arraycopy(previousList, 0, newList, 0, previousList.length);</span>
<span class="fc" id="L1073"> newList[previousList.length] = i;</span>
<span class="fc" id="L1074"> sortedMap.put(keyList[i], newList);</span>
<span class="fc" id="L1075"> } else {</span>
<span class="fc" id="L1076"> sortedMap.put(keyList[i], new int[] { i });</span>
}
}
<span class="fc" id="L1079"> Collection<int[]> values = sortedMap.values();</span>
<span class="fc" id="L1080"> int[][] result = new int[sortedMap.size()][];</span>
<span class="fc" id="L1081"> return values.toArray(result);</span>
} else {
<span class="nc" id="L1083"> return null;</span>
}
} else {
<span class="nc" id="L1086"> throw new IOException("already closed");</span>
}
}
/**
* Remap data.
*
* @param mapping the mapping
* @throws IOException Signals that an I/O exception has occurred.
*/
protected void remapData(int[][] mapping) throws IOException {
<span class="pc bpc" id="L1097" title="1 of 2 branches missed."> if (!closed) {</span>
// remap and merge keys
<span class="fc" id="L1099"> String[] newKeyList = new String[mapping.length];</span>
// process mapping for functions?
<span class="fc" id="L1101"> HashMap<MtasDataCollector<?, ?>, MtasDataCollector<?, ?>> map = new HashMap<>();</span>
<span class="fc" id="L1102"> int[] newSourceNumberList = new int[mapping.length];</span>
<span class="fc" id="L1103"> int[] newErrorNumber = new int[mapping.length];</span>
@SuppressWarnings("unchecked")
<span class="fc" id="L1105"> HashMap<String, Integer>[] newErrorList = (HashMap<String, Integer>[]) new HashMap<?, ?>[mapping.length];</span>
<span class="fc bfc" id="L1106" title="All 2 branches covered."> for (int i = 0; i < mapping.length; i++) {</span>
<span class="fc" id="L1107"> newKeyList[i] = keyList[mapping[i][0]];</span>
<span class="fc" id="L1108"> newSourceNumberList[i] = sourceNumberList[mapping[i][0]];</span>
<span class="fc bfc" id="L1109" title="All 2 branches covered."> for (int j = 0; j < mapping[i].length; j++) {</span>
<span class="fc bfc" id="L1110" title="All 2 branches covered."> if (j == 0) {</span>
<span class="fc" id="L1111"> newErrorNumber[i] = errorNumber[mapping[i][j]];</span>
<span class="fc" id="L1112"> newErrorList[i] = errorList[mapping[i][j]];</span>
} else {
<span class="fc" id="L1114"> newErrorNumber[i] += errorNumber[mapping[i][j]];</span>
<span class="pc bpc" id="L1115" title="1 of 2 branches missed."> for (Entry<String, Integer> entry : errorList[mapping[i][j]]</span>
<span class="fc" id="L1116"> .entrySet()) {</span>
<span class="nc bnc" id="L1117" title="All 2 branches missed."> if (newErrorList[i].containsKey(entry.getKey())) {</span>
<span class="nc" id="L1118"> newErrorList[i].put(entry.getKey(),</span>
<span class="nc" id="L1119"> newErrorList[i].get(entry.getKey()) + entry.getValue());</span>
} else {
<span class="nc" id="L1121"> newErrorList[i].put(entry.getKey(), entry.getValue());</span>
}
<span class="nc" id="L1123"> }</span>
}
}
}
<span class="pc bpc" id="L1127" title="1 of 2 branches missed."> if (hasSub) {</span>
<span class="nc" id="L1128"> newSubCollectorListNextLevel = new MtasDataCollector<?, ?>[mapping.length];</span>
<span class="nc bnc" id="L1129" title="All 2 branches missed."> for (int i = 0; i < mapping.length; i++) {</span>
<span class="nc bnc" id="L1130" title="All 2 branches missed."> for (int j = 0; j < mapping[i].length; j++) {</span>
<span class="nc bnc" id="L1131" title="All 4 branches missed."> if (j == 0 || newSubCollectorListNextLevel[i] == null) {</span>
<span class="nc" id="L1132"> newSubCollectorListNextLevel[i] = subCollectorListNextLevel[mapping[i][j]];</span>
} else {
<span class="nc" id="L1134"> newSubCollectorListNextLevel[i]</span>
<span class="nc" id="L1135"> .merge(subCollectorListNextLevel[mapping[i][j]], map, false);</span>
}
}
}
<span class="nc" id="L1139"> subCollectorListNextLevel = newSubCollectorListNextLevel;</span>
}
<span class="fc" id="L1141"> keyList = newKeyList;</span>
<span class="fc" id="L1142"> sourceNumberList = newSourceNumberList;</span>
<span class="fc" id="L1143"> errorNumber = newErrorNumber;</span>
<span class="fc" id="L1144"> errorList = newErrorList;</span>
<span class="fc" id="L1145"> size = keyList.length;</span>
<span class="fc" id="L1146"> position = 0;</span>
<span class="fc" id="L1147"> } else {</span>
<span class="nc" id="L1148"> throw new IOException("already closed");</span>
}
<span class="fc" id="L1150"> }</span>
/**
* Close new list.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public void closeNewList() throws IOException {
<span class="fc bfc" id="L1158" title="All 2 branches covered."> if (!closed) {</span>
<span class="fc bfc" id="L1159" title="All 2 branches covered."> if (segmentRegistration != null) {</span>
<span class="fc" id="L1160"> this.segmentName = null;</span>
}
<span class="fc bfc" id="L1162" title="All 2 branches covered."> if (newSize > 0) {</span>
// add remaining old
<span class="fc bfc" id="L1164" title="All 2 branches covered."> while (position < getSize()) {</span>
<span class="pc bpc" id="L1165" title="1 of 2 branches missed."> if (newPosition == newSize) {</span>
<span class="nc" id="L1166"> increaseNewListSize();</span>
}
<span class="fc" id="L1168"> newKeyList[newPosition] = keyList[position];</span>
<span class="fc" id="L1169"> newSourceNumberList[newPosition] = sourceNumberList[position];</span>
<span class="fc" id="L1170"> newErrorNumber[newPosition] = errorNumber[position];</span>
<span class="fc" id="L1171"> newErrorList[newPosition] = errorList[position];</span>
<span class="pc bpc" id="L1172" title="1 of 2 branches missed."> if (hasSub) {</span>
<span class="nc" id="L1173"> newSubCollectorListNextLevel[newPosition] = subCollectorListNextLevel[position];</span>
}
<span class="fc" id="L1175"> copyToNew(position, newPosition);</span>
<span class="fc" id="L1176"> position++;</span>
<span class="fc" id="L1177"> newPosition++;</span>
}
// copy
<span class="fc" id="L1180"> keyList = newKeyList;</span>
<span class="fc" id="L1181"> sourceNumberList = newSourceNumberList;</span>
<span class="fc" id="L1182"> errorNumber = newErrorNumber;</span>
<span class="fc" id="L1183"> errorList = newErrorList;</span>
<span class="fc" id="L1184"> subCollectorListNextLevel = newSubCollectorListNextLevel;</span>
<span class="fc" id="L1185"> copyFromNew();</span>
<span class="fc" id="L1186"> size = newPosition;</span>
// sort and merge
<span class="fc bfc" id="L1188" title="All 2 branches covered."> if (!sortedAndUnique(keyList, getSize())) {</span>
<span class="fc" id="L1189"> remapData(computeSortAndUniqueMapping(keyList, getSize()));</span>
}
}
<span class="fc" id="L1192"> position = 0;</span>
<span class="fc" id="L1193"> newSize = 0;</span>
<span class="fc" id="L1194"> newPosition = 0;</span>
<span class="fc" id="L1195"> newCurrentPosition = 0;</span>
}
<span class="fc" id="L1197"> }</span>
/**
* Gets the item.
*
* @param i the i
* @return the item
*/
abstract protected MtasDataItem<T1, T2> getItem(int i);
/**
* Checks for sub.
*
* @return true, if successful
*/
protected boolean hasSub() {
<span class="fc" id="L1213"> return hasSub;</span>
}
/**
* Error.
*
* @param error the error
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract void error(String error) throws IOException;
/**
* Error.
*
* @param key the key
* @param error the error
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract void error(String key, String error) throws IOException;
/**
* Adds the.
*
* @param valueSum the value sum
* @param valueN the value N
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract MtasDataCollector add(long valueSum, long valueN)
throws IOException;
/**
* Adds the.
*
* @param values the values
* @param number the number
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract MtasDataCollector add(long[] values, int number)
throws IOException;
/**
* Adds the.
*
* @param valueSum the value sum
* @param valueN the value N
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract MtasDataCollector add(double valueSum, long valueN)
throws IOException;
/**
* Adds the.
*
* @param values the values
* @param number the number
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract MtasDataCollector add(double[] values, int number)
throws IOException;
/**
* Adds the.
*
* @param key the key
* @param valueSum the value sum
* @param valueN the value N
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract MtasDataCollector add(String key, long valueSum, long valueN)
throws IOException;
/**
* Adds the.
*
* @param key the key
* @param values the values
* @param number the number
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract MtasDataCollector add(String key, long[] values, int number)
throws IOException;
/**
* Adds the.
*
* @param key the key
* @param valueSum the value sum
* @param valueN the value N
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract MtasDataCollector add(String key, double valueSum,
long valueN) throws IOException;
/**
* Adds the.
*
* @param key the key
* @param values the values
* @param number the number
* @return the mtas data collector
* @throws IOException Signals that an I/O exception has occurred.
*/
public abstract MtasDataCollector add(String key, double[] values, int number)
throws IOException;
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
<span class="nc" id="L1332"> StringBuilder text = new StringBuilder();</span>
<span class="nc" id="L1333"> text.append(this.getClass().getSimpleName() + "-" + this.hashCode() + "\n");</span>
<span class="nc" id="L1334"> text.append("\t=== " + collectorType + " - " + statsType + " " + statsItems</span>
+ " " + hasSub + " ===\n");
<span class="nc" id="L1336"> text.append("\tclosed: " + closed + "\n");</span>
<span class="nc" id="L1337"> text.append("\tkeylist: " + Arrays.asList(keyList) + "\n");</span>
<span class="nc bnc" id="L1338" title="All 2 branches missed."> text.append("\tsegmentKeys: "</span>
<span class="nc" id="L1339"> + (segmentKeys != null ? segmentKeys.contains("1") : "null") + "\n");</span>
<span class="nc" id="L1340"> return text.toString().trim();</span>
}
/**
* Gets the result.
*
* @return the result
* @throws IOException Signals that an I/O exception has occurred.
*/
public MtasDataCollectorResult<T1, T2> getResult() throws IOException {
<span class="fc bfc" id="L1350" title="All 2 branches covered."> if (!closed) {</span>
<span class="fc" id="L1351"> close();</span>
}
<span class="fc" id="L1353"> return result;</span>
}
/**
* Gets the key list.
*
* @return the key list
* @throws IOException Signals that an I/O exception has occurred.
*/
public Set<String> getKeyList() throws IOException {
<span class="nc bnc" id="L1363" title="All 2 branches missed."> if (!closed) {</span>
<span class="nc" id="L1364"> close();</span>
}
<span class="nc" id="L1366"> return new HashSet<>(Arrays.asList(keyList));</span>
}
/**
* Gets the stats items.
*
* @return the stats items
*/
public SortedSet<String> getStatsItems() {
<span class="fc" id="L1375"> return statsItems;</span>
}
/**
* Close.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public void close() throws IOException {
<span class="pc bpc" id="L1385" title="1 of 2 branches missed."> if (!closed) {</span>
<span class="fc" id="L1386"> closeNewList();</span>
<span class="fc bfc" id="L1387" title="All 2 branches covered."> if (collectorType.equals(DataCollector.COLLECTOR_TYPE_LIST)) {</span>
// compute initial basic list
<span class="fc" id="L1389"> TreeMap<String, MtasDataItem<T1, T2>> basicList = new TreeMap<>();</span>
<span class="fc bfc" id="L1390" title="All 2 branches covered."> for (int i = 0; i < getSize(); i++) {</span>
<span class="fc" id="L1391"> MtasDataItem<T1, T2> newItem = getItem(i);</span>
<span class="pc bpc" id="L1392" title="1 of 2 branches missed."> if (basicList.containsKey(keyList[i])) {</span>
<span class="nc" id="L1393"> newItem.add(basicList.get(keyList[i]));</span>
}
<span class="fc" id="L1395"> basicList.put(keyList[i], newItem);</span>
}
// create result based on basic list
<span class="fc" id="L1398"> result = new MtasDataCollectorResult<>(collectorType, sortType,</span>
sortDirection, basicList, start, number);
// reduce
<span class="fc bfc" id="L1401" title="All 2 branches covered."> if (segmentRegistration != null) {</span>
<span class="fc bfc" id="L1402" title="All 2 branches covered."> if (segmentRegistration.equals(SEGMENT_SORT_ASC)</span>
<span class="pc bpc" id="L1403" title="1 of 2 branches missed."> || segmentRegistration.equals(SEGMENT_SORT_DESC)) {</span>
<span class="fc" id="L1404"> reduceToKeys(result.getComparatorList().keySet());</span>
<span class="nc bnc" id="L1405" title="All 2 branches missed."> } else if (segmentRegistration.equals(SEGMENT_BOUNDARY_ASC)</span>
<span class="nc bnc" id="L1406" title="All 2 branches missed."> || segmentRegistration.equals(SEGMENT_BOUNDARY_DESC)) {</span>
<span class="nc" id="L1407"> Map<String, MtasDataItemNumberComparator> comparatorList = result</span>
<span class="nc" id="L1408"> .getComparatorList();</span>
<span class="nc" id="L1409"> HashSet<String> filteredKeySet = new HashSet<>();</span>
<span class="nc bnc" id="L1410" title="All 2 branches missed."> if (segmentRegistration.equals(SEGMENT_BOUNDARY_ASC)) {</span>
<span class="nc bnc" id="L1411" title="All 2 branches missed."> for (Entry<String, MtasDataItemNumberComparator> entry : comparatorList</span>
<span class="nc" id="L1412"> .entrySet()) {</span>
<span class="nc bnc" id="L1413" title="All 2 branches missed."> if (entry.getValue().compareTo(segmentValueBoundary) < 0) {</span>
<span class="nc" id="L1414"> filteredKeySet.add(entry.getKey());</span>
}
<span class="nc" id="L1416"> }</span>
} else {
<span class="nc bnc" id="L1418" title="All 2 branches missed."> for (Entry<String, MtasDataItemNumberComparator> entry : comparatorList</span>
<span class="nc" id="L1419"> .entrySet()) {</span>
<span class="nc bnc" id="L1420" title="All 2 branches missed."> if (entry.getValue().compareTo(segmentValueBoundary) > 0) {</span>
<span class="nc" id="L1421"> filteredKeySet.add(entry.getKey());</span>
}
<span class="nc" id="L1423"> }</span>
}
<span class="nc" id="L1425"> reduceToKeys(filteredKeySet);</span>
<span class="nc" id="L1426"> basicList.keySet().retainAll(filteredKeySet);</span>
<span class="nc" id="L1427"> result = new MtasDataCollectorResult<>(collectorType, sortType,</span>
sortDirection, basicList, start, number);
}
}
<span class="pc bpc" id="L1431" title="1 of 2 branches missed."> } else if (collectorType.equals(DataCollector.COLLECTOR_TYPE_DATA)) {</span>
<span class="fc bfc" id="L1432" title="All 2 branches covered."> if (getSize() > 0) {</span>
<span class="fc" id="L1433"> result = new MtasDataCollectorResult<>(collectorType, getItem(0));</span>
} else {
<span class="fc" id="L1435"> result = new MtasDataCollectorResult<>(collectorType, sortType,</span>
sortDirection);
}
} else {
<span class="nc" id="L1439"> throw new IOException("type " + collectorType + " not supported");</span>
}
<span class="fc" id="L1441"> closed = true;</span>
}
<span class="fc" id="L1443"> }</span>
/**
* Gets the collector type.
*
* @return the collector type
*/
public String getCollectorType() {
<span class="fc" id="L1451"> return collectorType;</span>
}
/**
* Gets the stats type.
*
* @return the stats type
*/
public String getStatsType() {
<span class="fc" id="L1460"> return statsType;</span>
}
/**
* Gets the data type.
*
* @return the data type
*/
public String getDataType() {
<span class="fc" id="L1469"> return dataType;</span>
}
/**
* Gets the size.
*
* @return the size
*/
public int getSize() {
<span class="fc" id="L1478"> return size;</span>
}
/**
* With total.
*
* @return true, if successful
*/
public boolean withTotal() {
<span class="fc" id="L1487"> return withTotal;</span>
}
/**
* Sets the with total.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public void setWithTotal() throws IOException {
<span class="pc bpc" id="L1496" title="1 of 2 branches missed."> if (collectorType.equals(DataCollector.COLLECTOR_TYPE_LIST)) {</span>
<span class="pc bpc" id="L1497" title="1 of 2 branches missed."> if (segmentName != null) {</span>
<span class="nc" id="L1498"> throw new IOException("can't get total with segmentRegistration");</span>
} else {
<span class="fc" id="L1500"> withTotal = true;</span>
}
} else {
<span class="nc" id="L1503"> throw new IOException(</span>
"can't get total for dataCollector of type " + collectorType);
}
<span class="fc" id="L1506"> }</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>