CodecCollector.java.html
249 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
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
<?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>CodecCollector.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</a> > <span class="el_source">CodecCollector.java</span></div><h1>CodecCollector.java</h1><pre class="source lang-java linenums">package mtas.codec.util;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.regex.Pattern;
import mtas.analysis.token.MtasToken;
import mtas.analysis.token.MtasTokenString;
import mtas.codec.MtasCodecPostingsFormat;
import mtas.codec.tree.IntervalTreeNodeData;
import mtas.codec.util.CodecComponent.ComponentDocument;
import mtas.codec.util.CodecComponent.ComponentFacet;
import mtas.codec.util.CodecComponent.ComponentField;
import mtas.codec.util.CodecComponent.ComponentGroup;
import mtas.codec.util.CodecComponent.ComponentJoin;
import mtas.codec.util.CodecComponent.ComponentKwic;
import mtas.codec.util.CodecComponent.ComponentList;
import mtas.codec.util.CodecComponent.ComponentPosition;
import mtas.codec.util.CodecComponent.ComponentSpan;
import mtas.codec.util.CodecComponent.ComponentTermVector;
import mtas.codec.util.CodecComponent.ComponentToken;
import mtas.codec.util.CodecComponent.GroupHit;
import mtas.codec.util.CodecComponent.KwicHit;
import mtas.codec.util.CodecComponent.KwicToken;
import mtas.codec.util.CodecComponent.ListHit;
import mtas.codec.util.CodecComponent.ListToken;
import mtas.codec.util.CodecComponent.Match;
import mtas.codec.util.CodecComponent.SubComponentFunction;
import mtas.codec.util.CodecInfo.IndexDoc;
import mtas.codec.util.CodecSearchTree.MtasTreeHit;
import mtas.codec.util.collector.MtasDataCollector;
import mtas.parser.function.ParseException;
import mtas.parser.function.util.MtasFunctionParserFunction;
import mtas.search.spans.MtasSpanAndQuery;
import mtas.search.spans.MtasSpanMatchAllQuery;
import mtas.search.spans.MtasSpanSequenceItem;
import mtas.search.spans.MtasSpanSequenceQuery;
import mtas.search.spans.MtasSpanTermQuery;
import mtas.search.spans.util.MtasSpanQuery;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.spans.SpanWeight;
import org.apache.lucene.search.spans.Spans;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LegacyNumericUtils;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.apache.lucene.util.automaton.CompiledAutomaton;
import org.apache.lucene.util.automaton.RegExp;
/**
* The Class CodecCollector.
*/
public class CodecCollector {
/** The Constant log. */
<span class="fc" id="L87"> private static final Log log = LogFactory.getLog(CodecCollector.class);</span>
/**
* Instantiates a new codec collector.
*/
<span class="nc" id="L92"> private CodecCollector() {</span>
// don't do anything
<span class="nc" id="L94"> }</span>
/**
* Collect field.
*
* @param field
* the field
* @param searcher
* the searcher
* @param reader
* the reader
* @param rawReader
* the raw reader
* @param fullDocList
* the full doc list
* @param fullDocSet
* the full doc set
* @param fieldInfo
* the field info
* @param spansQueryWeight
* the spans query weight
* @throws IllegalAccessException
* the illegal access exception
* @throws IllegalArgumentException
* the illegal argument exception
* @throws InvocationTargetException
* the invocation target exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void collectField(String field, IndexSearcher searcher,
IndexReader reader, IndexReader rawReader, List<Integer> fullDocList,
List<Integer> fullDocSet, ComponentField fieldInfo,
Map<MtasSpanQuery, SpanWeight> spansQueryWeight)
throws IllegalAccessException, IllegalArgumentException,
InvocationTargetException, IOException {
<span class="fc" id="L131"> Map<Integer, List<Integer>> docSets = new HashMap<>();</span>
<span class="fc" id="L133"> ListIterator<LeafReaderContext> iterator = reader.leaves().listIterator();</span>
<span class="fc bfc" id="L134" title="All 2 branches covered."> while (iterator.hasNext()) {</span>
<span class="fc" id="L135"> LeafReaderContext lrc = iterator.next();</span>
<span class="fc" id="L136"> LeafReader r = lrc.reader();</span>
// compute relevant docSet/docList
<span class="fc" id="L139"> List<Integer> docSet = null;</span>
<span class="fc" id="L140"> List<Integer> docList = null;</span>
<span class="fc bfc" id="L141" title="All 2 branches covered."> if (fullDocSet != null) {</span>
<span class="fc" id="L142"> docSet = new ArrayList<>();</span>
<span class="fc" id="L143"> docSets.put(lrc.ord, docSet);</span>
<span class="fc" id="L144"> Iterator<Integer> docSetIterator = fullDocSet.iterator();</span>
<span class="fc" id="L145"> Integer docSetId = null;</span>
<span class="fc" id="L146"> Bits liveDocs = lrc.reader().getLiveDocs();</span>
<span class="fc bfc" id="L147" title="All 2 branches covered."> while (docSetIterator.hasNext()) {</span>
<span class="fc" id="L148"> docSetId = docSetIterator.next();</span>
// just to make sure to ignore deleted documents
<span class="fc bfc" id="L150" title="All 2 branches covered."> if ((docSetId >= lrc.docBase)</span>
<span class="fc bfc" id="L151" title="All 4 branches covered."> && (docSetId < lrc.docBase + lrc.reader().maxDoc())</span>
<span class="pc bpc" id="L152" title="1 of 2 branches missed."> && (liveDocs == null || liveDocs.get((docSetId - lrc.docBase)))) {</span>
<span class="fc" id="L153"> docSet.add(docSetId);</span>
}
}
<span class="fc" id="L156"> Collections.sort(docSet);</span>
}
<span class="pc bpc" id="L158" title="1 of 2 branches missed."> if (fullDocList != null) {</span>
<span class="fc" id="L159"> docList = new ArrayList<>();</span>
<span class="fc" id="L160"> Iterator<Integer> docListIterator = fullDocList.iterator();</span>
<span class="fc" id="L161"> Integer docListId = null;</span>
<span class="fc bfc" id="L162" title="All 2 branches covered."> while (docListIterator.hasNext()) {</span>
<span class="fc" id="L163"> docListId = docListIterator.next();</span>
<span class="fc bfc" id="L164" title="All 2 branches covered."> if ((docListId >= lrc.docBase)</span>
<span class="fc bfc" id="L165" title="All 2 branches covered."> && (docListId < lrc.docBase + lrc.reader().maxDoc())) {</span>
<span class="fc" id="L166"> docList.add(docListId);</span>
}
}
<span class="fc" id="L169"> Collections.sort(docList);</span>
}
<span class="fc" id="L172"> Terms t = rawReader.leaves().get(lrc.ord).reader().terms(field);</span>
<span class="pc bpc" id="L173" title="1 of 2 branches missed."> CodecInfo mtasCodecInfo = t == null ? null</span>
<span class="fc" id="L174"> : CodecInfo.getCodecInfoFromTerms(t);</span>
<span class="fc" id="L176"> collectSpansPositionsAndTokens(spansQueryWeight, searcher, mtasCodecInfo,</span>
r, lrc, field, t, docSet, docList, fieldInfo,
<span class="fc" id="L178"> rawReader.leaves().get(lrc.ord).reader().getFieldInfos());</span>
<span class="fc" id="L179"> collectPrefixes(rawReader.leaves().get(lrc.ord).reader().getFieldInfos(),</span>
field, fieldInfo);
<span class="fc" id="L181"> }</span>
// check termvectors
<span class="fc bfc" id="L184" title="All 2 branches covered."> if (!fieldInfo.termVectorList.isEmpty()</span>
<span class="fc bfc" id="L185" title="All 2 branches covered."> && needSecondRoundTermvector(fieldInfo.termVectorList)) {</span>
// check positions
<span class="fc" id="L187"> boolean needPositions = false;</span>
<span class="pc bpc" id="L188" title="1 of 2 branches missed."> if (!fieldInfo.termVectorList.isEmpty()) {</span>
<span class="fc bfc" id="L189" title="All 2 branches covered."> for (ComponentTermVector ctv : fieldInfo.termVectorList) {</span>
<span class="pc bpc" id="L190" title="1 of 2 branches missed."> if (!needPositions) {</span>
<span class="pc bpc" id="L191" title="1 of 2 branches missed."> needPositions = ctv.functions != null ? ctv.functionNeedPositions()</span>
: needPositions;
}
<span class="fc" id="L194"> }</span>
}
<span class="fc" id="L196"> Map<Integer, Integer> positionsData = null;</span>
// loop
<span class="fc" id="L199"> iterator = reader.leaves().listIterator();</span>
<span class="fc bfc" id="L200" title="All 2 branches covered."> while (iterator.hasNext()) {</span>
<span class="fc" id="L201"> LeafReaderContext lrc = iterator.next();</span>
<span class="fc" id="L202"> LeafReader r = lrc.reader();</span>
<span class="fc" id="L203"> List<Integer> docSet = docSets.get(lrc.ord);</span>
<span class="fc" id="L204"> Terms t = rawReader.leaves().get(lrc.ord).reader().terms(field);</span>
<span class="pc bpc" id="L205" title="1 of 2 branches missed."> if (needPositions) {</span>
<span class="nc bnc" id="L206" title="All 2 branches missed."> CodecInfo mtasCodecInfo = t == null ? null</span>
<span class="nc" id="L207"> : CodecInfo.getCodecInfoFromTerms(t);</span>
<span class="nc" id="L208"> positionsData = computePositions(mtasCodecInfo, r, lrc, field,</span>
docSet);
}
<span class="fc" id="L211"> createTermvectorSecondRound(fieldInfo.termVectorList, positionsData,</span>
<span class="fc" id="L212"> docSets.get(lrc.ord), t, r, lrc);</span>
<span class="fc" id="L213"> }</span>
}
<span class="fc" id="L215"> }</span>
/**
* Collect join.
*
* @param reader
* the reader
* @param docSet
* the doc set
* @param joinInfo
* the join info
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void collectJoin(IndexReader reader, List<Integer> docSet,
ComponentJoin joinInfo) throws IOException {
<span class="nc" id="L231"> BytesRef term = null;</span>
<span class="nc" id="L232"> PostingsEnum postingsEnum = null;</span>
Integer docId;
<span class="nc" id="L234"> Integer termDocId = -1;</span>
Terms terms;
LeafReaderContext lrc;
LeafReader r;
<span class="nc" id="L238"> ListIterator<LeafReaderContext> iterator = reader.leaves().listIterator();</span>
<span class="nc bnc" id="L239" title="All 2 branches missed."> while (iterator.hasNext()) {</span>
<span class="nc" id="L240"> lrc = iterator.next();</span>
<span class="nc" id="L241"> r = lrc.reader();</span>
<span class="nc bnc" id="L242" title="All 2 branches missed."> for (String field : joinInfo.fields()) {</span>
<span class="nc bnc" id="L243" title="All 2 branches missed."> if ((terms = r.fields().terms(field)) != null) {</span>
<span class="nc" id="L244"> TermsEnum termsEnum = terms.iterator();</span>
<span class="nc" id="L245"> termDocId = -1;</span>
<span class="nc bnc" id="L246" title="All 2 branches missed."> while ((term = termsEnum.next()) != null) {</span>
<span class="nc" id="L247"> Iterator<Integer> docIterator = docSet.iterator();</span>
<span class="nc" id="L248"> postingsEnum = termsEnum.postings(postingsEnum, PostingsEnum.NONE);</span>
<span class="nc bnc" id="L249" title="All 2 branches missed."> while (docIterator.hasNext()) {</span>
<span class="nc" id="L250"> docId = docIterator.next() - lrc.docBase;</span>
<span class="nc bnc" id="L251" title="All 4 branches missed."> if ((docId >= termDocId) && ((docId.equals(termDocId))</span>
<span class="nc" id="L252"> || ((termDocId = postingsEnum.advance(docId))</span>
<span class="nc bnc" id="L253" title="All 2 branches missed."> .equals(docId)))) {</span>
<span class="nc" id="L254"> joinInfo.add(term.utf8ToString());</span>
<span class="nc" id="L255"> break;</span>
}
}
<span class="nc" id="L258"> }</span>
}
<span class="nc" id="L260"> }</span>
}
<span class="nc" id="L262"> }</span>
/**
* Collect spans positions and tokens.
*
* @param spansQueryWeight
* the spans query weight
* @param searcher
* the searcher
* @param mtasCodecInfo
* the mtas codec info
* @param r
* the r
* @param lrc
* the lrc
* @param field
* the field
* @param t
* the t
* @param docSet
* the doc set
* @param docList
* the doc list
* @param fieldInfo
* the field info
* @param fieldInfos
* the field infos
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void collectSpansPositionsAndTokens(
Map<MtasSpanQuery, SpanWeight> spansQueryWeight, IndexSearcher searcher,
CodecInfo mtasCodecInfo, LeafReader r, LeafReaderContext lrc,
String field, Terms t, List<Integer> docSet, List<Integer> docList,
ComponentField fieldInfo, FieldInfos fieldInfos) throws IOException {
<span class="fc" id="L298"> boolean needSpans = false;</span>
<span class="fc" id="L299"> boolean needPositions = false;</span>
<span class="fc" id="L300"> boolean needTokens = false;</span>
// results
<span class="fc" id="L303"> Map<Integer, Integer> positionsData = null;</span>
<span class="fc" id="L304"> Map<Integer, Integer> tokensData = null;</span>
<span class="fc" id="L305"> Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData = null;</span>
<span class="fc" id="L306"> Map<MtasSpanQuery, Map<Integer, List<Match>>> spansMatchData = null;</span>
<span class="fc" id="L307"> Map<String, SortedMap<String, int[]>> facetData = null;</span>
<span class="fc" id="L308"> Map<String, String> facetDataType = null;</span>
// collect position stats
<span class="fc bfc" id="L311" title="All 2 branches covered."> if (!fieldInfo.statsPositionList.isEmpty()) {</span>
<span class="fc" id="L312"> needPositions = true;</span>
}
// collect token stats
<span class="fc bfc" id="L315" title="All 2 branches covered."> if (!fieldInfo.statsTokenList.isEmpty()) {</span>
<span class="fc" id="L316"> needTokens = true;</span>
}
<span class="fc bfc" id="L318" title="All 2 branches covered."> if (!fieldInfo.termVectorList.isEmpty()) {</span>
<span class="fc bfc" id="L319" title="All 2 branches covered."> for (ComponentTermVector ctv : fieldInfo.termVectorList) {</span>
<span class="fc bfc" id="L320" title="All 2 branches covered."> if (!needPositions) {</span>
<span class="pc bpc" id="L321" title="1 of 2 branches missed."> needPositions = (ctv.functions == null</span>
<span class="pc" id="L322"> ? ctv.subComponentFunction.parserFunction.needPositions()</span>
<span class="fc" id="L323"> : ctv.functionNeedPositions());</span>
}
<span class="fc" id="L325"> }</span>
}
// compute from spans for selected docs
<span class="fc bfc" id="L329" title="All 2 branches covered."> if (!fieldInfo.spanQueryList.isEmpty()) {</span>
// check for statsSpans
<span class="fc" id="L331"> spansNumberData = new HashMap<>();</span>
<span class="fc" id="L332"> spansMatchData = new HashMap<>();</span>
<span class="fc" id="L333"> facetData = new HashMap<>();</span>
<span class="fc" id="L334"> facetDataType = new HashMap<>();</span>
// spans
<span class="pc bpc" id="L336" title="1 of 2 branches missed."> if (!fieldInfo.statsSpanList.isEmpty()) {</span>
<span class="fc bfc" id="L337" title="All 2 branches covered."> for (ComponentSpan cs : fieldInfo.statsSpanList) {</span>
<span class="fc bfc" id="L338" title="All 2 branches covered."> needPositions = (!needPositions) ? cs.parser.needPositions()</span>
: needPositions;
<span class="fc bfc" id="L340" title="All 2 branches covered."> needPositions = (!needPositions) ? cs.functionNeedPositions()</span>
: needPositions;
<span class="pc bpc" id="L342" title="1 of 4 branches missed."> needSpans = (!needSpans) ? cs.parser.needArgumentsNumber() > 0</span>
: needSpans;
<span class="fc" id="L344"> HashSet<Integer> arguments = cs.parser.needArgument();</span>
<span class="fc" id="L345"> arguments.addAll(cs.functionNeedArguments());</span>
<span class="fc bfc" id="L346" title="All 2 branches covered."> for (int a : arguments) {</span>
<span class="pc bpc" id="L347" title="1 of 2 branches missed."> if (cs.queries.length > a) {</span>
<span class="fc" id="L348"> MtasSpanQuery q = cs.queries[a];</span>
<span class="fc bfc" id="L349" title="All 2 branches covered."> if (!spansNumberData.containsKey(q)) {</span>
<span class="fc" id="L350"> spansNumberData.put(q, new HashMap<Integer, Integer>());</span>
}
}
<span class="fc" id="L353"> }</span>
<span class="fc" id="L354"> }</span>
}
// kwic
<span class="pc bpc" id="L357" title="1 of 2 branches missed."> if (!fieldInfo.kwicList.isEmpty()) {</span>
<span class="nc" id="L358"> needSpans = true;</span>
<span class="nc bnc" id="L359" title="All 2 branches missed."> for (ComponentKwic ck : fieldInfo.kwicList) {</span>
<span class="nc bnc" id="L360" title="All 2 branches missed."> if (!spansMatchData.containsKey(ck.query)) {</span>
<span class="nc" id="L361"> spansMatchData.put(ck.query, new HashMap<Integer, List<Match>>());</span>
}
<span class="nc" id="L363"> }</span>
}
// list
<span class="pc bpc" id="L366" title="1 of 2 branches missed."> if (!fieldInfo.listList.isEmpty()) {</span>
<span class="nc" id="L367"> needSpans = true;</span>
<span class="nc bnc" id="L368" title="All 2 branches missed."> for (ComponentList cl : fieldInfo.listList) {</span>
<span class="nc bnc" id="L369" title="All 2 branches missed."> if (!spansMatchData.containsKey(cl.spanQuery)) {</span>
<span class="nc bnc" id="L370" title="All 2 branches missed."> if (cl.number > 0) {</span>
// only if needed
<span class="nc bnc" id="L372" title="All 2 branches missed."> if (cl.position < (cl.start + cl.number)) {</span>
<span class="nc" id="L373"> spansMatchData.put(cl.spanQuery,</span>
new HashMap<Integer, List<Match>>());
} else {
<span class="nc" id="L376"> spansNumberData.put(cl.spanQuery,</span>
new HashMap<Integer, Integer>());
}
<span class="nc bnc" id="L379" title="All 2 branches missed."> } else if (!spansNumberData.containsKey(cl.spanQuery)) {</span>
<span class="nc" id="L380"> spansNumberData.put(cl.spanQuery,</span>
new HashMap<Integer, Integer>());
}
}
<span class="nc" id="L384"> }</span>
}
// group
<span class="fc bfc" id="L387" title="All 2 branches covered."> if (!fieldInfo.groupList.isEmpty()) {</span>
<span class="fc" id="L388"> needSpans = true;</span>
<span class="fc bfc" id="L389" title="All 2 branches covered."> for (ComponentGroup cg : fieldInfo.groupList) {</span>
<span class="pc bpc" id="L390" title="1 of 2 branches missed."> if (!spansMatchData.containsKey(cg.spanQuery)) {</span>
<span class="fc" id="L391"> spansMatchData.put(cg.spanQuery,</span>
new HashMap<Integer, List<Match>>());
}
<span class="fc" id="L394"> }</span>
}
// facet
<span class="pc bpc" id="L397" title="1 of 2 branches missed."> if (!fieldInfo.facetList.isEmpty()) {</span>
<span class="nc bnc" id="L398" title="All 2 branches missed."> for (ComponentFacet cf : fieldInfo.facetList) {</span>
<span class="nc bnc" id="L399" title="All 2 branches missed."> needPositions = !needPositions ? cf.baseParserNeedPositions()</span>
: needPositions;
<span class="nc bnc" id="L401" title="All 2 branches missed."> needPositions = !needPositions ? cf.functionNeedPositions()</span>
: needPositions;
<span class="nc bnc" id="L403" title="All 2 branches missed."> for (int i = 0; i < cf.baseFields.length; i++) {</span>
<span class="nc bnc" id="L404" title="All 4 branches missed."> needSpans = !needSpans ? cf.baseParsers[i].needArgumentsNumber() > 0</span>
: needSpans;
<span class="nc" id="L406"> HashSet<Integer> arguments = cf.baseParsers[i].needArgument();</span>
<span class="nc bnc" id="L407" title="All 2 branches missed."> for (int a : arguments) {</span>
<span class="nc bnc" id="L408" title="All 2 branches missed."> if (cf.spanQueries.length > a) {</span>
<span class="nc" id="L409"> MtasSpanQuery q = cf.spanQueries[a];</span>
<span class="nc bnc" id="L410" title="All 2 branches missed."> if (!spansNumberData.containsKey(q)) {</span>
<span class="nc" id="L411"> spansNumberData.put(q, new HashMap<Integer, Integer>());</span>
}
}
<span class="nc" id="L414"> }</span>
<span class="nc bnc" id="L415" title="All 2 branches missed."> for (MtasFunctionParserFunction function : cf.baseFunctionParserFunctions[i]) {</span>
<span class="nc bnc" id="L416" title="All 4 branches missed."> needSpans = !needSpans ? function.needArgumentsNumber() > 0</span>
: needSpans;
<span class="nc" id="L418"> arguments = function.needArgument();</span>
<span class="nc bnc" id="L419" title="All 2 branches missed."> for (int a : arguments) {</span>
<span class="nc bnc" id="L420" title="All 2 branches missed."> if (cf.spanQueries.length > a) {</span>
<span class="nc" id="L421"> MtasSpanQuery q = cf.spanQueries[a];</span>
<span class="nc bnc" id="L422" title="All 2 branches missed."> if (!spansNumberData.containsKey(q)) {</span>
<span class="nc" id="L423"> spansNumberData.put(q, new HashMap<Integer, Integer>());</span>
}
}
<span class="nc" id="L426"> }</span>
}
<span class="nc bnc" id="L428" title="All 2 branches missed."> if (!facetData.containsKey(cf.baseFields[i])) {</span>
<span class="nc" id="L429"> facetData.put(cf.baseFields[i], new TreeMap<String, int[]>());</span>
<span class="nc" id="L430"> facetDataType.put(cf.baseFields[i], cf.baseFieldTypes[i]);</span>
}
}
<span class="nc" id="L433"> }</span>
}
// termvector
<span class="pc bpc" id="L436" title="1 of 2 branches missed."> if (!fieldInfo.termVectorList.isEmpty()) {</span>
<span class="nc bnc" id="L437" title="All 2 branches missed."> for (ComponentTermVector ctv : fieldInfo.termVectorList) {</span>
<span class="nc bnc" id="L438" title="All 2 branches missed."> if ((ctv.subComponentFunction.parserFunction != null</span>
<span class="nc bnc" id="L439" title="All 4 branches missed."> && ctv.subComponentFunction.parserFunction.needPositions())</span>
<span class="nc bnc" id="L440" title="All 2 branches missed."> || (ctv.functions != null && ctv.functionNeedPositions())) {</span>
<span class="nc" id="L441"> needPositions = true;</span>
}
<span class="nc" id="L443"> }</span>
}
}
<span class="fc bfc" id="L447" title="All 2 branches covered."> if (needSpans) {</span>
Map<Integer, Integer> numberData;
Map<Integer, List<Match>> matchData;
// collect values for facetFields
<span class="pc bpc" id="L452" title="1 of 2 branches missed."> for (Entry<String, SortedMap<String, int[]>> entry : facetData</span>
<span class="fc" id="L453"> .entrySet()) {</span>
<span class="nc" id="L454"> Terms fft = r.terms(entry.getKey());</span>
<span class="nc bnc" id="L455" title="All 2 branches missed."> if (fft != null) {</span>
<span class="nc" id="L456"> TermsEnum termsEnum = fft.iterator();</span>
<span class="nc" id="L457"> BytesRef term = null;</span>
<span class="nc" id="L458"> PostingsEnum postingsEnum = null;</span>
<span class="nc" id="L459"> SortedMap<String, int[]> facetDataList = entry.getValue();</span>
<span class="nc bnc" id="L460" title="All 2 branches missed."> while ((term = termsEnum.next()) != null) {</span>
int docId;
<span class="nc" id="L462"> int termDocId = -1;</span>
<span class="nc" id="L463"> int[] facetDataSublist = new int[docSet.size()];</span>
<span class="nc" id="L464"> int facetDataSublistCounter = 0;</span>
<span class="nc" id="L465"> Iterator<Integer> docIterator = docSet.iterator();</span>
<span class="nc" id="L466"> postingsEnum = termsEnum.postings(postingsEnum);</span>
<span class="nc bnc" id="L467" title="All 2 branches missed."> while (docIterator.hasNext()) {</span>
<span class="nc" id="L468"> docId = docIterator.next() - lrc.docBase;</span>
<span class="nc bnc" id="L469" title="All 4 branches missed."> if (docId >= termDocId && ((docId == termDocId)</span>
<span class="nc bnc" id="L470" title="All 2 branches missed."> || ((termDocId = postingsEnum.advance(docId)) == docId))) {</span>
<span class="nc" id="L471"> facetDataSublist[facetDataSublistCounter] = docId + lrc.docBase;</span>
<span class="nc" id="L472"> facetDataSublistCounter++;</span>
}
}
<span class="nc bnc" id="L475" title="All 2 branches missed."> if (facetDataSublistCounter > 0) {</span>
<span class="nc" id="L476"> String termValue = null;</span>
<span class="nc" id="L477"> if (facetDataType.get(entry.getKey())</span>
<span class="nc bnc" id="L478" title="All 2 branches missed."> .equals(ComponentFacet.TYPE_INTEGER)) {</span>
// only values without shifting bits
<span class="nc bnc" id="L480" title="All 2 branches missed."> if (term.bytes[term.offset] == LegacyNumericUtils.SHIFT_START_INT) {</span>
<span class="nc" id="L481"> termValue = Integer</span>
<span class="nc" id="L482"> .toString(LegacyNumericUtils.prefixCodedToInt(term));</span>
} else {
continue;
}
<span class="nc" id="L486"> } else if (facetDataType.get(entry.getKey())</span>
<span class="nc bnc" id="L487" title="All 2 branches missed."> .equals(ComponentFacet.TYPE_LONG)) {</span>
<span class="nc bnc" id="L488" title="All 2 branches missed."> if (term.bytes[term.offset] == LegacyNumericUtils.SHIFT_START_LONG) {</span>
<span class="nc" id="L489"> termValue = Long</span>
<span class="nc" id="L490"> .toString(LegacyNumericUtils.prefixCodedToLong(term));</span>
} else {
continue;
}
} else {
<span class="nc" id="L495"> termValue = term.utf8ToString();</span>
}
<span class="nc bnc" id="L497" title="All 2 branches missed."> if (!facetDataList.containsKey(termValue)) {</span>
<span class="nc" id="L498"> facetDataList.put(termValue,</span>
<span class="nc" id="L499"> Arrays.copyOf(facetDataSublist, facetDataSublistCounter));</span>
} else {
<span class="nc" id="L501"> int[] oldList = facetDataList.get(termValue);</span>
<span class="nc" id="L502"> int[] newList = new int[oldList.length</span>
+ facetDataSublistCounter];
<span class="nc" id="L504"> System.arraycopy(oldList, 0, newList, 0, oldList.length);</span>
<span class="nc" id="L505"> System.arraycopy(facetDataSublist, 0, newList, oldList.length,</span>
facetDataSublistCounter);
<span class="nc" id="L507"> facetDataList.put(termValue, newList);</span>
}
}
<span class="nc" id="L510"> }</span>
}
<span class="nc" id="L512"> }</span>
<span class="fc bfc" id="L514" title="All 2 branches covered."> for (MtasSpanQuery sq : fieldInfo.spanQueryList) {</span>
// what to collect
<span class="pc bpc" id="L516" title="1 of 2 branches missed."> if (spansNumberData.containsKey(sq)) {</span>
<span class="fc" id="L517"> numberData = spansNumberData.get(sq);</span>
} else {
<span class="nc" id="L519"> numberData = null;</span>
}
<span class="fc bfc" id="L521" title="All 2 branches covered."> if (spansMatchData.containsKey(sq)) {</span>
<span class="fc" id="L522"> matchData = spansMatchData.get(sq);</span>
} else {
<span class="fc" id="L524"> matchData = null;</span>
}
<span class="pc bpc" id="L526" title="3 of 4 branches missed."> if ((numberData != null) || (matchData != null)) {</span>
<span class="fc" id="L527"> Spans spans = spansQueryWeight.get(sq).getSpans(lrc,</span>
SpanWeight.Postings.POSITIONS);
<span class="fc bfc" id="L529" title="All 2 branches covered."> if (spans != null) {</span>
Iterator<Integer> it;
<span class="pc bpc" id="L531" title="1 of 2 branches missed."> if (docSet != null) {</span>
<span class="fc" id="L532"> it = docSet.iterator();</span>
} else {
<span class="nc" id="L534"> it = docList.iterator();</span>
}
<span class="pc bpc" id="L536" title="1 of 2 branches missed."> if (it.hasNext()) {</span>
<span class="fc" id="L537"> int docId = it.next();</span>
int number;
ArrayList<Match> matchDataList;
<span class="fc" id="L540"> Integer spansDocId = null;</span>
<span class="pc bpc" id="L541" title="1 of 2 branches missed."> while (docId != DocIdSetIterator.NO_MORE_DOCS) {</span>
<span class="fc bfc" id="L542" title="All 2 branches covered."> if (spans.advance(</span>
(docId - lrc.docBase)) == DocIdSetIterator.NO_MORE_DOCS) {
<span class="fc" id="L544"> break;</span>
}
<span class="fc" id="L546"> spansDocId = spans.docID() + lrc.docBase;</span>
<span class="pc bpc" id="L547" title="1 of 4 branches missed."> while ((docId < spansDocId) && it.hasNext()) {</span>
<span class="fc" id="L548"> docId = it.next();</span>
}
<span class="pc bpc" id="L550" title="1 of 2 branches missed."> if (docId < spansDocId) {</span>
<span class="nc" id="L551"> break;</span>
}
<span class="pc bpc" id="L553" title="1 of 2 branches missed."> if (spansDocId.equals(docId)) {</span>
<span class="fc" id="L554"> number = 0;</span>
<span class="fc" id="L555"> matchDataList = new ArrayList<>();</span>
int tmpStartPosition;
<span class="fc" id="L557"> while ((tmpStartPosition = spans</span>
<span class="fc bfc" id="L558" title="All 2 branches covered."> .nextStartPosition()) != Spans.NO_MORE_POSITIONS) {</span>
<span class="fc" id="L559"> number++;</span>
<span class="fc bfc" id="L560" title="All 2 branches covered."> if (matchData != null) {</span>
<span class="fc" id="L561"> Match m = new Match(tmpStartPosition,</span>
<span class="fc" id="L562"> spans.endPosition());</span>
<span class="fc" id="L563"> matchDataList.add(m);</span>
<span class="fc" id="L564"> }</span>
}
<span class="pc bpc" id="L566" title="1 of 2 branches missed."> if ((numberData != null)) {</span>
<span class="fc" id="L567"> numberData.put(spansDocId, number);</span>
}
<span class="fc bfc" id="L569" title="All 2 branches covered."> if ((matchData != null)) {</span>
<span class="fc" id="L570"> matchData.put(spansDocId, matchDataList);</span>
}
<span class="fc bfc" id="L572" title="All 2 branches covered."> if (it.hasNext()) {</span>
<span class="fc" id="L573"> docId = it.next();</span>
} else {
break;
}
<span class="fc" id="L577"> }</span>
}
}
}
}
<span class="fc" id="L582"> }</span>
}
// collect position stats
<span class="fc bfc" id="L586" title="All 2 branches covered."> if (needPositions) {</span>
<span class="pc bpc" id="L587" title="1 of 2 branches missed."> if (mtasCodecInfo != null) {</span>
// for relatively small numbers, compute only what is needed
<span class="fc bfc" id="L589" title="All 2 branches covered."> if (docSet.size() < Math.log(r.maxDoc())) {</span>
<span class="fc" id="L590"> positionsData = new HashMap<>();</span>
<span class="fc bfc" id="L591" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L592"> positionsData.put(docId, mtasCodecInfo.getNumberOfPositions(field,</span>
(docId - lrc.docBase)));
<span class="fc" id="L594"> }</span>
// compute everything, only use what is needed
} else {
<span class="fc" id="L597"> positionsData = mtasCodecInfo.getAllNumberOfPositions(field,</span>
lrc.docBase);
<span class="fc bfc" id="L599" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="pc bpc" id="L600" title="1 of 2 branches missed."> if (!positionsData.containsKey(docId)) {</span>
<span class="nc" id="L601"> positionsData.put(docId, 0);</span>
}
<span class="fc" id="L603"> }</span>
}
} else {
<span class="nc" id="L606"> positionsData = new HashMap<>();</span>
<span class="nc bnc" id="L607" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L608"> positionsData.put(docId, 0);</span>
<span class="nc" id="L609"> }</span>
}
}
// collect token stats
<span class="fc bfc" id="L614" title="All 2 branches covered."> if (needTokens) {</span>
<span class="pc bpc" id="L615" title="1 of 2 branches missed."> if (mtasCodecInfo != null) {</span>
// for relatively small numbers, compute only what is needed
<span class="fc bfc" id="L617" title="All 2 branches covered."> if (docSet.size() < Math.log(r.maxDoc())) {</span>
<span class="fc" id="L618"> tokensData = new HashMap<>();</span>
<span class="fc bfc" id="L619" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L620"> tokensData.put(docId,</span>
<span class="fc" id="L621"> mtasCodecInfo.getNumberOfTokens(field, (docId - lrc.docBase)));</span>
<span class="fc" id="L622"> }</span>
// compute everything, only use what is needed
} else {
<span class="fc" id="L625"> tokensData = mtasCodecInfo.getAllNumberOfTokens(field, lrc.docBase);</span>
<span class="fc bfc" id="L626" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="pc bpc" id="L627" title="1 of 2 branches missed."> if (!tokensData.containsKey(docId)) {</span>
<span class="nc" id="L628"> tokensData.put(docId, 0);</span>
}
<span class="fc" id="L630"> }</span>
}
} else {
<span class="nc" id="L633"> tokensData = new HashMap<>();</span>
<span class="nc bnc" id="L634" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L635"> tokensData.put(docId, 0);</span>
<span class="nc" id="L636"> }</span>
}
}
<span class="fc bfc" id="L640" title="All 2 branches covered."> if (!fieldInfo.statsPositionList.isEmpty()) {</span>
// create positions
<span class="fc" id="L642"> createPositions(fieldInfo.statsPositionList, positionsData, docSet);</span>
}
<span class="fc bfc" id="L645" title="All 2 branches covered."> if (!fieldInfo.statsTokenList.isEmpty()) {</span>
// create positions
<span class="fc" id="L647"> createTokens(fieldInfo.statsTokenList, tokensData, docSet);</span>
}
<span class="pc bpc" id="L650" title="1 of 2 branches missed."> if (!fieldInfo.documentList.isEmpty()) {</span>
// create document
<span class="nc" id="L652"> createDocument(fieldInfo.documentList, docList, fieldInfo.uniqueKeyField,</span>
searcher, t, lrc);
}
<span class="fc bfc" id="L655" title="All 2 branches covered."> if (!fieldInfo.spanQueryList.isEmpty()) {</span>
<span class="pc bpc" id="L656" title="1 of 2 branches missed."> if (!fieldInfo.statsSpanList.isEmpty()) {</span>
// create stats
<span class="fc" id="L658"> createStats(fieldInfo.statsSpanList, positionsData, spansNumberData,</span>
<span class="fc" id="L659"> docSet.toArray(new Integer[docSet.size()]));</span>
}
<span class="pc bpc" id="L661" title="1 of 2 branches missed."> if (!fieldInfo.listList.isEmpty()) {</span>
// create list
<span class="nc" id="L663"> createList(fieldInfo.listList, spansNumberData, spansMatchData, docSet,</span>
field, lrc.docBase, fieldInfo.uniqueKeyField, mtasCodecInfo,
searcher);
}
<span class="fc bfc" id="L667" title="All 2 branches covered."> if (!fieldInfo.groupList.isEmpty()) {</span>
// create group
<span class="fc" id="L669"> createGroup(fieldInfo.groupList, spansMatchData, docSet,</span>
<span class="fc" id="L670"> fieldInfos.fieldInfo(field), field, lrc.docBase, mtasCodecInfo,</span>
searcher, lrc);
}
<span class="pc bpc" id="L673" title="1 of 2 branches missed."> if (!fieldInfo.kwicList.isEmpty()) {</span>
// create kwic
<span class="nc" id="L675"> createKwic(fieldInfo.kwicList, spansMatchData, docList, field,</span>
lrc.docBase, fieldInfo.uniqueKeyField, mtasCodecInfo, searcher);
}
<span class="pc bpc" id="L678" title="1 of 2 branches missed."> if (!fieldInfo.facetList.isEmpty()) {</span>
// create facets
<span class="nc" id="L680"> createFacet(fieldInfo.facetList, positionsData, spansNumberData,</span>
facetData, docSet);
}
}
<span class="fc bfc" id="L684" title="All 2 branches covered."> if (!fieldInfo.termVectorList.isEmpty()) {</span>
<span class="fc" id="L685"> createTermvectorFull(fieldInfo.termVectorList, positionsData, docSet, t,</span>
r, lrc);
<span class="fc" id="L687"> createTermvectorFirstRound(fieldInfo.termVectorList, positionsData,</span>
docSet, t, r, lrc);
}
<span class="fc" id="L690"> }</span>
/**
* Collect known prefixes.
*
* @param fi
* the fi
* @return the sets the
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static Set<String> collectKnownPrefixes(FieldInfo fi)
throws IOException {
<span class="pc bpc" id="L703" title="1 of 2 branches missed."> if (fi != null) {</span>
<span class="fc" id="L704"> HashSet<String> result = new HashSet<>();</span>
<span class="fc" id="L705"> String singlePositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SINGLE_POSITION);
<span class="fc" id="L707"> String multiplePositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_MULTIPLE_POSITION);
<span class="fc" id="L709"> String setPositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SET_POSITION);
<span class="pc bpc" id="L711" title="1 of 2 branches missed."> if (singlePositionPrefixes != null) {</span>
<span class="fc" id="L712"> String[] prefixes = singlePositionPrefixes</span>
<span class="fc" id="L713"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L714" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L715"> String item = prefixes[i].trim();</span>
<span class="pc bpc" id="L716" title="1 of 2 branches missed."> if (!item.equals("")) {</span>
<span class="fc" id="L717"> result.add(item);</span>
}
}
}
<span class="pc bpc" id="L721" title="1 of 2 branches missed."> if (multiplePositionPrefixes != null) {</span>
<span class="fc" id="L722"> String[] prefixes = multiplePositionPrefixes</span>
<span class="fc" id="L723"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L724" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L725"> String item = prefixes[i].trim();</span>
<span class="pc bpc" id="L726" title="1 of 2 branches missed."> if (!item.equals("")) {</span>
<span class="fc" id="L727"> result.add(item);</span>
}
}
}
<span class="pc bpc" id="L731" title="1 of 2 branches missed."> if (setPositionPrefixes != null) {</span>
<span class="fc" id="L732"> String[] prefixes = setPositionPrefixes</span>
<span class="fc" id="L733"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L734" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L735"> String item = prefixes[i].trim();</span>
<span class="pc bpc" id="L736" title="1 of 2 branches missed."> if (!item.equals("")) {</span>
<span class="fc" id="L737"> result.add(item);</span>
}
}
}
<span class="fc" id="L741"> return result;</span>
} else {
<span class="nc" id="L743"> return Collections.emptySet();</span>
}
}
/**
* Collect intersection prefixes.
*
* @param fi
* the fi
* @return the sets the
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static Set<String> collectIntersectionPrefixes(FieldInfo fi)
throws IOException {
<span class="pc bpc" id="L758" title="1 of 2 branches missed."> if (fi != null) {</span>
<span class="fc" id="L759"> Set<String> result = new HashSet<>();</span>
<span class="fc" id="L760"> String intersectingPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_INTERSECTION);
<span class="pc bpc" id="L762" title="1 of 2 branches missed."> if (intersectingPrefixes != null) {</span>
<span class="fc" id="L763"> String[] prefixes = intersectingPrefixes</span>
<span class="fc" id="L764"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L765" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L766"> String item = prefixes[i].trim();</span>
<span class="pc bpc" id="L767" title="1 of 2 branches missed."> if (!item.equals("")) {</span>
<span class="fc" id="L768"> result.add(item);</span>
}
}
}
<span class="fc" id="L772"> return result;</span>
} else {
<span class="nc" id="L774"> return Collections.emptySet();</span>
}
}
/**
* Collect prefixes.
*
* @param fieldInfos
* the field infos
* @param field
* the field
* @param fieldInfo
* the field info
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void collectPrefixes(FieldInfos fieldInfos, String field,
ComponentField fieldInfo) throws IOException {
<span class="fc bfc" id="L792" title="All 2 branches covered."> if (fieldInfo.prefix != null) {</span>
<span class="fc" id="L793"> FieldInfo fi = fieldInfos.fieldInfo(field);</span>
<span class="pc bpc" id="L794" title="1 of 2 branches missed."> if (fi != null) {</span>
<span class="fc" id="L795"> String singlePositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SINGLE_POSITION);
<span class="fc" id="L797"> String multiplePositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_MULTIPLE_POSITION);
<span class="fc" id="L799"> String setPositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SET_POSITION);
<span class="fc" id="L801"> String intersectingPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_INTERSECTION);
<span class="pc bpc" id="L803" title="1 of 2 branches missed."> if (singlePositionPrefixes != null) {</span>
<span class="fc" id="L804"> String[] prefixes = singlePositionPrefixes</span>
<span class="fc" id="L805"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L806" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L807"> fieldInfo.prefix.addSinglePosition(prefixes[i]);</span>
}
}
<span class="pc bpc" id="L810" title="1 of 2 branches missed."> if (multiplePositionPrefixes != null) {</span>
<span class="fc" id="L811"> String[] prefixes = multiplePositionPrefixes</span>
<span class="fc" id="L812"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L813" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L814"> fieldInfo.prefix.addMultiplePosition(prefixes[i]);</span>
}
}
<span class="pc bpc" id="L817" title="1 of 2 branches missed."> if (setPositionPrefixes != null) {</span>
<span class="fc" id="L818"> String[] prefixes = setPositionPrefixes</span>
<span class="fc" id="L819"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L820" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L821"> fieldInfo.prefix.addSetPosition(prefixes[i]);</span>
}
}
<span class="pc bpc" id="L824" title="1 of 2 branches missed."> if (intersectingPrefixes != null) {</span>
<span class="fc" id="L825"> String[] prefixes = intersectingPrefixes</span>
<span class="fc" id="L826"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L827" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L828"> fieldInfo.prefix.addIntersecting(prefixes[i]);</span>
}
}
}
}
<span class="fc" id="L833"> }</span>
/**
* Collect spans for occurences.
*
* @param occurences
* the occurences
* @param prefixes
* the prefixes
* @param field
* the field
* @param searcher
* the searcher
* @param lrc
* the lrc
* @return the map
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static Map<GroupHit, Spans> collectSpansForOccurences(
Set<GroupHit> occurences, Set<String> prefixes, String field,
IndexSearcher searcher, LeafReaderContext lrc) throws IOException {
<span class="nc" id="L855"> Map<GroupHit, Spans> list = new HashMap<>();</span>
<span class="nc" id="L856"> IndexReader reader = searcher.getIndexReader();</span>
<span class="nc bnc" id="L857" title="All 2 branches missed."> for (GroupHit hit : occurences) {</span>
<span class="nc" id="L858"> MtasSpanQuery queryHit = createQueryFromGroupHit(prefixes, field, hit);</span>
<span class="nc bnc" id="L859" title="All 2 branches missed."> if (queryHit != null) {</span>
<span class="nc" id="L860"> MtasSpanQuery queryHitRewritten = queryHit.rewrite(reader);</span>
<span class="nc" id="L861"> SpanWeight weight = queryHitRewritten.createWeight(searcher, false);</span>
<span class="nc" id="L862"> Spans spans = weight.getSpans(lrc, SpanWeight.Postings.POSITIONS);</span>
<span class="nc bnc" id="L863" title="All 2 branches missed."> if (spans != null) {</span>
<span class="nc" id="L864"> list.put(hit, spans);</span>
}
}
<span class="nc" id="L867"> }</span>
<span class="nc" id="L868"> return list;</span>
}
/**
* Creates the query from group hit.
*
* @param prefixes
* the prefixes
* @param field
* the field
* @param hit
* the hit
* @return the mtas span query
*/
private static MtasSpanQuery createQueryFromGroupHit(Set<String> prefixes,
String field, GroupHit hit) {
// initial check
<span class="nc bnc" id="L885" title="All 6 branches missed."> if (prefixes == null || field == null || hit == null) {</span>
<span class="nc" id="L886"> return null;</span>
} else {
<span class="nc" id="L888"> MtasSpanQuery query = null;</span>
<span class="nc" id="L889"> MtasSpanQuery hitQuery = null;</span>
// check for missing
<span class="nc bnc" id="L891" title="All 4 branches missed."> if (hit.missingLeft != null && hit.missingLeft.length > 0) {</span>
<span class="nc bnc" id="L892" title="All 2 branches missed."> for (int i = 0; i < hit.missingLeft.length; i++) {</span>
<span class="nc bnc" id="L893" title="All 2 branches missed."> if (hit.missingLeft[i].size() != hit.unknownLeft[i].size()) {</span>
<span class="nc" id="L894"> return null;</span>
}
}
}
<span class="nc bnc" id="L898" title="All 4 branches missed."> if (hit.missingHit != null && hit.missingHit.length > 0) {</span>
<span class="nc bnc" id="L899" title="All 2 branches missed."> for (int i = 0; i < hit.missingHit.length; i++) {</span>
<span class="nc bnc" id="L900" title="All 2 branches missed."> if (hit.missingHit[i].size() != hit.unknownHit[i].size()) {</span>
<span class="nc" id="L901"> return null;</span>
}
}
}
<span class="nc bnc" id="L905" title="All 4 branches missed."> if (hit.missingRight != null && hit.missingRight.length > 0) {</span>
<span class="nc bnc" id="L906" title="All 2 branches missed."> for (int i = 0; i < hit.missingRight.length; i++) {</span>
<span class="nc bnc" id="L907" title="All 2 branches missed."> if (hit.missingRight[i].size() != hit.unknownRight[i].size()) {</span>
<span class="nc" id="L908"> return null;</span>
}
}
}
<span class="nc bnc" id="L913" title="All 4 branches missed."> if (hit.dataHit != null && hit.dataHit.length > 0) {</span>
<span class="nc" id="L914"> List<MtasSpanSequenceItem> items = new ArrayList<>();</span>
<span class="nc bnc" id="L915" title="All 2 branches missed."> for (int i = 0; i < hit.dataHit.length; i++) {</span>
<span class="nc" id="L916"> MtasSpanQuery item = null;</span>
<span class="nc bnc" id="L917" title="All 2 branches missed."> if (hit.dataHit[i].isEmpty()) {</span>
<span class="nc" id="L918"> item = new MtasSpanMatchAllQuery(field);</span>
<span class="nc bnc" id="L919" title="All 2 branches missed."> } else if (hit.dataHit[i].size() == 1) {</span>
<span class="nc" id="L920"> Term term = new Term(field, hit.dataHit[i].get(0));</span>
<span class="nc" id="L921"> item = new MtasSpanTermQuery(term);</span>
<span class="nc" id="L922"> } else {</span>
<span class="nc" id="L923"> MtasSpanQuery[] subList = new MtasSpanQuery[hit.dataHit[i].size()];</span>
<span class="nc bnc" id="L924" title="All 2 branches missed."> for (int j = 0; j < hit.dataHit[i].size(); j++) {</span>
<span class="nc" id="L925"> Term term = new Term(field, hit.dataHit[i].get(j));</span>
<span class="nc" id="L926"> subList[j] = new MtasSpanTermQuery(term);</span>
}
<span class="nc" id="L928"> item = new MtasSpanAndQuery(subList);</span>
}
<span class="nc" id="L930"> items.add(new MtasSpanSequenceItem(item, false));</span>
}
<span class="nc" id="L932"> hitQuery = new MtasSpanSequenceQuery(items, null, null);</span>
}
<span class="nc bnc" id="L934" title="All 2 branches missed."> if (hitQuery != null) {</span>
<span class="nc" id="L935"> query = hitQuery;</span>
}
<span class="nc" id="L937"> return query;</span>
}
}
/**
* Compute positions.
*
* @param mtasCodecInfo
* the mtas codec info
* @param r
* the r
* @param lrc
* the lrc
* @param field
* the field
* @param docSet
* the doc set
* @return the map
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static Map<Integer, Integer> computePositions(CodecInfo mtasCodecInfo,
LeafReader r, LeafReaderContext lrc, String field, List<Integer> docSet)
throws IOException {
HashMap<Integer, Integer> positionsData;
<span class="nc bnc" id="L962" title="All 2 branches missed."> if (mtasCodecInfo != null) {</span>
// for relatively small numbers, compute only what is needed
<span class="nc bnc" id="L964" title="All 2 branches missed."> if (docSet.size() < Math.log(r.maxDoc())) {</span>
<span class="nc" id="L965"> positionsData = new HashMap<>();</span>
<span class="nc bnc" id="L966" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L967"> positionsData.put(docId,</span>
<span class="nc" id="L968"> mtasCodecInfo.getNumberOfPositions(field, (docId - lrc.docBase)));</span>
<span class="nc" id="L969"> }</span>
// compute everything, only use what is needed
} else {
<span class="nc" id="L972"> positionsData = mtasCodecInfo.getAllNumberOfPositions(field,</span>
lrc.docBase);
<span class="nc bnc" id="L974" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc bnc" id="L975" title="All 2 branches missed."> if (!positionsData.containsKey(docId)) {</span>
<span class="nc" id="L976"> positionsData.put(docId, 0);</span>
}
<span class="nc" id="L978"> }</span>
}
} else {
<span class="nc" id="L981"> positionsData = new HashMap<>();</span>
<span class="nc bnc" id="L982" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L983"> positionsData.put(docId, 0);</span>
<span class="nc" id="L984"> }</span>
}
<span class="nc" id="L986"> return positionsData;</span>
}
/**
* Compute arguments.
*
* @param spansNumberData
* the spans number data
* @param queries
* the queries
* @param docSet
* the doc set
* @return the map
*/
private static Map<Integer, long[]> computeArguments(
Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData,
MtasSpanQuery[] queries, Integer[] docSet) {
<span class="fc" id="L1003"> Map<Integer, long[]> args = new HashMap<>();</span>
<span class="fc bfc" id="L1004" title="All 2 branches covered."> for (int q = 0; q < queries.length; q++) {</span>
<span class="fc" id="L1005"> Map<Integer, Integer> tmpData = spansNumberData.get(queries[q]);</span>
<span class="fc" id="L1006"> long[] tmpList = null;</span>
<span class="fc bfc" id="L1007" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="pc bpc" id="L1008" title="1 of 4 branches missed."> if (tmpData != null && tmpData.containsKey(docId)) {</span>
<span class="fc bfc" id="L1009" title="All 2 branches covered."> if (!args.containsKey(docId)) {</span>
<span class="fc" id="L1010"> tmpList = new long[queries.length];</span>
} else {
<span class="fc" id="L1012"> tmpList = args.get(docId);</span>
}
<span class="fc" id="L1014"> tmpList[q] = tmpData.get(docId);</span>
<span class="fc" id="L1015"> args.put(docId, tmpList);</span>
<span class="pc bpc" id="L1016" title="1 of 2 branches missed."> } else if (!args.containsKey(docId)) {</span>
<span class="fc" id="L1017"> tmpList = new long[queries.length];</span>
<span class="fc" id="L1018"> args.put(docId, tmpList);</span>
}
}
}
<span class="fc" id="L1022"> return args;</span>
}
/**
* Intersected doc list.
*
* @param facetDocList
* the facet doc list
* @param docSet
* the doc set
* @return the integer[]
*/
private static Integer[] intersectedDocList(int[] facetDocList,
Integer[] docSet) {
<span class="nc bnc" id="L1036" title="All 4 branches missed."> if (facetDocList != null && docSet != null) {</span>
<span class="nc" id="L1037"> Integer[] c = new Integer[Math.min(facetDocList.length, docSet.length)];</span>
<span class="nc" id="L1038"> int ai = 0;</span>
<span class="nc" id="L1039"> int bi = 0;</span>
<span class="nc" id="L1040"> int ci = 0;</span>
<span class="nc bnc" id="L1041" title="All 4 branches missed."> while (ai < facetDocList.length && bi < docSet.length) {</span>
<span class="nc bnc" id="L1042" title="All 2 branches missed."> if (facetDocList[ai] < docSet[bi]) {</span>
<span class="nc" id="L1043"> ai++;</span>
<span class="nc bnc" id="L1044" title="All 2 branches missed."> } else if (facetDocList[ai] > docSet[bi]) {</span>
<span class="nc" id="L1045"> bi++;</span>
} else {
<span class="nc bnc" id="L1047" title="All 4 branches missed."> if (ci == 0 || facetDocList[ai] != c[ci - 1]) {</span>
<span class="nc" id="L1048"> c[ci++] = facetDocList[ai];</span>
}
<span class="nc" id="L1050"> ai++;</span>
<span class="nc" id="L1051"> bi++;</span>
}
}
<span class="nc" id="L1054"> return Arrays.copyOfRange(c, 0, ci);</span>
}
<span class="nc" id="L1056"> return new Integer[] {};</span>
}
/**
* Creates the positions.
*
* @param statsPositionList
* the stats position list
* @param positionsData
* the positions data
* @param docSet
* the doc set
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createPositions(List<ComponentPosition> statsPositionList,
Map<Integer, Integer> positionsData, List<Integer> docSet)
throws IOException {
<span class="pc bpc" id="L1074" title="1 of 2 branches missed."> if (statsPositionList != null) {</span>
<span class="fc bfc" id="L1075" title="All 2 branches covered."> for (ComponentPosition position : statsPositionList) {</span>
<span class="fc" id="L1076"> position.dataCollector.initNewList(1);</span>
Integer tmpValue;
<span class="fc" id="L1078"> long[] values = new long[docSet.size()];</span>
int value;
<span class="fc" id="L1080"> int number = 0;</span>
<span class="fc bfc" id="L1081" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L1082"> tmpValue = positionsData.get(docId);</span>
<span class="pc bpc" id="L1083" title="1 of 2 branches missed."> value = tmpValue == null ? 0 : tmpValue.intValue();</span>
<span class="fc bfc" id="L1084" title="All 2 branches covered."> if (((position.minimumLong == null)</span>
<span class="fc bfc" id="L1085" title="All 4 branches covered."> || (value >= position.minimumLong))</span>
&& ((position.maximumLong == null)
<span class="fc bfc" id="L1087" title="All 2 branches covered."> || (value <= position.maximumLong))) {</span>
<span class="fc" id="L1088"> values[number] = value;</span>
<span class="fc" id="L1089"> number++;</span>
}
<span class="fc" id="L1091"> }</span>
<span class="fc bfc" id="L1092" title="All 2 branches covered."> if (number > 0) {</span>
<span class="fc" id="L1093"> position.dataCollector.add(values, number);</span>
}
<span class="fc" id="L1095"> position.dataCollector.closeNewList();</span>
<span class="fc" id="L1096"> }</span>
}
<span class="fc" id="L1098"> }</span>
/**
* Creates the tokens.
*
* @param statsTokenList
* the stats token list
* @param tokensData
* the tokens data
* @param docSet
* the doc set
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createTokens(List<ComponentToken> statsTokenList,
Map<Integer, Integer> tokensData, List<Integer> docSet)
throws IOException {
<span class="pc bpc" id="L1115" title="1 of 2 branches missed."> if (statsTokenList != null) {</span>
<span class="fc bfc" id="L1116" title="All 2 branches covered."> for (ComponentToken token : statsTokenList) {</span>
<span class="fc" id="L1117"> token.dataCollector.initNewList(1);</span>
Integer tmpValue;
<span class="fc" id="L1119"> long[] values = new long[docSet.size()];</span>
int value;
<span class="fc" id="L1121"> int number = 0;</span>
<span class="pc bpc" id="L1122" title="1 of 2 branches missed."> if (tokensData != null) {</span>
<span class="fc bfc" id="L1123" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L1124"> tmpValue = tokensData.get(docId);</span>
<span class="pc bpc" id="L1125" title="1 of 2 branches missed."> value = tmpValue == null ? 0 : tmpValue.intValue();</span>
<span class="pc bpc" id="L1126" title="1 of 6 branches missed."> if (((token.minimumLong == null) || (value >= token.minimumLong))</span>
&& ((token.maximumLong == null)
<span class="pc bpc" id="L1128" title="1 of 2 branches missed."> || (value <= token.maximumLong))) {</span>
<span class="fc" id="L1129"> values[number] = value;</span>
<span class="fc" id="L1130"> number++;</span>
}
<span class="fc" id="L1132"> }</span>
}
<span class="fc bfc" id="L1134" title="All 2 branches covered."> if (number > 0) {</span>
<span class="fc" id="L1135"> token.dataCollector.add(values, number);</span>
}
<span class="fc" id="L1137"> token.dataCollector.closeNewList();</span>
<span class="fc" id="L1138"> }</span>
}
<span class="fc" id="L1140"> }</span>
/**
* Creates the stats.
*
* @param statsSpanList
* the stats span list
* @param positionsData
* the positions data
* @param spansNumberData
* the spans number data
* @param docSet
* the doc set
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createStats(List<ComponentSpan> statsSpanList,
Map<Integer, Integer> positionsData,
Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData,
Integer[] docSet) throws IOException {
<span class="pc bpc" id="L1160" title="1 of 2 branches missed."> if (statsSpanList != null) {</span>
<span class="fc bfc" id="L1161" title="All 2 branches covered."> for (ComponentSpan span : statsSpanList) {</span>
<span class="pc bpc" id="L1162" title="1 of 2 branches missed."> if (span.parser.needArgumentsNumber() > span.queries.length) {</span>
<span class="nc" id="L1163"> throw new IOException(</span>
"function " + span.parser + " expects (at least) "
<span class="nc" id="L1165"> + span.parser.needArgumentsNumber() + " queries");</span>
}
// collect
<span class="fc" id="L1168"> Map<Integer, long[]> args = computeArguments(spansNumberData,</span>
span.queries, docSet);
<span class="pc bpc" id="L1170" title="1 of 2 branches missed."> if (span.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
// try to call functionParser as little as possible
<span class="pc bpc" id="L1172" title="2 of 8 branches missed."> if (span.statsType.equals(CodecUtil.STATS_BASIC)</span>
&& (span.minimumLong == null) && (span.maximumLong == null)
&& (span.functions == null
<span class="pc bpc" id="L1175" title="2 of 4 branches missed."> || (span.functionBasic() && span.functionSumRule()</span>
<span class="pc bpc" id="L1176" title="1 of 2 branches missed."> && !span.functionNeedPositions()))) {</span>
// initialise
<span class="fc" id="L1178"> int length = span.parser.needArgumentsNumber();</span>
<span class="fc" id="L1179"> long[] valueSum = new long[length];</span>
<span class="fc" id="L1180"> long valuePositions = 0;</span>
// collect
<span class="pc bpc" id="L1182" title="1 of 2 branches missed."> if (docSet.length > 0) {</span>
long[] tmpArgs;
<span class="fc bfc" id="L1184" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L1185"> tmpArgs = args.get(docId);</span>
<span class="fc bfc" id="L1186" title="All 2 branches covered."> valuePositions += (positionsData == null) ? 0</span>
<span class="fc" id="L1187"> : positionsData.get(docId);</span>
<span class="pc bpc" id="L1188" title="1 of 2 branches missed."> if (tmpArgs != null) {</span>
<span class="fc bfc" id="L1189" title="All 2 branches covered."> for (int i = 0; i < length; i++) {</span>
<span class="fc" id="L1190"> valueSum[i] += tmpArgs[i];</span>
}
}
}
long valueLong;
<span class="fc" id="L1195"> span.dataCollector.initNewList(1);</span>
try {
<span class="fc" id="L1197"> valueLong = span.parser.getValueLong(valueSum, valuePositions);</span>
<span class="fc" id="L1198"> span.dataCollector.add(valueLong, docSet.length);</span>
<span class="nc" id="L1199"> } catch (IOException e) {</span>
<span class="nc" id="L1200"> log.debug(e);</span>
<span class="nc" id="L1201"> span.dataCollector.error(e.getMessage());</span>
<span class="fc" id="L1202"> }</span>
<span class="pc bpc" id="L1203" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="fc bfc" id="L1204" title="All 2 branches covered."> for (SubComponentFunction function : span.functions) {</span>
<span class="fc" id="L1205"> function.dataCollector.initNewList(1);</span>
<span class="pc bpc" id="L1206" title="1 of 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
try {
<span class="fc" id="L1208"> valueLong = function.parserFunction.getValueLong(valueSum,</span>
valuePositions);
<span class="fc" id="L1210"> function.dataCollector.add(valueLong, docSet.length);</span>
<span class="nc" id="L1211"> } catch (IOException e) {</span>
<span class="nc" id="L1212"> log.debug(e);</span>
<span class="nc" id="L1213"> function.dataCollector.error(e.getMessage());</span>
<span class="pc" id="L1214"> }</span>
<span class="nc" id="L1215"> } else if (function.dataType</span>
<span class="nc bnc" id="L1216" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
try {
<span class="nc" id="L1218"> double valueDouble = function.parserFunction</span>
<span class="nc" id="L1219"> .getValueDouble(valueSum, valuePositions);</span>
<span class="nc" id="L1220"> function.dataCollector.add(valueDouble, docSet.length);</span>
<span class="nc" id="L1221"> } catch (IOException e) {</span>
<span class="nc" id="L1222"> log.debug(e);</span>
<span class="nc" id="L1223"> function.dataCollector.error(e.getMessage());</span>
<span class="nc" id="L1224"> }</span>
} else {
<span class="nc" id="L1226"> throw new IOException(</span>
"can't handle function dataType " + function.dataType);
}
<span class="fc" id="L1229"> function.dataCollector.closeNewList();</span>
<span class="fc" id="L1230"> }</span>
}
<span class="fc" id="L1232"> span.dataCollector.closeNewList();</span>
}
<span class="fc" id="L1234"> } else {</span>
// collect
<span class="pc bpc" id="L1236" title="1 of 2 branches missed."> if (docSet.length > 0) {</span>
<span class="fc" id="L1237"> int number = 0;</span>
int positions;
long valueLong;
double valueDouble;
<span class="fc" id="L1241"> long[] values = new long[docSet.length];</span>
<span class="fc" id="L1242"> long[][] functionValuesLong = null;</span>
<span class="fc" id="L1243"> double[][] functionValuesDouble = null;</span>
<span class="fc" id="L1244"> span.dataCollector.initNewList(1);</span>
<span class="pc bpc" id="L1245" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="fc" id="L1246"> functionValuesLong = new long[span.functions.size()][];</span>
<span class="fc" id="L1247"> functionValuesDouble = new double[span.functions.size()][];</span>
<span class="pc bpc" id="L1248" title="1 of 2 branches missed."> for (int i = 0; i < span.functions.size(); i++) {</span>
<span class="nc" id="L1249"> SubComponentFunction function = span.functions.get(i);</span>
<span class="nc bnc" id="L1250" title="All 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L1251"> functionValuesLong[i] = new long[docSet.length];</span>
<span class="nc" id="L1252"> functionValuesDouble[i] = null;</span>
<span class="nc" id="L1253"> } else if (function.dataType</span>
<span class="nc bnc" id="L1254" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L1255"> functionValuesLong[i] = null;</span>
<span class="nc" id="L1256"> functionValuesDouble[i] = new double[docSet.length];</span>
}
<span class="nc" id="L1258"> function.dataCollector.initNewList(1);</span>
}
}
<span class="fc bfc" id="L1261" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc bfc" id="L1262" title="All 2 branches covered."> if (positionsData == null) {</span>
<span class="fc" id="L1263"> positions = 0;</span>
} else {
<span class="pc bpc" id="L1265" title="1 of 2 branches missed."> positions = (positionsData.get(docId) == null ? 0</span>
<span class="fc" id="L1266"> : positionsData.get(docId));</span>
}
<span class="fc" id="L1268"> valueLong = span.parser.getValueLong(args.get(docId),</span>
positions);
<span class="fc bfc" id="L1270" title="All 2 branches covered."> if (((span.minimumLong == null)</span>
<span class="fc bfc" id="L1271" title="All 4 branches covered."> || (valueLong >= span.minimumLong))</span>
&& ((span.maximumLong == null)
<span class="fc bfc" id="L1273" title="All 2 branches covered."> || (valueLong <= span.maximumLong))) {</span>
<span class="fc" id="L1274"> values[number] = valueLong;</span>
<span class="pc bpc" id="L1275" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="pc bpc" id="L1276" title="1 of 2 branches missed."> for (int i = 0; i < span.functions.size(); i++) {</span>
<span class="nc" id="L1277"> SubComponentFunction function = span.functions.get(i);</span>
try {
<span class="nc" id="L1279"> if (function.dataType</span>
<span class="nc bnc" id="L1280" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L1281"> valueLong = function.parserFunction</span>
<span class="nc" id="L1282"> .getValueLong(args.get(docId), positions);</span>
<span class="nc" id="L1283"> functionValuesLong[i][number] = valueLong;</span>
<span class="nc" id="L1284"> } else if (function.dataType</span>
<span class="nc bnc" id="L1285" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L1286"> valueDouble = function.parserFunction</span>
<span class="nc" id="L1287"> .getValueDouble(args.get(docId), positions);</span>
<span class="nc" id="L1288"> functionValuesDouble[i][number] = valueDouble;</span>
}
<span class="nc" id="L1290"> } catch (IOException e) {</span>
<span class="nc" id="L1291"> log.debug(e);</span>
<span class="nc" id="L1292"> function.dataCollector.error(e.getMessage());</span>
<span class="nc" id="L1293"> }</span>
}
}
<span class="fc" id="L1296"> number++;</span>
}
}
<span class="fc bfc" id="L1299" title="All 2 branches covered."> if (number > 0) {</span>
<span class="fc" id="L1300"> span.dataCollector.add(values, number);</span>
<span class="pc bpc" id="L1301" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="pc bpc" id="L1302" title="1 of 2 branches missed."> for (int i = 0; i < span.functions.size(); i++) {</span>
<span class="nc" id="L1303"> SubComponentFunction function = span.functions.get(i);</span>
<span class="nc bnc" id="L1304" title="All 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L1305"> function.dataCollector.add(functionValuesLong[i], number);</span>
<span class="nc" id="L1306"> } else if (function.dataType</span>
<span class="nc bnc" id="L1307" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L1308"> function.dataCollector.add(functionValuesDouble[i],</span>
number);
}
}
}
}
<span class="fc" id="L1314"> span.dataCollector.closeNewList();</span>
<span class="pc bpc" id="L1315" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="pc bpc" id="L1316" title="1 of 2 branches missed."> for (SubComponentFunction function : span.functions) {</span>
<span class="nc" id="L1317"> function.dataCollector.closeNewList();</span>
<span class="nc" id="L1318"> }</span>
}
<span class="fc" id="L1320"> }</span>
}
} else {
<span class="nc" id="L1323"> throw new IOException("unexpected dataType " + span.dataType);</span>
}
<span class="fc" id="L1325"> }</span>
}
<span class="fc" id="L1327"> }</span>
/**
* Creates the list.
*
* @param listList
* the list list
* @param spansNumberData
* the spans number data
* @param spansMatchData
* the spans match data
* @param docSet
* the doc set
* @param field
* the field
* @param docBase
* the doc base
* @param uniqueKeyField
* the unique key field
* @param mtasCodecInfo
* the mtas codec info
* @param searcher
* the searcher
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createList(List<ComponentList> listList,
Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData,
Map<MtasSpanQuery, Map<Integer, List<Match>>> spansMatchData,
List<Integer> docSet, String field, int docBase, String uniqueKeyField,
CodecInfo mtasCodecInfo, IndexSearcher searcher) throws IOException {
<span class="nc bnc" id="L1358" title="All 2 branches missed."> if (listList != null) {</span>
<span class="nc bnc" id="L1359" title="All 2 branches missed."> for (ComponentList list : listList) {</span>
// collect not only stats
<span class="nc bnc" id="L1361" title="All 2 branches missed."> if (list.number > 0) {</span>
<span class="nc" id="L1362"> Map<Integer, List<Match>> matchData = spansMatchData</span>
<span class="nc" id="L1363"> .get(list.spanQuery);</span>
<span class="nc" id="L1364"> Map<Integer, Integer> numberData = spansNumberData</span>
<span class="nc" id="L1365"> .get(list.spanQuery);</span>
List<Match> matchList;
Integer matchNumber;
<span class="nc bnc" id="L1368" title="All 2 branches missed."> if (list.output.equals(ComponentList.LIST_OUTPUT_HIT)) {</span>
<span class="nc bnc" id="L1369" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc bnc" id="L1370" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L1371" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null) {</span>
<span class="nc bnc" id="L1372" title="All 2 branches missed."> if (list.position < (list.start + list.number)) {</span>
<span class="nc" id="L1373"> boolean getDoc = false;</span>
Match m;
<span class="nc bnc" id="L1375" title="All 2 branches missed."> for (int i = 0; i < matchList.size(); i++) {</span>
<span class="nc bnc" id="L1376" title="All 4 branches missed."> if ((list.position >= list.start)</span>
&& (list.position < (list.start + list.number))) {
<span class="nc" id="L1378"> m = matchList.get(i);</span>
<span class="nc" id="L1379"> getDoc = true;</span>
<span class="nc" id="L1380"> int startPosition = m.startPosition;</span>
<span class="nc" id="L1381"> int endPosition = m.endPosition - 1;</span>
<span class="nc" id="L1382"> List<MtasTreeHit<String>> terms = mtasCodecInfo</span>
<span class="nc" id="L1383"> .getPositionedTermsByPrefixesAndPositionRange(field,</span>
(docId - docBase), list.prefixes,
startPosition - list.left,
endPosition + list.right);
// construct hit
<span class="nc" id="L1388"> Map<Integer, List<String>> kwicListHits = new HashMap<>();</span>
<span class="nc" id="L1389"> for (int position = Math.max(0,</span>
<span class="nc bnc" id="L1390" title="All 2 branches missed."> startPosition - list.left); position <= (endPosition</span>
<span class="nc" id="L1391"> + list.right); position++) {</span>
<span class="nc" id="L1392"> kwicListHits.put(position, new ArrayList<String>());</span>
}
List<String> termList;
<span class="nc bnc" id="L1395" title="All 2 branches missed."> for (MtasTreeHit<String> term : terms) {</span>
<span class="nc" id="L1396"> for (int position = Math.max(</span>
(startPosition - list.left),
<span class="nc bnc" id="L1398" title="All 2 branches missed."> term.startPosition); position <= Math.min(</span>
(endPosition + list.right),
<span class="nc" id="L1400"> term.endPosition); position++) {</span>
<span class="nc" id="L1401"> termList = kwicListHits.get(position);</span>
<span class="nc" id="L1402"> termList.add(term.data);</span>
}
<span class="nc" id="L1404"> }</span>
<span class="nc" id="L1405"> list.hits.add(new ListHit(docId, i, m, kwicListHits));</span>
}
<span class="nc" id="L1407"> list.position++;</span>
}
<span class="nc bnc" id="L1409" title="All 2 branches missed."> if (getDoc) {</span>
// get unique id
<span class="nc" id="L1411"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L1412"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
<span class="nc" id="L1413"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
// get other doc info
<span class="nc bnc" id="L1415" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L1416"> list.uniqueKey.put(docId, indxfld.stringValue());</span>
}
<span class="nc" id="L1418"> list.subTotal.put(docId, matchList.size());</span>
<span class="nc" id="L1419"> IndexDoc mDoc = mtasCodecInfo.getDoc(field,</span>
(docId - docBase));
<span class="nc bnc" id="L1421" title="All 2 branches missed."> if (mDoc != null) {</span>
<span class="nc" id="L1422"> list.minPosition.put(docId, mDoc.minPosition);</span>
<span class="nc" id="L1423"> list.maxPosition.put(docId, mDoc.maxPosition);</span>
}
}
<span class="nc" id="L1426"> } else {</span>
<span class="nc" id="L1427"> list.position += matchList.size();</span>
}
<span class="nc bnc" id="L1429" title="All 2 branches missed."> } else if (numberData != null</span>
<span class="nc bnc" id="L1430" title="All 2 branches missed."> && (matchNumber = numberData.get(docId)) != null) {</span>
<span class="nc" id="L1431"> list.position += matchNumber;</span>
}
<span class="nc" id="L1433"> }</span>
<span class="nc" id="L1434"> list.total = list.position;</span>
<span class="nc bnc" id="L1435" title="All 2 branches missed."> } else if (list.output.equals(ComponentList.LIST_OUTPUT_TOKEN)) {</span>
<span class="nc bnc" id="L1436" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc bnc" id="L1437" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L1438" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null) {</span>
<span class="nc bnc" id="L1439" title="All 2 branches missed."> if (list.position < (list.start + list.number)) {</span>
<span class="nc" id="L1440"> boolean getDoc = false;</span>
Match m;
<span class="nc bnc" id="L1442" title="All 2 branches missed."> for (int i = 0; i < matchList.size(); i++) {</span>
<span class="nc bnc" id="L1443" title="All 4 branches missed."> if ((list.position >= list.start)</span>
&& (list.position < (list.start + list.number))) {
<span class="nc" id="L1445"> m = matchList.get(i);</span>
<span class="nc" id="L1446"> getDoc = true;</span>
<span class="nc" id="L1447"> int startPosition = m.startPosition;</span>
<span class="nc" id="L1448"> int endPosition = m.endPosition - 1;</span>
List<MtasTokenString> tokens;
<span class="nc" id="L1450"> tokens = mtasCodecInfo</span>
<span class="nc" id="L1451"> .getPrefixFilteredObjectsByPositions(field,</span>
(docId - docBase), list.prefixes,
startPosition - list.left,
endPosition + list.right);
<span class="nc" id="L1455"> list.tokens.add(new ListToken(docId, i, m, tokens));</span>
}
<span class="nc" id="L1457"> list.position++;</span>
}
<span class="nc bnc" id="L1459" title="All 2 branches missed."> if (getDoc) {</span>
// get unique id
<span class="nc" id="L1461"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L1462"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
<span class="nc" id="L1463"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
// get other doc info
<span class="nc bnc" id="L1465" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L1466"> list.uniqueKey.put(docId, indxfld.stringValue());</span>
}
<span class="nc" id="L1468"> list.subTotal.put(docId, matchList.size());</span>
<span class="nc" id="L1469"> IndexDoc mDoc = mtasCodecInfo.getDoc(field,</span>
(docId - docBase));
<span class="nc bnc" id="L1471" title="All 2 branches missed."> if (mDoc != null) {</span>
<span class="nc" id="L1472"> list.minPosition.put(docId, mDoc.minPosition);</span>
<span class="nc" id="L1473"> list.maxPosition.put(docId, mDoc.maxPosition);</span>
}
}
<span class="nc" id="L1476"> } else {</span>
<span class="nc" id="L1477"> list.position += matchList.size();</span>
}
<span class="nc bnc" id="L1479" title="All 2 branches missed."> } else if (numberData != null</span>
<span class="nc bnc" id="L1480" title="All 2 branches missed."> && (matchNumber = numberData.get(docId)) != null) {</span>
<span class="nc" id="L1481"> list.position += matchNumber;</span>
}
<span class="nc" id="L1483"> }</span>
<span class="nc" id="L1484"> list.total = list.position;</span>
}
<span class="nc" id="L1487"> } else {</span>
<span class="nc" id="L1488"> Map<Integer, Integer> data = spansNumberData.get(list.spanQuery);</span>
<span class="nc bnc" id="L1489" title="All 2 branches missed."> if (data != null) {</span>
<span class="nc bnc" id="L1490" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L1491"> Integer matchNumber = data.get(docId);</span>
<span class="nc bnc" id="L1492" title="All 2 branches missed."> if (matchNumber != null) {</span>
<span class="nc" id="L1493"> list.position += matchNumber;</span>
}
<span class="nc" id="L1495"> }</span>
<span class="nc" id="L1496"> list.total = list.position;</span>
}
}
<span class="nc" id="L1499"> }</span>
}
<span class="nc" id="L1501"> }</span>
/**
* Creates the group.
*
* @param groupList
* the group list
* @param spansMatchData
* the spans match data
* @param docSet
* the doc set
* @param fieldInfo
* the field info
* @param field
* the field
* @param docBase
* the doc base
* @param mtasCodecInfo
* the mtas codec info
* @param searcher
* the searcher
* @param lrc
* the lrc
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createGroup(List<ComponentGroup> groupList,
Map<MtasSpanQuery, Map<Integer, List<Match>>> spansMatchData,
List<Integer> docSet, FieldInfo fieldInfo, String field, int docBase,
CodecInfo mtasCodecInfo, IndexSearcher searcher, LeafReaderContext lrc)
throws IOException {
<span class="pc bpc" id="L1533" title="2 of 4 branches missed."> if (mtasCodecInfo != null && groupList != null) {</span>
List<Match> matchList;
Map<Integer, List<Match>> matchData;
<span class="fc bfc" id="L1536" title="All 2 branches covered."> for (ComponentGroup group : groupList) {</span>
<span class="fc" id="L1537"> group.dataCollector.setWithTotal();</span>
<span class="pc bpc" id="L1538" title="1 of 2 branches missed."> if (!group.prefixes.isEmpty()) {</span>
<span class="fc" id="L1539"> matchData = spansMatchData.get(group.spanQuery);</span>
<span class="fc" id="L1540"> Set<String> knownPrefixes = collectKnownPrefixes(fieldInfo);</span>
<span class="fc" id="L1541"> Set<String> intersectionPrefixes = collectIntersectionPrefixes(</span>
fieldInfo);
<span class="fc" id="L1543"> boolean intersectionGroupPrefixes = intersectionPrefixes(group,</span>
intersectionPrefixes);
<span class="fc" id="L1545"> boolean availablePrefixes = availablePrefixes(group, knownPrefixes);</span>
// sort match lists
<span class="pc bpc" id="L1547" title="1 of 2 branches missed."> if (!intersectionGroupPrefixes) {</span>
<span class="fc bfc" id="L1548" title="All 2 branches covered."> for (Entry<Integer, List<Match>> entry : matchData.entrySet()) {</span>
<span class="fc" id="L1549"> sortMatchList(entry.getValue());</span>
<span class="fc" id="L1550"> }</span>
}
// init
<span class="fc" id="L1553"> group.dataCollector.initNewList(1);</span>
int docId;
<span class="fc" id="L1556"> Map<GroupHit, Long> occurencesSum = new HashMap<>();</span>
<span class="fc" id="L1557"> Map<GroupHit, Integer> occurencesN = new HashMap<>();</span>
<span class="fc" id="L1558"> Set<GroupHit> occurencesInCurrentDocument = new HashSet<>();</span>
<span class="pc bpc" id="L1560" title="1 of 2 branches missed."> if (!availablePrefixes) {</span>
<span class="nc" id="L1561"> HashMap<Integer, GroupHit> hits = new HashMap<>();</span>
<span class="nc bnc" id="L1562" title="All 2 branches missed."> for (int docCounter = 0; docCounter < docSet.size(); docCounter++) {</span>
<span class="nc" id="L1563"> occurencesInCurrentDocument.clear();</span>
<span class="nc" id="L1564"> docId = docSet.get(docCounter);</span>
GroupHit hit;
GroupHit hitKey;
<span class="nc bnc" id="L1567" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L1568" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null</span>
<span class="nc bnc" id="L1569" title="All 2 branches missed."> && !matchList.isEmpty()) {</span>
<span class="nc" id="L1570"> Iterator<Match> it = matchList.listIterator();</span>
<span class="nc bnc" id="L1571" title="All 2 branches missed."> while (it.hasNext()) {</span>
<span class="nc" id="L1572"> Match m = it.next();</span>
<span class="nc" id="L1573"> IntervalTreeNodeData<String> positionHit = createPositionHit(</span>
m, group);
<span class="nc" id="L1575"> int length = m.endPosition - m.startPosition;</span>
<span class="nc" id="L1576"> hitKey = null;</span>
<span class="nc bnc" id="L1577" title="All 2 branches missed."> if (!hits.containsKey(length)) {</span>
<span class="nc" id="L1578"> hit = new GroupHit(positionHit.list, positionHit.start,</span>
positionHit.end, positionHit.hitStart,
positionHit.hitEnd, group, knownPrefixes);
<span class="nc" id="L1581"> hits.put(length, hit);</span>
} else {
<span class="nc" id="L1583"> hit = hits.get(length);</span>
<span class="nc bnc" id="L1584" title="All 2 branches missed."> for (GroupHit hitKeyItem : occurencesSum.keySet()) {</span>
<span class="nc bnc" id="L1585" title="All 2 branches missed."> if (hitKeyItem.equals(hit)) {</span>
<span class="nc" id="L1586"> hitKey = hitKeyItem;</span>
<span class="nc" id="L1587"> break;</span>
}
<span class="nc" id="L1589"> }</span>
}
<span class="nc bnc" id="L1591" title="All 2 branches missed."> if (hitKey == null) {</span>
<span class="nc" id="L1592"> occurencesSum.put(hit, Long.valueOf(1));</span>
<span class="nc" id="L1593"> occurencesN.put(hit, 1);</span>
<span class="nc" id="L1594"> occurencesInCurrentDocument.add(hit);</span>
} else {
<span class="nc" id="L1596"> occurencesSum.put(hitKey, occurencesSum.get(hitKey) + 1);</span>
<span class="nc bnc" id="L1597" title="All 2 branches missed."> if (!occurencesInCurrentDocument.contains(hitKey)) {</span>
<span class="nc bnc" id="L1598" title="All 2 branches missed."> if (occurencesN.containsKey(hitKey)) {</span>
<span class="nc" id="L1599"> occurencesN.put(hitKey, occurencesN.get(hitKey) + 1);</span>
} else {
<span class="nc" id="L1601"> occurencesN.put(hitKey, 1);</span>
}
<span class="nc" id="L1603"> occurencesInCurrentDocument.add(hitKey);</span>
}
}
<span class="nc" id="L1606"> }</span>
}
}
<span class="nc" id="L1610"> } else {</span>
<span class="fc" id="L1611"> int maximumNumberOfDocuments = 0;</span>
<span class="fc" id="L1612"> int boundaryMinimumNumberOfDocuments = 1;</span>
<span class="fc" id="L1613"> int boundaryMaximumNumberOfDocuments = 5;</span>
<span class="fc" id="L1614"> Set<GroupHit> administrationOccurrences = new HashSet<>();</span>
<span class="fc bfc" id="L1615" title="All 2 branches covered."> for (int docCounter = 0; docCounter < docSet.size(); docCounter++) {</span>
<span class="fc" id="L1616"> occurencesInCurrentDocument.clear();</span>
<span class="fc" id="L1617"> docId = docSet.get(docCounter);</span>
<span class="pc bpc" id="L1618" title="1 of 2 branches missed."> if (matchData != null</span>
<span class="pc bpc" id="L1619" title="1 of 2 branches missed."> && (matchList = matchData.get(docId)) != null</span>
<span class="pc bpc" id="L1620" title="1 of 2 branches missed."> && !matchList.isEmpty()) {</span>
// loop over matches
<span class="fc" id="L1622"> Iterator<Match> it = matchList.listIterator();</span>
<span class="fc" id="L1623"> ArrayList<IntervalTreeNodeData<String>> positionsHits = new ArrayList<>();</span>
<span class="fc bfc" id="L1624" title="All 2 branches covered."> while (it.hasNext()) {</span>
<span class="fc" id="L1625"> Match m = it.next();</span>
<span class="fc" id="L1626"> positionsHits.add(createPositionHit(m, group));</span>
<span class="fc" id="L1627"> }</span>
<span class="fc" id="L1628"> mtasCodecInfo.collectTermsByPrefixesForListOfHitPositions(field,</span>
(docId - docBase), group.prefixes, positionsHits);
// administration
<span class="fc bfc" id="L1631" title="All 2 branches covered."> for (IntervalTreeNodeData<String> positionHit : positionsHits) {</span>
<span class="fc" id="L1632"> GroupHit hit = new GroupHit(positionHit.list,</span>
positionHit.start, positionHit.end, positionHit.hitStart,
positionHit.hitEnd, group, knownPrefixes);
<span class="fc" id="L1635"> GroupHit hitKey = null;</span>
<span class="fc bfc" id="L1636" title="All 2 branches covered."> for (GroupHit hitKeyItem : occurencesSum.keySet()) {</span>
<span class="fc bfc" id="L1637" title="All 2 branches covered."> if (hitKeyItem.equals(hit)) {</span>
<span class="fc" id="L1638"> hitKey = hitKeyItem;</span>
<span class="fc" id="L1639"> break;</span>
}
<span class="fc" id="L1641"> }</span>
<span class="fc bfc" id="L1642" title="All 2 branches covered."> if (hitKey == null) {</span>
<span class="fc" id="L1643"> occurencesSum.put(hit, Long.valueOf(1));</span>
<span class="fc" id="L1644"> occurencesN.put(hit, 1);</span>
<span class="fc" id="L1645"> occurencesInCurrentDocument.add(hit);</span>
} else {
<span class="fc" id="L1647"> occurencesSum.put(hitKey, occurencesSum.get(hitKey) + 1);</span>
<span class="pc bpc" id="L1648" title="1 of 2 branches missed."> if (!occurencesInCurrentDocument.contains(hitKey)) {</span>
<span class="nc bnc" id="L1649" title="All 2 branches missed."> if (occurencesN.containsKey(hitKey)) {</span>
<span class="nc" id="L1650"> occurencesN.put(hitKey, occurencesN.get(hitKey) + 1);</span>
} else {
<span class="nc" id="L1652"> occurencesN.put(hitKey, 1);</span>
}
<span class="nc" id="L1654"> occurencesInCurrentDocument.add(hitKey);</span>
}
}
<span class="fc" id="L1657"> }</span>
<span class="pc bpc" id="L1658" title="1 of 2 branches missed."> if (!intersectionGroupPrefixes) {</span>
<span class="fc bfc" id="L1659" title="All 2 branches covered."> for (GroupHit groupHit : occurencesInCurrentDocument) {</span>
<span class="fc" id="L1660"> int tmpNumber = occurencesN.get(groupHit);</span>
<span class="fc" id="L1661"> maximumNumberOfDocuments = Math</span>
<span class="fc" id="L1662"> .max(maximumNumberOfDocuments, tmpNumber);</span>
<span class="pc bpc" id="L1663" title="1 of 2 branches missed."> if (tmpNumber > boundaryMinimumNumberOfDocuments) {</span>
<span class="nc" id="L1664"> administrationOccurrences.add(groupHit);</span>
}
<span class="fc" id="L1666"> }</span>
// collect spans
<span class="pc bpc" id="L1668" title="1 of 2 branches missed."> if (maximumNumberOfDocuments > boundaryMaximumNumberOfDocuments) {</span>
<span class="nc bnc" id="L1669" title="All 2 branches missed."> if (!administrationOccurrences.isEmpty()) {</span>
<span class="nc" id="L1670"> Map<GroupHit, Spans> list = collectSpansForOccurences(</span>
administrationOccurrences, knownPrefixes, field,
searcher, lrc);
<span class="nc bnc" id="L1673" title="All 2 branches missed."> if (list.size() > 0) {</span>
<span class="nc" id="L1674"> collectGroupUsingSpans(list, docSet, docBase,</span>
docCounter, matchData, occurencesSum, occurencesN);
}
}
<span class="nc" id="L1678"> administrationOccurrences.clear();</span>
<span class="nc" id="L1679"> maximumNumberOfDocuments = 0;</span>
<span class="nc" id="L1680"> boundaryMinimumNumberOfDocuments = (int) Math</span>
<span class="nc" id="L1681"> .ceil(boundaryMinimumNumberOfDocuments * 1.2);</span>
<span class="nc" id="L1682"> boundaryMaximumNumberOfDocuments = (int) Math</span>
<span class="nc" id="L1683"> .ceil(boundaryMaximumNumberOfDocuments * 1.2);</span>
}
}
}
}
}
<span class="fc bfc" id="L1690" title="All 2 branches covered."> for (Entry<GroupHit, Long> entry : occurencesSum.entrySet()) {</span>
<span class="fc" id="L1691"> group.dataCollector.add(entry.getKey().toString(), entry.getValue(),</span>
<span class="fc" id="L1692"> occurencesN.get(entry.getKey()));</span>
<span class="fc" id="L1693"> }</span>
<span class="fc" id="L1694"> group.dataCollector.closeNewList();</span>
}
<span class="fc" id="L1696"> }</span>
}
<span class="fc" id="L1698"> }</span>
/**
* Available prefixes.
*
* @param group
* the group
* @param knownPrefixes
* the known prefixes
* @return true, if successful
*/
private static boolean availablePrefixes(ComponentGroup group,
Set<String> knownPrefixes) {
<span class="pc bpc" id="L1711" title="1 of 2 branches missed."> if (knownPrefixes != null) {</span>
<span class="pc bpc" id="L1712" title="1 of 2 branches missed."> for (String prefix : group.prefixes) {</span>
<span class="pc bpc" id="L1713" title="1 of 2 branches missed."> if (knownPrefixes.contains(prefix)) {</span>
<span class="fc" id="L1714"> return true;</span>
}
<span class="nc" id="L1716"> }</span>
}
<span class="nc" id="L1718"> return false;</span>
}
/**
* Intersection prefixes.
*
* @param group
* the group
* @param intersectionPrefixes
* the intersection prefixes
* @return true, if successful
*/
private static boolean intersectionPrefixes(ComponentGroup group,
Set<String> intersectionPrefixes) {
<span class="pc bpc" id="L1732" title="1 of 2 branches missed."> if (intersectionPrefixes != null) {</span>
<span class="fc bfc" id="L1733" title="All 2 branches covered."> for (String prefix : group.prefixes) {</span>
<span class="pc bpc" id="L1734" title="1 of 2 branches missed."> if (intersectionPrefixes.contains(prefix)) {</span>
<span class="nc" id="L1735"> return true;</span>
}
<span class="fc" id="L1737"> }</span>
}
<span class="fc" id="L1739"> return false;</span>
}
/**
* Creates the position hit.
*
* @param m
* the m
* @param group
* the group
* @return the interval tree node data
*/
private static IntervalTreeNodeData<String> createPositionHit(Match m,
ComponentGroup group) {
<span class="fc" id="L1753"> Integer start = null;</span>
<span class="fc" id="L1754"> Integer end = null;</span>
<span class="pc bpc" id="L1755" title="5 of 6 branches missed."> if (group.hitInside != null || group.hitInsideLeft != null</span>
|| group.hitInsideRight != null) {
<span class="fc" id="L1757"> start = m.startPosition;</span>
<span class="fc" id="L1758"> end = m.endPosition - 1;</span>
} else {
<span class="nc" id="L1760"> start = null;</span>
<span class="nc" id="L1761"> end = null;</span>
}
<span class="pc bpc" id="L1763" title="1 of 2 branches missed."> if (group.hitLeft != null) {</span>
<span class="nc" id="L1764"> start = m.startPosition;</span>
<span class="nc" id="L1765"> end = Math.max(m.startPosition + group.hitLeft.length - 1,</span>
m.endPosition - 1);
}
<span class="pc bpc" id="L1768" title="1 of 2 branches missed."> if (group.hitRight != null) {</span>
<span class="nc" id="L1769"> start = Math.min(m.endPosition - group.hitRight.length + 1,</span>
m.startPosition);
<span class="nc bnc" id="L1771" title="All 2 branches missed."> end = end == null ? m.endPosition : Math.max(end, m.endPosition);</span>
}
<span class="pc bpc" id="L1773" title="1 of 2 branches missed."> if (group.left != null) {</span>
<span class="nc bnc" id="L1774" title="All 2 branches missed."> start = start == null ? m.startPosition - group.left.length</span>
<span class="nc" id="L1775"> : Math.min(m.startPosition - group.left.length, start);</span>
<span class="nc bnc" id="L1776" title="All 2 branches missed."> end = end == null ? m.startPosition - 1</span>
<span class="nc" id="L1777"> : Math.max(m.startPosition - 1, end);</span>
}
<span class="pc bpc" id="L1779" title="1 of 2 branches missed."> if (group.right != null) {</span>
<span class="nc bnc" id="L1780" title="All 2 branches missed."> start = start == null ? m.endPosition : Math.min(m.endPosition, start);</span>
<span class="nc bnc" id="L1781" title="All 2 branches missed."> end = end == null ? m.endPosition + group.right.length</span>
<span class="nc" id="L1782"> : Math.max(m.endPosition + group.right.length, end);</span>
}
<span class="fc" id="L1784"> return new IntervalTreeNodeData<>(start, end, m.startPosition,</span>
m.endPosition - 1);
}
/**
* Collect group using spans.
*
* @param list
* the list
* @param docSet
* the doc set
* @param docBase
* the doc base
* @param docCounter
* the doc counter
* @param matchData
* the match data
* @param occurencesSum
* the occurences sum
* @param occurencesN
* the occurences N
* @return the int
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static int collectGroupUsingSpans(Map<GroupHit, Spans> list,
List<Integer> docSet, int docBase, int docCounter,
Map<Integer, List<Match>> matchData, Map<GroupHit, Long> occurencesSum,
Map<GroupHit, Integer> occurencesN) throws IOException {
<span class="nc" id="L1813"> int total = 0;</span>
<span class="nc bnc" id="L1814" title="All 2 branches missed."> if (docCounter + 1 < docSet.size()) {</span>
// initialize
<span class="nc" id="L1816"> int nextDocCounter = docCounter + 1;</span>
<span class="nc" id="L1817"> long[] subSum = new long[list.size()];</span>
<span class="nc" id="L1818"> int[] subN = new int[list.size()];</span>
<span class="nc" id="L1819"> boolean[] newNextDocs = new boolean[list.size()];</span>
boolean newNextDoc;
<span class="nc" id="L1821"> int[] spansNextDoc = new int[list.size()];</span>
<span class="nc" id="L1822"> int nextDoc = 0;</span>
List<Match> matchList;
<span class="nc" id="L1824"> GroupHit[] hitList = list.keySet().toArray(new GroupHit[list.size()]);</span>
<span class="nc" id="L1825"> Spans[] spansList = new Spans[list.size()];</span>
<span class="nc" id="L1826"> boolean[] finishedSpansList = new boolean[list.size()];</span>
<span class="nc" id="L1827"> newNextDoc = true;</span>
// advance spans, find nextDoc
<span class="nc bnc" id="L1829" title="All 2 branches missed."> for (int i = 0; i < hitList.length; i++) {</span>
<span class="nc" id="L1830"> newNextDocs[i] = true;</span>
<span class="nc" id="L1831"> spansList[i] = list.get(hitList[i]);</span>
<span class="nc" id="L1832"> spansNextDoc[i] = spansList[i]</span>
<span class="nc" id="L1833"> .advance(docSet.get(nextDocCounter) - docBase);</span>
<span class="nc bnc" id="L1834" title="All 2 branches missed."> nextDoc = (i == 0) ? spansNextDoc[i]</span>
<span class="nc" id="L1835"> : Math.min(nextDoc, spansNextDoc[i]);</span>
}
// loop over future documents
<span class="nc bnc" id="L1838" title="All 2 branches missed."> while (nextDoc < DocIdSetIterator.NO_MORE_DOCS) {</span>
// find matches for next document
<span class="nc bnc" id="L1840" title="All 2 branches missed."> while (nextDocCounter < docSet.size()</span>
<span class="nc bnc" id="L1841" title="All 2 branches missed."> && docSet.get(nextDocCounter) < (nextDoc + docBase)) {</span>
<span class="nc" id="L1842"> nextDocCounter++;</span>
}
// finish, if no more docs in set
<span class="nc bnc" id="L1845" title="All 2 branches missed."> if (nextDocCounter >= docSet.size()) {</span>
<span class="nc" id="L1846"> break;</span>
}
// go to the matches
<span class="nc bnc" id="L1849" title="All 2 branches missed."> if (docSet.get(nextDocCounter) == nextDoc + docBase) {</span>
<span class="nc" id="L1850"> matchList = matchData.get(nextDoc + docBase);</span>
<span class="nc bnc" id="L1851" title="All 4 branches missed."> if (matchList != null && !matchList.isEmpty()) {</span>
// initialize
<span class="nc" id="L1853"> int currentMatchPosition = 0;</span>
<span class="nc" id="L1854"> int lastMatchStartPosition = matchList</span>
<span class="nc" id="L1855"> .get(matchList.size() - 1).startPosition;</span>
<span class="nc" id="L1856"> ArrayList<Match> newMatchList = new ArrayList<>(matchList.size());</span>
<span class="nc" id="L1857"> int currentSpanPosition = Spans.NO_MORE_POSITIONS;</span>
// check and initialize for each span
<span class="nc bnc" id="L1859" title="All 2 branches missed."> for (int i = 0; i < spansList.length; i++) {</span>
<span class="nc bnc" id="L1860" title="All 2 branches missed."> if (spansList[i].docID() == nextDoc) {</span>
<span class="nc" id="L1861"> int tmpStartPosition = spansList[i].nextStartPosition();</span>
<span class="nc bnc" id="L1862" title="All 2 branches missed."> if (tmpStartPosition < Spans.NO_MORE_POSITIONS) {</span>
<span class="nc" id="L1863"> finishedSpansList[i] = false;</span>
} else {
<span class="nc" id="L1865"> finishedSpansList[i] = true;</span>
}
// compute position
<span class="nc bnc" id="L1868" title="All 2 branches missed."> currentSpanPosition = (currentSpanPosition == Spans.NO_MORE_POSITIONS)</span>
? tmpStartPosition
<span class="nc" id="L1870"> : Math.min(currentSpanPosition, tmpStartPosition);</span>
<span class="nc" id="L1871"> } else {</span>
<span class="nc" id="L1872"> finishedSpansList[i] = true;</span>
}
}
// loop over matches
<span class="nc bnc" id="L1876" title="All 4 branches missed."> while (currentMatchPosition < matchList.size()</span>
&& currentSpanPosition < Spans.NO_MORE_POSITIONS) {
<span class="nc" id="L1879"> if (currentSpanPosition < matchList</span>
<span class="nc bnc" id="L1880" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
// do nothing, match not reached
<span class="nc bnc" id="L1882" title="All 2 branches missed."> } else if (currentSpanPosition > lastMatchStartPosition) {</span>
// finish, past last match
<span class="nc" id="L1884"> break;</span>
} else {
// advance matches
<span class="nc bnc" id="L1887" title="All 2 branches missed."> while (currentMatchPosition < matchList.size()</span>
&& currentSpanPosition > matchList
<span class="nc bnc" id="L1889" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
// store current match, not relevant
<span class="nc" id="L1891"> newMatchList.add(matchList.get(currentMatchPosition));</span>
<span class="nc" id="L1892"> currentMatchPosition++;</span>
}
// equal startPosition
<span class="nc bnc" id="L1895" title="All 2 branches missed."> while (currentMatchPosition < matchList.size()</span>
&& currentSpanPosition == matchList
<span class="nc bnc" id="L1897" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
// check for each span
<span class="nc bnc" id="L1899" title="All 2 branches missed."> for (int i = 0; i < spansList.length; i++) {</span>
// equal start and end, therefore match
<span class="nc bnc" id="L1901" title="All 4 branches missed."> if (!finishedSpansList[i] && spansList[i].docID() == nextDoc</span>
<span class="nc" id="L1902"> && spansList[i].startPosition() == matchList</span>
<span class="nc bnc" id="L1903" title="All 2 branches missed."> .get(currentMatchPosition).startPosition</span>
<span class="nc" id="L1904"> && spansList[i].endPosition() == matchList</span>
<span class="nc bnc" id="L1905" title="All 2 branches missed."> .get(currentMatchPosition).endPosition) {</span>
// administration
<span class="nc" id="L1907"> total++;</span>
<span class="nc" id="L1908"> subSum[i]++;</span>
<span class="nc bnc" id="L1909" title="All 2 branches missed."> if (newNextDocs[i]) {</span>
<span class="nc" id="L1910"> subN[i]++;</span>
<span class="nc" id="L1911"> newNextDocs[i] = false;</span>
<span class="nc" id="L1912"> newNextDoc = false;</span>
}
<span class="nc bnc" id="L1914" title="All 2 branches missed."> } else if (!finishedSpansList[i]</span>
<span class="nc bnc" id="L1915" title="All 2 branches missed."> && spansList[i].docID() == nextDoc</span>
<span class="nc" id="L1916"> && spansList[i].startPosition() == matchList</span>
<span class="nc bnc" id="L1917" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
// no match, store
<span class="nc" id="L1919"> newMatchList.add(matchList.get(currentMatchPosition));</span>
}
}
<span class="nc" id="L1922"> currentMatchPosition++;</span>
}
}
// advance spans
<span class="nc bnc" id="L1927" title="All 2 branches missed."> if (currentMatchPosition < matchList.size()) {</span>
<span class="nc" id="L1928"> currentSpanPosition = Spans.NO_MORE_POSITIONS;</span>
<span class="nc bnc" id="L1929" title="All 2 branches missed."> for (int i = 0; i < spansList.length; i++) {</span>
<span class="nc bnc" id="L1930" title="All 2 branches missed."> if (!finishedSpansList[i]</span>
<span class="nc bnc" id="L1931" title="All 2 branches missed."> && (spansList[i].docID() == nextDoc)) {</span>
<span class="nc bnc" id="L1932" title="All 2 branches missed."> while (!finishedSpansList[i]</span>
<span class="nc" id="L1933"> && spansList[i].startPosition() < matchList</span>
<span class="nc bnc" id="L1934" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
<span class="nc" id="L1935"> int tmpStartPosition = spansList[i].nextStartPosition();</span>
<span class="nc bnc" id="L1936" title="All 2 branches missed."> if (tmpStartPosition == Spans.NO_MORE_POSITIONS) {</span>
<span class="nc" id="L1937"> finishedSpansList[i] = true;</span>
}
<span class="nc" id="L1939"> }</span>
<span class="nc bnc" id="L1940" title="All 2 branches missed."> if (!finishedSpansList[i]) {</span>
<span class="nc bnc" id="L1941" title="All 2 branches missed."> currentSpanPosition = (currentSpanPosition == Spans.NO_MORE_POSITIONS)</span>
<span class="nc" id="L1942"> ? spansList[i].startPosition()</span>
<span class="nc" id="L1943"> : Math.min(currentSpanPosition,</span>
<span class="nc" id="L1944"> spansList[i].startPosition());</span>
}
} else {
<span class="nc" id="L1947"> finishedSpansList[i] = true;</span>
}
}
}
}
<span class="nc bnc" id="L1952" title="All 2 branches missed."> if (!newNextDoc) {</span>
// add other matches
<span class="nc bnc" id="L1954" title="All 2 branches missed."> while (currentMatchPosition < matchList.size()) {</span>
<span class="nc" id="L1955"> newMatchList.add(matchList.get(currentMatchPosition));</span>
<span class="nc" id="L1956"> currentMatchPosition++;</span>
}
// update administration
<span class="nc bnc" id="L1959" title="All 2 branches missed."> if (!newMatchList.isEmpty()) {</span>
<span class="nc" id="L1960"> matchData.put(nextDoc + docBase, newMatchList);</span>
} else {
<span class="nc" id="L1962"> matchData.put(nextDoc + docBase, null);</span>
}
}
}
}
// advance to next document
<span class="nc" id="L1968"> nextDocCounter++;</span>
<span class="nc" id="L1969"> newNextDoc = true;</span>
<span class="nc bnc" id="L1970" title="All 2 branches missed."> for (int i = 0; i < hitList.length; i++) {</span>
<span class="nc" id="L1971"> newNextDocs[i] = true;</span>
}
// advance spans
<span class="nc bnc" id="L1974" title="All 2 branches missed."> if (nextDocCounter < docSet.size()) {</span>
<span class="nc" id="L1975"> nextDoc = Spans.NO_MORE_DOCS;</span>
// advance spans
<span class="nc bnc" id="L1977" title="All 2 branches missed."> for (int i = 0; i < hitList.length; i++) {</span>
<span class="nc bnc" id="L1978" title="All 2 branches missed."> if (spansNextDoc[i] < (docSet.get(nextDocCounter) - docBase)) {</span>
<span class="nc" id="L1979"> spansNextDoc[i] = spansList[i]</span>
<span class="nc" id="L1980"> .advance(docSet.get(nextDocCounter) - docBase);</span>
}
<span class="nc bnc" id="L1982" title="All 2 branches missed."> if (spansNextDoc[i] < Spans.NO_MORE_DOCS) {</span>
<span class="nc bnc" id="L1983" title="All 2 branches missed."> nextDoc = (nextDoc == Spans.NO_MORE_DOCS) ? spansNextDoc[i]</span>
<span class="nc" id="L1984"> : Math.min(nextDoc, spansNextDoc[i]);</span>
}
}
}
}
// update administration
<span class="nc bnc" id="L1990" title="All 2 branches missed."> for (int i = 0; i < hitList.length; i++) {</span>
<span class="nc bnc" id="L1991" title="All 4 branches missed."> if (subSum[i] > 0 && (occurencesSum.containsKey(hitList[i]))) {</span>
<span class="nc" id="L1992"> occurencesSum.put(hitList[i],</span>
<span class="nc" id="L1993"> occurencesSum.get(hitList[i]) + subSum[i]);</span>
<span class="nc" id="L1994"> occurencesN.put(hitList[i], occurencesN.get(hitList[i]) + subN[i]);</span>
}
}
}
<span class="nc" id="L1999"> return total;</span>
}
/**
* Sort match list.
*
* @param list
* the list
*/
private static void sortMatchList(List<Match> list) {
<span class="pc bpc" id="L2009" title="1 of 2 branches missed."> if (list != null) {</span>
// light sorting on start position
<span class="fc" id="L2011"> Collections.sort(list, (Match m1,</span>
<span class="fc" id="L2012"> Match m2) -> (Integer.compare(m1.startPosition, m2.startPosition)));</span>
}
<span class="fc" id="L2014"> }</span>
/**
* Creates the document.
*
* @param documentList
* the document list
* @param docList
* the doc list
* @param uniqueKeyField
* the unique key field
* @param searcher
* the searcher
* @param t
* the t
* @param lrc
* the lrc
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createDocument(List<ComponentDocument> documentList,
List<Integer> docList, String uniqueKeyField, IndexSearcher searcher,
Terms t, LeafReaderContext lrc) throws IOException {
<span class="nc bnc" id="L2037" title="All 2 branches missed."> if (documentList != null) {</span>
<span class="nc" id="L2038"> SortedSet<String> listStatsItems = CodecUtil.createStatsItems("sum");</span>
<span class="nc" id="L2039"> String listStatsType = CodecUtil.createStatsType(listStatsItems,</span>
CodecUtil.STATS_TYPE_SUM, null);
<span class="nc bnc" id="L2041" title="All 2 branches missed."> for (ComponentDocument document : documentList) {</span>
// initialize
<span class="nc bnc" id="L2043" title="All 2 branches missed."> for (int docId : docList) {</span>
// get unique id
<span class="nc" id="L2045"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L2046"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
<span class="nc" id="L2047"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
// get other doc info
<span class="nc bnc" id="L2049" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L2050"> document.uniqueKey.put(docId, indxfld.stringValue());</span>
<span class="nc" id="L2051"> MtasDataCollector<?, ?> stats = DataCollector.getCollector(</span>
DataCollector.COLLECTOR_TYPE_DATA, document.dataType,
document.statsType, document.statsItems, null, null, null, null,
null, null);
<span class="nc" id="L2055"> document.statsData.put(docId, stats);</span>
<span class="nc bnc" id="L2056" title="All 2 branches missed."> if (document.statsList != null) {</span>
MtasDataCollector<?, ?> list;
<span class="nc bnc" id="L2058" title="All 2 branches missed."> if (document.listExpand) {</span>
<span class="nc" id="L2059"> SortedSet<String>[] baseStatsItems = new SortedSet[] {</span>
listStatsItems };
<span class="nc" id="L2061"> list = DataCollector.getCollector(</span>
DataCollector.COLLECTOR_TYPE_LIST, CodecUtil.DATA_TYPE_LONG,
listStatsType, listStatsItems, CodecUtil.STATS_TYPE_SUM,
<span class="nc" id="L2064"> CodecUtil.SORT_DESC, 0, document.listNumber,</span>
new String[] { DataCollector.COLLECTOR_TYPE_LIST },
new String[] { CodecUtil.DATA_TYPE_LONG },
new String[] { listStatsType },
<span class="nc" id="L2068"> Arrays.copyOfRange(baseStatsItems, 0,</span>
baseStatsItems.length),
new String[] { CodecUtil.STATS_TYPE_SUM },
<span class="nc" id="L2071"> new String[] { CodecUtil.SORT_DESC }, new Integer[] { 0 },</span>
<span class="nc" id="L2072"> new Integer[] { document.listExpandNumber }, null, null);</span>
<span class="nc" id="L2073"> } else {</span>
<span class="nc" id="L2074"> list = DataCollector.getCollector(</span>
DataCollector.COLLECTOR_TYPE_LIST, CodecUtil.DATA_TYPE_LONG,
listStatsType, listStatsItems, CodecUtil.STATS_TYPE_SUM,
<span class="nc" id="L2077"> CodecUtil.SORT_DESC, 0, document.listNumber, null, null);</span>
}
<span class="nc" id="L2079"> document.statsList.put(docId, list);</span>
}
}
<span class="nc" id="L2082"> }</span>
<span class="nc" id="L2083"> }</span>
// collect
<span class="nc bnc" id="L2085" title="All 2 branches missed."> if (t != null) {</span>
BytesRef term;
TermsEnum termsEnum;
<span class="nc" id="L2088"> PostingsEnum postingsEnum = null;</span>
// loop over termvectors
<span class="nc bnc" id="L2090" title="All 2 branches missed."> for (ComponentDocument document : documentList) {</span>
List<CompiledAutomaton> listAutomata;
Map<String, Automaton> automatonMap;
Map<String, ByteRunAutomaton> byteRunAutomatonMap;
<span class="nc bnc" id="L2095" title="All 2 branches missed."> if (document.list == null) {</span>
<span class="nc" id="L2096"> automatonMap = null;</span>
<span class="nc" id="L2097"> byteRunAutomatonMap = null;</span>
<span class="nc" id="L2098"> listAutomata = new ArrayList<>();</span>
CompiledAutomaton compiledAutomaton;
Automaton automaton;
<span class="nc bnc" id="L2101" title="All 4 branches missed."> if ((document.regexp == null) || (document.regexp.isEmpty())) {</span>
<span class="nc" id="L2102"> RegExp re = new RegExp(</span>
document.prefix + MtasToken.DELIMITER + ".*");
<span class="nc" id="L2104"> automaton = re.toAutomaton();</span>
<span class="nc" id="L2105"> } else {</span>
<span class="nc" id="L2106"> RegExp re = new RegExp(document.prefix + MtasToken.DELIMITER</span>
+ document.regexp + "\u0000*");
<span class="nc" id="L2108"> automaton = re.toAutomaton();</span>
}
<span class="nc" id="L2110"> compiledAutomaton = new CompiledAutomaton(automaton);</span>
<span class="nc" id="L2111"> listAutomata.add(compiledAutomaton);</span>
<span class="nc" id="L2112"> } else {</span>
<span class="nc bnc" id="L2113" title="All 2 branches missed."> automatonMap = MtasToken.createAutomatonMap(document.prefix,</span>
new ArrayList<String>(document.list),
<span class="nc" id="L2115"> document.listRegexp ? false : true);</span>
<span class="nc" id="L2116"> byteRunAutomatonMap = MtasToken.byteRunAutomatonMap(automatonMap);</span>
<span class="nc" id="L2117"> listAutomata = MtasToken.createAutomata(document.prefix,</span>
document.regexp, automatonMap);
}
<span class="nc" id="L2120"> List<ByteRunAutomaton> ignoreByteRunAutomatonList = null;</span>
<span class="nc bnc" id="L2121" title="All 2 branches missed."> if ((document.ignoreRegexp != null)</span>
<span class="nc bnc" id="L2122" title="All 2 branches missed."> && (!document.ignoreRegexp.isEmpty())) {</span>
<span class="nc" id="L2123"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
<span class="nc" id="L2124"> RegExp re = new RegExp(document.prefix + MtasToken.DELIMITER</span>
+ document.ignoreRegexp + "\u0000*");
<span class="nc" id="L2126"> ignoreByteRunAutomatonList</span>
<span class="nc" id="L2127"> .add(new ByteRunAutomaton(re.toAutomaton()));</span>
}
<span class="nc bnc" id="L2129" title="All 2 branches missed."> if (document.ignoreList != null) {</span>
<span class="nc bnc" id="L2130" title="All 2 branches missed."> if (ignoreByteRunAutomatonList == null) {</span>
<span class="nc" id="L2131"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
}
<span class="nc bnc" id="L2133" title="All 2 branches missed."> Map<String, Automaton> list = MtasToken.createAutomatonMap(</span>
document.prefix, new ArrayList<String>(document.ignoreList),
<span class="nc" id="L2135"> document.ignoreListRegexp ? false : true);</span>
<span class="nc bnc" id="L2136" title="All 2 branches missed."> for (Automaton automaton : list.values()) {</span>
<span class="nc" id="L2137"> ignoreByteRunAutomatonList.add(new ByteRunAutomaton(automaton));</span>
<span class="nc" id="L2138"> }</span>
}
<span class="nc bnc" id="L2141" title="All 2 branches missed."> for (CompiledAutomaton compiledAutomaton : listAutomata) {</span>
<span class="nc" id="L2142"> if (!compiledAutomaton.type</span>
<span class="nc bnc" id="L2143" title="All 2 branches missed."> .equals(CompiledAutomaton.AUTOMATON_TYPE.NONE)) {</span>
<span class="nc" id="L2144"> termsEnum = t.intersect(compiledAutomaton, null);</span>
// init
<span class="nc" id="L2146"> int initBaseSize = Math.min((int) t.size(), 1000);</span>
<span class="nc bnc" id="L2147" title="All 2 branches missed."> int initListSize = document.statsList != null</span>
<span class="nc" id="L2148"> ? Math.min(document.statsList.size(), initBaseSize)</span>
: initBaseSize;
<span class="nc" id="L2150"> HashSet<MtasDataCollector<?, ?>> initialised = new HashSet<>();</span>
<span class="nc bnc" id="L2151" title="All 2 branches missed."> for (int docId : docList) {</span>
<span class="nc" id="L2152"> document.statsData.get(docId).initNewList(1);</span>
<span class="nc" id="L2153"> initialised.add(document.statsData.get(docId));</span>
<span class="nc bnc" id="L2154" title="All 2 branches missed."> if (document.statsList != null</span>
<span class="nc bnc" id="L2155" title="All 2 branches missed."> && document.statsList.size() > 0) {</span>
<span class="nc" id="L2156"> document.statsList.get(docId).initNewList(initListSize);</span>
<span class="nc" id="L2157"> initialised.add(document.statsList.get(docId));</span>
}
<span class="nc" id="L2159"> }</span>
// fill
int termDocId;
boolean acceptedTerm;
<span class="nc bnc" id="L2163" title="All 2 branches missed."> while ((term = termsEnum.next()) != null) {</span>
<span class="nc" id="L2164"> Iterator<Integer> docIterator = docList.iterator();</span>
<span class="nc" id="L2165"> postingsEnum = termsEnum.postings(postingsEnum,</span>
PostingsEnum.FREQS);
<span class="nc" id="L2167"> termDocId = -1;</span>
<span class="nc" id="L2168"> acceptedTerm = true;</span>
<span class="nc bnc" id="L2169" title="All 2 branches missed."> if (ignoreByteRunAutomatonList != null) {</span>
<span class="nc bnc" id="L2170" title="All 2 branches missed."> for (ByteRunAutomaton ignoreByteRunAutomaton : ignoreByteRunAutomatonList) {</span>
<span class="nc bnc" id="L2171" title="All 2 branches missed."> if (ignoreByteRunAutomaton.run(term.bytes, term.offset,</span>
term.length)) {
<span class="nc" id="L2173"> acceptedTerm = false;</span>
<span class="nc" id="L2174"> break;</span>
}
<span class="nc" id="L2176"> }</span>
}
<span class="nc bnc" id="L2178" title="All 2 branches missed."> if (acceptedTerm) {</span>
<span class="nc bnc" id="L2179" title="All 2 branches missed."> while (docIterator.hasNext()) {</span>
<span class="nc" id="L2180"> int segmentDocId = docIterator.next() - lrc.docBase;</span>
<span class="nc bnc" id="L2181" title="All 4 branches missed."> if (segmentDocId >= termDocId</span>
&& ((segmentDocId == termDocId)
|| ((termDocId = postingsEnum
<span class="nc bnc" id="L2184" title="All 2 branches missed."> .advance(segmentDocId)) == segmentDocId))) {</span>
// register stats
<span class="nc" id="L2186"> document.statsData.get(segmentDocId + lrc.docBase)</span>
<span class="nc" id="L2187"> .add(new long[] { postingsEnum.freq() }, 1);</span>
// register list
<span class="nc bnc" id="L2189" title="All 2 branches missed."> if (document.statsList != null) {</span>
<span class="nc bnc" id="L2190" title="All 2 branches missed."> if (automatonMap != null) {</span>
MtasDataCollector<?, ?> dataCollector;
MtasDataCollector<?, ?> subSataCollector;
<span class="nc bnc" id="L2193" title="All 2 branches missed."> for (Entry<String, ByteRunAutomaton> entry : byteRunAutomatonMap</span>
<span class="nc" id="L2194"> .entrySet()) {</span>
<span class="nc" id="L2195"> ByteRunAutomaton bra = entry.getValue();</span>
<span class="nc bnc" id="L2196" title="All 2 branches missed."> if (bra.run(term.bytes, term.offset, term.length)) {</span>
<span class="nc" id="L2197"> dataCollector = document.statsList</span>
<span class="nc" id="L2198"> .get(segmentDocId + lrc.docBase);</span>
<span class="nc" id="L2199"> subSataCollector = dataCollector.add(</span>
<span class="nc" id="L2200"> entry.getKey(),</span>
<span class="nc" id="L2201"> new long[] { postingsEnum.freq() }, 1);</span>
<span class="nc bnc" id="L2202" title="All 4 branches missed."> if (document.listExpand</span>
&& subSataCollector != null) {
<span class="nc bnc" id="L2204" title="All 2 branches missed."> if (!initialised.contains(subSataCollector)) {</span>
<span class="nc" id="L2205"> subSataCollector.initNewList(initBaseSize);</span>
<span class="nc" id="L2206"> initialised.add(subSataCollector);</span>
}
<span class="nc" id="L2208"> subSataCollector.add(</span>
<span class="nc" id="L2209"> MtasToken.getPostfixFromValue(term),</span>
<span class="nc" id="L2210"> new long[] { postingsEnum.freq() }, 1);</span>
}
}
<span class="nc" id="L2213"> }</span>
} else {
<span class="nc" id="L2215"> document.statsList.get(segmentDocId + lrc.docBase)</span>
<span class="nc" id="L2216"> .add(MtasToken.getPostfixFromValue(term),</span>
<span class="nc" id="L2217"> new long[] { postingsEnum.freq() }, 1);</span>
}
}
}
<span class="nc" id="L2221"> }</span>
}
<span class="nc" id="L2223"> }</span>
// close
<span class="nc bnc" id="L2225" title="All 2 branches missed."> for (MtasDataCollector<?, ?> item : initialised) {</span>
<span class="nc" id="L2226"> item.closeNewList();</span>
<span class="nc" id="L2227"> }</span>
<span class="nc" id="L2228"> initialised.clear();</span>
}
<span class="nc" id="L2230"> }</span>
<span class="nc" id="L2231"> }</span>
}
}
<span class="nc" id="L2234"> }</span>
/**
* Creates the kwic.
*
* @param kwicList
* the kwic list
* @param spansMatchData
* the spans match data
* @param docList
* the doc list
* @param field
* the field
* @param docBase
* the doc base
* @param uniqueKeyField
* the unique key field
* @param mtasCodecInfo
* the mtas codec info
* @param searcher
* the searcher
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createKwic(List<ComponentKwic> kwicList,
Map<MtasSpanQuery, Map<Integer, List<Match>>> spansMatchData,
List<Integer> docList, String field, int docBase, String uniqueKeyField,
CodecInfo mtasCodecInfo, IndexSearcher searcher) throws IOException {
<span class="nc bnc" id="L2262" title="All 2 branches missed."> if (kwicList != null) {</span>
<span class="nc bnc" id="L2263" title="All 2 branches missed."> for (ComponentKwic kwic : kwicList) {</span>
<span class="nc" id="L2264"> Map<Integer, List<Match>> matchData = spansMatchData.get(kwic.query);</span>
List<Match> matchList;
<span class="nc bnc" id="L2266" title="All 2 branches missed."> if (kwic.output.equals(ComponentKwic.KWIC_OUTPUT_HIT)) {</span>
<span class="nc bnc" id="L2267" title="All 2 branches missed."> for (int docId : docList) {</span>
<span class="nc bnc" id="L2268" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L2269" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null) {</span>
// get unique id
<span class="nc" id="L2271"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L2272"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
<span class="nc" id="L2273"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
// get other doc info
<span class="nc bnc" id="L2275" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L2276"> kwic.uniqueKey.put(docId, indxfld.stringValue());</span>
}
<span class="nc" id="L2278"> kwic.subTotal.put(docId, matchList.size());</span>
<span class="nc" id="L2279"> IndexDoc mDoc = mtasCodecInfo.getDoc(field, (docId - docBase));</span>
<span class="nc bnc" id="L2280" title="All 2 branches missed."> if (mDoc != null) {</span>
<span class="nc" id="L2281"> kwic.minPosition.put(docId, mDoc.minPosition);</span>
<span class="nc" id="L2282"> kwic.maxPosition.put(docId, mDoc.maxPosition);</span>
}
// kwiclist
<span class="nc" id="L2285"> List<KwicHit> kwicItemList = new ArrayList<>();</span>
<span class="nc" id="L2286"> int number = 0;</span>
<span class="nc bnc" id="L2287" title="All 2 branches missed."> for (Match m : matchList) {</span>
<span class="nc bnc" id="L2288" title="All 2 branches missed."> if (kwic.number != null</span>
<span class="nc bnc" id="L2289" title="All 2 branches missed."> && number >= (kwic.start + kwic.number)) {</span>
<span class="nc" id="L2290"> break;</span>
}
<span class="nc bnc" id="L2292" title="All 2 branches missed."> if (number >= kwic.start) {</span>
<span class="nc" id="L2293"> int startPosition = m.startPosition;</span>
<span class="nc" id="L2294"> int endPosition = m.endPosition - 1;</span>
<span class="nc" id="L2295"> List<MtasTreeHit<String>> terms = mtasCodecInfo</span>
<span class="nc" id="L2296"> .getPositionedTermsByPrefixesAndPositionRange(field,</span>
(docId - docBase), kwic.prefixes,
<span class="nc" id="L2298"> Math.max(mDoc.minPosition, startPosition - kwic.left),</span>
<span class="nc" id="L2299"> Math.min(mDoc.maxPosition, endPosition + kwic.right));</span>
// construct hit
<span class="nc" id="L2301"> Map<Integer, List<String>> kwicListHits = new HashMap<>();</span>
<span class="nc" id="L2302"> for (int position = Math.max(mDoc.minPosition,</span>
<span class="nc bnc" id="L2303" title="All 2 branches missed."> startPosition - kwic.left); position <= Math.min(</span>
mDoc.maxPosition,
<span class="nc" id="L2305"> endPosition + kwic.right); position++) {</span>
<span class="nc" id="L2306"> kwicListHits.put(position, new ArrayList<String>());</span>
}
List<String> termList;
<span class="nc bnc" id="L2309" title="All 2 branches missed."> for (MtasTreeHit<String> term : terms) {</span>
<span class="nc" id="L2310"> for (int position = Math.max((startPosition - kwic.left),</span>
<span class="nc bnc" id="L2311" title="All 2 branches missed."> term.startPosition); position <= Math.min(</span>
(endPosition + kwic.right),
<span class="nc" id="L2313"> term.endPosition); position++) {</span>
<span class="nc" id="L2314"> termList = kwicListHits.get(position);</span>
<span class="nc" id="L2315"> termList.add(term.data);</span>
}
<span class="nc" id="L2317"> }</span>
<span class="nc" id="L2318"> kwicItemList.add(new KwicHit(m, kwicListHits));</span>
}
<span class="nc" id="L2320"> number++;</span>
<span class="nc" id="L2321"> }</span>
<span class="nc" id="L2322"> kwic.hits.put(docId, kwicItemList);</span>
}
<span class="nc" id="L2324"> }</span>
<span class="nc bnc" id="L2325" title="All 2 branches missed."> } else if (kwic.output.equals(ComponentKwic.KWIC_OUTPUT_TOKEN)) {</span>
<span class="nc bnc" id="L2326" title="All 2 branches missed."> for (int docId : docList) {</span>
<span class="nc bnc" id="L2327" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L2328" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null) {</span>
// get unique id
<span class="nc" id="L2330"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L2331"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
// get other doc info
<span class="nc" id="L2333"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
<span class="nc bnc" id="L2334" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L2335"> kwic.uniqueKey.put(docId, indxfld.stringValue());</span>
}
<span class="nc" id="L2337"> kwic.subTotal.put(docId, matchList.size());</span>
<span class="nc" id="L2338"> IndexDoc mDoc = mtasCodecInfo.getDoc(field, (docId - docBase));</span>
<span class="nc bnc" id="L2339" title="All 2 branches missed."> if (mDoc != null) {</span>
<span class="nc" id="L2340"> kwic.minPosition.put(docId, mDoc.minPosition);</span>
<span class="nc" id="L2341"> kwic.maxPosition.put(docId, mDoc.maxPosition);</span>
<span class="nc" id="L2342"> List<KwicToken> kwicItemList = new ArrayList<>();</span>
<span class="nc" id="L2343"> int number = 0;</span>
<span class="nc bnc" id="L2344" title="All 2 branches missed."> for (Match m : matchList) {</span>
<span class="nc bnc" id="L2345" title="All 2 branches missed."> if (kwic.number != null</span>
<span class="nc bnc" id="L2346" title="All 2 branches missed."> && number >= (kwic.start + kwic.number)) {</span>
<span class="nc" id="L2347"> break;</span>
}
<span class="nc bnc" id="L2349" title="All 2 branches missed."> if (number >= kwic.start) {</span>
<span class="nc" id="L2350"> int startPosition = m.startPosition;</span>
<span class="nc" id="L2351"> int endPosition = m.endPosition - 1;</span>
List<MtasTokenString> tokens;
<span class="nc" id="L2353"> tokens = mtasCodecInfo.getPrefixFilteredObjectsByPositions(</span>
field, (docId - docBase), kwic.prefixes,
<span class="nc" id="L2355"> Math.max(mDoc.minPosition, startPosition - kwic.left),</span>
<span class="nc" id="L2356"> Math.min(mDoc.maxPosition, endPosition + kwic.right));</span>
<span class="nc" id="L2357"> kwicItemList.add(new KwicToken(m, tokens));</span>
}
<span class="nc" id="L2359"> number++;</span>
<span class="nc" id="L2360"> }</span>
<span class="nc" id="L2361"> kwic.tokens.put(docId, kwicItemList);</span>
}
}
<span class="nc" id="L2364"> }</span>
}
<span class="nc" id="L2366"> }</span>
}
<span class="nc" id="L2368"> }</span>
/**
* Creates the facet base.
*
* @param cf
* the cf
* @param level
* the level
* @param dataCollector
* the data collector
* @param positionsData
* the positions data
* @param spansNumberData
* the spans number data
* @param facetData
* the facet data
* @param docSet
* the doc set
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createFacetBase(ComponentFacet cf, int level,
MtasDataCollector<?, ?> dataCollector,
Map<Integer, Integer> positionsData,
Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData,
Map<String, SortedMap<String, int[]>> facetData, Integer[] docSet)
throws IOException {
<span class="nc bnc" id="L2396" title="All 2 branches missed."> for (MtasFunctionParserFunction function : cf.baseFunctionParserFunctions[level]) {</span>
<span class="nc bnc" id="L2397" title="All 2 branches missed."> if (function.needArgumentsNumber() > cf.spanQueries.length) {</span>
<span class="nc" id="L2398"> throw new IOException("function " + function + " expects (at least) "</span>
<span class="nc" id="L2399"> + function.needArgumentsNumber() + " queries");</span>
}
}
<span class="nc" id="L2402"> Map<String, int[]> list = facetData.get(cf.baseFields[level]);</span>
<span class="nc bnc" id="L2403" title="All 2 branches missed."> if (dataCollector != null) {</span>
<span class="nc" id="L2404"> MtasDataCollector<?, ?> subDataCollector = null;</span>
<span class="nc" id="L2405"> dataCollector.initNewList(1);</span>
<span class="nc bnc" id="L2406" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null) {</span>
SubComponentFunction[] tmpList;
<span class="nc bnc" id="L2408" title="All 2 branches missed."> if (!cf.baseFunctionList[level].containsKey(dataCollector)) {</span>
<span class="nc" id="L2409"> tmpList = new SubComponentFunction[cf.baseFunctionParserFunctions[level].length];</span>
<span class="nc" id="L2410"> cf.baseFunctionList[level].put(dataCollector, tmpList);</span>
<span class="nc bnc" id="L2411" title="All 2 branches missed."> for (int i = 0; i < cf.baseFunctionParserFunctions[level].length; i++) {</span>
try {
<span class="nc" id="L2413"> tmpList[i] = new SubComponentFunction(</span>
DataCollector.COLLECTOR_TYPE_LIST,
cf.baseFunctionKeys[level][i], cf.baseFunctionTypes[level][i],
<span class="nc" id="L2416"> cf.baseFunctionParserFunctions[level][i], null, null, 0,</span>
<span class="nc" id="L2417"> Integer.MAX_VALUE, null, null);</span>
<span class="nc" id="L2419"> } catch (ParseException e) {</span>
<span class="nc" id="L2420"> throw new IOException(e.getMessage());</span>
<span class="nc" id="L2421"> }</span>
}
} else {
<span class="nc" id="L2424"> tmpList = cf.baseFunctionList[level].get(dataCollector);</span>
}
<span class="nc bnc" id="L2426" title="All 2 branches missed."> for (SubComponentFunction function : tmpList) {</span>
<span class="nc" id="L2427"> function.dataCollector.initNewList(1);</span>
}
}
// check type
<span class="nc" id="L2431"> if (dataCollector.getCollectorType()</span>
<span class="nc bnc" id="L2432" title="All 2 branches missed."> .equals(DataCollector.COLLECTOR_TYPE_LIST)) {</span>
<span class="nc" id="L2433"> dataCollector.setWithTotal();</span>
// only if documents and facets
<span class="nc bnc" id="L2435" title="All 4 branches missed."> if (docSet.length > 0 && list.size() > 0) {</span>
<span class="nc" id="L2436"> HashMap<String, Integer[]> docLists = new HashMap<>();</span>
<span class="nc" id="L2437"> HashMap<String, String> groupedKeys = new HashMap<>();</span>
<span class="nc" id="L2438"> boolean documentsInFacets = false;</span>
// compute intersections
<span class="nc bnc" id="L2440" title="All 2 branches missed."> for (Entry<String, int[]> entry : list.entrySet()) {</span>
// fill grouped keys
<span class="nc bnc" id="L2442" title="All 2 branches missed."> if (!groupedKeys.containsKey(entry.getKey())) {</span>
<span class="nc" id="L2443"> groupedKeys.put(entry.getKey(), groupedKeyName(entry.getKey(),</span>
cf.baseRangeSizes[level], cf.baseRangeBases[level]));
}
// intersect docSet with docList
<span class="nc" id="L2447"> Integer[] docList = intersectedDocList(entry.getValue(), docSet);</span>
<span class="nc bnc" id="L2448" title="All 4 branches missed."> if (docList != null && docList.length > 0) {</span>
<span class="nc" id="L2449"> documentsInFacets = true;</span>
}
// update docLists
<span class="nc bnc" id="L2452" title="All 2 branches missed."> if (docLists.containsKey(groupedKeys.get(entry.getKey()))) {</span>
<span class="nc" id="L2453"> docLists.put(groupedKeys.get(entry.getKey()), mergeDocLists(</span>
<span class="nc" id="L2454"> docLists.get(groupedKeys.get(entry.getKey())), docList));</span>
} else {
<span class="nc" id="L2456"> docLists.put(groupedKeys.get(entry.getKey()), docList);</span>
}
<span class="nc" id="L2458"> }</span>
// compute stats for each key
<span class="nc bnc" id="L2460" title="All 2 branches missed."> if (documentsInFacets) {</span>
<span class="nc" id="L2461"> Map<Integer, long[]> args = computeArguments(spansNumberData,</span>
cf.spanQueries, docSet);
<span class="nc bnc" id="L2463" title="All 2 branches missed."> if (cf.baseDataTypes[level].equals(CodecUtil.DATA_TYPE_LONG)) {</span>
// check functions
<span class="nc" id="L2465"> boolean applySumRule = false;</span>
<span class="nc bnc" id="L2466" title="All 2 branches missed."> if (cf.baseStatsTypes[level].equals(CodecUtil.STATS_BASIC)</span>
<span class="nc bnc" id="L2467" title="All 6 branches missed."> && cf.baseParsers[level].sumRule()</span>
&& (cf.baseMinimumLongs[level] == null)
&& (cf.baseMaximumLongs[level] == null)) {
<span class="nc" id="L2470"> applySumRule = true;</span>
<span class="nc bnc" id="L2471" title="All 2 branches missed."> if (cf.baseFunctionList[level].get(dataCollector) != null) {</span>
for (SubComponentFunction function : cf.baseFunctionList[level]
<span class="nc bnc" id="L2473" title="All 2 branches missed."> .get(dataCollector)) {</span>
<span class="nc bnc" id="L2474" title="All 2 branches missed."> if (!function.statsType.equals(CodecUtil.STATS_BASIC)</span>
<span class="nc bnc" id="L2475" title="All 2 branches missed."> || !function.parserFunction.sumRule()</span>
<span class="nc bnc" id="L2476" title="All 2 branches missed."> || function.parserFunction.needPositions()) {</span>
<span class="nc" id="L2477"> applySumRule = false;</span>
<span class="nc" id="L2478"> break;</span>
}
}
}
}
<span class="nc bnc" id="L2483" title="All 2 branches missed."> if (applySumRule) {</span>
<span class="nc bnc" id="L2484" title="All 2 branches missed."> for (String key : new LinkedHashSet<String>(</span>
<span class="nc" id="L2485"> groupedKeys.values())) {</span>
<span class="nc bnc" id="L2486" title="All 2 branches missed."> if (docLists.get(key).length > 0) {</span>
// initialise
<span class="nc" id="L2488"> Integer[] subDocSet = docLists.get(key);</span>
<span class="nc" id="L2489"> int length = cf.baseParsers[level].needArgumentsNumber();</span>
<span class="nc" id="L2490"> long[] valueSum = new long[length];</span>
<span class="nc" id="L2491"> long valuePositions = 0;</span>
// collect
<span class="nc bnc" id="L2493" title="All 2 branches missed."> if (subDocSet.length > 0) {</span>
long[] tmpArgs;
<span class="nc bnc" id="L2495" title="All 2 branches missed."> for (int docId : subDocSet) {</span>
<span class="nc" id="L2496"> tmpArgs = args.get(docId);</span>
<span class="nc bnc" id="L2497" title="All 2 branches missed."> if (positionsData != null</span>
<span class="nc bnc" id="L2498" title="All 2 branches missed."> && positionsData.containsKey(docId)</span>
<span class="nc bnc" id="L2499" title="All 2 branches missed."> && positionsData.get(docId) != null) {</span>
<span class="nc" id="L2500"> valuePositions += positionsData.get(docId)</span>
<span class="nc" id="L2501"> .longValue();</span>
}
<span class="nc bnc" id="L2503" title="All 2 branches missed."> if (tmpArgs != null) {</span>
<span class="nc bnc" id="L2504" title="All 2 branches missed."> for (int i = 0; i < length; i++) {</span>
<span class="nc" id="L2505"> valueSum[i] += tmpArgs[i];</span>
}
}
}
long value;
try {
<span class="nc" id="L2511"> value = cf.baseParsers[level].getValueLong(valueSum,</span>
valuePositions);
<span class="nc" id="L2513"> subDataCollector = dataCollector.add(key, value,</span>
subDocSet.length);
<span class="nc" id="L2515"> } catch (IOException e) {</span>
<span class="nc" id="L2516"> log.debug(e);</span>
<span class="nc" id="L2517"> dataCollector.error(key, e.getMessage());</span>
<span class="nc" id="L2518"> subDataCollector = null;</span>
<span class="nc" id="L2519"> }</span>
<span class="nc bnc" id="L2520" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null</span>
&& cf.baseFunctionList[level]
<span class="nc bnc" id="L2522" title="All 2 branches missed."> .containsKey(dataCollector)) {</span>
<span class="nc" id="L2523"> SubComponentFunction[] functionList = cf.baseFunctionList[level]</span>
<span class="nc" id="L2524"> .get(dataCollector);</span>
<span class="nc bnc" id="L2525" title="All 2 branches missed."> for (SubComponentFunction function : functionList) {</span>
<span class="nc" id="L2526"> if (function.dataType</span>
<span class="nc bnc" id="L2527" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
try {
<span class="nc" id="L2529"> long valueLong = function.parserFunction</span>
<span class="nc" id="L2530"> .getValueLong(valueSum, valuePositions);</span>
<span class="nc" id="L2531"> function.dataCollector.add(key, valueLong,</span>
subDocSet.length);
<span class="nc" id="L2533"> } catch (IOException e) {</span>
<span class="nc" id="L2534"> log.debug(e);</span>
<span class="nc" id="L2535"> function.dataCollector.error(key, e.getMessage());</span>
<span class="nc" id="L2536"> }</span>
<span class="nc" id="L2537"> } else if (function.dataType</span>
<span class="nc bnc" id="L2538" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
try {
<span class="nc" id="L2540"> double valueDouble = function.parserFunction</span>
<span class="nc" id="L2541"> .getValueDouble(valueSum, valuePositions);</span>
<span class="nc" id="L2542"> function.dataCollector.add(key, valueDouble,</span>
subDocSet.length);
<span class="nc" id="L2544"> } catch (IOException e) {</span>
<span class="nc" id="L2545"> log.debug(e);</span>
<span class="nc" id="L2546"> function.dataCollector.error(key, e.getMessage());</span>
<span class="nc" id="L2547"> }</span>
}
}
}
<span class="nc bnc" id="L2551" title="All 2 branches missed."> if (subDataCollector != null) {</span>
<span class="nc" id="L2552"> createFacetBase(cf, (level + 1), subDataCollector,</span>
positionsData, spansNumberData, facetData,
subDocSet);
}
}
}
<span class="nc" id="L2558"> }</span>
} else {
<span class="nc bnc" id="L2560" title="All 2 branches missed."> for (String key : new LinkedHashSet<String>(</span>
<span class="nc" id="L2561"> groupedKeys.values())) {</span>
<span class="nc bnc" id="L2562" title="All 2 branches missed."> if (docLists.get(key).length > 0) {</span>
// initialise
<span class="nc" id="L2564"> Integer[] subDocSet = docLists.get(key);</span>
// collect
<span class="nc bnc" id="L2566" title="All 2 branches missed."> if (subDocSet.length > 0 && cf.baseDataTypes[level]</span>
<span class="nc bnc" id="L2567" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
// check for functions
<span class="nc" id="L2569"> long[][] functionValuesLong = null;</span>
<span class="nc" id="L2570"> double[][] functionValuesDouble = null;</span>
<span class="nc" id="L2571"> int[] functionNumber = null;</span>
<span class="nc" id="L2572"> SubComponentFunction[] functionList = null;</span>
<span class="nc bnc" id="L2573" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null</span>
&& cf.baseFunctionList[level]
<span class="nc bnc" id="L2575" title="All 2 branches missed."> .containsKey(dataCollector)) {</span>
<span class="nc" id="L2576"> functionList = cf.baseFunctionList[level]</span>
<span class="nc" id="L2577"> .get(dataCollector);</span>
<span class="nc" id="L2578"> functionValuesLong = new long[functionList.length][];</span>
<span class="nc" id="L2579"> functionValuesDouble = new double[functionList.length][];</span>
<span class="nc" id="L2580"> functionNumber = new int[functionList.length];</span>
<span class="nc bnc" id="L2581" title="All 2 branches missed."> for (int i = 0; i < functionList.length; i++) {</span>
<span class="nc" id="L2582"> functionValuesLong[i] = new long[subDocSet.length];</span>
<span class="nc" id="L2583"> functionValuesDouble[i] = new double[subDocSet.length];</span>
}
}
// check main
<span class="nc" id="L2587"> int number = 0;</span>
<span class="nc" id="L2588"> Integer[] restrictedSubDocSet = new Integer[subDocSet.length];</span>
<span class="nc" id="L2589"> long[] values = new long[subDocSet.length];</span>
<span class="nc bnc" id="L2590" title="All 2 branches missed."> for (int docId : subDocSet) {</span>
<span class="nc" id="L2591"> long[] tmpArgs = args.get(docId);</span>
<span class="nc bnc" id="L2592" title="All 2 branches missed."> int tmpPositions = (positionsData == null) ? 0</span>
<span class="nc" id="L2593"> : positionsData.get(docId);</span>
<span class="nc" id="L2594"> long value = cf.baseParsers[level].getValueLong(tmpArgs,</span>
tmpPositions);
<span class="nc bnc" id="L2596" title="All 2 branches missed."> if ((cf.baseMinimumLongs[level] == null</span>
<span class="nc bnc" id="L2597" title="All 4 branches missed."> || value >= cf.baseMinimumLongs[level])</span>
&& (cf.baseMaximumLongs[level] == null
<span class="nc bnc" id="L2599" title="All 2 branches missed."> || value <= cf.baseMaximumLongs[level])) {</span>
<span class="nc" id="L2600"> values[number] = value;</span>
<span class="nc" id="L2601"> restrictedSubDocSet[number] = docId;</span>
<span class="nc" id="L2602"> number++;</span>
<span class="nc bnc" id="L2603" title="All 2 branches missed."> if (functionList != null) {</span>
<span class="nc bnc" id="L2604" title="All 2 branches missed."> for (int i = 0; i < functionList.length; i++) {</span>
<span class="nc" id="L2605"> SubComponentFunction function = functionList[i];</span>
<span class="nc" id="L2606"> if (function.dataType</span>
<span class="nc bnc" id="L2607" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
try {
<span class="nc" id="L2609"> functionValuesLong[i][functionNumber[i]] = function.parserFunction</span>
<span class="nc" id="L2610"> .getValueLong(tmpArgs, tmpPositions);</span>
<span class="nc" id="L2611"> functionNumber[i]++;</span>
<span class="nc" id="L2612"> } catch (IOException e) {</span>
<span class="nc" id="L2613"> log.debug(e);</span>
<span class="nc" id="L2614"> function.dataCollector.error(key,</span>
<span class="nc" id="L2615"> e.getMessage());</span>
<span class="nc" id="L2616"> }</span>
<span class="nc" id="L2617"> } else if (function.dataType</span>
<span class="nc bnc" id="L2618" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
try {
<span class="nc" id="L2620"> functionValuesDouble[i][functionNumber[i]] = function.parserFunction</span>
<span class="nc" id="L2621"> .getValueDouble(tmpArgs, tmpPositions);</span>
<span class="nc" id="L2622"> functionNumber[i]++;</span>
<span class="nc" id="L2623"> } catch (IOException e) {</span>
<span class="nc" id="L2624"> log.debug(e);</span>
<span class="nc" id="L2625"> function.dataCollector.error(key,</span>
<span class="nc" id="L2626"> e.getMessage());</span>
<span class="nc" id="L2627"> }</span>
}
}
}
}
}
<span class="nc bnc" id="L2633" title="All 2 branches missed."> if (number > 0) {</span>
<span class="nc" id="L2634"> subDataCollector = dataCollector.add(key, values,</span>
number);
<span class="nc bnc" id="L2636" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null</span>
&& cf.baseFunctionList[level]
<span class="nc bnc" id="L2638" title="All 2 branches missed."> .containsKey(dataCollector)) {</span>
<span class="nc bnc" id="L2639" title="All 2 branches missed."> for (int i = 0; i < functionList.length; i++) {</span>
<span class="nc" id="L2640"> SubComponentFunction function = functionList[i];</span>
<span class="nc" id="L2641"> if (function.dataType</span>
<span class="nc bnc" id="L2642" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L2643"> function.dataCollector.add(key,</span>
functionValuesLong[i], functionNumber[i]);
<span class="nc" id="L2645"> } else if (function.dataType</span>
<span class="nc bnc" id="L2646" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L2647"> function.dataCollector.add(key,</span>
functionValuesDouble[i], functionNumber[i]);
}
}
}
<span class="nc bnc" id="L2652" title="All 2 branches missed."> if (subDataCollector != null) {</span>
<span class="nc" id="L2653"> createFacetBase(cf, (level + 1), subDataCollector,</span>
positionsData, spansNumberData, facetData, Arrays
<span class="nc" id="L2655"> .copyOfRange(restrictedSubDocSet, 0, number));</span>
}
}
}
}
<span class="nc" id="L2660"> }</span>
}
<span class="nc" id="L2662"> } else {</span>
<span class="nc" id="L2663"> throw new IOException(</span>
"unexpected dataType " + cf.baseDataTypes[level]);
}
}
<span class="nc" id="L2667"> }</span>
} else {
<span class="nc" id="L2669"> throw new IOException(</span>
<span class="nc" id="L2670"> "unexpected type " + dataCollector.getCollectorType());</span>
}
<span class="nc" id="L2672"> dataCollector.closeNewList();</span>
<span class="nc bnc" id="L2673" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null</span>
<span class="nc bnc" id="L2674" title="All 2 branches missed."> && cf.baseFunctionList[level].containsKey(dataCollector)) {</span>
<span class="nc" id="L2675"> SubComponentFunction[] tmpList = cf.baseFunctionList[level]</span>
<span class="nc" id="L2676"> .get(dataCollector);</span>
<span class="nc bnc" id="L2677" title="All 2 branches missed."> for (SubComponentFunction function : tmpList) {</span>
<span class="nc" id="L2678"> function.dataCollector.closeNewList();</span>
}
}
}
<span class="nc" id="L2683"> }</span>
/**
* Grouped key name.
*
* @param key
* the key
* @param baseRangeSize
* the base range size
* @param baseRangeBase
* the base range base
* @return the string
*/
private static String groupedKeyName(String key, Double baseRangeSize,
Double baseRangeBase) {
<span class="nc" id="L2698"> final double precision = 0.000001;</span>
<span class="nc bnc" id="L2699" title="All 4 branches missed."> if (baseRangeSize == null || baseRangeSize <= 0) {</span>
<span class="nc" id="L2700"> return key;</span>
} else {
Double doubleKey;
Double doubleBase;
Double doubleNumber;
Double doubleStart;
Double doubleEnd;
try {
<span class="nc" id="L2708"> doubleKey = Double.parseDouble(key);</span>
<span class="nc bnc" id="L2709" title="All 2 branches missed."> doubleBase = baseRangeBase != null ? baseRangeBase : 0;</span>
<span class="nc" id="L2710"> doubleNumber = Math.floor((doubleKey - doubleBase) / baseRangeSize);</span>
<span class="nc" id="L2711"> doubleStart = doubleBase + doubleNumber * baseRangeSize;</span>
<span class="nc" id="L2712"> doubleEnd = doubleStart + baseRangeSize;</span>
<span class="nc" id="L2713"> } catch (NumberFormatException e) {</span>
<span class="nc" id="L2714"> return key;</span>
<span class="nc" id="L2715"> }</span>
// integer
<span class="nc bnc" id="L2717" title="All 2 branches missed."> if (Math.abs(baseRangeSize - Math.floor(baseRangeSize)) < precision</span>
<span class="nc bnc" id="L2718" title="All 2 branches missed."> && Math.abs(doubleBase - Math.floor(doubleBase)) < precision) {</span>
try {
<span class="nc bnc" id="L2720" title="All 2 branches missed."> if (baseRangeSize > 1) {</span>
<span class="nc" id="L2721"> return String.format("%.0f", doubleStart) + "-"</span>
<span class="nc" id="L2722"> + String.format("%.0f", doubleEnd - 1);</span>
} else {
<span class="nc" id="L2724"> return String.format("%.0f", doubleStart);</span>
}
<span class="nc" id="L2726"> } catch (NumberFormatException e) {</span>
<span class="nc" id="L2727"> return key;</span>
}
} else {
<span class="nc" id="L2730"> return "[" + doubleStart + "," + doubleEnd + ")";</span>
}
}
}
/**
* Merge doc lists.
*
* @param a
* the a
* @param b
* the b
* @return the integer[]
*/
private static Integer[] mergeDocLists(Integer[] a, Integer[] b) {
<span class="nc" id="L2745"> Integer[] answer = new Integer[a.length + b.length];</span>
<span class="nc" id="L2746"> int i = 0;</span>
<span class="nc" id="L2747"> int j = 0;</span>
<span class="nc" id="L2748"> int k = 0;</span>
Integer tmp;
<span class="nc bnc" id="L2750" title="All 4 branches missed."> while (i < a.length && j < b.length) {</span>
<span class="nc bnc" id="L2751" title="All 2 branches missed."> tmp = a[i] < b[j] ? a[i++] : b[j++];</span>
<span class="nc bnc" id="L2752" title="All 4 branches missed."> for (; i < a.length && a[i].equals(tmp); i++)</span>
;
<span class="nc bnc" id="L2754" title="All 4 branches missed."> for (; j < b.length && b[j].equals(tmp); j++)</span>
;
<span class="nc" id="L2756"> answer[k++] = tmp;</span>
}
<span class="nc bnc" id="L2758" title="All 2 branches missed."> while (i < a.length) {</span>
<span class="nc" id="L2759"> tmp = a[i++];</span>
<span class="nc bnc" id="L2760" title="All 4 branches missed."> for (; i < a.length && a[i].equals(tmp); i++)</span>
;
<span class="nc" id="L2762"> answer[k++] = tmp;</span>
}
<span class="nc bnc" id="L2764" title="All 2 branches missed."> while (j < b.length) {</span>
<span class="nc" id="L2765"> tmp = b[j++];</span>
<span class="nc bnc" id="L2766" title="All 4 branches missed."> for (; j < b.length && b[j].equals(tmp); j++)</span>
;
<span class="nc" id="L2768"> answer[k++] = tmp;</span>
}
<span class="nc" id="L2770"> return Arrays.copyOf(answer, k);</span>
}
/**
* Creates the facet.
*
* @param facetList
* the facet list
* @param positionsData
* the positions data
* @param spansNumberData
* the spans number data
* @param facetData
* the facet data
* @param docSet
* the doc set
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createFacet(List<ComponentFacet> facetList,
Map<Integer, Integer> positionsData,
Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData,
Map<String, SortedMap<String, int[]>> facetData, List<Integer> docSet)
throws IOException {
<span class="nc bnc" id="L2795" title="All 2 branches missed."> if (facetList != null) {</span>
<span class="nc bnc" id="L2796" title="All 2 branches missed."> for (ComponentFacet cf : facetList) {</span>
<span class="nc bnc" id="L2797" title="All 2 branches missed."> if (cf.baseFields.length > 0) {</span>
<span class="nc" id="L2798"> createFacetBase(cf, 0, cf.dataCollector, positionsData,</span>
spansNumberData, facetData,
<span class="nc" id="L2800"> docSet.toArray(new Integer[docSet.size()]));</span>
}
<span class="nc" id="L2802"> }</span>
}
<span class="nc" id="L2804"> }</span>
/**
* Creates the termvector full.
*
* @param termVectorList
* the term vector list
* @param positionsData
* the positions data
* @param docSet
* the doc set
* @param t
* the t
* @param r
* the r
* @param lrc
* the lrc
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createTermvectorFull(
List<ComponentTermVector> termVectorList,
Map<Integer, Integer> positionsData, List<Integer> docSet, Terms t,
LeafReader r, LeafReaderContext lrc) throws IOException {
<span class="pc bpc" id="L2828" title="1 of 2 branches missed."> if (t != null) {</span>
BytesRef term;
TermsEnum termsEnum;
<span class="fc" id="L2831"> PostingsEnum postingsEnum = null;</span>
<span class="fc" id="L2832"> String segmentName = "segment" + lrc.ord;</span>
<span class="fc" id="L2833"> int segmentNumber = lrc.parent.leaves().size();</span>
// loop over termvectors
<span class="fc bfc" id="L2835" title="All 2 branches covered."> for (ComponentTermVector termVector : termVectorList) {</span>
<span class="fc bfc" id="L2836" title="All 4 branches covered."> if (termVector.full || termVector.list != null) {</span>
<span class="fc bfc" id="L2837" title="All 2 branches covered."> if (termVector.full) {</span>
<span class="fc" id="L2838"> termVector.subComponentFunction.dataCollector.setWithTotal();</span>
}
List<CompiledAutomaton> listAutomata;
Map<String, Automaton> automatonMap;
<span class="fc bfc" id="L2842" title="All 2 branches covered."> if (termVector.list == null) {</span>
<span class="fc" id="L2843"> listAutomata = new ArrayList<>();</span>
CompiledAutomaton compiledAutomaton;
Automaton automaton;
<span class="pc bpc" id="L2846" title="1 of 4 branches missed."> if ((termVector.regexp == null) || (termVector.regexp.isEmpty())) {</span>
<span class="fc" id="L2847"> RegExp re = new RegExp(</span>
termVector.prefix + MtasToken.DELIMITER + ".*");
<span class="fc" id="L2849"> automaton = re.toAutomaton();</span>
<span class="fc" id="L2850"> } else {</span>
<span class="fc" id="L2851"> RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER</span>
+ termVector.regexp + "\u0000*");
<span class="fc" id="L2853"> automaton = re.toAutomaton();</span>
}
<span class="fc" id="L2855"> compiledAutomaton = new CompiledAutomaton(automaton);</span>
<span class="fc" id="L2856"> listAutomata.add(compiledAutomaton);</span>
<span class="fc" id="L2857"> } else {</span>
<span class="fc bfc" id="L2858" title="All 2 branches covered."> automatonMap = MtasToken.createAutomatonMap(termVector.prefix,</span>
new ArrayList<String>(termVector.list),
<span class="fc" id="L2860"> termVector.listRegexp ? false : true);</span>
<span class="fc" id="L2861"> listAutomata = MtasToken.createAutomata(termVector.prefix,</span>
termVector.regexp, automatonMap);
}
<span class="fc" id="L2864"> List<ByteRunAutomaton> ignoreByteRunAutomatonList = null;</span>
<span class="fc bfc" id="L2865" title="All 2 branches covered."> if ((termVector.ignoreRegexp != null)</span>
<span class="pc bpc" id="L2866" title="1 of 2 branches missed."> && (!termVector.ignoreRegexp.isEmpty())) {</span>
<span class="fc" id="L2867"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
<span class="fc" id="L2868"> RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER</span>
+ termVector.ignoreRegexp + "\u0000*");
<span class="fc" id="L2870"> ignoreByteRunAutomatonList</span>
<span class="fc" id="L2871"> .add(new ByteRunAutomaton(re.toAutomaton()));</span>
}
<span class="fc bfc" id="L2873" title="All 2 branches covered."> if (termVector.ignoreList != null) {</span>
<span class="pc bpc" id="L2874" title="1 of 2 branches missed."> if (ignoreByteRunAutomatonList == null) {</span>
<span class="nc" id="L2875"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
}
<span class="pc bpc" id="L2877" title="1 of 2 branches missed."> Map<String, Automaton> list = MtasToken.createAutomatonMap(</span>
termVector.prefix, new ArrayList<String>(termVector.ignoreList),
<span class="fc" id="L2879"> termVector.ignoreListRegexp ? false : true);</span>
<span class="fc bfc" id="L2880" title="All 2 branches covered."> for (Automaton automaton : list.values()) {</span>
<span class="fc" id="L2881"> ignoreByteRunAutomatonList.add(new ByteRunAutomaton(automaton));</span>
<span class="fc" id="L2882"> }</span>
}
<span class="fc bfc" id="L2885" title="All 2 branches covered."> for (CompiledAutomaton compiledAutomaton : listAutomata) {</span>
<span class="fc" id="L2886"> if (!compiledAutomaton.type</span>
<span class="fc bfc" id="L2887" title="All 2 branches covered."> .equals(CompiledAutomaton.AUTOMATON_TYPE.NORMAL)) {</span>
<span class="fc" id="L2888"> if (compiledAutomaton.type</span>
<span class="pc bpc" id="L2889" title="1 of 2 branches missed."> .equals(CompiledAutomaton.AUTOMATON_TYPE.NONE)) {</span>
// do nothing
} else {
<span class="nc" id="L2892"> throw new IOException(</span>
"compiledAutomaton is " + compiledAutomaton.type);
}
} else {
<span class="fc" id="L2896"> termsEnum = t.intersect(compiledAutomaton, null);</span>
<span class="fc" id="L2897"> int initSize = Math.min((int) t.size(), 1000);</span>
<span class="fc" id="L2898"> termVector.subComponentFunction.dataCollector.initNewList(</span>
initSize, segmentName, segmentNumber, termVector.boundary);
<span class="fc" id="L2900"> boolean doBasic = termVector.subComponentFunction.dataCollector</span>
<span class="fc" id="L2901"> .getStatsType().equals(CodecUtil.STATS_BASIC);</span>
<span class="pc bpc" id="L2902" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L2903" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L2904"> function.dataCollector.initNewList(initSize);</span>
<span class="nc bnc" id="L2905" title="All 4 branches missed."> doBasic = doBasic ? (function.parserFunction.sumRule()</span>
<span class="nc bnc" id="L2906" title="All 2 branches missed."> && !function.parserFunction.needPositions()</span>
<span class="nc" id="L2907"> && function.dataCollector.getStatsType()</span>
<span class="nc bnc" id="L2908" title="All 2 branches missed."> .equals(CodecUtil.STATS_BASIC))</span>
: doBasic;
<span class="nc" id="L2910"> }</span>
}
// only if documents
<span class="pc bpc" id="L2913" title="1 of 2 branches missed."> if (!docSet.isEmpty()) {</span>
int termDocId;
boolean acceptedTerm;
String key;
// loop over terms
<span class="fc bfc" id="L2918" title="All 2 branches covered."> while ((term = termsEnum.next()) != null) {</span>
<span class="pc bpc" id="L2919" title="1 of 2 branches missed."> if (validateTermWithStartValue(term, termVector)) {</span>
<span class="fc" id="L2920"> termDocId = -1;</span>
<span class="fc" id="L2921"> acceptedTerm = true;</span>
<span class="fc bfc" id="L2922" title="All 2 branches covered."> if (ignoreByteRunAutomatonList != null) {</span>
<span class="fc bfc" id="L2923" title="All 2 branches covered."> for (ByteRunAutomaton ignoreByteRunAutomaton : ignoreByteRunAutomatonList) {</span>
<span class="fc bfc" id="L2924" title="All 2 branches covered."> if (ignoreByteRunAutomaton.run(term.bytes, term.offset,</span>
term.length)) {
<span class="fc" id="L2926"> acceptedTerm = false;</span>
<span class="fc" id="L2927"> break;</span>
}
<span class="fc" id="L2929"> }</span>
}
<span class="fc bfc" id="L2931" title="All 2 branches covered."> if (acceptedTerm) {</span>
<span class="fc bfc" id="L2932" title="All 2 branches covered."> if (doBasic) {</span>
// compute numbers;
<span class="fc" id="L2934"> TermvectorNumberBasic numberBasic = computeTermvectorNumberBasic(</span>
docSet, termDocId, termsEnum, r, lrc, postingsEnum);
// register
<span class="fc bfc" id="L2937" title="All 2 branches covered."> if (numberBasic.docNumber > 0) {</span>
<span class="fc" id="L2938"> long valueLong = 0;</span>
<span class="fc" id="L2939"> key = MtasToken.getPostfixFromValue(term);</span>
try {
<span class="fc" id="L2941"> valueLong = termVector.subComponentFunction.parserFunction</span>
<span class="fc" id="L2942"> .getValueLong(numberBasic.valueSum, 1);</span>
<span class="nc" id="L2943"> } catch (IOException e) {</span>
<span class="nc" id="L2944"> log.debug(e);</span>
<span class="nc" id="L2945"> termVector.subComponentFunction.dataCollector.error(</span>
<span class="nc" id="L2946"> MtasToken.getPostfixFromValue(term),</span>
<span class="nc" id="L2947"> e.getMessage());</span>
<span class="fc" id="L2948"> }</span>
<span class="fc" id="L2949"> termVector.subComponentFunction.dataCollector.add(key,</span>
valueLong, numberBasic.docNumber);
<span class="pc bpc" id="L2951" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L2952" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L2953"> if (function.dataType</span>
<span class="nc bnc" id="L2954" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L2955"> long valueFunction = function.parserFunction</span>
<span class="nc" id="L2956"> .getValueLong(numberBasic.valueSum, 0);</span>
<span class="nc" id="L2957"> function.dataCollector.add(key, valueFunction,</span>
numberBasic.docNumber);
<span class="nc" id="L2959"> } else if (function.dataType</span>
<span class="nc bnc" id="L2960" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L2961"> double valueFunction = function.parserFunction</span>
<span class="nc" id="L2962"> .getValueDouble(numberBasic.valueSum, 0);</span>
<span class="nc" id="L2963"> function.dataCollector.add(key, valueFunction,</span>
numberBasic.docNumber);
}
<span class="nc" id="L2966"> }</span>
}
}
<span class="fc" id="L2969"> } else {</span>
<span class="fc" id="L2970"> TermvectorNumberFull numberFull = computeTermvectorNumberFull(</span>
docSet, termDocId, termsEnum, lrc, postingsEnum,
positionsData);
<span class="pc bpc" id="L2973" title="1 of 2 branches missed."> if (numberFull.docNumber > 0) {</span>
<span class="fc" id="L2974"> long[] valuesLong = new long[numberFull.docNumber];</span>
<span class="fc" id="L2975"> key = MtasToken.getPostfixFromValue(term);</span>
<span class="fc bfc" id="L2976" title="All 2 branches covered."> for (int i = 0; i < numberFull.docNumber; i++) {</span>
try {
<span class="fc" id="L2978"> valuesLong[i] = termVector.subComponentFunction.parserFunction</span>
<span class="fc" id="L2979"> .getValueLong(</span>
new long[] { numberFull.args[i] },
numberFull.positions[i]);
<span class="nc" id="L2982"> } catch (IOException e) {</span>
<span class="nc" id="L2983"> log.debug(e);</span>
<span class="nc" id="L2984"> termVector.subComponentFunction.dataCollector</span>
<span class="nc" id="L2985"> .error(key, e.getMessage());</span>
<span class="fc" id="L2986"> }</span>
}
<span class="fc" id="L2988"> termVector.subComponentFunction.dataCollector.add(key,</span>
valuesLong, valuesLong.length);
<span class="pc bpc" id="L2990" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L2991" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L2992"> if (function.dataType</span>
<span class="nc bnc" id="L2993" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L2994"> valuesLong = new long[numberFull.docNumber];</span>
<span class="nc bnc" id="L2995" title="All 2 branches missed."> for (int i = 0; i < numberFull.docNumber; i++) {</span>
try {
<span class="nc" id="L2997"> valuesLong[i] = function.parserFunction</span>
<span class="nc" id="L2998"> .getValueLong(</span>
new long[] { numberFull.args[i] },
numberFull.positions[i]);
<span class="nc" id="L3001"> } catch (IOException e) {</span>
<span class="nc" id="L3002"> log.debug(e);</span>
<span class="nc" id="L3003"> function.dataCollector.error(key,</span>
<span class="nc" id="L3004"> e.getMessage());</span>
<span class="nc" id="L3005"> }</span>
}
<span class="nc" id="L3007"> function.dataCollector.add(key, valuesLong,</span>
valuesLong.length);
<span class="nc" id="L3009"> } else if (function.dataType</span>
<span class="nc bnc" id="L3010" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L3011"> double[] valuesDouble = new double[numberFull.docNumber];</span>
<span class="nc bnc" id="L3012" title="All 2 branches missed."> for (int i = 0; i < numberFull.docNumber; i++) {</span>
try {
<span class="nc" id="L3014"> valuesDouble[i] = function.parserFunction</span>
<span class="nc" id="L3015"> .getValueDouble(</span>
new long[] { numberFull.args[i] },
numberFull.positions[i]);
<span class="nc" id="L3018"> } catch (IOException e) {</span>
<span class="nc" id="L3019"> log.debug(e);</span>
<span class="nc" id="L3020"> function.dataCollector.error(key,</span>
<span class="nc" id="L3021"> e.getMessage());</span>
<span class="nc" id="L3022"> }</span>
}
<span class="nc" id="L3024"> function.dataCollector.add(key, valuesDouble,</span>
valuesDouble.length);
}
<span class="nc" id="L3027"> }</span>
}
}
<span class="fc" id="L3031"> }</span>
}
}
}
}
<span class="fc" id="L3036"> termVector.subComponentFunction.dataCollector.closeNewList();</span>
<span class="pc bpc" id="L3037" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3038" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3039"> function.dataCollector.closeNewList();</span>
<span class="nc" id="L3040"> }</span>
}
}
<span class="fc" id="L3043"> }</span>
}
<span class="fc" id="L3045"> }</span>
}
<span class="fc" id="L3047"> }</span>
/**
* Creates the termvector first round.
*
* @param termVectorList
* the term vector list
* @param positionsData
* the positions data
* @param docSet
* the doc set
* @param t
* the t
* @param r
* the r
* @param lrc
* the lrc
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createTermvectorFirstRound(
List<ComponentTermVector> termVectorList,
Map<Integer, Integer> positionsData, List<Integer> docSet, Terms t,
LeafReader r, LeafReaderContext lrc) throws IOException {
<span class="pc bpc" id="L3071" title="1 of 2 branches missed."> if (t != null) {</span>
BytesRef term;
TermsEnum termsEnum;
<span class="fc" id="L3074"> PostingsEnum postingsEnum = null;</span>
<span class="fc" id="L3075"> String segmentName = "segment" + lrc.ord;</span>
<span class="fc" id="L3076"> String[] mutableKey = new String[1];</span>
<span class="fc" id="L3077"> int segmentNumber = lrc.parent.leaves().size();</span>
// loop over termvectors
<span class="fc bfc" id="L3079" title="All 2 branches covered."> for (ComponentTermVector termVector : termVectorList) {</span>
CompiledAutomaton compiledAutomaton;
<span class="pc bpc" id="L3081" title="1 of 4 branches missed."> if ((termVector.regexp == null) || (termVector.regexp.isEmpty())) {</span>
<span class="fc" id="L3082"> RegExp re = new RegExp(</span>
termVector.prefix + MtasToken.DELIMITER + ".*");
<span class="fc" id="L3084"> compiledAutomaton = new CompiledAutomaton(re.toAutomaton());</span>
<span class="fc" id="L3085"> } else {</span>
<span class="fc" id="L3086"> RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER</span>
+ termVector.regexp + "\u0000*");
<span class="fc" id="L3088"> compiledAutomaton = new CompiledAutomaton(re.toAutomaton());</span>
}
<span class="fc" id="L3090"> List<ByteRunAutomaton> ignoreByteRunAutomatonList = null;</span>
<span class="fc bfc" id="L3091" title="All 2 branches covered."> if ((termVector.ignoreRegexp != null)</span>
<span class="pc bpc" id="L3092" title="1 of 2 branches missed."> && (!termVector.ignoreRegexp.isEmpty())) {</span>
<span class="fc" id="L3093"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
<span class="fc" id="L3094"> RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER</span>
+ termVector.ignoreRegexp + "\u0000*");
<span class="fc" id="L3096"> ignoreByteRunAutomatonList</span>
<span class="fc" id="L3097"> .add(new ByteRunAutomaton(re.toAutomaton()));</span>
}
<span class="fc bfc" id="L3099" title="All 2 branches covered."> if (termVector.ignoreList != null) {</span>
<span class="pc bpc" id="L3100" title="1 of 2 branches missed."> if (ignoreByteRunAutomatonList == null) {</span>
<span class="nc" id="L3101"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
}
<span class="pc bpc" id="L3103" title="1 of 2 branches missed."> Map<String, Automaton> list = MtasToken.createAutomatonMap(</span>
termVector.prefix, new ArrayList<String>(termVector.ignoreList),
<span class="fc" id="L3105"> termVector.ignoreListRegexp ? false : true);</span>
<span class="fc bfc" id="L3106" title="All 2 branches covered."> for (Automaton automaton : list.values()) {</span>
<span class="fc" id="L3107"> ignoreByteRunAutomatonList.add(new ByteRunAutomaton(automaton));</span>
<span class="fc" id="L3108"> }</span>
}
<span class="fc bfc" id="L3110" title="All 4 branches covered."> if (!termVector.full && termVector.list == null) {</span>
<span class="fc" id="L3111"> termsEnum = t.intersect(compiledAutomaton, null);</span>
<span class="fc" id="L3112"> int initSize = Math.min((int) t.size(), 1000);</span>
<span class="fc" id="L3113"> termVector.subComponentFunction.dataCollector.initNewList(initSize,</span>
segmentName, segmentNumber, termVector.boundary);
<span class="pc bpc" id="L3115" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3116" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3117"> function.dataCollector.initNewList(initSize);</span>
<span class="nc" id="L3118"> }</span>
}
// only if documents
<span class="pc bpc" id="L3121" title="1 of 2 branches missed."> if (!docSet.isEmpty()) {</span>
int termDocId;
<span class="fc" id="L3123"> int termNumberMaximum = termVector.number;</span>
<span class="fc" id="L3124"> HashMap<BytesRef, RegisterStatus> computeFullList = new HashMap<>();</span>
RegisterStatus registerStatus;
// basic, don't need full values
<span class="fc" id="L3127"> if (termVector.subComponentFunction.sortType</span>
<span class="fc bfc" id="L3128" title="All 2 branches covered."> .equals(CodecUtil.SORT_TERM)</span>
|| termVector.subComponentFunction.sortType
<span class="pc bpc" id="L3130" title="1 of 2 branches missed."> .equals(CodecUtil.STATS_TYPE_SUM)</span>
|| termVector.subComponentFunction.sortType
<span class="nc bnc" id="L3132" title="All 2 branches missed."> .equals(CodecUtil.STATS_TYPE_N)) {</span>
<span class="fc" id="L3133"> int termCounter = 0;</span>
boolean continueAfterPreliminaryCheck;
<span class="fc" id="L3136"> boolean preliminaryCheck = false;</span>
<span class="pc bpc" id="L3137" title="1 of 4 branches missed."> if (r.getLiveDocs() == null && (docSet.size() != r.numDocs())) {</span>
<span class="nc" id="L3138"> preliminaryCheck = true;</span>
}
// loop over terms
boolean acceptedTerm;
<span class="fc bfc" id="L3142" title="All 2 branches covered."> while ((term = termsEnum.next()) != null) {</span>
<span class="pc bpc" id="L3143" title="1 of 2 branches missed."> if (validateTermWithStartValue(term, termVector)) {</span>
<span class="fc" id="L3144"> termDocId = -1;</span>
<span class="fc" id="L3145"> acceptedTerm = true;</span>
<span class="fc bfc" id="L3146" title="All 2 branches covered."> if (ignoreByteRunAutomatonList != null) {</span>
<span class="fc bfc" id="L3147" title="All 2 branches covered."> for (ByteRunAutomaton ignoreByteRunAutomaton : ignoreByteRunAutomatonList) {</span>
<span class="pc bpc" id="L3148" title="1 of 2 branches missed."> if (ignoreByteRunAutomaton.run(term.bytes, term.offset,</span>
term.length)) {
<span class="nc" id="L3150"> acceptedTerm = false;</span>
<span class="nc" id="L3151"> break;</span>
}
<span class="fc" id="L3153"> }</span>
}
<span class="pc bpc" id="L3155" title="1 of 2 branches missed."> if (acceptedTerm) {</span>
<span class="fc" id="L3156"> continueAfterPreliminaryCheck = true;</span>
<span class="fc" id="L3157"> mutableKey[0] = null;</span>
<span class="pc bpc" id="L3158" title="1 of 2 branches missed."> if (preliminaryCheck) {</span>
try {
<span class="nc" id="L3160"> TermvectorNumberBasic preliminaryNumberBasic = computeTermvectorNumberBasic(</span>
termsEnum, r);
<span class="nc bnc" id="L3162" title="All 2 branches missed."> if (preliminaryNumberBasic.docNumber > 0) {</span>
<span class="nc" id="L3163"> continueAfterPreliminaryCheck = preliminaryRegisterValue(</span>
term, termVector, preliminaryNumberBasic,
<span class="nc" id="L3165"> termNumberMaximum, segmentNumber, mutableKey);</span>
} else {
<span class="nc" id="L3167"> continueAfterPreliminaryCheck = false;</span>
}
<span class="nc" id="L3169"> } catch (IOException e) {</span>
<span class="nc" id="L3170"> log.debug(e);</span>
<span class="nc" id="L3171"> continueAfterPreliminaryCheck = true;</span>
<span class="nc" id="L3172"> }</span>
}
<span class="pc bpc" id="L3174" title="1 of 2 branches missed."> if (continueAfterPreliminaryCheck) {</span>
// compute numbers;
<span class="fc" id="L3176"> TermvectorNumberBasic numberBasic = computeTermvectorNumberBasic(</span>
docSet, termDocId, termsEnum, r, lrc, postingsEnum);
// register
<span class="fc bfc" id="L3179" title="All 2 branches covered."> if (numberBasic.docNumber > 0) {</span>
<span class="fc" id="L3180"> termCounter++;</span>
<span class="fc" id="L3181"> registerStatus = registerValue(term, termVector,</span>
<span class="fc" id="L3182"> numberBasic, termNumberMaximum, segmentNumber,</span>
false, mutableKey);
<span class="fc bfc" id="L3184" title="All 2 branches covered."> if (registerStatus != null) {</span>
<span class="fc" id="L3185"> computeFullList.put(BytesRef.deepCopyOf(term),</span>
registerStatus);
}
}
}
// stop after termCounterMaximum
<span class="fc" id="L3191"> if (termVector.subComponentFunction.sortType</span>
<span class="fc bfc" id="L3192" title="All 2 branches covered."> .equals(CodecUtil.SORT_TERM)</span>
&& termVector.subComponentFunction.sortDirection
<span class="fc bfc" id="L3194" title="All 4 branches covered."> .equals(CodecUtil.SORT_ASC)</span>
&& termCounter >= termNumberMaximum) {
<span class="fc" id="L3196"> break;</span>
}
}
}
}
// rerun for full
<span class="fc bfc" id="L3202" title="All 2 branches covered."> if (computeFullList.size() > 0) {</span>
<span class="fc" id="L3203"> termsEnum = t.intersect(compiledAutomaton, null);</span>
<span class="fc bfc" id="L3204" title="All 2 branches covered."> while ((term = termsEnum.next()) != null) {</span>
<span class="pc bpc" id="L3205" title="1 of 2 branches missed."> if (validateTermWithStartValue(term, termVector)) {</span>
<span class="fc" id="L3206"> termDocId = -1;</span>
<span class="fc" id="L3207"> mutableKey[0] = null;</span>
// only if (probably) needed
<span class="fc bfc" id="L3209" title="All 2 branches covered."> if (computeFullList.containsKey(term)) {</span>
<span class="fc" id="L3210"> registerStatus = computeFullList.get(term);</span>
boolean doAdd;
<span class="fc" id="L3212"> doAdd = termVector.subComponentFunction.sortType</span>
<span class="fc" id="L3213"> .equals(CodecUtil.SORT_TERM);</span>
<span class="fc" id="L3214"> doAdd |= termVector.subComponentFunction.sortDirection</span>
<span class="fc" id="L3215"> .equals(CodecUtil.SORT_ASC);</span>
<span class="pc bpc" id="L3216" title="1 of 2 branches missed."> doAdd |= termVector.list != null;</span>
<span class="fc" id="L3217"> doAdd |= termVector.boundaryRegistration;</span>
<span class="fc" id="L3218"> doAdd |= registerStatus.force;</span>
<span class="fc" id="L3219"> doAdd |= termVector.subComponentFunction.dataCollector</span>
<span class="fc" id="L3220"> .validateSegmentBoundary(</span>
<span class="fc" id="L3221"> registerStatus.sortValue); </span>
<span class="fc bfc" id="L3222" title="All 2 branches covered."> if (doAdd) {</span>
<span class="fc" id="L3223"> TermvectorNumberFull numberFull = computeTermvectorNumberFull(</span>
docSet, termDocId, termsEnum, lrc, postingsEnum,
positionsData);
<span class="pc bpc" id="L3226" title="1 of 2 branches missed."> if (numberFull.docNumber > 0) {</span>
<span class="fc" id="L3227"> termCounter++;</span>
<span class="fc" id="L3228"> registerValue(term, termVector, numberFull,</span>
mutableKey);
}
}
<span class="fc" id="L3232"> }</span>
}
}
<span class="fc" id="L3235"> computeFullList.clear();</span>
}
<span class="fc" id="L3237"> } else {</span>
<span class="nc" id="L3238"> throw new IOException(</span>
"sort '" + termVector.subComponentFunction.sortType + " "
+ termVector.subComponentFunction.sortDirection
+ "' not supported");
}
// finish if segments are used
<span class="fc" id="L3244"> termVector.subComponentFunction.dataCollector</span>
<span class="fc" id="L3245"> .closeSegmentKeyValueRegistration();</span>
<span class="pc bpc" id="L3246" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3247" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3248"> function.dataCollector.closeSegmentKeyValueRegistration();</span>
<span class="nc" id="L3249"> }</span>
}
}
<span class="fc" id="L3252"> termVector.subComponentFunction.dataCollector.closeNewList();</span>
<span class="pc bpc" id="L3253" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3254" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3255"> function.dataCollector.closeNewList();</span>
<span class="nc" id="L3256"> }</span>
}
}
<span class="fc" id="L3259"> }</span>
}
<span class="fc" id="L3261"> }</span>
/**
* Creates the termvector second round.
*
* @param termVectorList
* the term vector list
* @param positionsData
* the positions data
* @param docSet
* the doc set
* @param t
* the t
* @param r
* the r
* @param lrc
* the lrc
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static void createTermvectorSecondRound(
List<ComponentTermVector> termVectorList,
Map<Integer, Integer> positionsData, List<Integer> docSet, Terms t,
LeafReader r, LeafReaderContext lrc) throws IOException {
<span class="pc bpc" id="L3285" title="1 of 2 branches missed."> if (t != null) {</span>
BytesRef term;
TermsEnum termsEnum;
<span class="fc" id="L3288"> PostingsEnum postingsEnum = null;</span>
<span class="fc" id="L3289"> String segmentName = "segment" + lrc.ord;</span>
<span class="fc" id="L3290"> int segmentNumber = lrc.parent.leaves().size();</span>
<span class="fc" id="L3291"> String[] mutableKey = new String[1];</span>
<span class="fc bfc" id="L3292" title="All 2 branches covered."> for (ComponentTermVector termVector : termVectorList) {</span>
<span class="pc bpc" id="L3293" title="2 of 6 branches missed."> if (!termVector.full && termVector.list == null</span>
&& (termVector.subComponentFunction.dataCollector.segmentRecomputeKeyList != null
&& termVector.subComponentFunction.dataCollector.segmentRecomputeKeyList
<span class="fc bfc" id="L3296" title="All 2 branches covered."> .containsKey(segmentName))) {</span>
<span class="fc" id="L3297"> Set<String> recomputeKeyList = termVector.subComponentFunction.dataCollector.segmentRecomputeKeyList</span>
<span class="fc" id="L3298"> .get(segmentName);</span>
<span class="pc bpc" id="L3299" title="1 of 2 branches missed."> if (!recomputeKeyList.isEmpty()) {</span>
<span class="fc" id="L3300"> Map<String, Automaton> automatonMap = MtasToken.createAutomatonMap(</span>
termVector.prefix, new ArrayList<String>(recomputeKeyList),
<span class="fc" id="L3302"> true);</span>
<span class="fc" id="L3303"> List<CompiledAutomaton> listCompiledAutomata = MtasToken</span>
<span class="fc" id="L3304"> .createAutomata(termVector.prefix, termVector.regexp,</span>
automatonMap);
<span class="fc bfc" id="L3306" title="All 2 branches covered."> for (CompiledAutomaton compiledAutomaton : listCompiledAutomata) {</span>
<span class="fc" id="L3307"> termsEnum = t.intersect(compiledAutomaton, null);</span>
<span class="fc" id="L3308"> termVector.subComponentFunction.dataCollector</span>
<span class="fc" id="L3309"> .initNewList(</span>
termVector.subComponentFunction.dataCollector.segmentKeys
<span class="fc" id="L3311"> .size(),</span>
segmentName, segmentNumber, termVector.boundary);
<span class="fc" id="L3313"> RegisterStatus registerStatus = null;</span>
<span class="pc bpc" id="L3314" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3315" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3316"> function.dataCollector.initNewList((int) t.size(),</span>
segmentName, segmentNumber, null);
<span class="nc" id="L3318"> }</span>
}
<span class="pc bpc" id="L3320" title="1 of 2 branches missed."> if (!docSet.isEmpty()) {</span>
int termDocId;
<span class="fc bfc" id="L3322" title="All 2 branches covered."> while ((term = termsEnum.next()) != null) {</span>
<span class="pc bpc" id="L3323" title="1 of 2 branches missed."> if (validateTermWithStartValue(term, termVector)) {</span>
<span class="fc" id="L3324"> termDocId = -1;</span>
<span class="fc" id="L3325"> mutableKey[0] = null;</span>
// compute numbers;
<span class="fc" id="L3327"> TermvectorNumberBasic numberBasic = computeTermvectorNumberBasic(</span>
docSet, termDocId, termsEnum, r, lrc, postingsEnum);
<span class="fc bfc" id="L3329" title="All 2 branches covered."> if (numberBasic.docNumber > 0) {</span>
<span class="fc" id="L3330"> registerStatus = registerValue(term, termVector,</span>
<span class="fc" id="L3331"> numberBasic, 0, segmentNumber, true, mutableKey);</span>
<span class="fc bfc" id="L3332" title="All 2 branches covered."> if (registerStatus != null) {</span>
<span class="fc" id="L3333"> TermvectorNumberFull numberFull = computeTermvectorNumberFull(</span>
docSet, termDocId, termsEnum, lrc, postingsEnum,
positionsData);
<span class="pc bpc" id="L3336" title="1 of 2 branches missed."> if (numberFull.docNumber > 0) {</span>
<span class="fc" id="L3337"> registerValue(term, termVector, numberFull,</span>
mutableKey);
}
}
}
<span class="fc" id="L3342"> }</span>
}
}
<span class="fc" id="L3345"> termVector.subComponentFunction.dataCollector.closeNewList();</span>
<span class="pc bpc" id="L3346" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3347" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3348"> function.dataCollector.closeNewList();</span>
<span class="nc" id="L3349"> }</span>
}
<span class="fc" id="L3351"> }</span>
}
}
<span class="fc" id="L3354"> }</span>
}
<span class="fc" id="L3356"> }</span>
/**
* Validate term with start value.
*
* @param term
* the term
* @param termVector
* the term vector
* @return true, if successful
*/
private static boolean validateTermWithStartValue(BytesRef term,
ComponentTermVector termVector) {
<span class="pc bpc" id="L3369" title="1 of 2 branches missed."> if (termVector.startValue == null) {</span>
<span class="fc" id="L3370"> return true;</span>
<span class="nc" id="L3371"> } else if (termVector.subComponentFunction.sortType</span>
<span class="nc bnc" id="L3372" title="All 2 branches missed."> .equals(CodecUtil.SORT_TERM)) {</span>
<span class="nc bnc" id="L3373" title="All 2 branches missed."> if (term.length > termVector.startValue.length) {</span>
<span class="nc" id="L3374"> byte[] zeroBytes = (new BytesRef("\u0000")).bytes;</span>
<span class="nc" id="L3375"> int n = (int) (Math</span>
<span class="nc" id="L3376"> .ceil(((double) (term.length - termVector.startValue.length))</span>
/ zeroBytes.length));
<span class="nc" id="L3378"> byte[] newBytes = new byte[termVector.startValue.length</span>
+ n * zeroBytes.length];
<span class="nc" id="L3380"> System.arraycopy(termVector.startValue.bytes, 0, newBytes, 0,</span>
termVector.startValue.length);
<span class="nc bnc" id="L3382" title="All 2 branches missed."> for (int i = 0; i < n; i++) {</span>
<span class="nc" id="L3383"> System.arraycopy(zeroBytes, 0, newBytes,</span>
termVector.startValue.length + i * zeroBytes.length,
zeroBytes.length);
}
<span class="nc" id="L3387"> termVector.startValue = new BytesRef(newBytes);</span>
}
<span class="nc bnc" id="L3389" title="All 2 branches missed."> if ((termVector.subComponentFunction.sortDirection.equals(</span>
<span class="nc bnc" id="L3390" title="All 2 branches missed."> CodecUtil.SORT_ASC) && (termVector.startValue.compareTo(term) < 0))</span>
|| (termVector.subComponentFunction.sortDirection
<span class="nc bnc" id="L3392" title="All 2 branches missed."> .equals(CodecUtil.SORT_DESC)</span>
<span class="nc bnc" id="L3393" title="All 2 branches missed."> && (termVector.startValue.compareTo(term) > 0))) {</span>
<span class="nc" id="L3394"> return true;</span>
}
}
<span class="nc" id="L3397"> return false;</span>
}
/**
* Need second round termvector.
*
* @param termVectorList
* the term vector list
* @return true, if successful
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static boolean needSecondRoundTermvector(
List<ComponentTermVector> termVectorList) throws IOException {
<span class="fc" id="L3411"> boolean needSecondRound = false;</span>
<span class="fc bfc" id="L3412" title="All 2 branches covered."> for (ComponentTermVector termVector : termVectorList) {</span>
<span class="fc bfc" id="L3413" title="All 4 branches covered."> if (!termVector.full && termVector.list == null) {</span>
boolean doCheck;
<span class="fc bfc" id="L3415" title="All 2 branches covered."> doCheck = termVector.subComponentFunction.dataCollector.segmentRegistration != null</span>
&& (termVector.subComponentFunction.dataCollector.segmentRegistration
<span class="fc bfc" id="L3417" title="All 2 branches covered."> .equals(MtasDataCollector.SEGMENT_SORT_ASC)</span>
|| termVector.subComponentFunction.dataCollector.segmentRegistration
<span class="pc bpc" id="L3419" title="2 of 4 branches missed."> .equals(MtasDataCollector.SEGMENT_SORT_DESC))</span>
&& termVector.number > 0;
<span class="fc bfc" id="L3421" title="All 2 branches covered."> doCheck |= termVector.subComponentFunction.dataCollector.segmentRegistration != null</span>
&& (termVector.subComponentFunction.dataCollector.segmentRegistration
<span class="pc bpc" id="L3423" title="1 of 2 branches missed."> .equals(MtasDataCollector.SEGMENT_BOUNDARY_ASC)</span>
|| termVector.subComponentFunction.dataCollector.segmentRegistration
<span class="pc bpc" id="L3425" title="3 of 4 branches missed."> .equals(MtasDataCollector.SEGMENT_BOUNDARY_DESC))</span>
&& termVector.number > 0;
<span class="fc bfc" id="L3427" title="All 2 branches covered."> if (doCheck) {</span>
<span class="fc" id="L3428"> termVector.subComponentFunction.dataCollector.recomputeSegmentKeys();</span>
<span class="fc" id="L3429"> if (!termVector.subComponentFunction.dataCollector</span>
<span class="fc bfc" id="L3430" title="All 2 branches covered."> .checkExistenceNecessaryKeys()) {</span>
<span class="fc" id="L3431"> needSecondRound = true;</span>
}
<span class="fc" id="L3433"> termVector.subComponentFunction.dataCollector.reduceToSegmentKeys();</span>
}
}
<span class="fc" id="L3436"> }</span>
<span class="fc" id="L3437"> return needSecondRound;</span>
}
/**
* The Class TermvectorNumberBasic.
*/
private static class TermvectorNumberBasic {
/** The value sum. */
public long[] valueSum;
/** The doc number. */
public int docNumber;
/**
* Instantiates a new termvector number basic.
*/
<span class="fc" id="L3454"> TermvectorNumberBasic() {</span>
<span class="fc" id="L3455"> valueSum = new long[] { 0 };</span>
<span class="fc" id="L3456"> docNumber = 0;</span>
<span class="fc" id="L3457"> }</span>
}
/**
* The Class TermvectorNumberFull.
*/
private static class TermvectorNumberFull {
/** The args. */
public long[] args;
/** The positions. */
public int[] positions;
/** The doc number. */
public int docNumber;
/**
* Instantiates a new termvector number full.
*
* @param maxSize
* the max size
*/
<span class="fc" id="L3480"> TermvectorNumberFull(int maxSize) {</span>
<span class="fc" id="L3481"> args = new long[maxSize];</span>
<span class="fc" id="L3482"> positions = new int[maxSize];</span>
<span class="fc" id="L3483"> docNumber = 0;</span>
<span class="fc" id="L3484"> }</span>
}
/**
* The Class RegisterStatus.
*/
private static class RegisterStatus {
/** The sort value. */
public long sortValue;
/** The force. */
public boolean force;
/**
* Instantiates a new register status.
*
* @param sortValue
* the sort value
* @param force
* the force
*/
<span class="fc" id="L3506"> RegisterStatus(long sortValue, boolean force) {</span>
<span class="fc" id="L3507"> this.sortValue = sortValue;</span>
<span class="fc" id="L3508"> this.force = force;</span>
<span class="fc" id="L3509"> }</span>
}
/**
* Register value.
*
* @param term
* the term
* @param termVector
* the term vector
* @param number
* the number
* @param termNumberMaximum
* the term number maximum
* @param segmentNumber
* the segment number
* @param forceAccept
* the force accept
* @param mutableKey
* the mutable key
* @return the register status
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@SuppressWarnings("unchecked")
private static RegisterStatus registerValue(BytesRef term,
ComponentTermVector termVector, TermvectorNumberBasic number,
Integer termNumberMaximum, Integer segmentNumber, boolean forceAccept,
String[] mutableKey) throws IOException {
<span class="fc" id="L3538"> long value = termVector.subComponentFunction.parserFunction</span>
<span class="fc" id="L3539"> .getValueLong(number.valueSum, 0);</span>
<span class="fc" id="L3540"> long sortValue = 0;</span>
<span class="fc" id="L3541"> if (termVector.subComponentFunction.sortType</span>
<span class="fc bfc" id="L3542" title="All 2 branches covered."> .equals(CodecUtil.STATS_TYPE_SUM)) {</span>
<span class="fc" id="L3543"> sortValue = value;</span>
<span class="fc" id="L3544"> } else if (termVector.subComponentFunction.sortType</span>
<span class="pc bpc" id="L3545" title="1 of 2 branches missed."> .equals(CodecUtil.STATS_TYPE_N)) {</span>
<span class="nc" id="L3546"> sortValue = number.docNumber;</span>
}
<span class="fc" id="L3548"> boolean addItem = false;</span>
<span class="fc" id="L3549"> boolean addItemForced = false;</span>
<span class="fc" id="L3550"> MtasDataCollector<Long, ?> dataCollector = (MtasDataCollector<Long, ?>) termVector.subComponentFunction.dataCollector;</span>
//sort on term
<span class="fc bfc" id="L3552" title="All 2 branches covered."> if (termVector.subComponentFunction.sortType.equals(CodecUtil.SORT_TERM)) {</span>
<span class="fc" id="L3553"> addItem = true;</span>
<span class="fc" id="L3554"> addItemForced = true;</span>
//sort on sum or n
<span class="fc" id="L3556"> } else if (termVector.subComponentFunction.sortType</span>
<span class="pc bpc" id="L3557" title="1 of 2 branches missed."> .equals(CodecUtil.STATS_TYPE_SUM)</span>
|| termVector.subComponentFunction.sortType
<span class="nc bnc" id="L3559" title="All 2 branches missed."> .equals(CodecUtil.STATS_TYPE_N)) {</span>
//always accept
<span class="fc bfc" id="L3561" title="All 2 branches covered."> if (forceAccept) {</span>
<span class="fc" id="L3562"> addItem = true;</span>
<span class="fc" id="L3563"> addItemForced = addItem;</span>
//check boundary
<span class="pc bpc" id="L3565" title="1 of 2 branches missed."> } else if (termVector.boundaryRegistration) {</span>
<span class="nc" id="L3566"> addItem = dataCollector.validateSegmentBoundary(sortValue);</span>
<span class="nc bnc" id="L3567" title="All 2 branches missed."> if (addItem) {</span>
<span class="nc bnc" id="L3568" title="All 2 branches missed."> if (mutableKey[0] == null) {</span>
<span class="nc" id="L3569"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
}
<span class="nc" id="L3571"> String segmentStatus = dataCollector.validateSegmentValue(</span>
<span class="nc" id="L3572"> mutableKey[0], sortValue, termNumberMaximum, segmentNumber,</span>
false);
<span class="nc bnc" id="L3574" title="All 2 branches missed."> if (segmentStatus != null) {</span>
<span class="nc bnc" id="L3575" title="All 2 branches missed."> if (segmentStatus.equals(MtasDataCollector.SEGMENT_KEY)) {</span>
<span class="nc" id="L3576"> addItemForced = true;</span>
}
} else {
// shouldn't happen
}
<span class="nc" id="L3581"> }</span>
//no boundary
} else {
<span class="fc" id="L3584"> String segmentStatus = dataCollector.validateSegmentValue(sortValue,</span>
<span class="fc" id="L3585"> termNumberMaximum, segmentNumber);</span>
<span class="fc bfc" id="L3586" title="All 2 branches covered."> if (segmentStatus != null) {</span>
boolean possibleAddItem;
<span class="fc bfc" id="L3588" title="All 2 branches covered."> if (segmentStatus.equals(MtasDataCollector.SEGMENT_KEY_OR_NEW)) {</span>
<span class="fc" id="L3589"> possibleAddItem = true;</span>
<span class="fc" id="L3590"> } else if (segmentStatus</span>
<span class="pc bpc" id="L3591" title="1 of 2 branches missed."> .equals(MtasDataCollector.SEGMENT_POSSIBLE_KEY)) {</span>
<span class="fc" id="L3592"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
<span class="fc" id="L3593"> segmentStatus = dataCollector.validateSegmentValue(mutableKey[0],</span>
<span class="fc" id="L3594"> sortValue, termNumberMaximum, segmentNumber, true);</span>
<span class="fc bfc" id="L3595" title="All 2 branches covered."> if (segmentStatus != null) {</span>
<span class="fc" id="L3596"> possibleAddItem = true;</span>
} else {
<span class="fc" id="L3598"> possibleAddItem = false;</span>
}
} else {
// should never happen?
<span class="nc" id="L3602"> possibleAddItem = false;</span>
}
//further checks, passed initial
<span class="fc bfc" id="L3605" title="All 2 branches covered."> if (possibleAddItem) {</span>
<span class="fc bfc" id="L3606" title="All 2 branches covered."> if (mutableKey[0] == null) {</span>
<span class="fc" id="L3607"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
}
<span class="fc" id="L3609"> segmentStatus = dataCollector.validateSegmentValue(mutableKey[0],</span>
<span class="fc" id="L3610"> sortValue, termNumberMaximum, segmentNumber, false);</span>
<span class="pc bpc" id="L3611" title="1 of 2 branches missed."> if (segmentStatus != null) {</span>
<span class="fc" id="L3612"> addItem = true;</span>
<span class="fc bfc" id="L3613" title="All 2 branches covered."> if (segmentStatus.equals(MtasDataCollector.SEGMENT_KEY)) {</span>
<span class="fc" id="L3614"> addItemForced = true;</span>
}
}
}
<span class="fc" id="L3618"> } else {</span>
<span class="fc" id="L3619"> addItem = false;</span>
}
<span class="fc" id="L3621"> }</span>
//don't sort?
} else {
<span class="nc" id="L3624"> addItem = false;</span>
}
<span class="fc bfc" id="L3626" title="All 2 branches covered."> if (addItem) {</span>
<span class="fc" id="L3627"> boolean computeFull = false;</span>
<span class="fc bfc" id="L3628" title="All 2 branches covered."> if (mutableKey[0] == null) {</span>
<span class="fc" id="L3629"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
}
//check dataCollector type
<span class="fc" id="L3632"> if (termVector.subComponentFunction.statsType</span>
<span class="fc bfc" id="L3633" title="All 2 branches covered."> .equals(CodecUtil.STATS_BASIC)) {</span>
<span class="fc" id="L3634"> dataCollector.add(mutableKey[0], value, number.docNumber);</span>
} else {
<span class="fc" id="L3636"> computeFull = true;</span>
}
//functions
<span class="pc bpc" id="L3639" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3640" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc bnc" id="L3641" title="All 2 branches missed."> if (function.parserFunction.sumRule()</span>
<span class="nc bnc" id="L3642" title="All 2 branches missed."> && !function.parserFunction.needPositions()</span>
<span class="nc bnc" id="L3643" title="All 2 branches missed."> && function.statsType.equals(CodecUtil.STATS_BASIC)) {</span>
<span class="nc bnc" id="L3644" title="All 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L3645"> long valueFunction = function.parserFunction</span>
<span class="nc" id="L3646"> .getValueLong(number.valueSum, 0);</span>
<span class="nc" id="L3647"> function.dataCollector.add(mutableKey[0], valueFunction,</span>
number.docNumber);
<span class="nc bnc" id="L3649" title="All 2 branches missed."> } else if (function.dataType.equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L3650"> double valueFunction = function.parserFunction</span>
<span class="nc" id="L3651"> .getValueDouble(number.valueSum, 0);</span>
<span class="nc" id="L3652"> function.dataCollector.add(mutableKey[0], valueFunction,</span>
number.docNumber);
<span class="nc" id="L3654"> }</span>
} else {
<span class="nc" id="L3656"> computeFull = true;</span>
}
<span class="nc" id="L3658"> }</span>
}
//add as full?
<span class="fc bfc" id="L3661" title="All 2 branches covered."> return computeFull ? new RegisterStatus(sortValue, addItemForced) : null;</span>
} else {
<span class="fc" id="L3663"> return null;</span>
}
}
/**
* Preliminary register value.
*
* @param term
* the term
* @param termVector
* the term vector
* @param number
* the number
* @param termNumberMaximum
* the term number maximum
* @param segmentNumber
* the segment number
* @param mutableKey
* the mutable key
* @return true, if successful
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static boolean preliminaryRegisterValue(BytesRef term,
ComponentTermVector termVector, TermvectorNumberBasic number,
Integer termNumberMaximum, Integer segmentNumber, String[] mutableKey)
throws IOException {
<span class="nc" id="L3690"> long sortValue = 0;</span>
<span class="nc" id="L3691"> if (termVector.subComponentFunction.sortDirection</span>
<span class="nc bnc" id="L3692" title="All 2 branches missed."> .equals(CodecUtil.SORT_DESC)</span>
&& termVector.subComponentFunction.sortType
<span class="nc bnc" id="L3694" title="All 2 branches missed."> .equals(CodecUtil.STATS_TYPE_SUM)) {</span>
<span class="nc" id="L3695"> sortValue = termVector.subComponentFunction.parserFunction</span>
<span class="nc" id="L3696"> .getValueLong(number.valueSum, 0);</span>
<span class="nc" id="L3697"> } else if (termVector.subComponentFunction.sortDirection</span>
<span class="nc bnc" id="L3698" title="All 2 branches missed."> .equals(CodecUtil.SORT_DESC)</span>
&& termVector.subComponentFunction.sortType
<span class="nc bnc" id="L3700" title="All 2 branches missed."> .equals(CodecUtil.STATS_TYPE_N)) {</span>
<span class="nc" id="L3701"> sortValue = number.docNumber;</span>
} else {
<span class="nc" id="L3703"> return true;</span>
}
<span class="nc" id="L3705"> MtasDataCollector<Long, ?> dataCollector = (MtasDataCollector<Long, ?>) termVector.subComponentFunction.dataCollector;</span>
<span class="nc bnc" id="L3706" title="All 2 branches missed."> if (termVector.boundaryRegistration) {</span>
<span class="nc" id="L3707"> return dataCollector.validateSegmentBoundary(sortValue);</span>
} else {
<span class="nc" id="L3709"> String segmentStatus = dataCollector.validateSegmentValue(sortValue,</span>
<span class="nc" id="L3710"> termNumberMaximum, segmentNumber);</span>
<span class="nc bnc" id="L3711" title="All 2 branches missed."> if (segmentStatus != null) {</span>
<span class="nc bnc" id="L3712" title="All 2 branches missed."> if (segmentStatus.equals(MtasDataCollector.SEGMENT_KEY_OR_NEW)) {</span>
<span class="nc" id="L3713"> return true;</span>
<span class="nc" id="L3714"> } else if (segmentStatus</span>
<span class="nc bnc" id="L3715" title="All 2 branches missed."> .equals(MtasDataCollector.SEGMENT_POSSIBLE_KEY)) {</span>
<span class="nc" id="L3716"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
<span class="nc" id="L3717"> segmentStatus = dataCollector.validateSegmentValue(mutableKey[0],</span>
<span class="nc" id="L3718"> sortValue, termNumberMaximum, segmentNumber, true);</span>
<span class="nc bnc" id="L3719" title="All 2 branches missed."> return segmentStatus != null;</span>
} else {
// should never happen?
<span class="nc" id="L3722"> return false;</span>
}
} else {
<span class="nc" id="L3725"> return false;</span>
}
}
}
/**
* Register value.
*
* @param term
* the term
* @param termVector
* the term vector
* @param number
* the number
* @param mutableKey
* the mutable key
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@SuppressWarnings("unchecked")
private static void registerValue(BytesRef term,
ComponentTermVector termVector, TermvectorNumberFull number,
String[] mutableKey) throws IOException {
<span class="pc bpc" id="L3748" title="1 of 2 branches missed."> if (number.docNumber > 0) {</span>
<span class="fc bfc" id="L3749" title="All 2 branches covered."> if (mutableKey[0] == null) {</span>
<span class="fc" id="L3750"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
}
<span class="fc" id="L3752"> MtasDataCollector<Long, ?> dataCollector = (MtasDataCollector<Long, ?>) termVector.subComponentFunction.dataCollector;</span>
<span class="fc" id="L3753"> long[] valuesLong = new long[number.docNumber];</span>
<span class="fc bfc" id="L3754" title="All 2 branches covered."> for (int i = 0; i < number.docNumber; i++) {</span>
try {
<span class="fc" id="L3756"> valuesLong[i] = termVector.subComponentFunction.parserFunction</span>
<span class="fc" id="L3757"> .getValueLong(new long[] { number.args[i] }, number.positions[i]);</span>
<span class="nc" id="L3758"> } catch (IOException e) {</span>
<span class="nc" id="L3759"> log.debug(e);</span>
<span class="nc" id="L3760"> dataCollector.error(mutableKey[0], e.getMessage());</span>
<span class="fc" id="L3761"> }</span>
}
<span class="fc" id="L3763"> if (!termVector.subComponentFunction.statsType</span>
<span class="pc bpc" id="L3764" title="1 of 2 branches missed."> .equals(CodecUtil.STATS_BASIC)) {</span>
<span class="fc" id="L3765"> dataCollector.add(mutableKey[0], valuesLong, valuesLong.length);</span>
}
<span class="pc bpc" id="L3767" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc bnc" id="L3768" title="All 2 branches missed."> if (!function.parserFunction.sumRule()</span>
<span class="nc bnc" id="L3769" title="All 2 branches missed."> || function.parserFunction.needPositions()</span>
<span class="nc bnc" id="L3770" title="All 2 branches missed."> || !function.statsType.equals(CodecUtil.STATS_BASIC)) {</span>
<span class="nc bnc" id="L3771" title="All 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L3772"> valuesLong = new long[number.docNumber];</span>
<span class="nc bnc" id="L3773" title="All 2 branches missed."> for (int i = 0; i < number.docNumber; i++) {</span>
try {
<span class="nc" id="L3775"> valuesLong[i] = function.parserFunction.getValueLong(</span>
new long[] { number.args[i] }, number.positions[i]);
<span class="nc" id="L3777"> } catch (IOException e) {</span>
<span class="nc" id="L3778"> log.debug(e);</span>
<span class="nc" id="L3779"> function.dataCollector.error(mutableKey[0], e.getMessage());</span>
<span class="nc" id="L3780"> }</span>
}
<span class="nc" id="L3782"> function.dataCollector.add(mutableKey[0], valuesLong,</span>
valuesLong.length);
<span class="nc bnc" id="L3784" title="All 2 branches missed."> } else if (function.dataType.equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L3785"> double[] valuesDouble = new double[number.docNumber];</span>
<span class="nc bnc" id="L3786" title="All 2 branches missed."> for (int i = 0; i < number.docNumber; i++) {</span>
try {
<span class="nc" id="L3788"> valuesDouble[i] = function.parserFunction.getValueDouble(</span>
new long[] { number.args[i] }, number.positions[i]);
<span class="nc" id="L3790"> } catch (IOException e) {</span>
<span class="nc" id="L3791"> log.debug(e);</span>
<span class="nc" id="L3792"> function.dataCollector.error(mutableKey[0], e.getMessage());</span>
<span class="nc" id="L3793"> }</span>
}
<span class="nc" id="L3795"> function.dataCollector.add(mutableKey[0], valuesDouble,</span>
valuesDouble.length);
}
}
<span class="nc" id="L3799"> }</span>
}
<span class="fc" id="L3801"> }</span>
/**
* Compute termvector number basic.
*
* @param termsEnum
* the terms enum
* @param r
* the r
* @return the termvector number basic
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static TermvectorNumberBasic computeTermvectorNumberBasic(
TermsEnum termsEnum, LeafReader r) throws IOException {
<span class="fc" id="L3816"> TermvectorNumberBasic result = new TermvectorNumberBasic();</span>
<span class="pc bpc" id="L3817" title="1 of 2 branches missed."> boolean hasDeletedDocuments = (r.getLiveDocs() != null);</span>
<span class="pc bpc" id="L3818" title="1 of 2 branches missed."> if (!hasDeletedDocuments) {</span>
<span class="fc" id="L3819"> result.valueSum[0] = termsEnum.totalTermFreq();</span>
<span class="fc" id="L3820"> result.docNumber = termsEnum.docFreq();</span>
<span class="pc bpc" id="L3821" title="1 of 2 branches missed."> if (result.valueSum[0] > -1) {</span>
<span class="fc" id="L3822"> return result;</span>
}
}
<span class="nc" id="L3825"> throw new IOException("should not call this");</span>
}
/**
* Compute termvector number basic.
*
* @param docSet
* the doc set
* @param termDocId
* the term doc id
* @param termsEnum
* the terms enum
* @param r
* the r
* @param lrc
* the lrc
* @param postingsEnum
* the postings enum
* @return the termvector number basic
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static TermvectorNumberBasic computeTermvectorNumberBasic(
List<Integer> docSet, int termDocId, TermsEnum termsEnum, LeafReader r,
LeafReaderContext lrc, PostingsEnum postingsEnum) throws IOException {
<span class="fc" id="L3850"> TermvectorNumberBasic result = new TermvectorNumberBasic();</span>
<span class="fc bfc" id="L3851" title="All 2 branches covered."> boolean hasDeletedDocuments = (r.getLiveDocs() != null);</span>
<span class="pc bpc" id="L3852" title="1 of 4 branches missed."> if ((docSet.size() == r.numDocs()) && !hasDeletedDocuments) {</span>
try {
<span class="fc" id="L3854"> return computeTermvectorNumberBasic(termsEnum, r);</span>
<span class="nc" id="L3855"> } catch (IOException e) {</span>
<span class="nc" id="L3856"> log.debug("problem", e);</span>
// problem
}
}
<span class="fc" id="L3860"> result.docNumber = 0;</span>
<span class="fc" id="L3861"> result.valueSum[0] = 0;</span>
<span class="fc" id="L3862"> int localTermDocId = termDocId;</span>
<span class="fc" id="L3863"> Iterator<Integer> docIterator = docSet.iterator();</span>
<span class="fc" id="L3864"> postingsEnum = termsEnum.postings(postingsEnum, PostingsEnum.FREQS);</span>
int docId;
<span class="fc bfc" id="L3866" title="All 2 branches covered."> while (docIterator.hasNext()) {</span>
<span class="fc" id="L3867"> docId = docIterator.next() - lrc.docBase;</span>
<span class="pc bpc" id="L3868" title="2 of 4 branches missed."> if (docId >= localTermDocId && ((docId == localTermDocId)</span>
<span class="fc bfc" id="L3869" title="All 2 branches covered."> || ((localTermDocId = postingsEnum.advance(docId)) == docId))) {</span>
<span class="fc" id="L3870"> result.docNumber++;</span>
<span class="fc" id="L3871"> result.valueSum[0] += postingsEnum.freq();</span>
}
<span class="pc bpc" id="L3873" title="1 of 2 branches missed."> if (localTermDocId == DocIdSetIterator.NO_MORE_DOCS) {</span>
<span class="nc" id="L3874"> break;</span>
}
}
<span class="fc" id="L3877"> return result;</span>
}
/**
* Compute termvector number full.
*
* @param docSet
* the doc set
* @param termDocId
* the term doc id
* @param termsEnum
* the terms enum
* @param lrc
* the lrc
* @param postingsEnum
* the postings enum
* @param positionsData
* the positions data
* @return the termvector number full
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private static TermvectorNumberFull computeTermvectorNumberFull(
List<Integer> docSet, int termDocId, TermsEnum termsEnum,
LeafReaderContext lrc, PostingsEnum postingsEnum,
Map<Integer, Integer> positionsData) throws IOException {
<span class="fc" id="L3903"> TermvectorNumberFull result = new TermvectorNumberFull(docSet.size());</span>
<span class="fc" id="L3904"> Iterator<Integer> docIterator = docSet.iterator();</span>
<span class="fc" id="L3905"> int localTermDocId = termDocId;</span>
<span class="fc" id="L3906"> postingsEnum = termsEnum.postings(postingsEnum, PostingsEnum.FREQS);</span>
<span class="fc bfc" id="L3907" title="All 2 branches covered."> while (docIterator.hasNext()) {</span>
<span class="fc" id="L3908"> int docId = docIterator.next() - lrc.docBase;</span>
<span class="fc bfc" id="L3909" title="All 4 branches covered."> if (docId >= localTermDocId && ((docId == localTermDocId)</span>
<span class="fc bfc" id="L3910" title="All 2 branches covered."> || ((localTermDocId = postingsEnum.advance(docId)) == docId))) {</span>
<span class="fc" id="L3911"> result.args[result.docNumber] = postingsEnum.freq();</span>
<span class="pc bpc" id="L3912" title="1 of 2 branches missed."> result.positions[result.docNumber] = (positionsData == null) ? 0</span>
<span class="pc" id="L3913"> : positionsData.get(docId + lrc.docBase);</span>
<span class="fc" id="L3914"> result.docNumber++;</span>
}
<span class="fc" id="L3916"> }</span>
<span class="fc" id="L3917"> return result;</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>