CodecCollector.java.html
246 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
<?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.ComponentCollection;
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.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="L86"> private static final Log log = LogFactory.getLog(CodecCollector.class);</span>
/**
* Instantiates a new codec collector.
*/
<span class="nc" id="L91"> private CodecCollector() {</span>
// don't do anything
<span class="nc" id="L93"> }</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="L118"> Map<Integer, List<Integer>> docSets = new HashMap<>();</span>
<span class="fc" id="L120"> ListIterator<LeafReaderContext> iterator = reader.leaves().listIterator();</span>
<span class="fc bfc" id="L121" title="All 2 branches covered."> while (iterator.hasNext()) {</span>
<span class="fc" id="L122"> LeafReaderContext lrc = iterator.next();</span>
<span class="fc" id="L123"> LeafReader r = lrc.reader();</span>
// compute relevant docSet/docList
<span class="fc" id="L126"> List<Integer> docSet = null;</span>
<span class="fc" id="L127"> List<Integer> docList = null;</span>
<span class="fc bfc" id="L128" title="All 2 branches covered."> if (fullDocSet != null) {</span>
<span class="fc" id="L129"> docSet = new ArrayList<>();</span>
<span class="fc" id="L130"> docSets.put(lrc.ord, docSet);</span>
<span class="fc" id="L131"> Iterator<Integer> docSetIterator = fullDocSet.iterator();</span>
<span class="fc" id="L132"> Integer docSetId = null;</span>
<span class="fc" id="L133"> Bits liveDocs = lrc.reader().getLiveDocs();</span>
<span class="fc bfc" id="L134" title="All 2 branches covered."> while (docSetIterator.hasNext()) {</span>
<span class="fc" id="L135"> docSetId = docSetIterator.next();</span>
// just to make sure to ignore deleted documents
<span class="fc bfc" id="L137" title="All 2 branches covered."> if ((docSetId >= lrc.docBase)</span>
<span class="fc bfc" id="L138" title="All 4 branches covered."> && (docSetId < lrc.docBase + lrc.reader().maxDoc())</span>
<span class="pc bpc" id="L139" title="1 of 2 branches missed."> && (liveDocs == null || liveDocs.get((docSetId - lrc.docBase)))) {</span>
<span class="fc" id="L140"> docSet.add(docSetId);</span>
}
}
<span class="fc" id="L143"> Collections.sort(docSet);</span>
}
<span class="pc bpc" id="L145" title="1 of 2 branches missed."> if (fullDocList != null) {</span>
<span class="fc" id="L146"> docList = new ArrayList<>();</span>
<span class="fc" id="L147"> Iterator<Integer> docListIterator = fullDocList.iterator();</span>
<span class="fc" id="L148"> Integer docListId = null;</span>
<span class="fc bfc" id="L149" title="All 2 branches covered."> while (docListIterator.hasNext()) {</span>
<span class="fc" id="L150"> docListId = docListIterator.next();</span>
<span class="fc bfc" id="L151" title="All 2 branches covered."> if ((docListId >= lrc.docBase)</span>
<span class="fc bfc" id="L152" title="All 2 branches covered."> && (docListId < lrc.docBase + lrc.reader().maxDoc())) {</span>
<span class="fc" id="L153"> docList.add(docListId);</span>
}
}
<span class="fc" id="L156"> Collections.sort(docList);</span>
}
<span class="fc" id="L159"> Terms t = rawReader.leaves().get(lrc.ord).reader().terms(field);</span>
<span class="pc bpc" id="L160" title="1 of 2 branches missed."> CodecInfo mtasCodecInfo = t == null ? null</span>
<span class="fc" id="L161"> : CodecInfo.getCodecInfoFromTerms(t);</span>
<span class="fc" id="L163"> collectSpansPositionsAndTokens(spansQueryWeight, searcher, mtasCodecInfo,</span>
r, lrc, field, t, docSet, docList, fieldInfo,
<span class="fc" id="L165"> rawReader.leaves().get(lrc.ord).reader().getFieldInfos());</span>
<span class="fc" id="L166"> collectPrefixes(rawReader.leaves().get(lrc.ord).reader().getFieldInfos(),</span>
field, fieldInfo);
<span class="fc" id="L168"> }</span>
// check termvectors
<span class="fc bfc" id="L171" title="All 2 branches covered."> if (!fieldInfo.termVectorList.isEmpty()</span>
<span class="fc bfc" id="L172" title="All 2 branches covered."> && needSecondRoundTermvector(fieldInfo.termVectorList)) {</span>
// check positions
<span class="fc" id="L174"> boolean needPositions = false;</span>
<span class="pc bpc" id="L175" title="1 of 2 branches missed."> if (!fieldInfo.termVectorList.isEmpty()) {</span>
<span class="fc bfc" id="L176" title="All 2 branches covered."> for (ComponentTermVector ctv : fieldInfo.termVectorList) {</span>
<span class="pc bpc" id="L177" title="1 of 2 branches missed."> if (!needPositions) {</span>
<span class="pc bpc" id="L178" title="1 of 2 branches missed."> needPositions = ctv.functions != null ? ctv.functionNeedPositions()</span>
: needPositions;
}
<span class="fc" id="L181"> }</span>
}
<span class="fc" id="L183"> Map<Integer, Integer> positionsData = null;</span>
// loop
<span class="fc" id="L186"> iterator = reader.leaves().listIterator();</span>
<span class="fc bfc" id="L187" title="All 2 branches covered."> while (iterator.hasNext()) {</span>
<span class="fc" id="L188"> LeafReaderContext lrc = iterator.next();</span>
<span class="fc" id="L189"> LeafReader r = lrc.reader();</span>
<span class="fc" id="L190"> List<Integer> docSet = docSets.get(lrc.ord);</span>
<span class="fc" id="L191"> Terms t = rawReader.leaves().get(lrc.ord).reader().terms(field);</span>
<span class="pc bpc" id="L192" title="1 of 2 branches missed."> if (needPositions) {</span>
<span class="nc bnc" id="L193" title="All 2 branches missed."> CodecInfo mtasCodecInfo = t == null ? null</span>
<span class="nc" id="L194"> : CodecInfo.getCodecInfoFromTerms(t);</span>
<span class="nc" id="L195"> positionsData = computePositions(mtasCodecInfo, r, lrc, field,</span>
docSet);
}
<span class="fc" id="L198"> createTermvectorSecondRound(fieldInfo.termVectorList, positionsData,</span>
<span class="fc" id="L199"> docSets.get(lrc.ord), t, r, lrc);</span>
<span class="fc" id="L200"> }</span>
}
<span class="fc" id="L202"> }</span>
/**
* Collect collection.
*
* @param reader the reader
* @param docSet the doc set
* @param collectionInfo the collection info
* @throws IOException Signals that an I/O exception has occurred.
*/
public static void collectCollection(IndexReader reader, List<Integer> docSet,
ComponentCollection collectionInfo) throws IOException {
<span class="fc bfc" id="L214" title="All 2 branches covered."> if (collectionInfo.action().equals(ComponentCollection.ACTION_CHECK)) {</span>
// can't do anything in lucene for check
<span class="fc" id="L216"> } else if (collectionInfo.action()</span>
<span class="fc bfc" id="L217" title="All 2 branches covered."> .equals(ComponentCollection.ACTION_LIST)) {</span>
// can't do anything in lucene for list
<span class="fc" id="L219"> } else if (collectionInfo.action()</span>
<span class="fc bfc" id="L220" title="All 2 branches covered."> .equals(ComponentCollection.ACTION_CREATE)) {</span>
<span class="fc" id="L221"> BytesRef term = null;</span>
<span class="fc" id="L222"> PostingsEnum postingsEnum = null;</span>
Integer docId;
<span class="fc" id="L224"> Integer termDocId = -1;</span>
Terms terms;
LeafReaderContext lrc;
LeafReader r;
<span class="fc" id="L228"> ListIterator<LeafReaderContext> iterator = reader.leaves().listIterator();</span>
<span class="fc bfc" id="L229" title="All 2 branches covered."> while (iterator.hasNext()) {</span>
<span class="fc" id="L230"> lrc = iterator.next();</span>
<span class="fc" id="L231"> r = lrc.reader();</span>
<span class="fc bfc" id="L232" title="All 2 branches covered."> for (String field : collectionInfo.fields()) {</span>
<span class="pc bpc" id="L233" title="1 of 2 branches missed."> if ((terms = r.terms(field)) != null) {</span>
<span class="fc" id="L234"> TermsEnum termsEnum = terms.iterator();</span>
<span class="fc bfc" id="L235" title="All 2 branches covered."> while ((term = termsEnum.next()) != null) {</span>
<span class="fc" id="L236"> Iterator<Integer> docIterator = docSet.iterator();</span>
<span class="fc" id="L237"> postingsEnum = termsEnum.postings(postingsEnum,</span>
PostingsEnum.NONE);
<span class="fc" id="L239"> termDocId = -1;</span>
<span class="pc bpc" id="L240" title="1 of 2 branches missed."> while (docIterator.hasNext()) {</span>
<span class="fc" id="L241"> docId = docIterator.next() - lrc.docBase;</span>
<span class="fc bfc" id="L242" title="All 4 branches covered."> if ((docId >= termDocId) && ((docId.equals(termDocId))</span>
<span class="fc" id="L243"> || ((termDocId = postingsEnum.advance(docId))</span>
<span class="fc bfc" id="L244" title="All 2 branches covered."> .equals(docId)))) {</span>
<span class="fc" id="L245"> collectionInfo.addValue(term.utf8ToString());</span>
<span class="fc" id="L246"> break;</span>
}
<span class="pc bpc" id="L248" title="1 of 2 branches missed."> if (termDocId.equals(PostingsEnum.NO_MORE_DOCS)) {</span>
<span class="nc" id="L249"> break;</span>
}
}
<span class="fc" id="L252"> }</span>
}
<span class="fc" id="L254"> }</span>
}
}
<span class="fc" id="L257"> }</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="L281"> boolean needSpans = false;</span>
<span class="fc" id="L282"> boolean needPositions = false;</span>
<span class="fc" id="L283"> boolean needTokens = false;</span>
// results
<span class="fc" id="L286"> Map<Integer, Integer> positionsData = null;</span>
<span class="fc" id="L287"> Map<Integer, Integer> tokensData = null;</span>
<span class="fc" id="L288"> Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData = null;</span>
<span class="fc" id="L289"> Map<MtasSpanQuery, Map<Integer, List<Match>>> spansMatchData = null;</span>
<span class="fc" id="L290"> Map<String, SortedMap<String, int[]>> facetData = null;</span>
<span class="fc" id="L291"> Map<String, String> facetDataType = null;</span>
// collect position stats
<span class="fc bfc" id="L294" title="All 2 branches covered."> if (!fieldInfo.statsPositionList.isEmpty()) {</span>
<span class="fc" id="L295"> needPositions = true;</span>
}
// collect token stats
<span class="fc bfc" id="L298" title="All 2 branches covered."> if (!fieldInfo.statsTokenList.isEmpty()) {</span>
<span class="fc" id="L299"> needTokens = true;</span>
}
<span class="fc bfc" id="L301" title="All 2 branches covered."> if (!fieldInfo.termVectorList.isEmpty()) {</span>
<span class="fc bfc" id="L302" title="All 2 branches covered."> for (ComponentTermVector ctv : fieldInfo.termVectorList) {</span>
<span class="fc bfc" id="L303" title="All 2 branches covered."> if (!needPositions) {</span>
<span class="pc bpc" id="L304" title="1 of 2 branches missed."> needPositions = (ctv.functions == null</span>
<span class="pc" id="L305"> ? ctv.subComponentFunction.parserFunction.needPositions()</span>
<span class="fc" id="L306"> : ctv.functionNeedPositions());</span>
}
<span class="fc" id="L308"> }</span>
}
// compute from spans for selected docs
<span class="fc bfc" id="L312" title="All 2 branches covered."> if (!fieldInfo.spanQueryList.isEmpty()) {</span>
// check for statsSpans
<span class="fc" id="L314"> spansNumberData = new HashMap<>();</span>
<span class="fc" id="L315"> spansMatchData = new HashMap<>();</span>
<span class="fc" id="L316"> facetData = new HashMap<>();</span>
<span class="fc" id="L317"> facetDataType = new HashMap<>();</span>
// spans
<span class="fc bfc" id="L319" title="All 2 branches covered."> if (!fieldInfo.statsSpanList.isEmpty()) {</span>
<span class="fc bfc" id="L320" title="All 2 branches covered."> for (ComponentSpan cs : fieldInfo.statsSpanList) {</span>
<span class="fc bfc" id="L321" title="All 2 branches covered."> needPositions = (!needPositions) ? cs.parser.needPositions()</span>
: needPositions;
<span class="fc bfc" id="L323" title="All 2 branches covered."> needPositions = (!needPositions) ? cs.functionNeedPositions()</span>
: needPositions;
<span class="pc bpc" id="L325" title="1 of 4 branches missed."> needSpans = (!needSpans) ? cs.parser.needArgumentsNumber() > 0</span>
: needSpans;
<span class="fc" id="L327"> HashSet<Integer> arguments = cs.parser.needArgument();</span>
<span class="fc" id="L328"> arguments.addAll(cs.functionNeedArguments());</span>
<span class="fc bfc" id="L329" title="All 2 branches covered."> for (int a : arguments) {</span>
<span class="pc bpc" id="L330" title="1 of 2 branches missed."> if (cs.queries.length > a) {</span>
<span class="fc" id="L331"> MtasSpanQuery q = cs.queries[a];</span>
<span class="fc bfc" id="L332" title="All 2 branches covered."> if (!spansNumberData.containsKey(q)) {</span>
<span class="fc" id="L333"> spansNumberData.put(q, new HashMap<Integer, Integer>());</span>
}
}
<span class="fc" id="L336"> }</span>
<span class="fc" id="L337"> }</span>
}
// kwic
<span class="pc bpc" id="L340" title="1 of 2 branches missed."> if (!fieldInfo.kwicList.isEmpty()) {</span>
<span class="nc" id="L341"> needSpans = true;</span>
<span class="nc bnc" id="L342" title="All 2 branches missed."> for (ComponentKwic ck : fieldInfo.kwicList) {</span>
<span class="nc bnc" id="L343" title="All 2 branches missed."> if (!spansMatchData.containsKey(ck.query)) {</span>
<span class="nc" id="L344"> spansMatchData.put(ck.query, new HashMap<Integer, List<Match>>());</span>
}
<span class="nc" id="L346"> }</span>
}
// list
<span class="pc bpc" id="L349" title="1 of 2 branches missed."> if (!fieldInfo.listList.isEmpty()) {</span>
<span class="nc" id="L350"> needSpans = true;</span>
<span class="nc bnc" id="L351" title="All 2 branches missed."> for (ComponentList cl : fieldInfo.listList) {</span>
<span class="nc bnc" id="L352" title="All 2 branches missed."> if (!spansMatchData.containsKey(cl.spanQuery)) {</span>
<span class="nc bnc" id="L353" title="All 2 branches missed."> if (cl.number > 0) {</span>
// only if needed
<span class="nc bnc" id="L355" title="All 2 branches missed."> if (cl.position < (cl.start + cl.number)) {</span>
<span class="nc" id="L356"> spansMatchData.put(cl.spanQuery,</span>
new HashMap<Integer, List<Match>>());
} else {
<span class="nc" id="L359"> spansNumberData.put(cl.spanQuery,</span>
new HashMap<Integer, Integer>());
}
<span class="nc bnc" id="L362" title="All 2 branches missed."> } else if (!spansNumberData.containsKey(cl.spanQuery)) {</span>
<span class="nc" id="L363"> spansNumberData.put(cl.spanQuery,</span>
new HashMap<Integer, Integer>());
}
}
<span class="nc" id="L367"> }</span>
}
// group
<span class="fc bfc" id="L370" title="All 2 branches covered."> if (!fieldInfo.groupList.isEmpty()) {</span>
<span class="fc" id="L371"> needSpans = true;</span>
<span class="fc bfc" id="L372" title="All 2 branches covered."> for (ComponentGroup cg : fieldInfo.groupList) {</span>
<span class="pc bpc" id="L373" title="1 of 2 branches missed."> if (!spansMatchData.containsKey(cg.spanQuery)) {</span>
<span class="fc" id="L374"> spansMatchData.put(cg.spanQuery,</span>
new HashMap<Integer, List<Match>>());
}
<span class="fc" id="L377"> }</span>
}
// facet
<span class="pc bpc" id="L380" title="1 of 2 branches missed."> if (!fieldInfo.facetList.isEmpty()) {</span>
<span class="nc bnc" id="L381" title="All 2 branches missed."> for (ComponentFacet cf : fieldInfo.facetList) {</span>
<span class="nc bnc" id="L382" title="All 2 branches missed."> needPositions = !needPositions ? cf.baseParserNeedPositions()</span>
: needPositions;
<span class="nc bnc" id="L384" title="All 2 branches missed."> needPositions = !needPositions ? cf.functionNeedPositions()</span>
: needPositions;
<span class="nc bnc" id="L386" title="All 2 branches missed."> for (int i = 0; i < cf.baseFields.length; i++) {</span>
<span class="nc bnc" id="L387" title="All 4 branches missed."> needSpans = !needSpans ? cf.baseParsers[i].needArgumentsNumber() > 0</span>
: needSpans;
<span class="nc" id="L389"> HashSet<Integer> arguments = cf.baseParsers[i].needArgument();</span>
<span class="nc bnc" id="L390" title="All 2 branches missed."> for (int a : arguments) {</span>
<span class="nc bnc" id="L391" title="All 2 branches missed."> if (cf.spanQueries.length > a) {</span>
<span class="nc" id="L392"> MtasSpanQuery q = cf.spanQueries[a];</span>
<span class="nc bnc" id="L393" title="All 2 branches missed."> if (!spansNumberData.containsKey(q)) {</span>
<span class="nc" id="L394"> spansNumberData.put(q, new HashMap<Integer, Integer>());</span>
}
}
<span class="nc" id="L397"> }</span>
<span class="nc bnc" id="L398" title="All 2 branches missed."> for (MtasFunctionParserFunction function : cf.baseFunctionParserFunctions[i]) {</span>
<span class="nc bnc" id="L399" title="All 4 branches missed."> needSpans = !needSpans ? function.needArgumentsNumber() > 0</span>
: needSpans;
<span class="nc" id="L401"> arguments = function.needArgument();</span>
<span class="nc bnc" id="L402" title="All 2 branches missed."> for (int a : arguments) {</span>
<span class="nc bnc" id="L403" title="All 2 branches missed."> if (cf.spanQueries.length > a) {</span>
<span class="nc" id="L404"> MtasSpanQuery q = cf.spanQueries[a];</span>
<span class="nc bnc" id="L405" title="All 2 branches missed."> if (!spansNumberData.containsKey(q)) {</span>
<span class="nc" id="L406"> spansNumberData.put(q, new HashMap<Integer, Integer>());</span>
}
}
<span class="nc" id="L409"> }</span>
}
<span class="nc bnc" id="L411" title="All 2 branches missed."> if (!facetData.containsKey(cf.baseFields[i])) {</span>
<span class="nc" id="L412"> facetData.put(cf.baseFields[i], new TreeMap<String, int[]>());</span>
<span class="nc" id="L413"> facetDataType.put(cf.baseFields[i], cf.baseFieldTypes[i]);</span>
}
}
<span class="nc" id="L416"> }</span>
}
// termvector
<span class="pc bpc" id="L419" title="1 of 2 branches missed."> if (!fieldInfo.termVectorList.isEmpty()) {</span>
<span class="nc bnc" id="L420" title="All 2 branches missed."> for (ComponentTermVector ctv : fieldInfo.termVectorList) {</span>
<span class="nc bnc" id="L421" title="All 2 branches missed."> if ((ctv.subComponentFunction.parserFunction != null</span>
<span class="nc bnc" id="L422" title="All 4 branches missed."> && ctv.subComponentFunction.parserFunction.needPositions())</span>
<span class="nc bnc" id="L423" title="All 2 branches missed."> || (ctv.functions != null && ctv.functionNeedPositions())) {</span>
<span class="nc" id="L424"> needPositions = true;</span>
}
<span class="nc" id="L426"> }</span>
}
}
<span class="fc bfc" id="L430" 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="L435" title="1 of 2 branches missed."> for (Entry<String, SortedMap<String, int[]>> entry : facetData</span>
<span class="fc" id="L436"> .entrySet()) {</span>
<span class="nc bnc" id="L437" title="All 4 branches missed."> if(!facetDataType.containsKey(entry.getKey()) || !facetDataType.get(entry.getKey()).equals(ComponentFacet.TYPE_STRING)) {</span>
<span class="nc" id="L438"> throw new IOException("unexpected type");</span>
}
<span class="nc" id="L440"> Terms fft = r.terms(entry.getKey());</span>
<span class="nc bnc" id="L441" title="All 2 branches missed."> if (fft != null) {</span>
<span class="nc" id="L442"> TermsEnum termsEnum = fft.iterator();</span>
<span class="nc" id="L443"> BytesRef term = null;</span>
<span class="nc" id="L444"> PostingsEnum postingsEnum = null;</span>
<span class="nc" id="L445"> SortedMap<String, int[]> facetDataList = entry.getValue();</span>
<span class="nc bnc" id="L446" title="All 2 branches missed."> while ((term = termsEnum.next()) != null) {</span>
int docId;
<span class="nc" id="L448"> int termDocId = -1;</span>
<span class="nc" id="L449"> int[] facetDataSublist = new int[docSet.size()];</span>
<span class="nc" id="L450"> int facetDataSublistCounter = 0;</span>
<span class="nc" id="L451"> Iterator<Integer> docIterator = docSet.iterator();</span>
<span class="nc" id="L452"> postingsEnum = termsEnum.postings(postingsEnum);</span>
<span class="nc bnc" id="L453" title="All 2 branches missed."> while (docIterator.hasNext()) {</span>
<span class="nc" id="L454"> docId = docIterator.next() - lrc.docBase;</span>
<span class="nc bnc" id="L455" title="All 4 branches missed."> if (docId >= termDocId && ((docId == termDocId)</span>
<span class="nc bnc" id="L456" title="All 2 branches missed."> || ((termDocId = postingsEnum.advance(docId)) == docId))) {</span>
<span class="nc" id="L457"> facetDataSublist[facetDataSublistCounter] = docId + lrc.docBase;</span>
<span class="nc" id="L458"> facetDataSublistCounter++;</span>
}
}
<span class="nc bnc" id="L461" title="All 2 branches missed."> if (facetDataSublistCounter > 0) { </span>
<span class="nc" id="L462"> String termValue = term.utf8ToString(); </span>
<span class="nc bnc" id="L463" title="All 2 branches missed."> if (!facetDataList.containsKey(termValue)) {</span>
<span class="nc" id="L464"> facetDataList.put(termValue,</span>
<span class="nc" id="L465"> Arrays.copyOf(facetDataSublist, facetDataSublistCounter));</span>
} else {
<span class="nc" id="L467"> int[] oldList = facetDataList.get(termValue);</span>
<span class="nc" id="L468"> int[] newList = new int[oldList.length</span>
+ facetDataSublistCounter];
<span class="nc" id="L470"> System.arraycopy(oldList, 0, newList, 0, oldList.length);</span>
<span class="nc" id="L471"> System.arraycopy(facetDataSublist, 0, newList, oldList.length,</span>
facetDataSublistCounter);
<span class="nc" id="L473"> facetDataList.put(termValue, newList);</span>
}
}
<span class="nc" id="L476"> }</span>
}
<span class="nc" id="L478"> }</span>
<span class="fc bfc" id="L480" title="All 2 branches covered."> for (MtasSpanQuery sq : fieldInfo.spanQueryList) {</span>
// what to collect
<span class="fc bfc" id="L482" title="All 2 branches covered."> if (spansNumberData.containsKey(sq)) {</span>
<span class="fc" id="L483"> numberData = spansNumberData.get(sq);</span>
} else {
<span class="fc" id="L485"> numberData = null;</span>
}
<span class="fc bfc" id="L487" title="All 2 branches covered."> if (spansMatchData.containsKey(sq)) {</span>
<span class="fc" id="L488"> matchData = spansMatchData.get(sq);</span>
} else {
<span class="fc" id="L490"> matchData = null;</span>
}
<span class="pc bpc" id="L492" title="1 of 4 branches missed."> if ((numberData != null) || (matchData != null)) {</span>
<span class="fc" id="L493"> Spans spans = spansQueryWeight.get(sq).getSpans(lrc,</span>
SpanWeight.Postings.POSITIONS);
<span class="fc bfc" id="L495" title="All 2 branches covered."> if (spans != null) {</span>
Iterator<Integer> it;
<span class="pc bpc" id="L497" title="1 of 2 branches missed."> if (docSet != null) {</span>
<span class="fc" id="L498"> it = docSet.iterator();</span>
} else {
<span class="nc" id="L500"> it = docList.iterator();</span>
}
<span class="pc bpc" id="L502" title="1 of 2 branches missed."> if (it.hasNext()) {</span>
<span class="fc" id="L503"> int docId = it.next();</span>
int number;
ArrayList<Match> matchDataList;
<span class="fc" id="L506"> Integer spansDocId = null;</span>
<span class="pc bpc" id="L507" title="1 of 2 branches missed."> while (docId != DocIdSetIterator.NO_MORE_DOCS) {</span>
<span class="fc bfc" id="L508" title="All 2 branches covered."> if (spans.advance(</span>
(docId - lrc.docBase)) == DocIdSetIterator.NO_MORE_DOCS) {
<span class="fc" id="L510"> break;</span>
}
<span class="fc" id="L512"> spansDocId = spans.docID() + lrc.docBase;</span>
<span class="pc bpc" id="L513" title="1 of 4 branches missed."> while ((docId < spansDocId) && it.hasNext()) {</span>
<span class="fc" id="L514"> docId = it.next();</span>
}
<span class="pc bpc" id="L516" title="1 of 2 branches missed."> if (docId < spansDocId) {</span>
<span class="nc" id="L517"> break;</span>
}
<span class="pc bpc" id="L519" title="1 of 2 branches missed."> if (spansDocId.equals(docId)) {</span>
<span class="fc" id="L520"> number = 0;</span>
<span class="fc" id="L521"> matchDataList = new ArrayList<>();</span>
int tmpStartPosition;
<span class="fc" id="L523"> while ((tmpStartPosition = spans</span>
<span class="fc bfc" id="L524" title="All 2 branches covered."> .nextStartPosition()) != Spans.NO_MORE_POSITIONS) {</span>
<span class="fc" id="L525"> number++;</span>
<span class="fc bfc" id="L526" title="All 2 branches covered."> if (matchData != null) {</span>
<span class="fc" id="L527"> Match m = new Match(tmpStartPosition,</span>
<span class="fc" id="L528"> spans.endPosition());</span>
<span class="fc" id="L529"> matchDataList.add(m);</span>
<span class="fc" id="L530"> }</span>
}
<span class="fc bfc" id="L532" title="All 2 branches covered."> if ((numberData != null)) {</span>
<span class="fc" id="L533"> numberData.put(spansDocId, number);</span>
}
<span class="fc bfc" id="L535" title="All 2 branches covered."> if ((matchData != null)) {</span>
<span class="fc" id="L536"> matchData.put(spansDocId, matchDataList);</span>
}
<span class="fc bfc" id="L538" title="All 2 branches covered."> if (it.hasNext()) {</span>
<span class="fc" id="L539"> docId = it.next();</span>
} else {
break;
}
<span class="fc" id="L543"> }</span>
}
}
}
}
<span class="fc" id="L548"> }</span>
}
// collect position stats
<span class="fc bfc" id="L552" title="All 2 branches covered."> if (needPositions) {</span>
<span class="pc bpc" id="L553" title="1 of 2 branches missed."> if (mtasCodecInfo != null) {</span>
// for relatively small numbers, compute only what is needed
<span class="fc bfc" id="L555" title="All 2 branches covered."> if (docSet.size() < Math.log(r.maxDoc())) {</span>
<span class="fc" id="L556"> positionsData = new HashMap<>();</span>
<span class="fc bfc" id="L557" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L558"> positionsData.put(docId, mtasCodecInfo.getNumberOfPositions(field,</span>
(docId - lrc.docBase)));
<span class="fc" id="L560"> }</span>
// compute everything, only use what is needed
} else {
<span class="fc" id="L563"> positionsData = mtasCodecInfo.getAllNumberOfPositions(field,</span>
lrc.docBase);
<span class="fc bfc" id="L565" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="pc bpc" id="L566" title="1 of 2 branches missed."> if (!positionsData.containsKey(docId)) {</span>
<span class="nc" id="L567"> positionsData.put(docId, 0);</span>
}
<span class="fc" id="L569"> }</span>
}
} else {
<span class="nc" id="L572"> positionsData = new HashMap<>();</span>
<span class="nc bnc" id="L573" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L574"> positionsData.put(docId, 0);</span>
<span class="nc" id="L575"> }</span>
}
}
// collect token stats
<span class="fc bfc" id="L580" title="All 2 branches covered."> if (needTokens) {</span>
<span class="pc bpc" id="L581" title="1 of 2 branches missed."> if (mtasCodecInfo != null) {</span>
// for relatively small numbers, compute only what is needed
<span class="fc bfc" id="L583" title="All 2 branches covered."> if (docSet.size() < Math.log(r.maxDoc())) {</span>
<span class="fc" id="L584"> tokensData = new HashMap<>();</span>
<span class="fc bfc" id="L585" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L586"> tokensData.put(docId,</span>
<span class="fc" id="L587"> mtasCodecInfo.getNumberOfTokens(field, (docId - lrc.docBase)));</span>
<span class="fc" id="L588"> }</span>
// compute everything, only use what is needed
} else {
<span class="fc" id="L591"> tokensData = mtasCodecInfo.getAllNumberOfTokens(field, lrc.docBase);</span>
<span class="fc bfc" id="L592" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="pc bpc" id="L593" title="1 of 2 branches missed."> if (!tokensData.containsKey(docId)) {</span>
<span class="nc" id="L594"> tokensData.put(docId, 0);</span>
}
<span class="fc" id="L596"> }</span>
}
} else {
<span class="nc" id="L599"> tokensData = new HashMap<>();</span>
<span class="nc bnc" id="L600" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L601"> tokensData.put(docId, 0);</span>
<span class="nc" id="L602"> }</span>
}
}
<span class="fc bfc" id="L606" title="All 2 branches covered."> if (!fieldInfo.statsPositionList.isEmpty()) {</span>
// create positions
<span class="fc" id="L608"> createPositions(fieldInfo.statsPositionList, positionsData, docSet);</span>
}
<span class="fc bfc" id="L611" title="All 2 branches covered."> if (!fieldInfo.statsTokenList.isEmpty()) {</span>
// create positions
<span class="fc" id="L613"> createTokens(fieldInfo.statsTokenList, tokensData, docSet);</span>
}
<span class="pc bpc" id="L616" title="1 of 2 branches missed."> if (!fieldInfo.documentList.isEmpty()) {</span>
// create document
<span class="nc" id="L618"> createDocument(fieldInfo.documentList, docList, fieldInfo.uniqueKeyField,</span>
searcher, t, lrc);
}
<span class="fc bfc" id="L621" title="All 2 branches covered."> if (!fieldInfo.spanQueryList.isEmpty()) {</span>
<span class="fc bfc" id="L622" title="All 2 branches covered."> if (!fieldInfo.statsSpanList.isEmpty()) {</span>
// create stats
<span class="fc" id="L624"> createStats(fieldInfo.statsSpanList, positionsData, spansNumberData,</span>
<span class="fc" id="L625"> docSet.toArray(new Integer[docSet.size()]));</span>
}
<span class="pc bpc" id="L627" title="1 of 2 branches missed."> if (!fieldInfo.listList.isEmpty()) {</span>
// create list
<span class="nc" id="L629"> createList(fieldInfo.listList, spansNumberData, spansMatchData, docSet,</span>
field, lrc.docBase, fieldInfo.uniqueKeyField, mtasCodecInfo,
searcher);
}
<span class="fc bfc" id="L633" title="All 2 branches covered."> if (!fieldInfo.groupList.isEmpty()) {</span>
// create group
<span class="fc" id="L635"> createGroup(fieldInfo.groupList, spansMatchData, docSet,</span>
<span class="fc" id="L636"> fieldInfos.fieldInfo(field), field, lrc.docBase, mtasCodecInfo,</span>
searcher, lrc);
}
<span class="pc bpc" id="L639" title="1 of 2 branches missed."> if (!fieldInfo.kwicList.isEmpty()) {</span>
// create kwic
<span class="nc" id="L641"> createKwic(fieldInfo.kwicList, spansMatchData, docList, field,</span>
lrc.docBase, fieldInfo.uniqueKeyField, mtasCodecInfo, searcher);
}
<span class="pc bpc" id="L644" title="1 of 2 branches missed."> if (!fieldInfo.facetList.isEmpty()) {</span>
// create facets
<span class="nc" id="L646"> createFacet(fieldInfo.facetList, positionsData, spansNumberData,</span>
facetData, docSet);
}
}
<span class="fc bfc" id="L650" title="All 2 branches covered."> if (!fieldInfo.termVectorList.isEmpty()) {</span>
<span class="fc" id="L651"> createTermvectorFull(fieldInfo.termVectorList, positionsData, docSet, t,</span>
r, lrc);
<span class="fc" id="L653"> createTermvectorFirstRound(fieldInfo.termVectorList, positionsData,</span>
docSet, t, r, lrc);
}
<span class="fc" id="L656"> }</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="L667" title="1 of 2 branches missed."> if (fi != null) {</span>
<span class="fc" id="L668"> HashSet<String> result = new HashSet<>();</span>
<span class="fc" id="L669"> String singlePositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SINGLE_POSITION);
<span class="fc" id="L671"> String multiplePositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_MULTIPLE_POSITION);
<span class="fc" id="L673"> String setPositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SET_POSITION);
<span class="pc bpc" id="L675" title="1 of 2 branches missed."> if (singlePositionPrefixes != null) {</span>
<span class="fc" id="L676"> String[] prefixes = singlePositionPrefixes</span>
<span class="fc" id="L677"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L678" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L679"> String item = prefixes[i].trim();</span>
<span class="pc bpc" id="L680" title="1 of 2 branches missed."> if (!item.equals("")) {</span>
<span class="fc" id="L681"> result.add(item);</span>
}
}
}
<span class="pc bpc" id="L685" title="1 of 2 branches missed."> if (multiplePositionPrefixes != null) {</span>
<span class="fc" id="L686"> String[] prefixes = multiplePositionPrefixes</span>
<span class="fc" id="L687"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L688" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L689"> String item = prefixes[i].trim();</span>
<span class="pc bpc" id="L690" title="1 of 2 branches missed."> if (!item.equals("")) {</span>
<span class="fc" id="L691"> result.add(item);</span>
}
}
}
<span class="pc bpc" id="L695" title="1 of 2 branches missed."> if (setPositionPrefixes != null) {</span>
<span class="fc" id="L696"> String[] prefixes = setPositionPrefixes</span>
<span class="fc" id="L697"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L698" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L699"> String item = prefixes[i].trim();</span>
<span class="pc bpc" id="L700" title="1 of 2 branches missed."> if (!item.equals("")) {</span>
<span class="fc" id="L701"> result.add(item);</span>
}
}
}
<span class="fc" id="L705"> return result;</span>
} else {
<span class="nc" id="L707"> 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="L720" title="1 of 2 branches missed."> if (fi != null) {</span>
<span class="fc" id="L721"> Set<String> result = new HashSet<>();</span>
<span class="fc" id="L722"> String intersectingPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_INTERSECTION);
<span class="pc bpc" id="L724" title="1 of 2 branches missed."> if (intersectingPrefixes != null) {</span>
<span class="fc" id="L725"> String[] prefixes = intersectingPrefixes</span>
<span class="fc" id="L726"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L727" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L728"> String item = prefixes[i].trim();</span>
<span class="pc bpc" id="L729" title="1 of 2 branches missed."> if (!item.equals("")) {</span>
<span class="fc" id="L730"> result.add(item);</span>
}
}
}
<span class="fc" id="L734"> return result;</span>
} else {
<span class="nc" id="L736"> 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="L750" title="All 2 branches covered."> if (fieldInfo.prefix != null) {</span>
<span class="fc" id="L751"> FieldInfo fi = fieldInfos.fieldInfo(field);</span>
<span class="pc bpc" id="L752" title="1 of 2 branches missed."> if (fi != null) {</span>
<span class="fc" id="L753"> String singlePositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SINGLE_POSITION);
<span class="fc" id="L755"> String multiplePositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_MULTIPLE_POSITION);
<span class="fc" id="L757"> String setPositionPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SET_POSITION);
<span class="fc" id="L759"> String intersectingPrefixes = fi.getAttribute(</span>
MtasCodecPostingsFormat.MTAS_FIELDINFO_ATTRIBUTE_PREFIX_INTERSECTION);
<span class="pc bpc" id="L761" title="1 of 2 branches missed."> if (singlePositionPrefixes != null) {</span>
<span class="fc" id="L762"> String[] prefixes = singlePositionPrefixes</span>
<span class="fc" id="L763"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L764" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L765"> fieldInfo.prefix.addSinglePosition(prefixes[i]);</span>
}
}
<span class="pc bpc" id="L768" title="1 of 2 branches missed."> if (multiplePositionPrefixes != null) {</span>
<span class="fc" id="L769"> String[] prefixes = multiplePositionPrefixes</span>
<span class="fc" id="L770"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L771" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L772"> fieldInfo.prefix.addMultiplePosition(prefixes[i]);</span>
}
}
<span class="pc bpc" id="L775" title="1 of 2 branches missed."> if (setPositionPrefixes != null) {</span>
<span class="fc" id="L776"> String[] prefixes = setPositionPrefixes</span>
<span class="fc" id="L777"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L778" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L779"> fieldInfo.prefix.addSetPosition(prefixes[i]);</span>
}
}
<span class="pc bpc" id="L782" title="1 of 2 branches missed."> if (intersectingPrefixes != null) {</span>
<span class="fc" id="L783"> String[] prefixes = intersectingPrefixes</span>
<span class="fc" id="L784"> .split(Pattern.quote(MtasToken.DELIMITER));</span>
<span class="fc bfc" id="L785" title="All 2 branches covered."> for (int i = 0; i < prefixes.length; i++) {</span>
<span class="fc" id="L786"> fieldInfo.prefix.addIntersecting(prefixes[i]);</span>
}
}
}
}
<span class="fc" id="L791"> }</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="L807"> Map<GroupHit, Spans> list = new HashMap<>();</span>
<span class="nc" id="L808"> IndexReader reader = searcher.getIndexReader();</span>
<span class="nc" id="L809"> final float boost = 0;</span>
<span class="nc bnc" id="L810" title="All 2 branches missed."> for (GroupHit hit : occurences) {</span>
<span class="nc" id="L811"> MtasSpanQuery queryHit = createQueryFromGroupHit(prefixes, field, hit);</span>
<span class="nc bnc" id="L812" title="All 2 branches missed."> if (queryHit != null) {</span>
<span class="nc" id="L813"> MtasSpanQuery queryHitRewritten = queryHit.rewrite(reader);</span>
<span class="nc" id="L814"> SpanWeight weight = queryHitRewritten.createWeight(searcher, false, boost);</span>
<span class="nc" id="L815"> Spans spans = weight.getSpans(lrc, SpanWeight.Postings.POSITIONS);</span>
<span class="nc bnc" id="L816" title="All 2 branches missed."> if (spans != null) {</span>
<span class="nc" id="L817"> list.put(hit, spans);</span>
}
}
<span class="nc" id="L820"> }</span>
<span class="nc" id="L821"> 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="L835" title="All 6 branches missed."> if (prefixes == null || field == null || hit == null) {</span>
<span class="nc" id="L836"> return null;</span>
} else {
<span class="nc" id="L838"> MtasSpanQuery query = null;</span>
<span class="nc" id="L839"> MtasSpanQuery hitQuery = null;</span>
// check for missing
<span class="nc bnc" id="L841" title="All 4 branches missed."> if (hit.missingLeft != null && hit.missingLeft.length > 0) {</span>
<span class="nc bnc" id="L842" title="All 2 branches missed."> for (int i = 0; i < hit.missingLeft.length; i++) {</span>
<span class="nc bnc" id="L843" title="All 2 branches missed."> if (hit.missingLeft[i].size() != hit.unknownLeft[i].size()) {</span>
<span class="nc" id="L844"> return null;</span>
}
}
}
<span class="nc bnc" id="L848" title="All 4 branches missed."> if (hit.missingHit != null && hit.missingHit.length > 0) {</span>
<span class="nc bnc" id="L849" title="All 2 branches missed."> for (int i = 0; i < hit.missingHit.length; i++) {</span>
<span class="nc bnc" id="L850" title="All 2 branches missed."> if (hit.missingHit[i].size() != hit.unknownHit[i].size()) {</span>
<span class="nc" id="L851"> return null;</span>
}
}
}
<span class="nc bnc" id="L855" title="All 4 branches missed."> if (hit.missingRight != null && hit.missingRight.length > 0) {</span>
<span class="nc bnc" id="L856" title="All 2 branches missed."> for (int i = 0; i < hit.missingRight.length; i++) {</span>
<span class="nc bnc" id="L857" title="All 2 branches missed."> if (hit.missingRight[i].size() != hit.unknownRight[i].size()) {</span>
<span class="nc" id="L858"> return null;</span>
}
}
}
<span class="nc bnc" id="L863" title="All 4 branches missed."> if (hit.dataHit != null && hit.dataHit.length > 0) {</span>
<span class="nc" id="L864"> List<MtasSpanSequenceItem> items = new ArrayList<>();</span>
<span class="nc bnc" id="L865" title="All 2 branches missed."> for (int i = 0; i < hit.dataHit.length; i++) {</span>
<span class="nc" id="L866"> MtasSpanQuery item = null;</span>
<span class="nc bnc" id="L867" title="All 2 branches missed."> if (hit.dataHit[i].isEmpty()) {</span>
<span class="nc" id="L868"> item = new MtasSpanMatchAllQuery(field);</span>
<span class="nc bnc" id="L869" title="All 2 branches missed."> } else if (hit.dataHit[i].size() == 1) {</span>
<span class="nc" id="L870"> Term term = new Term(field, hit.dataHit[i].get(0));</span>
<span class="nc" id="L871"> item = new MtasSpanTermQuery(term);</span>
<span class="nc" id="L872"> } else {</span>
<span class="nc" id="L873"> MtasSpanQuery[] subList = new MtasSpanQuery[hit.dataHit[i].size()];</span>
<span class="nc bnc" id="L874" title="All 2 branches missed."> for (int j = 0; j < hit.dataHit[i].size(); j++) {</span>
<span class="nc" id="L875"> Term term = new Term(field, hit.dataHit[i].get(j));</span>
<span class="nc" id="L876"> subList[j] = new MtasSpanTermQuery(term);</span>
}
<span class="nc" id="L878"> item = new MtasSpanAndQuery(subList);</span>
}
<span class="nc" id="L880"> items.add(new MtasSpanSequenceItem(item, false));</span>
}
<span class="nc" id="L882"> hitQuery = new MtasSpanSequenceQuery(items, null, null);</span>
}
<span class="nc bnc" id="L884" title="All 2 branches missed."> if (hitQuery != null) {</span>
<span class="nc" id="L885"> query = hitQuery;</span>
}
<span class="nc" id="L887"> 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="L906" title="All 2 branches missed."> if (mtasCodecInfo != null) {</span>
// for relatively small numbers, compute only what is needed
<span class="nc bnc" id="L908" title="All 2 branches missed."> if (docSet.size() < Math.log(r.maxDoc())) {</span>
<span class="nc" id="L909"> positionsData = new HashMap<>();</span>
<span class="nc bnc" id="L910" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L911"> positionsData.put(docId,</span>
<span class="nc" id="L912"> mtasCodecInfo.getNumberOfPositions(field, (docId - lrc.docBase)));</span>
<span class="nc" id="L913"> }</span>
// compute everything, only use what is needed
} else {
<span class="nc" id="L916"> positionsData = mtasCodecInfo.getAllNumberOfPositions(field,</span>
lrc.docBase);
<span class="nc bnc" id="L918" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc bnc" id="L919" title="All 2 branches missed."> if (!positionsData.containsKey(docId)) {</span>
<span class="nc" id="L920"> positionsData.put(docId, 0);</span>
}
<span class="nc" id="L922"> }</span>
}
} else {
<span class="nc" id="L925"> positionsData = new HashMap<>();</span>
<span class="nc bnc" id="L926" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L927"> positionsData.put(docId, 0);</span>
<span class="nc" id="L928"> }</span>
}
<span class="nc" id="L930"> 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="L944"> Map<Integer, long[]> args = new HashMap<>();</span>
<span class="fc bfc" id="L945" title="All 2 branches covered."> for (int q = 0; q < queries.length; q++) {</span>
<span class="fc" id="L946"> Map<Integer, Integer> tmpData = spansNumberData.get(queries[q]);</span>
<span class="fc" id="L947"> long[] tmpList = null;</span>
<span class="fc bfc" id="L948" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="pc bpc" id="L949" title="1 of 4 branches missed."> if (tmpData != null && tmpData.containsKey(docId)) {</span>
<span class="fc bfc" id="L950" title="All 2 branches covered."> if (!args.containsKey(docId)) {</span>
<span class="fc" id="L951"> tmpList = new long[queries.length];</span>
} else {
<span class="fc" id="L953"> tmpList = args.get(docId);</span>
}
<span class="fc" id="L955"> tmpList[q] = tmpData.get(docId);</span>
<span class="fc" id="L956"> args.put(docId, tmpList);</span>
<span class="pc bpc" id="L957" title="1 of 2 branches missed."> } else if (!args.containsKey(docId)) {</span>
<span class="fc" id="L958"> tmpList = new long[queries.length];</span>
<span class="fc" id="L959"> args.put(docId, tmpList);</span>
}
}
}
<span class="fc" id="L963"> 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="L975" title="All 4 branches missed."> if (facetDocList != null && docSet != null) {</span>
<span class="nc" id="L976"> Integer[] c = new Integer[Math.min(facetDocList.length, docSet.length)];</span>
<span class="nc" id="L977"> int ai = 0;</span>
<span class="nc" id="L978"> int bi = 0;</span>
<span class="nc" id="L979"> int ci = 0;</span>
<span class="nc bnc" id="L980" title="All 4 branches missed."> while (ai < facetDocList.length && bi < docSet.length) {</span>
<span class="nc bnc" id="L981" title="All 2 branches missed."> if (facetDocList[ai] < docSet[bi]) {</span>
<span class="nc" id="L982"> ai++;</span>
<span class="nc bnc" id="L983" title="All 2 branches missed."> } else if (facetDocList[ai] > docSet[bi]) {</span>
<span class="nc" id="L984"> bi++;</span>
} else {
<span class="nc bnc" id="L986" title="All 4 branches missed."> if (ci == 0 || facetDocList[ai] != c[ci - 1]) {</span>
<span class="nc" id="L987"> c[ci++] = facetDocList[ai];</span>
}
<span class="nc" id="L989"> ai++;</span>
<span class="nc" id="L990"> bi++;</span>
}
}
<span class="nc" id="L993"> return Arrays.copyOfRange(c, 0, ci);</span>
}
<span class="nc" id="L995"> 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="L1009" title="1 of 2 branches missed."> if (statsPositionList != null) {</span>
<span class="fc bfc" id="L1010" title="All 2 branches covered."> for (ComponentPosition position : statsPositionList) {</span>
<span class="fc" id="L1011"> position.dataCollector.initNewList(1);</span>
Integer tmpValue;
<span class="fc" id="L1013"> long[] values = new long[docSet.size()];</span>
int value;
<span class="fc" id="L1015"> int number = 0;</span>
<span class="fc bfc" id="L1016" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L1017"> tmpValue = positionsData.get(docId);</span>
<span class="pc bpc" id="L1018" title="1 of 2 branches missed."> value = tmpValue == null ? 0 : tmpValue.intValue();</span>
<span class="fc bfc" id="L1019" title="All 2 branches covered."> if (((position.minimumLong == null)</span>
<span class="fc bfc" id="L1020" title="All 4 branches covered."> || (value >= position.minimumLong))</span>
&& ((position.maximumLong == null)
<span class="fc bfc" id="L1022" title="All 2 branches covered."> || (value <= position.maximumLong))) {</span>
<span class="fc" id="L1023"> values[number] = value;</span>
<span class="fc" id="L1024"> number++;</span>
}
<span class="fc" id="L1026"> }</span>
<span class="fc bfc" id="L1027" title="All 2 branches covered."> if (number > 0) {</span>
<span class="fc" id="L1028"> position.dataCollector.add(values, number);</span>
}
<span class="fc" id="L1030"> position.dataCollector.closeNewList();</span>
<span class="fc" id="L1031"> }</span>
}
<span class="fc" id="L1033"> }</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="L1046" title="1 of 2 branches missed."> if (statsTokenList != null) {</span>
<span class="fc bfc" id="L1047" title="All 2 branches covered."> for (ComponentToken token : statsTokenList) {</span>
<span class="fc" id="L1048"> token.dataCollector.initNewList(1);</span>
Integer tmpValue;
<span class="fc" id="L1050"> long[] values = new long[docSet.size()];</span>
int value;
<span class="fc" id="L1052"> int number = 0;</span>
<span class="pc bpc" id="L1053" title="1 of 2 branches missed."> if (tokensData != null) {</span>
<span class="fc bfc" id="L1054" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L1055"> tmpValue = tokensData.get(docId);</span>
<span class="pc bpc" id="L1056" title="1 of 2 branches missed."> value = tmpValue == null ? 0 : tmpValue.intValue();</span>
<span class="pc bpc" id="L1057" title="1 of 6 branches missed."> if (((token.minimumLong == null) || (value >= token.minimumLong))</span>
&& ((token.maximumLong == null)
<span class="pc bpc" id="L1059" title="1 of 2 branches missed."> || (value <= token.maximumLong))) {</span>
<span class="fc" id="L1060"> values[number] = value;</span>
<span class="fc" id="L1061"> number++;</span>
}
<span class="fc" id="L1063"> }</span>
}
<span class="fc bfc" id="L1065" title="All 2 branches covered."> if (number > 0) {</span>
<span class="fc" id="L1066"> token.dataCollector.add(values, number);</span>
}
<span class="fc" id="L1068"> token.dataCollector.closeNewList();</span>
<span class="fc" id="L1069"> }</span>
}
<span class="fc" id="L1071"> }</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="L1086" title="1 of 2 branches missed."> if (statsSpanList != null) {</span>
<span class="fc bfc" id="L1087" title="All 2 branches covered."> for (ComponentSpan span : statsSpanList) {</span>
<span class="pc bpc" id="L1088" title="1 of 2 branches missed."> if (span.parser.needArgumentsNumber() > span.queries.length) {</span>
<span class="nc" id="L1089"> throw new IOException(</span>
"function " + span.parser + " expects (at least) "
<span class="nc" id="L1091"> + span.parser.needArgumentsNumber() + " queries");</span>
}
// collect
<span class="fc" id="L1094"> Map<Integer, long[]> args = computeArguments(spansNumberData,</span>
span.queries, docSet);
<span class="pc bpc" id="L1096" 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="L1098" title="1 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="L1101" title="2 of 4 branches missed."> || (span.functionBasic() && span.functionSumRule()</span>
<span class="pc bpc" id="L1102" title="1 of 2 branches missed."> && !span.functionNeedPositions()))) {</span>
// initialise
<span class="fc" id="L1104"> int length = span.parser.needArgumentsNumber();</span>
<span class="fc" id="L1105"> long[] valueSum = new long[length];</span>
<span class="fc" id="L1106"> long valuePositions = 0;</span>
// collect
<span class="pc bpc" id="L1108" title="1 of 2 branches missed."> if (docSet.length > 0) {</span>
long[] tmpArgs;
<span class="fc bfc" id="L1110" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc" id="L1111"> tmpArgs = args.get(docId);</span>
<span class="fc bfc" id="L1112" title="All 2 branches covered."> valuePositions += (positionsData == null) ? 0</span>
<span class="fc" id="L1113"> : positionsData.get(docId);</span>
<span class="pc bpc" id="L1114" title="1 of 2 branches missed."> if (tmpArgs != null) {</span>
<span class="fc bfc" id="L1115" title="All 2 branches covered."> for (int i = 0; i < length; i++) {</span>
<span class="fc" id="L1116"> valueSum[i] += tmpArgs[i];</span>
}
}
}
long valueLong;
<span class="fc" id="L1121"> span.dataCollector.initNewList(1);</span>
try {
<span class="fc" id="L1123"> valueLong = span.parser.getValueLong(valueSum, valuePositions);</span>
<span class="fc" id="L1124"> span.dataCollector.add(valueLong, docSet.length);</span>
<span class="nc" id="L1125"> } catch (IOException e) {</span>
<span class="nc" id="L1126"> log.debug(e);</span>
<span class="nc" id="L1127"> span.dataCollector.error(e.getMessage());</span>
<span class="fc" id="L1128"> }</span>
<span class="pc bpc" id="L1129" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="fc bfc" id="L1130" title="All 2 branches covered."> for (SubComponentFunction function : span.functions) {</span>
<span class="fc" id="L1131"> function.dataCollector.initNewList(1);</span>
<span class="pc bpc" id="L1132" title="1 of 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
try {
<span class="fc" id="L1134"> valueLong = function.parserFunction.getValueLong(valueSum,</span>
valuePositions);
<span class="fc" id="L1136"> function.dataCollector.add(valueLong, docSet.length);</span>
<span class="nc" id="L1137"> } catch (IOException e) {</span>
<span class="nc" id="L1138"> log.debug(e);</span>
<span class="nc" id="L1139"> function.dataCollector.error(e.getMessage());</span>
<span class="pc" id="L1140"> }</span>
<span class="nc" id="L1141"> } else if (function.dataType</span>
<span class="nc bnc" id="L1142" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
try {
<span class="nc" id="L1144"> double valueDouble = function.parserFunction</span>
<span class="nc" id="L1145"> .getValueDouble(valueSum, valuePositions);</span>
<span class="nc" id="L1146"> function.dataCollector.add(valueDouble, docSet.length);</span>
<span class="nc" id="L1147"> } catch (IOException e) {</span>
<span class="nc" id="L1148"> log.debug(e);</span>
<span class="nc" id="L1149"> function.dataCollector.error(e.getMessage());</span>
<span class="nc" id="L1150"> }</span>
} else {
<span class="nc" id="L1152"> throw new IOException(</span>
"can't handle function dataType " + function.dataType);
}
<span class="fc" id="L1155"> function.dataCollector.closeNewList();</span>
<span class="fc" id="L1156"> }</span>
}
<span class="fc" id="L1158"> span.dataCollector.closeNewList();</span>
}
<span class="fc" id="L1160"> } else {</span>
// collect
<span class="pc bpc" id="L1162" title="1 of 2 branches missed."> if (docSet.length > 0) {</span>
<span class="fc" id="L1163"> int number = 0;</span>
int positions;
long valueLong;
double valueDouble;
<span class="fc" id="L1167"> long[] values = new long[docSet.length];</span>
<span class="fc" id="L1168"> long[][] functionValuesLong = null;</span>
<span class="fc" id="L1169"> double[][] functionValuesDouble = null;</span>
<span class="fc" id="L1170"> span.dataCollector.initNewList(1);</span>
<span class="pc bpc" id="L1171" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="fc" id="L1172"> functionValuesLong = new long[span.functions.size()][];</span>
<span class="fc" id="L1173"> functionValuesDouble = new double[span.functions.size()][];</span>
<span class="pc bpc" id="L1174" title="1 of 2 branches missed."> for (int i = 0; i < span.functions.size(); i++) {</span>
<span class="nc" id="L1175"> SubComponentFunction function = span.functions.get(i);</span>
<span class="nc bnc" id="L1176" title="All 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L1177"> functionValuesLong[i] = new long[docSet.length];</span>
<span class="nc" id="L1178"> functionValuesDouble[i] = null;</span>
<span class="nc" id="L1179"> } else if (function.dataType</span>
<span class="nc bnc" id="L1180" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L1181"> functionValuesLong[i] = null;</span>
<span class="nc" id="L1182"> functionValuesDouble[i] = new double[docSet.length];</span>
}
<span class="nc" id="L1184"> function.dataCollector.initNewList(1);</span>
}
}
<span class="fc bfc" id="L1187" title="All 2 branches covered."> for (int docId : docSet) {</span>
<span class="fc bfc" id="L1188" title="All 2 branches covered."> if (positionsData == null) {</span>
<span class="fc" id="L1189"> positions = 0;</span>
} else {
<span class="pc bpc" id="L1191" title="1 of 2 branches missed."> positions = (positionsData.get(docId) == null ? 0</span>
<span class="fc" id="L1192"> : positionsData.get(docId));</span>
}
<span class="fc" id="L1194"> valueLong = span.parser.getValueLong(args.get(docId),</span>
positions);
<span class="fc bfc" id="L1196" title="All 2 branches covered."> if (((span.minimumLong == null)</span>
<span class="fc bfc" id="L1197" title="All 4 branches covered."> || (valueLong >= span.minimumLong))</span>
&& ((span.maximumLong == null)
<span class="fc bfc" id="L1199" title="All 2 branches covered."> || (valueLong <= span.maximumLong))) {</span>
<span class="fc" id="L1200"> values[number] = valueLong;</span>
<span class="pc bpc" id="L1201" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="pc bpc" id="L1202" title="1 of 2 branches missed."> for (int i = 0; i < span.functions.size(); i++) {</span>
<span class="nc" id="L1203"> SubComponentFunction function = span.functions.get(i);</span>
try {
<span class="nc" id="L1205"> if (function.dataType</span>
<span class="nc bnc" id="L1206" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L1207"> valueLong = function.parserFunction</span>
<span class="nc" id="L1208"> .getValueLong(args.get(docId), positions);</span>
<span class="nc" id="L1209"> functionValuesLong[i][number] = valueLong;</span>
<span class="nc" id="L1210"> } else if (function.dataType</span>
<span class="nc bnc" id="L1211" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L1212"> valueDouble = function.parserFunction</span>
<span class="nc" id="L1213"> .getValueDouble(args.get(docId), positions);</span>
<span class="nc" id="L1214"> functionValuesDouble[i][number] = valueDouble;</span>
}
<span class="nc" id="L1216"> } catch (IOException e) {</span>
<span class="nc" id="L1217"> log.debug(e);</span>
<span class="nc" id="L1218"> function.dataCollector.error(e.getMessage());</span>
<span class="nc" id="L1219"> }</span>
}
}
<span class="fc" id="L1222"> number++;</span>
}
}
<span class="fc bfc" id="L1225" title="All 2 branches covered."> if (number > 0) {</span>
<span class="fc" id="L1226"> span.dataCollector.add(values, number);</span>
<span class="pc bpc" id="L1227" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="pc bpc" id="L1228" title="1 of 2 branches missed."> for (int i = 0; i < span.functions.size(); i++) {</span>
<span class="nc" id="L1229"> SubComponentFunction function = span.functions.get(i);</span>
<span class="nc bnc" id="L1230" title="All 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L1231"> function.dataCollector.add(functionValuesLong[i], number);</span>
<span class="nc" id="L1232"> } else if (function.dataType</span>
<span class="nc bnc" id="L1233" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L1234"> function.dataCollector.add(functionValuesDouble[i],</span>
number);
}
}
}
}
<span class="fc" id="L1240"> span.dataCollector.closeNewList();</span>
<span class="pc bpc" id="L1241" title="1 of 2 branches missed."> if (span.functions != null) {</span>
<span class="pc bpc" id="L1242" title="1 of 2 branches missed."> for (SubComponentFunction function : span.functions) {</span>
<span class="nc" id="L1243"> function.dataCollector.closeNewList();</span>
<span class="nc" id="L1244"> }</span>
}
<span class="fc" id="L1246"> }</span>
}
} else {
<span class="nc" id="L1249"> throw new IOException("unexpected dataType " + span.dataType);</span>
}
<span class="fc" id="L1251"> }</span>
}
<span class="fc" id="L1253"> }</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="L1274" title="All 2 branches missed."> if (listList != null) {</span>
<span class="nc bnc" id="L1275" title="All 2 branches missed."> for (ComponentList list : listList) {</span>
// collect not only stats
<span class="nc bnc" id="L1277" title="All 2 branches missed."> if (list.number > 0) {</span>
<span class="nc" id="L1278"> Map<Integer, List<Match>> matchData = spansMatchData</span>
<span class="nc" id="L1279"> .get(list.spanQuery);</span>
<span class="nc" id="L1280"> Map<Integer, Integer> numberData = spansNumberData</span>
<span class="nc" id="L1281"> .get(list.spanQuery);</span>
List<Match> matchList;
Integer matchNumber;
<span class="nc bnc" id="L1284" title="All 2 branches missed."> if (list.output.equals(ComponentList.LIST_OUTPUT_HIT)) {</span>
<span class="nc bnc" id="L1285" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc bnc" id="L1286" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L1287" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null) {</span>
<span class="nc bnc" id="L1288" title="All 2 branches missed."> if (list.position < (list.start + list.number)) {</span>
<span class="nc" id="L1289"> boolean getDoc = false;</span>
Match m;
<span class="nc bnc" id="L1291" title="All 2 branches missed."> for (int i = 0; i < matchList.size(); i++) {</span>
<span class="nc bnc" id="L1292" title="All 4 branches missed."> if ((list.position >= list.start)</span>
&& (list.position < (list.start + list.number))) {
<span class="nc" id="L1294"> m = matchList.get(i);</span>
<span class="nc" id="L1295"> getDoc = true;</span>
<span class="nc" id="L1296"> int startPosition = m.startPosition;</span>
<span class="nc" id="L1297"> int endPosition = m.endPosition - 1;</span>
<span class="nc" id="L1298"> List<MtasTreeHit<String>> terms = mtasCodecInfo</span>
<span class="nc" id="L1299"> .getPositionedTermsByPrefixesAndPositionRange(field,</span>
(docId - docBase), list.prefixes,
startPosition - list.left,
endPosition + list.right);
// construct hit
<span class="nc" id="L1304"> Map<Integer, List<String>> kwicListHits = new HashMap<>();</span>
<span class="nc" id="L1305"> for (int position = Math.max(0,</span>
<span class="nc bnc" id="L1306" title="All 2 branches missed."> startPosition - list.left); position <= (endPosition</span>
<span class="nc" id="L1307"> + list.right); position++) {</span>
<span class="nc" id="L1308"> kwicListHits.put(position, new ArrayList<String>());</span>
}
List<String> termList;
<span class="nc bnc" id="L1311" title="All 2 branches missed."> for (MtasTreeHit<String> term : terms) {</span>
<span class="nc" id="L1312"> for (int position = Math.max(</span>
(startPosition - list.left),
<span class="nc bnc" id="L1314" title="All 2 branches missed."> term.startPosition); position <= Math.min(</span>
(endPosition + list.right),
<span class="nc" id="L1316"> term.endPosition); position++) {</span>
<span class="nc" id="L1317"> termList = kwicListHits.get(position);</span>
<span class="nc" id="L1318"> termList.add(term.data);</span>
}
<span class="nc" id="L1320"> }</span>
<span class="nc" id="L1321"> list.hits.add(new ListHit(docId, i, m, kwicListHits));</span>
}
<span class="nc" id="L1323"> list.position++;</span>
}
<span class="nc bnc" id="L1325" title="All 2 branches missed."> if (getDoc) {</span>
// get unique id
<span class="nc" id="L1327"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L1328"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
<span class="nc" id="L1329"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
// get other doc info
<span class="nc bnc" id="L1331" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L1332"> list.uniqueKey.put(docId, indxfld.stringValue());</span>
}
<span class="nc" id="L1334"> list.subTotal.put(docId, matchList.size());</span>
<span class="nc" id="L1335"> IndexDoc mDoc = mtasCodecInfo.getDoc(field,</span>
(docId - docBase));
<span class="nc bnc" id="L1337" title="All 2 branches missed."> if (mDoc != null) {</span>
<span class="nc" id="L1338"> list.minPosition.put(docId, mDoc.minPosition);</span>
<span class="nc" id="L1339"> list.maxPosition.put(docId, mDoc.maxPosition);</span>
}
}
<span class="nc" id="L1342"> } else {</span>
<span class="nc" id="L1343"> list.position += matchList.size();</span>
}
<span class="nc bnc" id="L1345" title="All 2 branches missed."> } else if (numberData != null</span>
<span class="nc bnc" id="L1346" title="All 2 branches missed."> && (matchNumber = numberData.get(docId)) != null) {</span>
<span class="nc" id="L1347"> list.position += matchNumber;</span>
}
<span class="nc" id="L1349"> }</span>
<span class="nc" id="L1350"> list.total = list.position;</span>
<span class="nc bnc" id="L1351" title="All 2 branches missed."> } else if (list.output.equals(ComponentList.LIST_OUTPUT_TOKEN)) {</span>
<span class="nc bnc" id="L1352" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc bnc" id="L1353" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L1354" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null) {</span>
<span class="nc bnc" id="L1355" title="All 2 branches missed."> if (list.position < (list.start + list.number)) {</span>
<span class="nc" id="L1356"> boolean getDoc = false;</span>
Match m;
<span class="nc bnc" id="L1358" title="All 2 branches missed."> for (int i = 0; i < matchList.size(); i++) {</span>
<span class="nc bnc" id="L1359" title="All 4 branches missed."> if ((list.position >= list.start)</span>
&& (list.position < (list.start + list.number))) {
<span class="nc" id="L1361"> m = matchList.get(i);</span>
<span class="nc" id="L1362"> getDoc = true;</span>
<span class="nc" id="L1363"> int startPosition = m.startPosition;</span>
<span class="nc" id="L1364"> int endPosition = m.endPosition - 1;</span>
List<MtasTokenString> tokens;
<span class="nc" id="L1366"> tokens = mtasCodecInfo</span>
<span class="nc" id="L1367"> .getPrefixFilteredObjectsByPositions(field,</span>
(docId - docBase), list.prefixes,
startPosition - list.left,
endPosition + list.right);
<span class="nc" id="L1371"> list.tokens.add(new ListToken(docId, i, m, tokens));</span>
}
<span class="nc" id="L1373"> list.position++;</span>
}
<span class="nc bnc" id="L1375" title="All 2 branches missed."> if (getDoc) {</span>
// get unique id
<span class="nc" id="L1377"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L1378"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
<span class="nc" id="L1379"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
// get other doc info
<span class="nc bnc" id="L1381" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L1382"> list.uniqueKey.put(docId, indxfld.stringValue());</span>
}
<span class="nc" id="L1384"> list.subTotal.put(docId, matchList.size());</span>
<span class="nc" id="L1385"> IndexDoc mDoc = mtasCodecInfo.getDoc(field,</span>
(docId - docBase));
<span class="nc bnc" id="L1387" title="All 2 branches missed."> if (mDoc != null) {</span>
<span class="nc" id="L1388"> list.minPosition.put(docId, mDoc.minPosition);</span>
<span class="nc" id="L1389"> list.maxPosition.put(docId, mDoc.maxPosition);</span>
}
}
<span class="nc" id="L1392"> } else {</span>
<span class="nc" id="L1393"> list.position += matchList.size();</span>
}
<span class="nc bnc" id="L1395" title="All 2 branches missed."> } else if (numberData != null</span>
<span class="nc bnc" id="L1396" title="All 2 branches missed."> && (matchNumber = numberData.get(docId)) != null) {</span>
<span class="nc" id="L1397"> list.position += matchNumber;</span>
}
<span class="nc" id="L1399"> }</span>
<span class="nc" id="L1400"> list.total = list.position;</span>
}
<span class="nc" id="L1403"> } else {</span>
<span class="nc" id="L1404"> Map<Integer, Integer> data = spansNumberData.get(list.spanQuery);</span>
<span class="nc bnc" id="L1405" title="All 2 branches missed."> if (data != null) {</span>
<span class="nc bnc" id="L1406" title="All 2 branches missed."> for (int docId : docSet) {</span>
<span class="nc" id="L1407"> Integer matchNumber = data.get(docId);</span>
<span class="nc bnc" id="L1408" title="All 2 branches missed."> if (matchNumber != null) {</span>
<span class="nc" id="L1409"> list.position += matchNumber;</span>
}
<span class="nc" id="L1411"> }</span>
<span class="nc" id="L1412"> list.total = list.position;</span>
}
}
<span class="nc" id="L1415"> }</span>
}
<span class="nc" id="L1417"> }</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="L1439" 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="L1442" title="All 2 branches covered."> for (ComponentGroup group : groupList) {</span>
<span class="fc" id="L1443"> group.dataCollector.setWithTotal();</span>
<span class="pc bpc" id="L1444" title="1 of 2 branches missed."> if (!group.prefixes.isEmpty()) {</span>
<span class="fc" id="L1445"> matchData = spansMatchData.get(group.spanQuery);</span>
<span class="fc" id="L1446"> Set<String> knownPrefixes = collectKnownPrefixes(fieldInfo);</span>
<span class="fc" id="L1447"> Set<String> intersectionPrefixes = collectIntersectionPrefixes(</span>
fieldInfo);
<span class="fc" id="L1449"> boolean intersectionGroupPrefixes = intersectionPrefixes(group,</span>
intersectionPrefixes);
<span class="fc" id="L1451"> boolean availablePrefixes = availablePrefixes(group, knownPrefixes);</span>
// sort match lists
<span class="pc bpc" id="L1453" title="1 of 2 branches missed."> if (!intersectionGroupPrefixes) {</span>
<span class="fc bfc" id="L1454" title="All 2 branches covered."> for (Entry<Integer, List<Match>> entry : matchData.entrySet()) {</span>
<span class="fc" id="L1455"> sortMatchList(entry.getValue());</span>
<span class="fc" id="L1456"> }</span>
}
// init
<span class="fc" id="L1459"> group.dataCollector.initNewList(1);</span>
int docId;
<span class="fc" id="L1462"> Map<GroupHit, Long> occurencesSum = new HashMap<>();</span>
<span class="fc" id="L1463"> Map<GroupHit, Integer> occurencesN = new HashMap<>();</span>
<span class="fc" id="L1464"> Set<GroupHit> occurencesInCurrentDocument = new HashSet<>();</span>
<span class="pc bpc" id="L1466" title="1 of 2 branches missed."> if (!availablePrefixes) {</span>
<span class="nc" id="L1467"> HashMap<Integer, GroupHit> hits = new HashMap<>();</span>
<span class="nc bnc" id="L1468" title="All 2 branches missed."> for (int docCounter = 0; docCounter < docSet.size(); docCounter++) {</span>
<span class="nc" id="L1469"> occurencesInCurrentDocument.clear();</span>
<span class="nc" id="L1470"> docId = docSet.get(docCounter);</span>
GroupHit hit;
GroupHit hitKey;
<span class="nc bnc" id="L1473" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L1474" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null</span>
<span class="nc bnc" id="L1475" title="All 2 branches missed."> && !matchList.isEmpty()) {</span>
<span class="nc" id="L1476"> Iterator<Match> it = matchList.listIterator();</span>
<span class="nc bnc" id="L1477" title="All 2 branches missed."> while (it.hasNext()) {</span>
<span class="nc" id="L1478"> Match m = it.next();</span>
<span class="nc" id="L1479"> IntervalTreeNodeData<String> positionHit = createPositionHit(</span>
m, group);
<span class="nc" id="L1481"> int length = m.endPosition - m.startPosition;</span>
<span class="nc" id="L1482"> hitKey = null;</span>
<span class="nc bnc" id="L1483" title="All 2 branches missed."> if (!hits.containsKey(length)) {</span>
<span class="nc" id="L1484"> hit = new GroupHit(positionHit.list, positionHit.start,</span>
positionHit.end, positionHit.hitStart,
positionHit.hitEnd, group, knownPrefixes);
<span class="nc" id="L1487"> hits.put(length, hit);</span>
} else {
<span class="nc" id="L1489"> hit = hits.get(length);</span>
<span class="nc bnc" id="L1490" title="All 2 branches missed."> for (GroupHit hitKeyItem : occurencesSum.keySet()) {</span>
<span class="nc bnc" id="L1491" title="All 2 branches missed."> if (hitKeyItem.equals(hit)) {</span>
<span class="nc" id="L1492"> hitKey = hitKeyItem;</span>
<span class="nc" id="L1493"> break;</span>
}
<span class="nc" id="L1495"> }</span>
}
<span class="nc bnc" id="L1497" title="All 2 branches missed."> if (hitKey == null) {</span>
<span class="nc" id="L1498"> occurencesSum.put(hit, Long.valueOf(1));</span>
<span class="nc" id="L1499"> occurencesN.put(hit, 1);</span>
<span class="nc" id="L1500"> occurencesInCurrentDocument.add(hit);</span>
} else {
<span class="nc" id="L1502"> occurencesSum.put(hitKey, occurencesSum.get(hitKey) + 1);</span>
<span class="nc bnc" id="L1503" title="All 2 branches missed."> if (!occurencesInCurrentDocument.contains(hitKey)) {</span>
<span class="nc bnc" id="L1504" title="All 2 branches missed."> if (occurencesN.containsKey(hitKey)) {</span>
<span class="nc" id="L1505"> occurencesN.put(hitKey, occurencesN.get(hitKey) + 1);</span>
} else {
<span class="nc" id="L1507"> occurencesN.put(hitKey, 1);</span>
}
<span class="nc" id="L1509"> occurencesInCurrentDocument.add(hitKey);</span>
}
}
<span class="nc" id="L1512"> }</span>
}
}
<span class="nc" id="L1515"> } else {</span>
<span class="fc" id="L1516"> int maximumNumberOfDocuments = 0;</span>
<span class="fc" id="L1517"> int boundaryMinimumNumberOfDocuments = 1;</span>
<span class="fc" id="L1518"> int boundaryMaximumNumberOfDocuments = 5;</span>
<span class="fc" id="L1519"> Set<GroupHit> administrationOccurrences = new HashSet<>();</span>
<span class="fc bfc" id="L1520" title="All 2 branches covered."> for (int docCounter = 0; docCounter < docSet.size(); docCounter++) {</span>
<span class="fc" id="L1521"> occurencesInCurrentDocument.clear();</span>
<span class="fc" id="L1522"> docId = docSet.get(docCounter);</span>
<span class="pc bpc" id="L1523" title="1 of 2 branches missed."> if (matchData != null</span>
<span class="pc bpc" id="L1524" title="1 of 2 branches missed."> && (matchList = matchData.get(docId)) != null</span>
<span class="pc bpc" id="L1525" title="1 of 2 branches missed."> && !matchList.isEmpty()) {</span>
// loop over matches
<span class="fc" id="L1527"> Iterator<Match> it = matchList.listIterator();</span>
<span class="fc" id="L1528"> ArrayList<IntervalTreeNodeData<String>> positionsHits = new ArrayList<>();</span>
<span class="fc bfc" id="L1529" title="All 2 branches covered."> while (it.hasNext()) {</span>
<span class="fc" id="L1530"> Match m = it.next();</span>
<span class="fc" id="L1531"> positionsHits.add(createPositionHit(m, group));</span>
<span class="fc" id="L1532"> }</span>
<span class="fc" id="L1533"> mtasCodecInfo.collectTermsByPrefixesForListOfHitPositions(field,</span>
(docId - docBase), group.prefixes, positionsHits);
// administration
<span class="fc bfc" id="L1536" title="All 2 branches covered."> for (IntervalTreeNodeData<String> positionHit : positionsHits) {</span>
<span class="fc" id="L1537"> GroupHit hit = new GroupHit(positionHit.list,</span>
positionHit.start, positionHit.end, positionHit.hitStart,
positionHit.hitEnd, group, knownPrefixes);
<span class="fc" id="L1540"> GroupHit hitKey = null;</span>
<span class="fc bfc" id="L1541" title="All 2 branches covered."> for (GroupHit hitKeyItem : occurencesSum.keySet()) {</span>
<span class="fc bfc" id="L1542" title="All 2 branches covered."> if (hitKeyItem.equals(hit)) {</span>
<span class="fc" id="L1543"> hitKey = hitKeyItem;</span>
<span class="fc" id="L1544"> break;</span>
}
<span class="fc" id="L1546"> }</span>
<span class="fc bfc" id="L1547" title="All 2 branches covered."> if (hitKey == null) {</span>
<span class="fc" id="L1548"> occurencesSum.put(hit, Long.valueOf(1));</span>
<span class="fc" id="L1549"> occurencesN.put(hit, 1);</span>
<span class="fc" id="L1550"> occurencesInCurrentDocument.add(hit);</span>
} else {
<span class="fc" id="L1552"> occurencesSum.put(hitKey, occurencesSum.get(hitKey) + 1);</span>
<span class="fc bfc" id="L1553" title="All 2 branches covered."> if (!occurencesInCurrentDocument.contains(hitKey)) {</span>
<span class="pc bpc" id="L1554" title="1 of 2 branches missed."> if (occurencesN.containsKey(hitKey)) {</span>
<span class="fc" id="L1555"> occurencesN.put(hitKey, occurencesN.get(hitKey) + 1);</span>
} else {
<span class="nc" id="L1557"> occurencesN.put(hitKey, 1);</span>
}
<span class="fc" id="L1559"> occurencesInCurrentDocument.add(hitKey);</span>
}
}
<span class="fc" id="L1562"> }</span>
<span class="pc bpc" id="L1563" title="1 of 2 branches missed."> if (!intersectionGroupPrefixes) {</span>
<span class="fc bfc" id="L1564" title="All 2 branches covered."> for (GroupHit groupHit : occurencesInCurrentDocument) {</span>
<span class="fc" id="L1565"> int tmpNumber = occurencesN.get(groupHit);</span>
<span class="fc" id="L1566"> maximumNumberOfDocuments = Math</span>
<span class="fc" id="L1567"> .max(maximumNumberOfDocuments, tmpNumber);</span>
<span class="fc bfc" id="L1568" title="All 2 branches covered."> if (tmpNumber > boundaryMinimumNumberOfDocuments) {</span>
<span class="fc" id="L1569"> administrationOccurrences.add(groupHit);</span>
}
<span class="fc" id="L1571"> }</span>
// collect spans
<span class="pc bpc" id="L1573" title="1 of 2 branches missed."> if (maximumNumberOfDocuments > boundaryMaximumNumberOfDocuments) {</span>
<span class="nc bnc" id="L1574" title="All 2 branches missed."> if (!administrationOccurrences.isEmpty()) {</span>
<span class="nc" id="L1575"> Map<GroupHit, Spans> list = collectSpansForOccurences(</span>
administrationOccurrences, knownPrefixes, field,
searcher, lrc);
<span class="nc bnc" id="L1578" title="All 2 branches missed."> if (list.size() > 0) {</span>
<span class="nc" id="L1579"> collectGroupUsingSpans(list, docSet, docBase,</span>
docCounter, matchData, occurencesSum, occurencesN);
}
}
<span class="nc" id="L1583"> administrationOccurrences.clear();</span>
<span class="nc" id="L1584"> maximumNumberOfDocuments = 0;</span>
<span class="nc" id="L1585"> boundaryMinimumNumberOfDocuments = (int) Math</span>
<span class="nc" id="L1586"> .ceil(boundaryMinimumNumberOfDocuments * 1.2);</span>
<span class="nc" id="L1587"> boundaryMaximumNumberOfDocuments = (int) Math</span>
<span class="nc" id="L1588"> .ceil(boundaryMaximumNumberOfDocuments * 1.2);</span>
}
}
}
}
}
<span class="fc bfc" id="L1595" title="All 2 branches covered."> for (Entry<GroupHit, Long> entry : occurencesSum.entrySet()) {</span>
<span class="fc" id="L1596"> group.dataCollector.add(entry.getKey().toString(), entry.getValue(),</span>
<span class="fc" id="L1597"> occurencesN.get(entry.getKey()));</span>
<span class="fc" id="L1598"> }</span>
<span class="fc" id="L1599"> group.dataCollector.closeNewList();</span>
}
<span class="fc" id="L1601"> }</span>
}
<span class="fc" id="L1603"> }</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="L1614" title="1 of 2 branches missed."> if (knownPrefixes != null) {</span>
<span class="pc bpc" id="L1615" title="1 of 2 branches missed."> for (String prefix : group.prefixes) {</span>
<span class="pc bpc" id="L1616" title="1 of 2 branches missed."> if (knownPrefixes.contains(prefix)) {</span>
<span class="fc" id="L1617"> return true;</span>
}
<span class="nc" id="L1619"> }</span>
}
<span class="nc" id="L1621"> 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="L1633" title="1 of 2 branches missed."> if (intersectionPrefixes != null) {</span>
<span class="fc bfc" id="L1634" title="All 2 branches covered."> for (String prefix : group.prefixes) {</span>
<span class="pc bpc" id="L1635" title="1 of 2 branches missed."> if (intersectionPrefixes.contains(prefix)) {</span>
<span class="nc" id="L1636"> return true;</span>
}
<span class="fc" id="L1638"> }</span>
}
<span class="fc" id="L1640"> 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="L1652"> Integer start = null;</span>
<span class="fc" id="L1653"> Integer end = null;</span>
<span class="fc bfc" id="L1654" title="All 6 branches covered."> if (group.hitInside != null || group.hitInsideLeft != null</span>
|| group.hitInsideRight != null) {
<span class="fc" id="L1656"> start = m.startPosition;</span>
<span class="fc" id="L1657"> end = m.endPosition - 1;</span>
} else {
<span class="fc" id="L1659"> start = null;</span>
<span class="fc" id="L1660"> end = null;</span>
}
<span class="fc bfc" id="L1662" title="All 2 branches covered."> if (group.hitLeft != null) {</span>
<span class="fc" id="L1663"> start = m.startPosition;</span>
<span class="fc" id="L1664"> end = Math.max(m.startPosition + group.hitLeft.length - 1,</span>
m.endPosition - 1);
}
<span class="fc bfc" id="L1667" title="All 2 branches covered."> if (group.hitRight != null) {</span>
<span class="fc" id="L1668"> start = Math.min(m.endPosition - group.hitRight.length, m.startPosition);</span>
<span class="fc bfc" id="L1669" title="All 2 branches covered."> end = end == null ? (m.endPosition - 1)</span>
<span class="fc" id="L1670"> : Math.max(end, (m.endPosition - 1));</span>
}
<span class="fc bfc" id="L1672" title="All 2 branches covered."> if (group.left != null) {</span>
<span class="fc bfc" id="L1673" title="All 2 branches covered."> start = start == null ? m.startPosition - group.left.length</span>
<span class="fc" id="L1674"> : Math.min(m.startPosition - group.left.length, start);</span>
<span class="fc bfc" id="L1675" title="All 2 branches covered."> end = end == null ? m.startPosition - 1</span>
<span class="fc" id="L1676"> : Math.max(m.startPosition - 1, end);</span>
}
<span class="fc bfc" id="L1678" title="All 2 branches covered."> if (group.right != null) {</span>
<span class="fc bfc" id="L1679" title="All 2 branches covered."> start = start == null ? m.endPosition : Math.min(m.endPosition, start);</span>
<span class="fc bfc" id="L1680" title="All 2 branches covered."> end = end == null ? m.endPosition + group.right.length - 1</span>
<span class="fc" id="L1681"> : Math.max(m.endPosition + group.right.length - 1, end);</span>
}
<span class="fc" id="L1683"> 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="L1704"> int total = 0;</span>
<span class="nc bnc" id="L1705" title="All 2 branches missed."> if (docCounter + 1 < docSet.size()) {</span>
// initialize
<span class="nc" id="L1707"> int nextDocCounter = docCounter + 1;</span>
<span class="nc" id="L1708"> long[] subSum = new long[list.size()];</span>
<span class="nc" id="L1709"> int[] subN = new int[list.size()];</span>
<span class="nc" id="L1710"> boolean[] newNextDocs = new boolean[list.size()];</span>
boolean newNextDoc;
<span class="nc" id="L1712"> int[] spansNextDoc = new int[list.size()];</span>
<span class="nc" id="L1713"> int nextDoc = 0;</span>
List<Match> matchList;
<span class="nc" id="L1715"> GroupHit[] hitList = list.keySet().toArray(new GroupHit[list.size()]);</span>
<span class="nc" id="L1716"> Spans[] spansList = new Spans[list.size()];</span>
<span class="nc" id="L1717"> boolean[] finishedSpansList = new boolean[list.size()];</span>
<span class="nc" id="L1718"> newNextDoc = true;</span>
// advance spans, find nextDoc
<span class="nc bnc" id="L1720" title="All 2 branches missed."> for (int i = 0; i < hitList.length; i++) {</span>
<span class="nc" id="L1721"> newNextDocs[i] = true;</span>
<span class="nc" id="L1722"> spansList[i] = list.get(hitList[i]);</span>
<span class="nc" id="L1723"> spansNextDoc[i] = spansList[i]</span>
<span class="nc" id="L1724"> .advance(docSet.get(nextDocCounter) - docBase);</span>
<span class="nc bnc" id="L1725" title="All 2 branches missed."> nextDoc = (i == 0) ? spansNextDoc[i]</span>
<span class="nc" id="L1726"> : Math.min(nextDoc, spansNextDoc[i]);</span>
}
// loop over future documents
<span class="nc bnc" id="L1729" title="All 2 branches missed."> while (nextDoc < DocIdSetIterator.NO_MORE_DOCS) {</span>
// find matches for next document
<span class="nc bnc" id="L1731" title="All 2 branches missed."> while (nextDocCounter < docSet.size()</span>
<span class="nc bnc" id="L1732" title="All 2 branches missed."> && docSet.get(nextDocCounter) < (nextDoc + docBase)) {</span>
<span class="nc" id="L1733"> nextDocCounter++;</span>
}
// finish, if no more docs in set
<span class="nc bnc" id="L1736" title="All 2 branches missed."> if (nextDocCounter >= docSet.size()) {</span>
<span class="nc" id="L1737"> break;</span>
}
// go to the matches
<span class="nc bnc" id="L1740" title="All 2 branches missed."> if (docSet.get(nextDocCounter) == nextDoc + docBase) {</span>
<span class="nc" id="L1741"> matchList = matchData.get(nextDoc + docBase);</span>
<span class="nc bnc" id="L1742" title="All 4 branches missed."> if (matchList != null && !matchList.isEmpty()) {</span>
// initialize
<span class="nc" id="L1744"> int currentMatchPosition = 0;</span>
<span class="nc" id="L1745"> int lastMatchStartPosition = matchList</span>
<span class="nc" id="L1746"> .get(matchList.size() - 1).startPosition;</span>
<span class="nc" id="L1747"> ArrayList<Match> newMatchList = new ArrayList<>(matchList.size());</span>
<span class="nc" id="L1748"> int currentSpanPosition = Spans.NO_MORE_POSITIONS;</span>
// check and initialize for each span
<span class="nc bnc" id="L1750" title="All 2 branches missed."> for (int i = 0; i < spansList.length; i++) {</span>
<span class="nc bnc" id="L1751" title="All 2 branches missed."> if (spansList[i].docID() == nextDoc) {</span>
<span class="nc" id="L1752"> int tmpStartPosition = spansList[i].nextStartPosition();</span>
<span class="nc bnc" id="L1753" title="All 2 branches missed."> if (tmpStartPosition < Spans.NO_MORE_POSITIONS) {</span>
<span class="nc" id="L1754"> finishedSpansList[i] = false;</span>
} else {
<span class="nc" id="L1756"> finishedSpansList[i] = true;</span>
}
// compute position
<span class="nc bnc" id="L1759" title="All 2 branches missed."> currentSpanPosition = (currentSpanPosition == Spans.NO_MORE_POSITIONS)</span>
? tmpStartPosition
<span class="nc" id="L1761"> : Math.min(currentSpanPosition, tmpStartPosition);</span>
<span class="nc" id="L1762"> } else {</span>
<span class="nc" id="L1763"> finishedSpansList[i] = true;</span>
}
}
// loop over matches
<span class="nc bnc" id="L1767" title="All 4 branches missed."> while (currentMatchPosition < matchList.size()</span>
&& currentSpanPosition < Spans.NO_MORE_POSITIONS) {
<span class="nc" id="L1770"> if (currentSpanPosition < matchList</span>
<span class="nc bnc" id="L1771" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
// do nothing, match not reached
<span class="nc bnc" id="L1773" title="All 2 branches missed."> } else if (currentSpanPosition > lastMatchStartPosition) {</span>
// finish, past last match
<span class="nc" id="L1775"> break;</span>
} else {
// advance matches
<span class="nc bnc" id="L1778" title="All 2 branches missed."> while (currentMatchPosition < matchList.size()</span>
&& currentSpanPosition > matchList
<span class="nc bnc" id="L1780" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
// store current match, not relevant
<span class="nc" id="L1782"> newMatchList.add(matchList.get(currentMatchPosition));</span>
<span class="nc" id="L1783"> currentMatchPosition++;</span>
}
// equal startPosition
<span class="nc bnc" id="L1786" title="All 2 branches missed."> while (currentMatchPosition < matchList.size()</span>
&& currentSpanPosition == matchList
<span class="nc bnc" id="L1788" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
// check for each span
<span class="nc bnc" id="L1790" 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="L1792" title="All 4 branches missed."> if (!finishedSpansList[i] && spansList[i].docID() == nextDoc</span>
<span class="nc" id="L1793"> && spansList[i].startPosition() == matchList</span>
<span class="nc bnc" id="L1794" title="All 2 branches missed."> .get(currentMatchPosition).startPosition</span>
<span class="nc" id="L1795"> && spansList[i].endPosition() == matchList</span>
<span class="nc bnc" id="L1796" title="All 2 branches missed."> .get(currentMatchPosition).endPosition) {</span>
// administration
<span class="nc" id="L1798"> total++;</span>
<span class="nc" id="L1799"> subSum[i]++;</span>
<span class="nc bnc" id="L1800" title="All 2 branches missed."> if (newNextDocs[i]) {</span>
<span class="nc" id="L1801"> subN[i]++;</span>
<span class="nc" id="L1802"> newNextDocs[i] = false;</span>
<span class="nc" id="L1803"> newNextDoc = false;</span>
}
<span class="nc bnc" id="L1805" title="All 2 branches missed."> } else if (!finishedSpansList[i]</span>
<span class="nc bnc" id="L1806" title="All 2 branches missed."> && spansList[i].docID() == nextDoc</span>
<span class="nc" id="L1807"> && spansList[i].startPosition() == matchList</span>
<span class="nc bnc" id="L1808" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
// no match, store
<span class="nc" id="L1810"> newMatchList.add(matchList.get(currentMatchPosition));</span>
}
}
<span class="nc" id="L1813"> currentMatchPosition++;</span>
}
}
// advance spans
<span class="nc bnc" id="L1818" title="All 2 branches missed."> if (currentMatchPosition < matchList.size()) {</span>
<span class="nc" id="L1819"> currentSpanPosition = Spans.NO_MORE_POSITIONS;</span>
<span class="nc bnc" id="L1820" title="All 2 branches missed."> for (int i = 0; i < spansList.length; i++) {</span>
<span class="nc bnc" id="L1821" title="All 2 branches missed."> if (!finishedSpansList[i]</span>
<span class="nc bnc" id="L1822" title="All 2 branches missed."> && (spansList[i].docID() == nextDoc)) {</span>
<span class="nc bnc" id="L1823" title="All 2 branches missed."> while (!finishedSpansList[i]</span>
<span class="nc" id="L1824"> && spansList[i].startPosition() < matchList</span>
<span class="nc bnc" id="L1825" title="All 2 branches missed."> .get(currentMatchPosition).startPosition) {</span>
<span class="nc" id="L1826"> int tmpStartPosition = spansList[i].nextStartPosition();</span>
<span class="nc bnc" id="L1827" title="All 2 branches missed."> if (tmpStartPosition == Spans.NO_MORE_POSITIONS) {</span>
<span class="nc" id="L1828"> finishedSpansList[i] = true;</span>
}
<span class="nc" id="L1830"> }</span>
<span class="nc bnc" id="L1831" title="All 2 branches missed."> if (!finishedSpansList[i]) {</span>
<span class="nc bnc" id="L1832" title="All 2 branches missed."> currentSpanPosition = (currentSpanPosition == Spans.NO_MORE_POSITIONS)</span>
<span class="nc" id="L1833"> ? spansList[i].startPosition()</span>
<span class="nc" id="L1834"> : Math.min(currentSpanPosition,</span>
<span class="nc" id="L1835"> spansList[i].startPosition());</span>
}
} else {
<span class="nc" id="L1838"> finishedSpansList[i] = true;</span>
}
}
}
}
<span class="nc bnc" id="L1843" title="All 2 branches missed."> if (!newNextDoc) {</span>
// add other matches
<span class="nc bnc" id="L1845" title="All 2 branches missed."> while (currentMatchPosition < matchList.size()) {</span>
<span class="nc" id="L1846"> newMatchList.add(matchList.get(currentMatchPosition));</span>
<span class="nc" id="L1847"> currentMatchPosition++;</span>
}
// update administration
<span class="nc bnc" id="L1850" title="All 2 branches missed."> if (!newMatchList.isEmpty()) {</span>
<span class="nc" id="L1851"> matchData.put(nextDoc + docBase, newMatchList);</span>
} else {
<span class="nc" id="L1853"> matchData.put(nextDoc + docBase, null);</span>
}
}
}
}
// advance to next document
<span class="nc" id="L1859"> nextDocCounter++;</span>
<span class="nc" id="L1860"> newNextDoc = true;</span>
<span class="nc bnc" id="L1861" title="All 2 branches missed."> for (int i = 0; i < hitList.length; i++) {</span>
<span class="nc" id="L1862"> newNextDocs[i] = true;</span>
}
// advance spans
<span class="nc bnc" id="L1865" title="All 2 branches missed."> if (nextDocCounter < docSet.size()) {</span>
<span class="nc" id="L1866"> nextDoc = Spans.NO_MORE_DOCS;</span>
// advance spans
<span class="nc bnc" id="L1868" title="All 2 branches missed."> for (int i = 0; i < hitList.length; i++) {</span>
<span class="nc bnc" id="L1869" title="All 2 branches missed."> if (spansNextDoc[i] < (docSet.get(nextDocCounter) - docBase)) {</span>
<span class="nc" id="L1870"> spansNextDoc[i] = spansList[i]</span>
<span class="nc" id="L1871"> .advance(docSet.get(nextDocCounter) - docBase);</span>
}
<span class="nc bnc" id="L1873" title="All 2 branches missed."> if (spansNextDoc[i] < Spans.NO_MORE_DOCS) {</span>
<span class="nc bnc" id="L1874" title="All 2 branches missed."> nextDoc = (nextDoc == Spans.NO_MORE_DOCS) ? spansNextDoc[i]</span>
<span class="nc" id="L1875"> : Math.min(nextDoc, spansNextDoc[i]);</span>
}
}
}
}
// update administration
<span class="nc bnc" id="L1881" title="All 2 branches missed."> for (int i = 0; i < hitList.length; i++) {</span>
<span class="nc bnc" id="L1882" title="All 4 branches missed."> if (subSum[i] > 0 && (occurencesSum.containsKey(hitList[i]))) {</span>
<span class="nc" id="L1883"> occurencesSum.put(hitList[i],</span>
<span class="nc" id="L1884"> occurencesSum.get(hitList[i]) + subSum[i]);</span>
<span class="nc" id="L1885"> occurencesN.put(hitList[i], occurencesN.get(hitList[i]) + subN[i]);</span>
}
}
}
<span class="nc" id="L1890"> return total;</span>
}
/**
* Sort match list.
*
* @param list the list
*/
private static void sortMatchList(List<Match> list) {
<span class="pc bpc" id="L1899" title="1 of 2 branches missed."> if (list != null) {</span>
// light sorting on start position
<span class="fc" id="L1901"> Collections.sort(list, (Match m1,</span>
<span class="fc" id="L1902"> Match m2) -> (Integer.compare(m1.startPosition, m2.startPosition)));</span>
}
<span class="fc" id="L1904"> }</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="L1920" title="All 2 branches missed."> if (documentList != null) {</span>
<span class="nc" id="L1921"> SortedSet<String> listStatsItems = CodecUtil.createStatsItems("sum");</span>
<span class="nc" id="L1922"> String listStatsType = CodecUtil.createStatsType(listStatsItems,</span>
CodecUtil.STATS_TYPE_SUM, null);
<span class="nc bnc" id="L1924" title="All 2 branches missed."> for (ComponentDocument document : documentList) {</span>
// initialize
<span class="nc bnc" id="L1926" title="All 2 branches missed."> for (int docId : docList) {</span>
// get unique id
<span class="nc" id="L1928"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L1929"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
<span class="nc" id="L1930"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
// get other doc info
<span class="nc bnc" id="L1932" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L1933"> document.uniqueKey.put(docId, indxfld.stringValue());</span>
<span class="nc" id="L1934"> 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="L1938"> document.statsData.put(docId, stats);</span>
<span class="nc bnc" id="L1939" title="All 2 branches missed."> if (document.statsList != null) {</span>
MtasDataCollector<?, ?> list;
<span class="nc bnc" id="L1941" title="All 2 branches missed."> if (document.listExpand) {</span>
<span class="nc" id="L1942"> SortedSet<String>[] baseStatsItems = new SortedSet[] {</span>
listStatsItems };
<span class="nc" id="L1944"> list = DataCollector.getCollector(</span>
DataCollector.COLLECTOR_TYPE_LIST, CodecUtil.DATA_TYPE_LONG,
listStatsType, listStatsItems, CodecUtil.STATS_TYPE_SUM,
<span class="nc" id="L1947"> 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="L1951"> Arrays.copyOfRange(baseStatsItems, 0,</span>
baseStatsItems.length),
new String[] { CodecUtil.STATS_TYPE_SUM },
<span class="nc" id="L1954"> new String[] { CodecUtil.SORT_DESC }, new Integer[] { 0 },</span>
<span class="nc" id="L1955"> new Integer[] { document.listExpandNumber }, null, null);</span>
<span class="nc" id="L1956"> } else {</span>
<span class="nc" id="L1957"> list = DataCollector.getCollector(</span>
DataCollector.COLLECTOR_TYPE_LIST, CodecUtil.DATA_TYPE_LONG,
listStatsType, listStatsItems, CodecUtil.STATS_TYPE_SUM,
<span class="nc" id="L1960"> CodecUtil.SORT_DESC, 0, document.listNumber, null, null);</span>
}
<span class="nc" id="L1962"> document.statsList.put(docId, list);</span>
}
}
<span class="nc" id="L1965"> }</span>
<span class="nc" id="L1966"> }</span>
// collect
<span class="nc bnc" id="L1968" title="All 2 branches missed."> if (t != null) {</span>
BytesRef term;
TermsEnum termsEnum;
<span class="nc" id="L1971"> PostingsEnum postingsEnum = null;</span>
// loop over termvectors
<span class="nc bnc" id="L1973" 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="L1978" title="All 2 branches missed."> if (document.list == null) {</span>
<span class="nc" id="L1979"> automatonMap = null;</span>
<span class="nc" id="L1980"> byteRunAutomatonMap = null;</span>
<span class="nc" id="L1981"> listAutomata = new ArrayList<>();</span>
CompiledAutomaton compiledAutomaton;
Automaton automaton;
<span class="nc bnc" id="L1984" title="All 4 branches missed."> if ((document.regexp == null) || (document.regexp.isEmpty())) {</span>
<span class="nc" id="L1985"> RegExp re = new RegExp(</span>
document.prefix + MtasToken.DELIMITER + ".*");
<span class="nc" id="L1987"> automaton = re.toAutomaton();</span>
<span class="nc" id="L1988"> } else {</span>
<span class="nc" id="L1989"> RegExp re = new RegExp(document.prefix + MtasToken.DELIMITER</span>
+ document.regexp + "\u0000*");
<span class="nc" id="L1991"> automaton = re.toAutomaton();</span>
}
<span class="nc" id="L1993"> compiledAutomaton = new CompiledAutomaton(automaton);</span>
<span class="nc" id="L1994"> listAutomata.add(compiledAutomaton);</span>
<span class="nc" id="L1995"> } else {</span>
<span class="nc bnc" id="L1996" title="All 2 branches missed."> automatonMap = MtasToken.createAutomatonMap(document.prefix,</span>
new ArrayList<String>(document.list),
<span class="nc" id="L1998"> document.listRegexp ? false : true);</span>
<span class="nc" id="L1999"> byteRunAutomatonMap = MtasToken.byteRunAutomatonMap(automatonMap);</span>
<span class="nc" id="L2000"> listAutomata = MtasToken.createAutomata(document.prefix,</span>
document.regexp, automatonMap);
}
<span class="nc" id="L2003"> List<ByteRunAutomaton> ignoreByteRunAutomatonList = null;</span>
<span class="nc bnc" id="L2004" title="All 2 branches missed."> if ((document.ignoreRegexp != null)</span>
<span class="nc bnc" id="L2005" title="All 2 branches missed."> && (!document.ignoreRegexp.isEmpty())) {</span>
<span class="nc" id="L2006"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
<span class="nc" id="L2007"> RegExp re = new RegExp(document.prefix + MtasToken.DELIMITER</span>
+ document.ignoreRegexp + "\u0000*");
<span class="nc" id="L2009"> ignoreByteRunAutomatonList</span>
<span class="nc" id="L2010"> .add(new ByteRunAutomaton(re.toAutomaton()));</span>
}
<span class="nc bnc" id="L2012" title="All 2 branches missed."> if (document.ignoreList != null) {</span>
<span class="nc bnc" id="L2013" title="All 2 branches missed."> if (ignoreByteRunAutomatonList == null) {</span>
<span class="nc" id="L2014"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
}
<span class="nc bnc" id="L2016" title="All 2 branches missed."> Map<String, Automaton> list = MtasToken.createAutomatonMap(</span>
document.prefix, new ArrayList<String>(document.ignoreList),
<span class="nc" id="L2018"> document.ignoreListRegexp ? false : true);</span>
<span class="nc bnc" id="L2019" title="All 2 branches missed."> for (Automaton automaton : list.values()) {</span>
<span class="nc" id="L2020"> ignoreByteRunAutomatonList.add(new ByteRunAutomaton(automaton));</span>
<span class="nc" id="L2021"> }</span>
}
<span class="nc bnc" id="L2024" title="All 2 branches missed."> for (CompiledAutomaton compiledAutomaton : listAutomata) {</span>
<span class="nc" id="L2025"> if (!compiledAutomaton.type</span>
<span class="nc bnc" id="L2026" title="All 2 branches missed."> .equals(CompiledAutomaton.AUTOMATON_TYPE.NONE)) {</span>
<span class="nc" id="L2027"> termsEnum = t.intersect(compiledAutomaton, null);</span>
// init
<span class="nc" id="L2029"> int initBaseSize = Math.min((int) t.size(), 1000);</span>
<span class="nc bnc" id="L2030" title="All 2 branches missed."> int initListSize = document.statsList != null</span>
<span class="nc" id="L2031"> ? Math.min(document.statsList.size(), initBaseSize)</span>
: initBaseSize;
<span class="nc" id="L2033"> HashSet<MtasDataCollector<?, ?>> initialised = new HashSet<>();</span>
<span class="nc bnc" id="L2034" title="All 2 branches missed."> for (int docId : docList) {</span>
<span class="nc" id="L2035"> document.statsData.get(docId).initNewList(1);</span>
<span class="nc" id="L2036"> initialised.add(document.statsData.get(docId));</span>
<span class="nc bnc" id="L2037" title="All 2 branches missed."> if (document.statsList != null</span>
<span class="nc bnc" id="L2038" title="All 2 branches missed."> && document.statsList.size() > 0) {</span>
<span class="nc" id="L2039"> document.statsList.get(docId).initNewList(initListSize);</span>
<span class="nc" id="L2040"> initialised.add(document.statsList.get(docId));</span>
}
<span class="nc" id="L2042"> }</span>
// fill
int termDocId;
boolean acceptedTerm;
<span class="nc bnc" id="L2046" title="All 2 branches missed."> while ((term = termsEnum.next()) != null) {</span>
<span class="nc" id="L2047"> Iterator<Integer> docIterator = docList.iterator();</span>
<span class="nc" id="L2048"> postingsEnum = termsEnum.postings(postingsEnum,</span>
PostingsEnum.FREQS);
<span class="nc" id="L2050"> termDocId = -1;</span>
<span class="nc" id="L2051"> acceptedTerm = true;</span>
<span class="nc bnc" id="L2052" title="All 2 branches missed."> if (ignoreByteRunAutomatonList != null) {</span>
<span class="nc bnc" id="L2053" title="All 2 branches missed."> for (ByteRunAutomaton ignoreByteRunAutomaton : ignoreByteRunAutomatonList) {</span>
<span class="nc bnc" id="L2054" title="All 2 branches missed."> if (ignoreByteRunAutomaton.run(term.bytes, term.offset,</span>
term.length)) {
<span class="nc" id="L2056"> acceptedTerm = false;</span>
<span class="nc" id="L2057"> break;</span>
}
<span class="nc" id="L2059"> }</span>
}
<span class="nc bnc" id="L2061" title="All 2 branches missed."> if (acceptedTerm) {</span>
<span class="nc bnc" id="L2062" title="All 2 branches missed."> while (docIterator.hasNext()) {</span>
<span class="nc" id="L2063"> int segmentDocId = docIterator.next() - lrc.docBase;</span>
<span class="nc bnc" id="L2064" title="All 4 branches missed."> if (segmentDocId >= termDocId</span>
&& ((segmentDocId == termDocId)
|| ((termDocId = postingsEnum
<span class="nc bnc" id="L2067" title="All 2 branches missed."> .advance(segmentDocId)) == segmentDocId))) {</span>
// register stats
<span class="nc" id="L2069"> document.statsData.get(segmentDocId + lrc.docBase)</span>
<span class="nc" id="L2070"> .add(new long[] { postingsEnum.freq() }, 1);</span>
// register list
<span class="nc bnc" id="L2072" title="All 2 branches missed."> if (document.statsList != null) {</span>
<span class="nc bnc" id="L2073" title="All 2 branches missed."> if (automatonMap != null) {</span>
MtasDataCollector<?, ?> dataCollector;
MtasDataCollector<?, ?> subSataCollector;
<span class="nc bnc" id="L2076" title="All 2 branches missed."> for (Entry<String, ByteRunAutomaton> entry : byteRunAutomatonMap</span>
<span class="nc" id="L2077"> .entrySet()) {</span>
<span class="nc" id="L2078"> ByteRunAutomaton bra = entry.getValue();</span>
<span class="nc bnc" id="L2079" title="All 2 branches missed."> if (bra.run(term.bytes, term.offset, term.length)) {</span>
<span class="nc" id="L2080"> dataCollector = document.statsList</span>
<span class="nc" id="L2081"> .get(segmentDocId + lrc.docBase);</span>
<span class="nc" id="L2082"> subSataCollector = dataCollector.add(</span>
<span class="nc" id="L2083"> entry.getKey(),</span>
<span class="nc" id="L2084"> new long[] { postingsEnum.freq() }, 1);</span>
<span class="nc bnc" id="L2085" title="All 4 branches missed."> if (document.listExpand</span>
&& subSataCollector != null) {
<span class="nc bnc" id="L2087" title="All 2 branches missed."> if (!initialised.contains(subSataCollector)) {</span>
<span class="nc" id="L2088"> subSataCollector.initNewList(initBaseSize);</span>
<span class="nc" id="L2089"> initialised.add(subSataCollector);</span>
}
<span class="nc" id="L2091"> subSataCollector.add(</span>
<span class="nc" id="L2092"> MtasToken.getPostfixFromValue(term),</span>
<span class="nc" id="L2093"> new long[] { postingsEnum.freq() }, 1);</span>
}
}
<span class="nc" id="L2096"> }</span>
} else {
<span class="nc" id="L2098"> document.statsList.get(segmentDocId + lrc.docBase)</span>
<span class="nc" id="L2099"> .add(MtasToken.getPostfixFromValue(term),</span>
<span class="nc" id="L2100"> new long[] { postingsEnum.freq() }, 1);</span>
}
}
}
<span class="nc" id="L2104"> }</span>
}
<span class="nc" id="L2106"> }</span>
// close
<span class="nc bnc" id="L2108" title="All 2 branches missed."> for (MtasDataCollector<?, ?> item : initialised) {</span>
<span class="nc" id="L2109"> item.closeNewList();</span>
<span class="nc" id="L2110"> }</span>
<span class="nc" id="L2111"> initialised.clear();</span>
}
<span class="nc" id="L2113"> }</span>
<span class="nc" id="L2114"> }</span>
}
}
<span class="nc" id="L2117"> }</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="L2136" title="All 2 branches missed."> if (kwicList != null) {</span>
<span class="nc bnc" id="L2137" title="All 2 branches missed."> for (ComponentKwic kwic : kwicList) {</span>
<span class="nc" id="L2138"> Map<Integer, List<Match>> matchData = spansMatchData.get(kwic.query);</span>
List<Match> matchList;
<span class="nc bnc" id="L2140" title="All 2 branches missed."> if (kwic.output.equals(ComponentKwic.KWIC_OUTPUT_HIT)) {</span>
<span class="nc bnc" id="L2141" title="All 2 branches missed."> for (int docId : docList) {</span>
<span class="nc bnc" id="L2142" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L2143" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null) {</span>
// get unique id
<span class="nc" id="L2145"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L2146"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
<span class="nc" id="L2147"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
// get other doc info
<span class="nc bnc" id="L2149" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L2150"> kwic.uniqueKey.put(docId, indxfld.stringValue());</span>
}
<span class="nc" id="L2152"> kwic.subTotal.put(docId, matchList.size());</span>
<span class="nc" id="L2153"> IndexDoc mDoc = mtasCodecInfo.getDoc(field, (docId - docBase));</span>
<span class="nc bnc" id="L2154" title="All 2 branches missed."> if (mDoc != null) {</span>
<span class="nc" id="L2155"> kwic.minPosition.put(docId, mDoc.minPosition);</span>
<span class="nc" id="L2156"> kwic.maxPosition.put(docId, mDoc.maxPosition);</span>
}
// kwiclist
<span class="nc" id="L2159"> List<KwicHit> kwicItemList = new ArrayList<>();</span>
<span class="nc" id="L2160"> int number = 0;</span>
<span class="nc bnc" id="L2161" title="All 2 branches missed."> for (Match m : matchList) {</span>
<span class="nc bnc" id="L2162" title="All 2 branches missed."> if (kwic.number != null</span>
<span class="nc bnc" id="L2163" title="All 2 branches missed."> && number >= (kwic.start + kwic.number)) {</span>
<span class="nc" id="L2164"> break;</span>
}
<span class="nc bnc" id="L2166" title="All 2 branches missed."> if (number >= kwic.start) {</span>
<span class="nc" id="L2167"> int startPosition = m.startPosition;</span>
<span class="nc" id="L2168"> int endPosition = m.endPosition - 1;</span>
<span class="nc" id="L2169"> List<MtasTreeHit<String>> terms = mtasCodecInfo</span>
<span class="nc" id="L2170"> .getPositionedTermsByPrefixesAndPositionRange(field,</span>
(docId - docBase), kwic.prefixes,
<span class="nc" id="L2172"> Math.max(mDoc.minPosition, startPosition - kwic.left),</span>
<span class="nc" id="L2173"> Math.min(mDoc.maxPosition, endPosition + kwic.right));</span>
// construct hit
<span class="nc" id="L2175"> Map<Integer, List<String>> kwicListHits = new HashMap<>();</span>
<span class="nc" id="L2176"> for (int position = Math.max(mDoc.minPosition,</span>
<span class="nc bnc" id="L2177" title="All 2 branches missed."> startPosition - kwic.left); position <= Math.min(</span>
mDoc.maxPosition,
<span class="nc" id="L2179"> endPosition + kwic.right); position++) {</span>
<span class="nc" id="L2180"> kwicListHits.put(position, new ArrayList<String>());</span>
}
List<String> termList;
<span class="nc bnc" id="L2183" title="All 2 branches missed."> for (MtasTreeHit<String> term : terms) {</span>
<span class="nc" id="L2184"> for (int position = Math.max((startPosition - kwic.left),</span>
<span class="nc bnc" id="L2185" title="All 2 branches missed."> term.startPosition); position <= Math.min(</span>
(endPosition + kwic.right),
<span class="nc" id="L2187"> term.endPosition); position++) {</span>
<span class="nc" id="L2188"> termList = kwicListHits.get(position);</span>
<span class="nc" id="L2189"> termList.add(term.data);</span>
}
<span class="nc" id="L2191"> }</span>
<span class="nc" id="L2192"> kwicItemList.add(new KwicHit(m, kwicListHits));</span>
}
<span class="nc" id="L2194"> number++;</span>
<span class="nc" id="L2195"> }</span>
<span class="nc" id="L2196"> kwic.hits.put(docId, kwicItemList);</span>
}
<span class="nc" id="L2198"> }</span>
<span class="nc bnc" id="L2199" title="All 2 branches missed."> } else if (kwic.output.equals(ComponentKwic.KWIC_OUTPUT_TOKEN)) {</span>
<span class="nc bnc" id="L2200" title="All 2 branches missed."> for (int docId : docList) {</span>
<span class="nc bnc" id="L2201" title="All 2 branches missed."> if (matchData != null</span>
<span class="nc bnc" id="L2202" title="All 2 branches missed."> && (matchList = matchData.get(docId)) != null) {</span>
// get unique id
<span class="nc" id="L2204"> Document doc = searcher.doc(docId,</span>
<span class="nc" id="L2205"> new HashSet<String>(Arrays.asList(uniqueKeyField)));</span>
// get other doc info
<span class="nc" id="L2207"> IndexableField indxfld = doc.getField(uniqueKeyField);</span>
<span class="nc bnc" id="L2208" title="All 2 branches missed."> if (indxfld != null) {</span>
<span class="nc" id="L2209"> kwic.uniqueKey.put(docId, indxfld.stringValue());</span>
}
<span class="nc" id="L2211"> kwic.subTotal.put(docId, matchList.size());</span>
<span class="nc" id="L2212"> IndexDoc mDoc = mtasCodecInfo.getDoc(field, (docId - docBase));</span>
<span class="nc bnc" id="L2213" title="All 2 branches missed."> if (mDoc != null) {</span>
<span class="nc" id="L2214"> kwic.minPosition.put(docId, mDoc.minPosition);</span>
<span class="nc" id="L2215"> kwic.maxPosition.put(docId, mDoc.maxPosition);</span>
<span class="nc" id="L2216"> List<KwicToken> kwicItemList = new ArrayList<>();</span>
<span class="nc" id="L2217"> int number = 0;</span>
<span class="nc bnc" id="L2218" title="All 2 branches missed."> for (Match m : matchList) {</span>
<span class="nc bnc" id="L2219" title="All 2 branches missed."> if (kwic.number != null</span>
<span class="nc bnc" id="L2220" title="All 2 branches missed."> && number >= (kwic.start + kwic.number)) {</span>
<span class="nc" id="L2221"> break;</span>
}
<span class="nc bnc" id="L2223" title="All 2 branches missed."> if (number >= kwic.start) {</span>
<span class="nc" id="L2224"> int startPosition = m.startPosition;</span>
<span class="nc" id="L2225"> int endPosition = m.endPosition - 1;</span>
List<MtasTokenString> tokens;
<span class="nc" id="L2227"> tokens = mtasCodecInfo.getPrefixFilteredObjectsByPositions(</span>
field, (docId - docBase), kwic.prefixes,
<span class="nc" id="L2229"> Math.max(mDoc.minPosition, startPosition - kwic.left),</span>
<span class="nc" id="L2230"> Math.min(mDoc.maxPosition, endPosition + kwic.right));</span>
<span class="nc" id="L2231"> kwicItemList.add(new KwicToken(m, tokens));</span>
}
<span class="nc" id="L2233"> number++;</span>
<span class="nc" id="L2234"> }</span>
<span class="nc" id="L2235"> kwic.tokens.put(docId, kwicItemList);</span>
}
}
<span class="nc" id="L2238"> }</span>
}
<span class="nc" id="L2240"> }</span>
}
<span class="nc" id="L2242"> }</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="L2262" title="All 2 branches missed."> for (MtasFunctionParserFunction function : cf.baseFunctionParserFunctions[level]) {</span>
<span class="nc bnc" id="L2263" title="All 2 branches missed."> if (function.needArgumentsNumber() > cf.spanQueries.length) {</span>
<span class="nc" id="L2264"> throw new IOException("function " + function + " expects (at least) "</span>
<span class="nc" id="L2265"> + function.needArgumentsNumber() + " queries");</span>
}
}
<span class="nc" id="L2268"> Map<String, int[]> list = facetData.get(cf.baseFields[level]);</span>
<span class="nc bnc" id="L2269" title="All 2 branches missed."> if (dataCollector != null) {</span>
<span class="nc" id="L2270"> MtasDataCollector<?, ?> subDataCollector = null;</span>
<span class="nc" id="L2271"> dataCollector.initNewList(1);</span>
<span class="nc bnc" id="L2272" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null) {</span>
SubComponentFunction[] tmpList;
<span class="nc bnc" id="L2274" title="All 2 branches missed."> if (!cf.baseFunctionList[level].containsKey(dataCollector)) {</span>
<span class="nc" id="L2275"> tmpList = new SubComponentFunction[cf.baseFunctionParserFunctions[level].length];</span>
<span class="nc" id="L2276"> cf.baseFunctionList[level].put(dataCollector, tmpList);</span>
<span class="nc bnc" id="L2277" title="All 2 branches missed."> for (int i = 0; i < cf.baseFunctionParserFunctions[level].length; i++) {</span>
try {
<span class="nc" id="L2279"> tmpList[i] = new SubComponentFunction(</span>
DataCollector.COLLECTOR_TYPE_LIST,
cf.baseFunctionKeys[level][i], cf.baseFunctionTypes[level][i],
<span class="nc" id="L2282"> cf.baseFunctionParserFunctions[level][i], null, null, 0,</span>
<span class="nc" id="L2283"> Integer.MAX_VALUE, null, null);</span>
<span class="nc" id="L2285"> } catch (ParseException e) {</span>
<span class="nc" id="L2286"> throw new IOException(e.getMessage());</span>
<span class="nc" id="L2287"> }</span>
}
} else {
<span class="nc" id="L2290"> tmpList = cf.baseFunctionList[level].get(dataCollector);</span>
}
<span class="nc bnc" id="L2292" title="All 2 branches missed."> for (SubComponentFunction function : tmpList) {</span>
<span class="nc" id="L2293"> function.dataCollector.initNewList(1);</span>
}
}
// check type
<span class="nc" id="L2297"> if (dataCollector.getCollectorType()</span>
<span class="nc bnc" id="L2298" title="All 2 branches missed."> .equals(DataCollector.COLLECTOR_TYPE_LIST)) {</span>
<span class="nc" id="L2299"> dataCollector.setWithTotal();</span>
// only if documents and facets
<span class="nc bnc" id="L2301" title="All 4 branches missed."> if (docSet.length > 0 && list.size() > 0) {</span>
<span class="nc" id="L2302"> HashMap<String, Integer[]> docLists = new HashMap<>();</span>
<span class="nc" id="L2303"> HashMap<String, String> groupedKeys = new HashMap<>();</span>
<span class="nc" id="L2304"> boolean documentsInFacets = false;</span>
// compute intersections
<span class="nc bnc" id="L2306" title="All 2 branches missed."> for (Entry<String, int[]> entry : list.entrySet()) {</span>
// fill grouped keys
<span class="nc bnc" id="L2308" title="All 2 branches missed."> if (!groupedKeys.containsKey(entry.getKey())) {</span>
<span class="nc" id="L2309"> groupedKeys.put(entry.getKey(), groupedKeyName(entry.getKey(),</span>
cf.baseRangeSizes[level], cf.baseRangeBases[level]));
}
// intersect docSet with docList
<span class="nc" id="L2313"> Integer[] docList = intersectedDocList(entry.getValue(), docSet);</span>
<span class="nc bnc" id="L2314" title="All 4 branches missed."> if (docList != null && docList.length > 0) {</span>
<span class="nc" id="L2315"> documentsInFacets = true;</span>
}
// update docLists
<span class="nc bnc" id="L2318" title="All 2 branches missed."> if (docLists.containsKey(groupedKeys.get(entry.getKey()))) {</span>
<span class="nc" id="L2319"> docLists.put(groupedKeys.get(entry.getKey()), mergeDocLists(</span>
<span class="nc" id="L2320"> docLists.get(groupedKeys.get(entry.getKey())), docList));</span>
} else {
<span class="nc" id="L2322"> docLists.put(groupedKeys.get(entry.getKey()), docList);</span>
}
<span class="nc" id="L2324"> }</span>
// compute stats for each key
<span class="nc bnc" id="L2326" title="All 2 branches missed."> if (documentsInFacets) {</span>
<span class="nc" id="L2327"> Map<Integer, long[]> args = computeArguments(spansNumberData,</span>
cf.spanQueries, docSet);
<span class="nc bnc" id="L2329" title="All 2 branches missed."> if (cf.baseDataTypes[level].equals(CodecUtil.DATA_TYPE_LONG)) {</span>
// check functions
<span class="nc" id="L2331"> boolean applySumRule = false;</span>
<span class="nc bnc" id="L2332" title="All 2 branches missed."> if (cf.baseStatsTypes[level].equals(CodecUtil.STATS_BASIC)</span>
<span class="nc bnc" id="L2333" title="All 6 branches missed."> && cf.baseParsers[level].sumRule()</span>
&& (cf.baseMinimumLongs[level] == null)
&& (cf.baseMaximumLongs[level] == null)) {
<span class="nc" id="L2336"> applySumRule = true;</span>
<span class="nc bnc" id="L2337" title="All 2 branches missed."> if (cf.baseFunctionList[level].get(dataCollector) != null) {</span>
for (SubComponentFunction function : cf.baseFunctionList[level]
<span class="nc bnc" id="L2339" title="All 2 branches missed."> .get(dataCollector)) {</span>
<span class="nc bnc" id="L2340" title="All 2 branches missed."> if (!function.statsType.equals(CodecUtil.STATS_BASIC)</span>
<span class="nc bnc" id="L2341" title="All 2 branches missed."> || !function.parserFunction.sumRule()</span>
<span class="nc bnc" id="L2342" title="All 2 branches missed."> || function.parserFunction.needPositions()) {</span>
<span class="nc" id="L2343"> applySumRule = false;</span>
<span class="nc" id="L2344"> break;</span>
}
}
}
}
<span class="nc bnc" id="L2349" title="All 2 branches missed."> if (applySumRule) {</span>
<span class="nc bnc" id="L2350" title="All 2 branches missed."> for (String key : new LinkedHashSet<String>(</span>
<span class="nc" id="L2351"> groupedKeys.values())) {</span>
<span class="nc bnc" id="L2352" title="All 2 branches missed."> if (docLists.get(key).length > 0) {</span>
// initialise
<span class="nc" id="L2354"> Integer[] subDocSet = docLists.get(key);</span>
<span class="nc" id="L2355"> int length = cf.baseParsers[level].needArgumentsNumber();</span>
<span class="nc" id="L2356"> long[] valueSum = new long[length];</span>
<span class="nc" id="L2357"> long valuePositions = 0;</span>
// collect
<span class="nc bnc" id="L2359" title="All 2 branches missed."> if (subDocSet.length > 0) {</span>
long[] tmpArgs;
<span class="nc bnc" id="L2361" title="All 2 branches missed."> for (int docId : subDocSet) {</span>
<span class="nc" id="L2362"> tmpArgs = args.get(docId);</span>
<span class="nc bnc" id="L2363" title="All 2 branches missed."> if (positionsData != null</span>
<span class="nc bnc" id="L2364" title="All 2 branches missed."> && positionsData.containsKey(docId)</span>
<span class="nc bnc" id="L2365" title="All 2 branches missed."> && positionsData.get(docId) != null) {</span>
<span class="nc" id="L2366"> valuePositions += positionsData.get(docId)</span>
<span class="nc" id="L2367"> .longValue();</span>
}
<span class="nc bnc" id="L2369" title="All 2 branches missed."> if (tmpArgs != null) {</span>
<span class="nc bnc" id="L2370" title="All 2 branches missed."> for (int i = 0; i < length; i++) {</span>
<span class="nc" id="L2371"> valueSum[i] += tmpArgs[i];</span>
}
}
}
long value;
try {
<span class="nc" id="L2377"> value = cf.baseParsers[level].getValueLong(valueSum,</span>
valuePositions);
<span class="nc" id="L2379"> subDataCollector = dataCollector.add(key, value,</span>
subDocSet.length);
<span class="nc" id="L2381"> } catch (IOException e) {</span>
<span class="nc" id="L2382"> log.debug(e);</span>
<span class="nc" id="L2383"> dataCollector.error(key, e.getMessage());</span>
<span class="nc" id="L2384"> subDataCollector = null;</span>
<span class="nc" id="L2385"> }</span>
<span class="nc bnc" id="L2386" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null</span>
&& cf.baseFunctionList[level]
<span class="nc bnc" id="L2388" title="All 2 branches missed."> .containsKey(dataCollector)) {</span>
<span class="nc" id="L2389"> SubComponentFunction[] functionList = cf.baseFunctionList[level]</span>
<span class="nc" id="L2390"> .get(dataCollector);</span>
<span class="nc bnc" id="L2391" title="All 2 branches missed."> for (SubComponentFunction function : functionList) {</span>
<span class="nc" id="L2392"> if (function.dataType</span>
<span class="nc bnc" id="L2393" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
try {
<span class="nc" id="L2395"> long valueLong = function.parserFunction</span>
<span class="nc" id="L2396"> .getValueLong(valueSum, valuePositions);</span>
<span class="nc" id="L2397"> function.dataCollector.add(key, valueLong,</span>
subDocSet.length);
<span class="nc" id="L2399"> } catch (IOException e) {</span>
<span class="nc" id="L2400"> log.debug(e);</span>
<span class="nc" id="L2401"> function.dataCollector.error(key, e.getMessage());</span>
<span class="nc" id="L2402"> }</span>
<span class="nc" id="L2403"> } else if (function.dataType</span>
<span class="nc bnc" id="L2404" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
try {
<span class="nc" id="L2406"> double valueDouble = function.parserFunction</span>
<span class="nc" id="L2407"> .getValueDouble(valueSum, valuePositions);</span>
<span class="nc" id="L2408"> function.dataCollector.add(key, valueDouble,</span>
subDocSet.length);
<span class="nc" id="L2410"> } catch (IOException e) {</span>
<span class="nc" id="L2411"> log.debug(e);</span>
<span class="nc" id="L2412"> function.dataCollector.error(key, e.getMessage());</span>
<span class="nc" id="L2413"> }</span>
}
}
}
<span class="nc bnc" id="L2417" title="All 2 branches missed."> if (subDataCollector != null) {</span>
<span class="nc" id="L2418"> createFacetBase(cf, (level + 1), subDataCollector,</span>
positionsData, spansNumberData, facetData,
subDocSet);
}
}
}
<span class="nc" id="L2424"> }</span>
} else {
<span class="nc bnc" id="L2426" title="All 2 branches missed."> for (String key : new LinkedHashSet<String>(</span>
<span class="nc" id="L2427"> groupedKeys.values())) {</span>
<span class="nc bnc" id="L2428" title="All 2 branches missed."> if (docLists.get(key).length > 0) {</span>
// initialise
<span class="nc" id="L2430"> Integer[] subDocSet = docLists.get(key);</span>
// collect
<span class="nc bnc" id="L2432" title="All 2 branches missed."> if (subDocSet.length > 0 && cf.baseDataTypes[level]</span>
<span class="nc bnc" id="L2433" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
// check for functions
<span class="nc" id="L2435"> long[][] functionValuesLong = null;</span>
<span class="nc" id="L2436"> double[][] functionValuesDouble = null;</span>
<span class="nc" id="L2437"> int[] functionNumber = null;</span>
<span class="nc" id="L2438"> SubComponentFunction[] functionList = null;</span>
<span class="nc bnc" id="L2439" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null</span>
&& cf.baseFunctionList[level]
<span class="nc bnc" id="L2441" title="All 2 branches missed."> .containsKey(dataCollector)) {</span>
<span class="nc" id="L2442"> functionList = cf.baseFunctionList[level]</span>
<span class="nc" id="L2443"> .get(dataCollector);</span>
<span class="nc" id="L2444"> functionValuesLong = new long[functionList.length][];</span>
<span class="nc" id="L2445"> functionValuesDouble = new double[functionList.length][];</span>
<span class="nc" id="L2446"> functionNumber = new int[functionList.length];</span>
<span class="nc bnc" id="L2447" title="All 2 branches missed."> for (int i = 0; i < functionList.length; i++) {</span>
<span class="nc" id="L2448"> functionValuesLong[i] = new long[subDocSet.length];</span>
<span class="nc" id="L2449"> functionValuesDouble[i] = new double[subDocSet.length];</span>
}
}
// check main
<span class="nc" id="L2453"> int number = 0;</span>
<span class="nc" id="L2454"> Integer[] restrictedSubDocSet = new Integer[subDocSet.length];</span>
<span class="nc" id="L2455"> long[] values = new long[subDocSet.length];</span>
<span class="nc bnc" id="L2456" title="All 2 branches missed."> for (int docId : subDocSet) {</span>
<span class="nc" id="L2457"> long[] tmpArgs = args.get(docId);</span>
<span class="nc bnc" id="L2458" title="All 2 branches missed."> int tmpPositions = (positionsData == null) ? 0</span>
<span class="nc" id="L2459"> : positionsData.get(docId);</span>
<span class="nc" id="L2460"> long value = cf.baseParsers[level].getValueLong(tmpArgs,</span>
tmpPositions);
<span class="nc bnc" id="L2462" title="All 2 branches missed."> if ((cf.baseMinimumLongs[level] == null</span>
<span class="nc bnc" id="L2463" title="All 4 branches missed."> || value >= cf.baseMinimumLongs[level])</span>
&& (cf.baseMaximumLongs[level] == null
<span class="nc bnc" id="L2465" title="All 2 branches missed."> || value <= cf.baseMaximumLongs[level])) {</span>
<span class="nc" id="L2466"> values[number] = value;</span>
<span class="nc" id="L2467"> restrictedSubDocSet[number] = docId;</span>
<span class="nc" id="L2468"> number++;</span>
<span class="nc bnc" id="L2469" title="All 2 branches missed."> if (functionList != null) {</span>
<span class="nc bnc" id="L2470" title="All 2 branches missed."> for (int i = 0; i < functionList.length; i++) {</span>
<span class="nc" id="L2471"> SubComponentFunction function = functionList[i];</span>
<span class="nc" id="L2472"> if (function.dataType</span>
<span class="nc bnc" id="L2473" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
try {
<span class="nc" id="L2475"> functionValuesLong[i][functionNumber[i]] = function.parserFunction</span>
<span class="nc" id="L2476"> .getValueLong(tmpArgs, tmpPositions);</span>
<span class="nc" id="L2477"> functionNumber[i]++;</span>
<span class="nc" id="L2478"> } catch (IOException e) {</span>
<span class="nc" id="L2479"> log.debug(e);</span>
<span class="nc" id="L2480"> function.dataCollector.error(key,</span>
<span class="nc" id="L2481"> e.getMessage());</span>
<span class="nc" id="L2482"> }</span>
<span class="nc" id="L2483"> } else if (function.dataType</span>
<span class="nc bnc" id="L2484" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
try {
<span class="nc" id="L2486"> functionValuesDouble[i][functionNumber[i]] = function.parserFunction</span>
<span class="nc" id="L2487"> .getValueDouble(tmpArgs, tmpPositions);</span>
<span class="nc" id="L2488"> functionNumber[i]++;</span>
<span class="nc" id="L2489"> } catch (IOException e) {</span>
<span class="nc" id="L2490"> log.debug(e);</span>
<span class="nc" id="L2491"> function.dataCollector.error(key,</span>
<span class="nc" id="L2492"> e.getMessage());</span>
<span class="nc" id="L2493"> }</span>
}
}
}
}
}
<span class="nc bnc" id="L2499" title="All 2 branches missed."> if (number > 0) {</span>
<span class="nc" id="L2500"> subDataCollector = dataCollector.add(key, values,</span>
number);
<span class="nc bnc" id="L2502" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null</span>
&& cf.baseFunctionList[level]
<span class="nc bnc" id="L2504" title="All 2 branches missed."> .containsKey(dataCollector)) {</span>
<span class="nc bnc" id="L2505" title="All 2 branches missed."> for (int i = 0; i < functionList.length; i++) {</span>
<span class="nc" id="L2506"> SubComponentFunction function = functionList[i];</span>
<span class="nc" id="L2507"> if (function.dataType</span>
<span class="nc bnc" id="L2508" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L2509"> function.dataCollector.add(key,</span>
functionValuesLong[i], functionNumber[i]);
<span class="nc" id="L2511"> } else if (function.dataType</span>
<span class="nc bnc" id="L2512" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L2513"> function.dataCollector.add(key,</span>
functionValuesDouble[i], functionNumber[i]);
}
}
}
<span class="nc bnc" id="L2518" title="All 2 branches missed."> if (subDataCollector != null) {</span>
<span class="nc" id="L2519"> createFacetBase(cf, (level + 1), subDataCollector,</span>
positionsData, spansNumberData, facetData, Arrays
<span class="nc" id="L2521"> .copyOfRange(restrictedSubDocSet, 0, number));</span>
}
}
}
}
<span class="nc" id="L2526"> }</span>
}
<span class="nc" id="L2528"> } else {</span>
<span class="nc" id="L2529"> throw new IOException(</span>
"unexpected dataType " + cf.baseDataTypes[level]);
}
}
<span class="nc" id="L2533"> }</span>
} else {
<span class="nc" id="L2535"> throw new IOException(</span>
<span class="nc" id="L2536"> "unexpected type " + dataCollector.getCollectorType());</span>
}
<span class="nc" id="L2538"> dataCollector.closeNewList();</span>
<span class="nc bnc" id="L2539" title="All 2 branches missed."> if (cf.baseFunctionList[level] != null</span>
<span class="nc bnc" id="L2540" title="All 2 branches missed."> && cf.baseFunctionList[level].containsKey(dataCollector)) {</span>
<span class="nc" id="L2541"> SubComponentFunction[] tmpList = cf.baseFunctionList[level]</span>
<span class="nc" id="L2542"> .get(dataCollector);</span>
<span class="nc bnc" id="L2543" title="All 2 branches missed."> for (SubComponentFunction function : tmpList) {</span>
<span class="nc" id="L2544"> function.dataCollector.closeNewList();</span>
}
}
}
<span class="nc" id="L2549"> }</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="L2561"> final double precision = 0.000001;</span>
<span class="nc bnc" id="L2562" title="All 4 branches missed."> if (baseRangeSize == null || baseRangeSize <= 0) {</span>
<span class="nc" id="L2563"> return key;</span>
} else {
Double doubleKey;
Double doubleBase;
Double doubleNumber;
Double doubleStart;
Double doubleEnd;
try {
<span class="nc" id="L2571"> doubleKey = Double.parseDouble(key);</span>
<span class="nc bnc" id="L2572" title="All 2 branches missed."> doubleBase = baseRangeBase != null ? baseRangeBase : 0;</span>
<span class="nc" id="L2573"> doubleNumber = Math.floor((doubleKey - doubleBase) / baseRangeSize);</span>
<span class="nc" id="L2574"> doubleStart = doubleBase + doubleNumber * baseRangeSize;</span>
<span class="nc" id="L2575"> doubleEnd = doubleStart + baseRangeSize;</span>
<span class="nc" id="L2576"> } catch (NumberFormatException e) {</span>
<span class="nc" id="L2577"> return key;</span>
<span class="nc" id="L2578"> }</span>
// integer
<span class="nc bnc" id="L2580" title="All 2 branches missed."> if (Math.abs(baseRangeSize - Math.floor(baseRangeSize)) < precision</span>
<span class="nc bnc" id="L2581" title="All 2 branches missed."> && Math.abs(doubleBase - Math.floor(doubleBase)) < precision) {</span>
try {
<span class="nc bnc" id="L2583" title="All 2 branches missed."> if (baseRangeSize > 1) {</span>
<span class="nc" id="L2584"> return String.format("%.0f", doubleStart) + "-"</span>
<span class="nc" id="L2585"> + String.format("%.0f", doubleEnd - 1);</span>
} else {
<span class="nc" id="L2587"> return String.format("%.0f", doubleStart);</span>
}
<span class="nc" id="L2589"> } catch (NumberFormatException e) {</span>
<span class="nc" id="L2590"> return key;</span>
}
} else {
<span class="nc" id="L2593"> 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="L2606"> Integer[] answer = new Integer[a.length + b.length];</span>
<span class="nc" id="L2607"> int i = 0;</span>
<span class="nc" id="L2608"> int j = 0;</span>
<span class="nc" id="L2609"> int k = 0;</span>
Integer tmp;
<span class="nc bnc" id="L2611" title="All 4 branches missed."> while (i < a.length && j < b.length) {</span>
<span class="nc bnc" id="L2612" title="All 2 branches missed."> tmp = a[i] < b[j] ? a[i++] : b[j++];</span>
<span class="nc bnc" id="L2613" title="All 4 branches missed."> for (; i < a.length && a[i].equals(tmp); i++)</span>
;
<span class="nc bnc" id="L2615" title="All 4 branches missed."> for (; j < b.length && b[j].equals(tmp); j++)</span>
;
<span class="nc" id="L2617"> answer[k++] = tmp;</span>
}
<span class="nc bnc" id="L2619" title="All 2 branches missed."> while (i < a.length) {</span>
<span class="nc" id="L2620"> tmp = a[i++];</span>
<span class="nc bnc" id="L2621" title="All 4 branches missed."> for (; i < a.length && a[i].equals(tmp); i++)</span>
;
<span class="nc" id="L2623"> answer[k++] = tmp;</span>
}
<span class="nc bnc" id="L2625" title="All 2 branches missed."> while (j < b.length) {</span>
<span class="nc" id="L2626"> tmp = b[j++];</span>
<span class="nc bnc" id="L2627" title="All 4 branches missed."> for (; j < b.length && b[j].equals(tmp); j++)</span>
;
<span class="nc" id="L2629"> answer[k++] = tmp;</span>
}
<span class="nc" id="L2631"> 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="L2650" title="All 2 branches missed."> if (facetList != null) {</span>
<span class="nc bnc" id="L2651" title="All 2 branches missed."> for (ComponentFacet cf : facetList) {</span>
<span class="nc bnc" id="L2652" title="All 2 branches missed."> if (cf.baseFields.length > 0) {</span>
<span class="nc" id="L2653"> createFacetBase(cf, 0, cf.dataCollector, positionsData,</span>
spansNumberData, facetData,
<span class="nc" id="L2655"> docSet.toArray(new Integer[docSet.size()]));</span>
}
<span class="nc" id="L2657"> }</span>
}
<span class="nc" id="L2659"> }</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="L2676" title="1 of 2 branches missed."> if (t != null) {</span>
BytesRef term;
TermsEnum termsEnum;
<span class="fc" id="L2679"> PostingsEnum postingsEnum = null;</span>
<span class="fc" id="L2680"> String segmentName = "segment" + lrc.ord;</span>
<span class="fc" id="L2681"> int segmentNumber = lrc.parent.leaves().size();</span>
// loop over termvectors
<span class="fc bfc" id="L2683" title="All 2 branches covered."> for (ComponentTermVector termVector : termVectorList) {</span>
<span class="fc bfc" id="L2684" title="All 4 branches covered."> if (termVector.full || termVector.list != null) {</span>
<span class="fc bfc" id="L2685" title="All 2 branches covered."> if (termVector.full) {</span>
<span class="fc" id="L2686"> termVector.subComponentFunction.dataCollector.setWithTotal();</span>
}
List<CompiledAutomaton> listAutomata;
Map<String, Automaton> automatonMap;
<span class="fc bfc" id="L2690" title="All 2 branches covered."> if (termVector.list == null) {</span>
<span class="fc" id="L2691"> listAutomata = new ArrayList<>();</span>
CompiledAutomaton compiledAutomaton;
Automaton automaton;
<span class="pc bpc" id="L2694" title="1 of 4 branches missed."> if ((termVector.regexp == null) || (termVector.regexp.isEmpty())) {</span>
<span class="fc" id="L2695"> RegExp re = new RegExp(</span>
termVector.prefix + MtasToken.DELIMITER + ".*");
<span class="fc" id="L2697"> automaton = re.toAutomaton();</span>
<span class="fc" id="L2698"> } else {</span>
<span class="fc" id="L2699"> RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER</span>
+ termVector.regexp + "\u0000*");
<span class="fc" id="L2701"> automaton = re.toAutomaton();</span>
}
<span class="fc" id="L2703"> compiledAutomaton = new CompiledAutomaton(automaton);</span>
<span class="fc" id="L2704"> listAutomata.add(compiledAutomaton);</span>
<span class="fc" id="L2705"> } else {</span>
<span class="fc bfc" id="L2706" title="All 2 branches covered."> automatonMap = MtasToken.createAutomatonMap(termVector.prefix,</span>
new ArrayList<String>(termVector.list),
<span class="fc" id="L2708"> termVector.listRegexp ? false : true);</span>
<span class="fc" id="L2709"> listAutomata = MtasToken.createAutomata(termVector.prefix,</span>
termVector.regexp, automatonMap);
}
<span class="fc" id="L2712"> List<ByteRunAutomaton> ignoreByteRunAutomatonList = null;</span>
<span class="fc bfc" id="L2713" title="All 2 branches covered."> if ((termVector.ignoreRegexp != null)</span>
<span class="pc bpc" id="L2714" title="1 of 2 branches missed."> && (!termVector.ignoreRegexp.isEmpty())) {</span>
<span class="fc" id="L2715"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
<span class="fc" id="L2716"> RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER</span>
+ termVector.ignoreRegexp + "\u0000*");
<span class="fc" id="L2718"> ignoreByteRunAutomatonList</span>
<span class="fc" id="L2719"> .add(new ByteRunAutomaton(re.toAutomaton()));</span>
}
<span class="fc bfc" id="L2721" title="All 2 branches covered."> if (termVector.ignoreList != null) {</span>
<span class="pc bpc" id="L2722" title="1 of 2 branches missed."> if (ignoreByteRunAutomatonList == null) {</span>
<span class="nc" id="L2723"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
}
<span class="pc bpc" id="L2725" title="1 of 2 branches missed."> Map<String, Automaton> list = MtasToken.createAutomatonMap(</span>
termVector.prefix, new ArrayList<String>(termVector.ignoreList),
<span class="fc" id="L2727"> termVector.ignoreListRegexp ? false : true);</span>
<span class="fc bfc" id="L2728" title="All 2 branches covered."> for (Automaton automaton : list.values()) {</span>
<span class="fc" id="L2729"> ignoreByteRunAutomatonList.add(new ByteRunAutomaton(automaton));</span>
<span class="fc" id="L2730"> }</span>
}
<span class="fc bfc" id="L2733" title="All 2 branches covered."> for (CompiledAutomaton compiledAutomaton : listAutomata) {</span>
<span class="fc" id="L2734"> if (!compiledAutomaton.type</span>
<span class="fc bfc" id="L2735" title="All 2 branches covered."> .equals(CompiledAutomaton.AUTOMATON_TYPE.NORMAL)) {</span>
<span class="fc" id="L2736"> if (compiledAutomaton.type</span>
<span class="pc bpc" id="L2737" title="1 of 2 branches missed."> .equals(CompiledAutomaton.AUTOMATON_TYPE.NONE)) {</span>
// do nothing
} else {
<span class="nc" id="L2740"> throw new IOException(</span>
"compiledAutomaton is " + compiledAutomaton.type);
}
} else {
<span class="fc" id="L2744"> termsEnum = t.intersect(compiledAutomaton, null);</span>
<span class="fc" id="L2745"> int initSize = Math.min((int) t.size(), 1000);</span>
<span class="fc" id="L2746"> termVector.subComponentFunction.dataCollector.initNewList(</span>
initSize, segmentName, segmentNumber, termVector.boundary);
<span class="fc" id="L2748"> boolean doBasic = termVector.subComponentFunction.dataCollector</span>
<span class="fc" id="L2749"> .getStatsType().equals(CodecUtil.STATS_BASIC);</span>
<span class="pc bpc" id="L2750" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L2751" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L2752"> function.dataCollector.initNewList(initSize);</span>
<span class="nc bnc" id="L2753" title="All 4 branches missed."> doBasic = doBasic ? (function.parserFunction.sumRule()</span>
<span class="nc bnc" id="L2754" title="All 2 branches missed."> && !function.parserFunction.needPositions()</span>
<span class="nc" id="L2755"> && function.dataCollector.getStatsType()</span>
<span class="nc bnc" id="L2756" title="All 2 branches missed."> .equals(CodecUtil.STATS_BASIC))</span>
: doBasic;
<span class="nc" id="L2758"> }</span>
}
// only if documents
<span class="pc bpc" id="L2761" title="1 of 2 branches missed."> if (!docSet.isEmpty()) {</span>
int termDocId;
boolean acceptedTerm;
String key;
// loop over terms
<span class="fc bfc" id="L2766" title="All 2 branches covered."> while ((term = termsEnum.next()) != null) {</span>
<span class="pc bpc" id="L2767" title="1 of 2 branches missed."> if (validateTermWithStartValue(term, termVector)) {</span>
<span class="fc" id="L2768"> termDocId = -1;</span>
<span class="fc" id="L2769"> acceptedTerm = true;</span>
<span class="fc bfc" id="L2770" title="All 2 branches covered."> if (ignoreByteRunAutomatonList != null) {</span>
<span class="fc bfc" id="L2771" title="All 2 branches covered."> for (ByteRunAutomaton ignoreByteRunAutomaton : ignoreByteRunAutomatonList) {</span>
<span class="fc bfc" id="L2772" title="All 2 branches covered."> if (ignoreByteRunAutomaton.run(term.bytes, term.offset,</span>
term.length)) {
<span class="fc" id="L2774"> acceptedTerm = false;</span>
<span class="fc" id="L2775"> break;</span>
}
<span class="fc" id="L2777"> }</span>
}
<span class="fc bfc" id="L2779" title="All 2 branches covered."> if (acceptedTerm) {</span>
<span class="fc bfc" id="L2780" title="All 2 branches covered."> if (doBasic) {</span>
// compute numbers;
<span class="fc" id="L2782"> TermvectorNumberBasic numberBasic = computeTermvectorNumberBasic(</span>
docSet, termDocId, termsEnum, r, lrc, postingsEnum);
// register
<span class="fc bfc" id="L2785" title="All 2 branches covered."> if (numberBasic.docNumber > 0) {</span>
<span class="fc" id="L2786"> long valueLong = 0;</span>
<span class="fc" id="L2787"> key = MtasToken.getPostfixFromValue(term);</span>
try {
<span class="fc" id="L2789"> valueLong = termVector.subComponentFunction.parserFunction</span>
<span class="fc" id="L2790"> .getValueLong(numberBasic.valueSum, 1);</span>
<span class="nc" id="L2791"> } catch (IOException e) {</span>
<span class="nc" id="L2792"> log.debug(e);</span>
<span class="nc" id="L2793"> termVector.subComponentFunction.dataCollector.error(</span>
<span class="nc" id="L2794"> MtasToken.getPostfixFromValue(term),</span>
<span class="nc" id="L2795"> e.getMessage());</span>
<span class="fc" id="L2796"> }</span>
<span class="fc" id="L2797"> termVector.subComponentFunction.dataCollector.add(key,</span>
valueLong, numberBasic.docNumber);
<span class="pc bpc" id="L2799" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L2800" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L2801"> if (function.dataType</span>
<span class="nc bnc" id="L2802" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L2803"> long valueFunction = function.parserFunction</span>
<span class="nc" id="L2804"> .getValueLong(numberBasic.valueSum, 0);</span>
<span class="nc" id="L2805"> function.dataCollector.add(key, valueFunction,</span>
numberBasic.docNumber);
<span class="nc" id="L2807"> } else if (function.dataType</span>
<span class="nc bnc" id="L2808" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L2809"> double valueFunction = function.parserFunction</span>
<span class="nc" id="L2810"> .getValueDouble(numberBasic.valueSum, 0);</span>
<span class="nc" id="L2811"> function.dataCollector.add(key, valueFunction,</span>
numberBasic.docNumber);
}
<span class="nc" id="L2814"> }</span>
}
}
<span class="fc" id="L2817"> } else {</span>
<span class="fc" id="L2818"> TermvectorNumberFull numberFull = computeTermvectorNumberFull(</span>
docSet, termDocId, termsEnum, lrc, postingsEnum,
positionsData);
<span class="pc bpc" id="L2821" title="1 of 2 branches missed."> if (numberFull.docNumber > 0) {</span>
<span class="fc" id="L2822"> long[] valuesLong = new long[numberFull.docNumber];</span>
<span class="fc" id="L2823"> key = MtasToken.getPostfixFromValue(term);</span>
<span class="fc bfc" id="L2824" title="All 2 branches covered."> for (int i = 0; i < numberFull.docNumber; i++) {</span>
try {
<span class="fc" id="L2826"> valuesLong[i] = termVector.subComponentFunction.parserFunction</span>
<span class="fc" id="L2827"> .getValueLong(</span>
new long[] { numberFull.args[i] },
numberFull.positions[i]);
<span class="nc" id="L2830"> } catch (IOException e) {</span>
<span class="nc" id="L2831"> log.debug(e);</span>
<span class="nc" id="L2832"> termVector.subComponentFunction.dataCollector</span>
<span class="nc" id="L2833"> .error(key, e.getMessage());</span>
<span class="fc" id="L2834"> }</span>
}
<span class="fc" id="L2836"> termVector.subComponentFunction.dataCollector.add(key,</span>
valuesLong, valuesLong.length);
<span class="pc bpc" id="L2838" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L2839" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L2840"> if (function.dataType</span>
<span class="nc bnc" id="L2841" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L2842"> valuesLong = new long[numberFull.docNumber];</span>
<span class="nc bnc" id="L2843" title="All 2 branches missed."> for (int i = 0; i < numberFull.docNumber; i++) {</span>
try {
<span class="nc" id="L2845"> valuesLong[i] = function.parserFunction</span>
<span class="nc" id="L2846"> .getValueLong(</span>
new long[] { numberFull.args[i] },
numberFull.positions[i]);
<span class="nc" id="L2849"> } catch (IOException e) {</span>
<span class="nc" id="L2850"> log.debug(e);</span>
<span class="nc" id="L2851"> function.dataCollector.error(key,</span>
<span class="nc" id="L2852"> e.getMessage());</span>
<span class="nc" id="L2853"> }</span>
}
<span class="nc" id="L2855"> function.dataCollector.add(key, valuesLong,</span>
valuesLong.length);
<span class="nc" id="L2857"> } else if (function.dataType</span>
<span class="nc bnc" id="L2858" title="All 2 branches missed."> .equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L2859"> double[] valuesDouble = new double[numberFull.docNumber];</span>
<span class="nc bnc" id="L2860" title="All 2 branches missed."> for (int i = 0; i < numberFull.docNumber; i++) {</span>
try {
<span class="nc" id="L2862"> valuesDouble[i] = function.parserFunction</span>
<span class="nc" id="L2863"> .getValueDouble(</span>
new long[] { numberFull.args[i] },
numberFull.positions[i]);
<span class="nc" id="L2866"> } catch (IOException e) {</span>
<span class="nc" id="L2867"> log.debug(e);</span>
<span class="nc" id="L2868"> function.dataCollector.error(key,</span>
<span class="nc" id="L2869"> e.getMessage());</span>
<span class="nc" id="L2870"> }</span>
}
<span class="nc" id="L2872"> function.dataCollector.add(key, valuesDouble,</span>
valuesDouble.length);
}
<span class="nc" id="L2875"> }</span>
}
}
<span class="fc" id="L2879"> }</span>
}
}
}
}
<span class="fc" id="L2884"> termVector.subComponentFunction.dataCollector.closeNewList();</span>
<span class="pc bpc" id="L2885" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L2886" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L2887"> function.dataCollector.closeNewList();</span>
<span class="nc" id="L2888"> }</span>
}
}
<span class="fc" id="L2891"> }</span>
}
<span class="fc" id="L2893"> }</span>
}
<span class="fc" id="L2895"> }</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="L2912" title="1 of 2 branches missed."> if (t != null) {</span>
BytesRef term;
TermsEnum termsEnum;
<span class="fc" id="L2915"> PostingsEnum postingsEnum = null;</span>
<span class="fc" id="L2916"> String segmentName = "segment" + lrc.ord;</span>
<span class="fc" id="L2917"> String[] mutableKey = new String[1];</span>
<span class="fc" id="L2918"> int segmentNumber = lrc.parent.leaves().size();</span>
// loop over termvectors
<span class="fc bfc" id="L2920" title="All 2 branches covered."> for (ComponentTermVector termVector : termVectorList) {</span>
CompiledAutomaton compiledAutomaton;
<span class="pc bpc" id="L2922" title="1 of 4 branches missed."> if ((termVector.regexp == null) || (termVector.regexp.isEmpty())) {</span>
<span class="fc" id="L2923"> RegExp re = new RegExp(</span>
termVector.prefix + MtasToken.DELIMITER + ".*");
<span class="fc" id="L2925"> compiledAutomaton = new CompiledAutomaton(re.toAutomaton());</span>
<span class="fc" id="L2926"> } else {</span>
<span class="fc" id="L2927"> RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER</span>
+ termVector.regexp + "\u0000*");
<span class="fc" id="L2929"> compiledAutomaton = new CompiledAutomaton(re.toAutomaton());</span>
}
<span class="fc" id="L2931"> List<ByteRunAutomaton> ignoreByteRunAutomatonList = null;</span>
<span class="fc bfc" id="L2932" title="All 2 branches covered."> if ((termVector.ignoreRegexp != null)</span>
<span class="pc bpc" id="L2933" title="1 of 2 branches missed."> && (!termVector.ignoreRegexp.isEmpty())) {</span>
<span class="fc" id="L2934"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
<span class="fc" id="L2935"> RegExp re = new RegExp(termVector.prefix + MtasToken.DELIMITER</span>
+ termVector.ignoreRegexp + "\u0000*");
<span class="fc" id="L2937"> ignoreByteRunAutomatonList</span>
<span class="fc" id="L2938"> .add(new ByteRunAutomaton(re.toAutomaton()));</span>
}
<span class="fc bfc" id="L2940" title="All 2 branches covered."> if (termVector.ignoreList != null) {</span>
<span class="pc bpc" id="L2941" title="1 of 2 branches missed."> if (ignoreByteRunAutomatonList == null) {</span>
<span class="nc" id="L2942"> ignoreByteRunAutomatonList = new ArrayList<>();</span>
}
<span class="pc bpc" id="L2944" title="1 of 2 branches missed."> Map<String, Automaton> list = MtasToken.createAutomatonMap(</span>
termVector.prefix, new ArrayList<String>(termVector.ignoreList),
<span class="fc" id="L2946"> termVector.ignoreListRegexp ? false : true);</span>
<span class="fc bfc" id="L2947" title="All 2 branches covered."> for (Automaton automaton : list.values()) {</span>
<span class="fc" id="L2948"> ignoreByteRunAutomatonList.add(new ByteRunAutomaton(automaton));</span>
<span class="fc" id="L2949"> }</span>
}
<span class="fc bfc" id="L2951" title="All 4 branches covered."> if (!termVector.full && termVector.list == null) {</span>
<span class="fc" id="L2952"> termsEnum = t.intersect(compiledAutomaton, null);</span>
<span class="fc" id="L2953"> int initSize = Math.min((int) t.size(), 1000);</span>
<span class="fc" id="L2954"> termVector.subComponentFunction.dataCollector.initNewList(initSize,</span>
segmentName, segmentNumber, termVector.boundary);
<span class="pc bpc" id="L2956" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L2957" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L2958"> function.dataCollector.initNewList(initSize);</span>
<span class="nc" id="L2959"> }</span>
}
// only if documents
<span class="pc bpc" id="L2962" title="1 of 2 branches missed."> if (!docSet.isEmpty()) {</span>
int termDocId;
<span class="fc" id="L2964"> int termNumberMaximum = termVector.number;</span>
<span class="fc" id="L2965"> HashMap<BytesRef, RegisterStatus> computeFullList = new HashMap<>();</span>
RegisterStatus registerStatus;
// basic, don't need full values
<span class="fc" id="L2968"> if (termVector.subComponentFunction.sortType</span>
<span class="fc bfc" id="L2969" title="All 2 branches covered."> .equals(CodecUtil.SORT_TERM)</span>
|| termVector.subComponentFunction.sortType
<span class="pc bpc" id="L2971" title="1 of 2 branches missed."> .equals(CodecUtil.STATS_TYPE_SUM)</span>
|| termVector.subComponentFunction.sortType
<span class="nc bnc" id="L2973" title="All 2 branches missed."> .equals(CodecUtil.STATS_TYPE_N)) {</span>
<span class="fc" id="L2974"> int termCounter = 0;</span>
boolean continueAfterPreliminaryCheck;
<span class="fc" id="L2977"> boolean preliminaryCheck = false;</span>
<span class="pc bpc" id="L2978" title="1 of 4 branches missed."> if (r.getLiveDocs() == null && (docSet.size() != r.numDocs())) {</span>
<span class="nc" id="L2979"> preliminaryCheck = true;</span>
}
// loop over terms
boolean acceptedTerm;
<span class="fc bfc" id="L2983" title="All 2 branches covered."> while ((term = termsEnum.next()) != null) {</span>
<span class="pc bpc" id="L2984" title="1 of 2 branches missed."> if (validateTermWithStartValue(term, termVector)) {</span>
<span class="fc" id="L2985"> termDocId = -1;</span>
<span class="fc" id="L2986"> acceptedTerm = true;</span>
<span class="fc bfc" id="L2987" title="All 2 branches covered."> if (ignoreByteRunAutomatonList != null) {</span>
<span class="fc bfc" id="L2988" title="All 2 branches covered."> for (ByteRunAutomaton ignoreByteRunAutomaton : ignoreByteRunAutomatonList) {</span>
<span class="pc bpc" id="L2989" title="1 of 2 branches missed."> if (ignoreByteRunAutomaton.run(term.bytes, term.offset,</span>
term.length)) {
<span class="nc" id="L2991"> acceptedTerm = false;</span>
<span class="nc" id="L2992"> break;</span>
}
<span class="fc" id="L2994"> }</span>
}
<span class="pc bpc" id="L2996" title="1 of 2 branches missed."> if (acceptedTerm) {</span>
<span class="fc" id="L2997"> continueAfterPreliminaryCheck = true;</span>
<span class="fc" id="L2998"> mutableKey[0] = null;</span>
<span class="pc bpc" id="L2999" title="1 of 2 branches missed."> if (preliminaryCheck) {</span>
try {
<span class="nc" id="L3001"> TermvectorNumberBasic preliminaryNumberBasic = computeTermvectorNumberBasic(</span>
termsEnum, r);
<span class="nc bnc" id="L3003" title="All 2 branches missed."> if (preliminaryNumberBasic.docNumber > 0) {</span>
<span class="nc" id="L3004"> continueAfterPreliminaryCheck = preliminaryRegisterValue(</span>
term, termVector, preliminaryNumberBasic,
<span class="nc" id="L3006"> termNumberMaximum, segmentNumber, mutableKey);</span>
} else {
<span class="nc" id="L3008"> continueAfterPreliminaryCheck = false;</span>
}
<span class="nc" id="L3010"> } catch (IOException e) {</span>
<span class="nc" id="L3011"> log.debug(e);</span>
<span class="nc" id="L3012"> continueAfterPreliminaryCheck = true;</span>
<span class="nc" id="L3013"> }</span>
}
<span class="pc bpc" id="L3015" title="1 of 2 branches missed."> if (continueAfterPreliminaryCheck) {</span>
// compute numbers;
<span class="fc" id="L3017"> TermvectorNumberBasic numberBasic = computeTermvectorNumberBasic(</span>
docSet, termDocId, termsEnum, r, lrc, postingsEnum);
// register
<span class="fc bfc" id="L3020" title="All 2 branches covered."> if (numberBasic.docNumber > 0) {</span>
<span class="fc" id="L3021"> termCounter++;</span>
<span class="fc" id="L3022"> registerStatus = registerValue(term, termVector,</span>
<span class="fc" id="L3023"> numberBasic, termNumberMaximum, segmentNumber,</span>
false, mutableKey);
<span class="fc bfc" id="L3025" title="All 2 branches covered."> if (registerStatus != null) {</span>
<span class="fc" id="L3026"> computeFullList.put(BytesRef.deepCopyOf(term),</span>
registerStatus);
}
}
}
// stop after termCounterMaximum
<span class="fc" id="L3032"> if (termVector.subComponentFunction.sortType</span>
<span class="fc bfc" id="L3033" title="All 2 branches covered."> .equals(CodecUtil.SORT_TERM)</span>
&& termVector.subComponentFunction.sortDirection
<span class="fc bfc" id="L3035" title="All 4 branches covered."> .equals(CodecUtil.SORT_ASC)</span>
&& termCounter >= termNumberMaximum) {
<span class="fc" id="L3037"> break;</span>
}
}
}
}
// rerun for full
<span class="fc bfc" id="L3043" title="All 2 branches covered."> if (computeFullList.size() > 0) {</span>
<span class="fc" id="L3044"> termsEnum = t.intersect(compiledAutomaton, null);</span>
<span class="fc bfc" id="L3045" title="All 2 branches covered."> while ((term = termsEnum.next()) != null) {</span>
<span class="pc bpc" id="L3046" title="1 of 2 branches missed."> if (validateTermWithStartValue(term, termVector)) {</span>
<span class="fc" id="L3047"> termDocId = -1;</span>
<span class="fc" id="L3048"> mutableKey[0] = null;</span>
// only if (probably) needed
<span class="fc bfc" id="L3050" title="All 2 branches covered."> if (computeFullList.containsKey(term)) {</span>
<span class="fc" id="L3051"> registerStatus = computeFullList.get(term);</span>
boolean doAdd;
<span class="fc" id="L3053"> doAdd = termVector.subComponentFunction.sortType</span>
<span class="fc" id="L3054"> .equals(CodecUtil.SORT_TERM);</span>
<span class="fc" id="L3055"> doAdd |= termVector.subComponentFunction.sortDirection</span>
<span class="fc" id="L3056"> .equals(CodecUtil.SORT_ASC);</span>
<span class="pc bpc" id="L3057" title="1 of 2 branches missed."> doAdd |= termVector.list != null;</span>
<span class="fc" id="L3058"> doAdd |= termVector.boundaryRegistration;</span>
<span class="fc" id="L3059"> doAdd |= registerStatus.force;</span>
<span class="fc" id="L3060"> doAdd |= termVector.subComponentFunction.dataCollector</span>
<span class="fc" id="L3061"> .validateSegmentBoundary(registerStatus.sortValue);</span>
<span class="fc bfc" id="L3062" title="All 2 branches covered."> if (doAdd) {</span>
<span class="fc" id="L3063"> TermvectorNumberFull numberFull = computeTermvectorNumberFull(</span>
docSet, termDocId, termsEnum, lrc, postingsEnum,
positionsData);
<span class="pc bpc" id="L3066" title="1 of 2 branches missed."> if (numberFull.docNumber > 0) {</span>
<span class="fc" id="L3067"> termCounter++;</span>
<span class="fc" id="L3068"> registerValue(term, termVector, numberFull,</span>
mutableKey);
}
}
<span class="fc" id="L3072"> }</span>
}
}
<span class="fc" id="L3075"> computeFullList.clear();</span>
}
<span class="fc" id="L3077"> } else {</span>
<span class="nc" id="L3078"> throw new IOException(</span>
"sort '" + termVector.subComponentFunction.sortType + " "
+ termVector.subComponentFunction.sortDirection
+ "' not supported");
}
// finish if segments are used
<span class="fc" id="L3084"> termVector.subComponentFunction.dataCollector</span>
<span class="fc" id="L3085"> .closeSegmentKeyValueRegistration();</span>
<span class="pc bpc" id="L3086" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3087" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3088"> function.dataCollector.closeSegmentKeyValueRegistration();</span>
<span class="nc" id="L3089"> }</span>
}
}
<span class="fc" id="L3092"> termVector.subComponentFunction.dataCollector.closeNewList();</span>
<span class="pc bpc" id="L3093" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3094" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3095"> function.dataCollector.closeNewList();</span>
<span class="nc" id="L3096"> }</span>
}
}
<span class="fc" id="L3099"> }</span>
}
<span class="fc" id="L3101"> }</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="L3118" title="1 of 2 branches missed."> if (t != null) {</span>
BytesRef term;
TermsEnum termsEnum;
<span class="fc" id="L3121"> PostingsEnum postingsEnum = null;</span>
<span class="fc" id="L3122"> String segmentName = "segment" + lrc.ord;</span>
<span class="fc" id="L3123"> int segmentNumber = lrc.parent.leaves().size();</span>
<span class="fc" id="L3124"> String[] mutableKey = new String[1];</span>
<span class="fc bfc" id="L3125" title="All 2 branches covered."> for (ComponentTermVector termVector : termVectorList) {</span>
<span class="pc bpc" id="L3126" 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="L3129" title="All 2 branches covered."> .containsKey(segmentName))) {</span>
<span class="fc" id="L3130"> Set<String> recomputeKeyList = termVector.subComponentFunction.dataCollector.segmentRecomputeKeyList</span>
<span class="fc" id="L3131"> .get(segmentName);</span>
<span class="pc bpc" id="L3132" title="1 of 2 branches missed."> if (!recomputeKeyList.isEmpty()) {</span>
<span class="fc" id="L3133"> Map<String, Automaton> automatonMap = MtasToken.createAutomatonMap(</span>
termVector.prefix, new ArrayList<String>(recomputeKeyList),
<span class="fc" id="L3135"> true);</span>
<span class="fc" id="L3136"> List<CompiledAutomaton> listCompiledAutomata = MtasToken</span>
<span class="fc" id="L3137"> .createAutomata(termVector.prefix, termVector.regexp,</span>
automatonMap);
<span class="fc bfc" id="L3139" title="All 2 branches covered."> for (CompiledAutomaton compiledAutomaton : listCompiledAutomata) {</span>
<span class="fc" id="L3140"> termsEnum = t.intersect(compiledAutomaton, null);</span>
<span class="fc" id="L3141"> termVector.subComponentFunction.dataCollector</span>
<span class="fc" id="L3142"> .initNewList(</span>
termVector.subComponentFunction.dataCollector.segmentKeys
<span class="fc" id="L3144"> .size(),</span>
segmentName, segmentNumber, termVector.boundary);
<span class="fc" id="L3146"> RegisterStatus registerStatus = null;</span>
<span class="pc bpc" id="L3147" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3148" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3149"> function.dataCollector.initNewList((int) t.size(),</span>
segmentName, segmentNumber, null);
<span class="nc" id="L3151"> }</span>
}
<span class="pc bpc" id="L3153" title="1 of 2 branches missed."> if (!docSet.isEmpty()) {</span>
int termDocId;
<span class="fc bfc" id="L3155" title="All 2 branches covered."> while ((term = termsEnum.next()) != null) {</span>
<span class="pc bpc" id="L3156" title="1 of 2 branches missed."> if (validateTermWithStartValue(term, termVector)) {</span>
<span class="fc" id="L3157"> termDocId = -1;</span>
<span class="fc" id="L3158"> mutableKey[0] = null;</span>
// compute numbers;
<span class="fc" id="L3160"> TermvectorNumberBasic numberBasic = computeTermvectorNumberBasic(</span>
docSet, termDocId, termsEnum, r, lrc, postingsEnum);
<span class="fc bfc" id="L3162" title="All 2 branches covered."> if (numberBasic.docNumber > 0) {</span>
<span class="fc" id="L3163"> registerStatus = registerValue(term, termVector,</span>
<span class="fc" id="L3164"> numberBasic, 0, segmentNumber, true, mutableKey);</span>
<span class="fc bfc" id="L3165" title="All 2 branches covered."> if (registerStatus != null) {</span>
<span class="fc" id="L3166"> TermvectorNumberFull numberFull = computeTermvectorNumberFull(</span>
docSet, termDocId, termsEnum, lrc, postingsEnum,
positionsData);
<span class="pc bpc" id="L3169" title="1 of 2 branches missed."> if (numberFull.docNumber > 0) {</span>
<span class="fc" id="L3170"> registerValue(term, termVector, numberFull,</span>
mutableKey);
}
}
}
<span class="fc" id="L3175"> }</span>
}
}
<span class="fc" id="L3178"> termVector.subComponentFunction.dataCollector.closeNewList();</span>
<span class="pc bpc" id="L3179" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3180" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc" id="L3181"> function.dataCollector.closeNewList();</span>
<span class="nc" id="L3182"> }</span>
}
<span class="fc" id="L3184"> }</span>
}
}
<span class="fc" id="L3187"> }</span>
}
<span class="fc" id="L3189"> }</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="L3200" title="1 of 2 branches missed."> if (termVector.startValue == null) {</span>
<span class="fc" id="L3201"> return true;</span>
<span class="nc" id="L3202"> } else if (termVector.subComponentFunction.sortType</span>
<span class="nc bnc" id="L3203" title="All 2 branches missed."> .equals(CodecUtil.SORT_TERM)) {</span>
<span class="nc bnc" id="L3204" title="All 2 branches missed."> if (term.length > termVector.startValue.length) {</span>
<span class="nc" id="L3205"> byte[] zeroBytes = (new BytesRef("\u0000")).bytes;</span>
<span class="nc" id="L3206"> int n = (int) (Math</span>
<span class="nc" id="L3207"> .ceil(((double) (term.length - termVector.startValue.length))</span>
/ zeroBytes.length));
<span class="nc" id="L3209"> byte[] newBytes = new byte[termVector.startValue.length</span>
+ n * zeroBytes.length];
<span class="nc" id="L3211"> System.arraycopy(termVector.startValue.bytes, 0, newBytes, 0,</span>
termVector.startValue.length);
<span class="nc bnc" id="L3213" title="All 2 branches missed."> for (int i = 0; i < n; i++) {</span>
<span class="nc" id="L3214"> System.arraycopy(zeroBytes, 0, newBytes,</span>
termVector.startValue.length + i * zeroBytes.length,
zeroBytes.length);
}
<span class="nc" id="L3218"> termVector.startValue = new BytesRef(newBytes);</span>
}
<span class="nc bnc" id="L3220" title="All 2 branches missed."> if ((termVector.subComponentFunction.sortDirection.equals(</span>
<span class="nc bnc" id="L3221" title="All 2 branches missed."> CodecUtil.SORT_ASC) && (termVector.startValue.compareTo(term) < 0))</span>
|| (termVector.subComponentFunction.sortDirection
<span class="nc bnc" id="L3223" title="All 2 branches missed."> .equals(CodecUtil.SORT_DESC)</span>
<span class="nc bnc" id="L3224" title="All 2 branches missed."> && (termVector.startValue.compareTo(term) > 0))) {</span>
<span class="nc" id="L3225"> return true;</span>
}
}
<span class="nc" id="L3228"> 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="L3240"> boolean needSecondRound = false;</span>
<span class="fc bfc" id="L3241" title="All 2 branches covered."> for (ComponentTermVector termVector : termVectorList) {</span>
<span class="fc bfc" id="L3242" title="All 4 branches covered."> if (!termVector.full && termVector.list == null) {</span>
boolean doCheck;
<span class="fc bfc" id="L3244" title="All 2 branches covered."> doCheck = termVector.subComponentFunction.dataCollector.segmentRegistration != null</span>
&& (termVector.subComponentFunction.dataCollector.segmentRegistration
<span class="fc bfc" id="L3246" title="All 2 branches covered."> .equals(MtasDataCollector.SEGMENT_SORT_ASC)</span>
|| termVector.subComponentFunction.dataCollector.segmentRegistration
<span class="pc bpc" id="L3248" title="2 of 4 branches missed."> .equals(MtasDataCollector.SEGMENT_SORT_DESC))</span>
&& termVector.number > 0;
<span class="fc bfc" id="L3250" title="All 2 branches covered."> doCheck |= termVector.subComponentFunction.dataCollector.segmentRegistration != null</span>
&& (termVector.subComponentFunction.dataCollector.segmentRegistration
<span class="pc bpc" id="L3252" title="1 of 2 branches missed."> .equals(MtasDataCollector.SEGMENT_BOUNDARY_ASC)</span>
|| termVector.subComponentFunction.dataCollector.segmentRegistration
<span class="pc bpc" id="L3254" title="3 of 4 branches missed."> .equals(MtasDataCollector.SEGMENT_BOUNDARY_DESC))</span>
&& termVector.number > 0;
<span class="fc bfc" id="L3256" title="All 2 branches covered."> if (doCheck) {</span>
<span class="fc" id="L3257"> termVector.subComponentFunction.dataCollector.recomputeSegmentKeys();</span>
<span class="fc" id="L3258"> if (!termVector.subComponentFunction.dataCollector</span>
<span class="fc bfc" id="L3259" title="All 2 branches covered."> .checkExistenceNecessaryKeys()) {</span>
<span class="fc" id="L3260"> needSecondRound = true;</span>
}
<span class="fc" id="L3262"> termVector.subComponentFunction.dataCollector.reduceToSegmentKeys();</span>
}
}
<span class="fc" id="L3265"> }</span>
<span class="fc" id="L3266"> 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="L3283"> TermvectorNumberBasic() {</span>
<span class="fc" id="L3284"> valueSum = new long[] { 0 };</span>
<span class="fc" id="L3285"> docNumber = 0;</span>
<span class="fc" id="L3286"> }</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="L3308"> TermvectorNumberFull(int maxSize) {</span>
<span class="fc" id="L3309"> args = new long[maxSize];</span>
<span class="fc" id="L3310"> positions = new int[maxSize];</span>
<span class="fc" id="L3311"> docNumber = 0;</span>
<span class="fc" id="L3312"> }</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="L3332"> RegisterStatus(long sortValue, boolean force) {</span>
<span class="fc" id="L3333"> this.sortValue = sortValue;</span>
<span class="fc" id="L3334"> this.force = force;</span>
<span class="fc" id="L3335"> }</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="L3356"> long value = termVector.subComponentFunction.parserFunction</span>
<span class="fc" id="L3357"> .getValueLong(number.valueSum, 0);</span>
<span class="fc" id="L3358"> long sortValue = 0;</span>
<span class="fc" id="L3359"> if (termVector.subComponentFunction.sortType</span>
<span class="fc bfc" id="L3360" title="All 2 branches covered."> .equals(CodecUtil.STATS_TYPE_SUM)) {</span>
<span class="fc" id="L3361"> sortValue = value;</span>
<span class="fc" id="L3362"> } else if (termVector.subComponentFunction.sortType</span>
<span class="pc bpc" id="L3363" title="1 of 2 branches missed."> .equals(CodecUtil.STATS_TYPE_N)) {</span>
<span class="nc" id="L3364"> sortValue = number.docNumber;</span>
}
<span class="fc" id="L3366"> boolean addItem = false;</span>
<span class="fc" id="L3367"> boolean addItemForced = false;</span>
<span class="fc" id="L3368"> MtasDataCollector<Long, ?> dataCollector = (MtasDataCollector<Long, ?>) termVector.subComponentFunction.dataCollector;</span>
// sort on term
<span class="fc bfc" id="L3370" title="All 2 branches covered."> if (termVector.subComponentFunction.sortType.equals(CodecUtil.SORT_TERM)) {</span>
<span class="fc" id="L3371"> addItem = true;</span>
<span class="fc" id="L3372"> addItemForced = true;</span>
// sort on sum or n
<span class="fc" id="L3374"> } else if (termVector.subComponentFunction.sortType</span>
<span class="pc bpc" id="L3375" title="1 of 2 branches missed."> .equals(CodecUtil.STATS_TYPE_SUM)</span>
|| termVector.subComponentFunction.sortType
<span class="nc bnc" id="L3377" title="All 2 branches missed."> .equals(CodecUtil.STATS_TYPE_N)) {</span>
// always accept
<span class="fc bfc" id="L3379" title="All 2 branches covered."> if (forceAccept) {</span>
<span class="fc" id="L3380"> addItem = true;</span>
<span class="fc" id="L3381"> addItemForced = addItem;</span>
// check boundary
<span class="pc bpc" id="L3383" title="1 of 2 branches missed."> } else if (termVector.boundaryRegistration) {</span>
<span class="nc" id="L3384"> addItem = dataCollector.validateSegmentBoundary(sortValue);</span>
<span class="nc bnc" id="L3385" title="All 2 branches missed."> if (addItem) {</span>
<span class="nc bnc" id="L3386" title="All 2 branches missed."> if (mutableKey[0] == null) {</span>
<span class="nc" id="L3387"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
}
<span class="nc" id="L3389"> String segmentStatus = dataCollector.validateSegmentValue(</span>
<span class="nc" id="L3390"> mutableKey[0], sortValue, termNumberMaximum, segmentNumber,</span>
false);
<span class="nc bnc" id="L3392" title="All 2 branches missed."> if (segmentStatus != null) {</span>
<span class="nc bnc" id="L3393" title="All 2 branches missed."> if (segmentStatus.equals(MtasDataCollector.SEGMENT_KEY)) {</span>
<span class="nc" id="L3394"> addItemForced = true;</span>
}
} else {
// shouldn't happen
}
<span class="nc" id="L3399"> }</span>
// no boundary
} else {
<span class="fc" id="L3402"> String segmentStatus = dataCollector.validateSegmentValue(sortValue,</span>
<span class="fc" id="L3403"> termNumberMaximum, segmentNumber);</span>
<span class="fc bfc" id="L3404" title="All 2 branches covered."> if (segmentStatus != null) {</span>
boolean possibleAddItem;
<span class="fc bfc" id="L3406" title="All 2 branches covered."> if (segmentStatus.equals(MtasDataCollector.SEGMENT_KEY_OR_NEW)) {</span>
<span class="fc" id="L3407"> possibleAddItem = true;</span>
<span class="fc" id="L3408"> } else if (segmentStatus</span>
<span class="pc bpc" id="L3409" title="1 of 2 branches missed."> .equals(MtasDataCollector.SEGMENT_POSSIBLE_KEY)) {</span>
<span class="fc" id="L3410"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
<span class="fc" id="L3411"> segmentStatus = dataCollector.validateSegmentValue(mutableKey[0],</span>
<span class="fc" id="L3412"> sortValue, termNumberMaximum, segmentNumber, true);</span>
<span class="fc bfc" id="L3413" title="All 2 branches covered."> if (segmentStatus != null) {</span>
<span class="fc" id="L3414"> possibleAddItem = true;</span>
} else {
<span class="fc" id="L3416"> possibleAddItem = false;</span>
}
} else {
// should never happen?
<span class="nc" id="L3420"> possibleAddItem = false;</span>
}
// further checks, passed initial
<span class="fc bfc" id="L3423" title="All 2 branches covered."> if (possibleAddItem) {</span>
<span class="fc bfc" id="L3424" title="All 2 branches covered."> if (mutableKey[0] == null) {</span>
<span class="fc" id="L3425"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
}
<span class="fc" id="L3427"> segmentStatus = dataCollector.validateSegmentValue(mutableKey[0],</span>
<span class="fc" id="L3428"> sortValue, termNumberMaximum, segmentNumber, false);</span>
<span class="pc bpc" id="L3429" title="1 of 2 branches missed."> if (segmentStatus != null) {</span>
<span class="fc" id="L3430"> addItem = true;</span>
<span class="fc bfc" id="L3431" title="All 2 branches covered."> if (segmentStatus.equals(MtasDataCollector.SEGMENT_KEY)) {</span>
<span class="fc" id="L3432"> addItemForced = true;</span>
}
}
}
<span class="fc" id="L3436"> } else {</span>
<span class="fc" id="L3437"> addItem = false;</span>
}
<span class="fc" id="L3439"> }</span>
// don't sort?
} else {
<span class="nc" id="L3442"> addItem = false;</span>
}
<span class="fc bfc" id="L3444" title="All 2 branches covered."> if (addItem) {</span>
<span class="fc" id="L3445"> boolean computeFull = false;</span>
<span class="fc bfc" id="L3446" title="All 2 branches covered."> if (mutableKey[0] == null) {</span>
<span class="fc" id="L3447"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
}
// check dataCollector type
<span class="fc" id="L3450"> if (termVector.subComponentFunction.statsType</span>
<span class="fc bfc" id="L3451" title="All 2 branches covered."> .equals(CodecUtil.STATS_BASIC)) {</span>
<span class="fc" id="L3452"> dataCollector.add(mutableKey[0], value, number.docNumber);</span>
} else {
<span class="fc" id="L3454"> computeFull = true;</span>
}
// functions
<span class="pc bpc" id="L3457" title="1 of 2 branches missed."> if (termVector.functions != null) {</span>
<span class="pc bpc" id="L3458" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc bnc" id="L3459" title="All 2 branches missed."> if (function.parserFunction.sumRule()</span>
<span class="nc bnc" id="L3460" title="All 2 branches missed."> && !function.parserFunction.needPositions()</span>
<span class="nc bnc" id="L3461" title="All 2 branches missed."> && function.statsType.equals(CodecUtil.STATS_BASIC)) {</span>
<span class="nc bnc" id="L3462" title="All 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L3463"> long valueFunction = function.parserFunction</span>
<span class="nc" id="L3464"> .getValueLong(number.valueSum, 0);</span>
<span class="nc" id="L3465"> function.dataCollector.add(mutableKey[0], valueFunction,</span>
number.docNumber);
<span class="nc bnc" id="L3467" title="All 2 branches missed."> } else if (function.dataType.equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L3468"> double valueFunction = function.parserFunction</span>
<span class="nc" id="L3469"> .getValueDouble(number.valueSum, 0);</span>
<span class="nc" id="L3470"> function.dataCollector.add(mutableKey[0], valueFunction,</span>
number.docNumber);
<span class="nc" id="L3472"> }</span>
} else {
<span class="nc" id="L3474"> computeFull = true;</span>
}
<span class="nc" id="L3476"> }</span>
}
// add as full?
<span class="fc bfc" id="L3479" title="All 2 branches covered."> return computeFull ? new RegisterStatus(sortValue, addItemForced) : null;</span>
} else {
<span class="fc" id="L3481"> 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="L3501"> long sortValue = 0;</span>
<span class="nc" id="L3502"> if (termVector.subComponentFunction.sortDirection</span>
<span class="nc bnc" id="L3503" title="All 2 branches missed."> .equals(CodecUtil.SORT_DESC)</span>
&& termVector.subComponentFunction.sortType
<span class="nc bnc" id="L3505" title="All 2 branches missed."> .equals(CodecUtil.STATS_TYPE_SUM)) {</span>
<span class="nc" id="L3506"> sortValue = termVector.subComponentFunction.parserFunction</span>
<span class="nc" id="L3507"> .getValueLong(number.valueSum, 0);</span>
<span class="nc" id="L3508"> } else if (termVector.subComponentFunction.sortDirection</span>
<span class="nc bnc" id="L3509" title="All 2 branches missed."> .equals(CodecUtil.SORT_DESC)</span>
&& termVector.subComponentFunction.sortType
<span class="nc bnc" id="L3511" title="All 2 branches missed."> .equals(CodecUtil.STATS_TYPE_N)) {</span>
<span class="nc" id="L3512"> sortValue = number.docNumber;</span>
} else {
<span class="nc" id="L3514"> return true;</span>
}
<span class="nc" id="L3516"> MtasDataCollector<Long, ?> dataCollector = (MtasDataCollector<Long, ?>) termVector.subComponentFunction.dataCollector;</span>
<span class="nc bnc" id="L3517" title="All 2 branches missed."> if (termVector.boundaryRegistration) {</span>
<span class="nc" id="L3518"> return dataCollector.validateSegmentBoundary(sortValue);</span>
} else {
<span class="nc" id="L3520"> String segmentStatus = dataCollector.validateSegmentValue(sortValue,</span>
<span class="nc" id="L3521"> termNumberMaximum, segmentNumber);</span>
<span class="nc bnc" id="L3522" title="All 2 branches missed."> if (segmentStatus != null) {</span>
<span class="nc bnc" id="L3523" title="All 2 branches missed."> if (segmentStatus.equals(MtasDataCollector.SEGMENT_KEY_OR_NEW)) {</span>
<span class="nc" id="L3524"> return true;</span>
<span class="nc" id="L3525"> } else if (segmentStatus</span>
<span class="nc bnc" id="L3526" title="All 2 branches missed."> .equals(MtasDataCollector.SEGMENT_POSSIBLE_KEY)) {</span>
<span class="nc" id="L3527"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
<span class="nc" id="L3528"> segmentStatus = dataCollector.validateSegmentValue(mutableKey[0],</span>
<span class="nc" id="L3529"> sortValue, termNumberMaximum, segmentNumber, true);</span>
<span class="nc bnc" id="L3530" title="All 2 branches missed."> return segmentStatus != null;</span>
} else {
// should never happen?
<span class="nc" id="L3533"> return false;</span>
}
} else {
<span class="nc" id="L3536"> 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="L3554" title="1 of 2 branches missed."> if (number.docNumber > 0) {</span>
<span class="fc bfc" id="L3555" title="All 2 branches covered."> if (mutableKey[0] == null) {</span>
<span class="fc" id="L3556"> mutableKey[0] = MtasToken.getPostfixFromValue(term);</span>
}
<span class="fc" id="L3558"> MtasDataCollector<Long, ?> dataCollector = (MtasDataCollector<Long, ?>) termVector.subComponentFunction.dataCollector;</span>
<span class="fc" id="L3559"> long[] valuesLong = new long[number.docNumber];</span>
<span class="fc bfc" id="L3560" title="All 2 branches covered."> for (int i = 0; i < number.docNumber; i++) {</span>
try {
<span class="fc" id="L3562"> valuesLong[i] = termVector.subComponentFunction.parserFunction</span>
<span class="fc" id="L3563"> .getValueLong(new long[] { number.args[i] }, number.positions[i]);</span>
<span class="nc" id="L3564"> } catch (IOException e) {</span>
<span class="nc" id="L3565"> log.debug(e);</span>
<span class="nc" id="L3566"> dataCollector.error(mutableKey[0], e.getMessage());</span>
<span class="fc" id="L3567"> }</span>
}
<span class="fc" id="L3569"> if (!termVector.subComponentFunction.statsType</span>
<span class="pc bpc" id="L3570" title="1 of 2 branches missed."> .equals(CodecUtil.STATS_BASIC)) {</span>
<span class="fc" id="L3571"> dataCollector.add(mutableKey[0], valuesLong, valuesLong.length);</span>
}
<span class="pc bpc" id="L3573" title="1 of 2 branches missed."> for (SubComponentFunction function : termVector.functions) {</span>
<span class="nc bnc" id="L3574" title="All 2 branches missed."> if (!function.parserFunction.sumRule()</span>
<span class="nc bnc" id="L3575" title="All 2 branches missed."> || function.parserFunction.needPositions()</span>
<span class="nc bnc" id="L3576" title="All 2 branches missed."> || !function.statsType.equals(CodecUtil.STATS_BASIC)) {</span>
<span class="nc bnc" id="L3577" title="All 2 branches missed."> if (function.dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span>
<span class="nc" id="L3578"> valuesLong = new long[number.docNumber];</span>
<span class="nc bnc" id="L3579" title="All 2 branches missed."> for (int i = 0; i < number.docNumber; i++) {</span>
try {
<span class="nc" id="L3581"> valuesLong[i] = function.parserFunction.getValueLong(</span>
new long[] { number.args[i] }, number.positions[i]);
<span class="nc" id="L3583"> } catch (IOException e) {</span>
<span class="nc" id="L3584"> log.debug(e);</span>
<span class="nc" id="L3585"> function.dataCollector.error(mutableKey[0], e.getMessage());</span>
<span class="nc" id="L3586"> }</span>
}
<span class="nc" id="L3588"> function.dataCollector.add(mutableKey[0], valuesLong,</span>
valuesLong.length);
<span class="nc bnc" id="L3590" title="All 2 branches missed."> } else if (function.dataType.equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span>
<span class="nc" id="L3591"> double[] valuesDouble = new double[number.docNumber];</span>
<span class="nc bnc" id="L3592" title="All 2 branches missed."> for (int i = 0; i < number.docNumber; i++) {</span>
try {
<span class="nc" id="L3594"> valuesDouble[i] = function.parserFunction.getValueDouble(</span>
new long[] { number.args[i] }, number.positions[i]);
<span class="nc" id="L3596"> } catch (IOException e) {</span>
<span class="nc" id="L3597"> log.debug(e);</span>
<span class="nc" id="L3598"> function.dataCollector.error(mutableKey[0], e.getMessage());</span>
<span class="nc" id="L3599"> }</span>
}
<span class="nc" id="L3601"> function.dataCollector.add(mutableKey[0], valuesDouble,</span>
valuesDouble.length);
}
}
<span class="nc" id="L3605"> }</span>
}
<span class="fc" id="L3607"> }</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="L3619"> TermvectorNumberBasic result = new TermvectorNumberBasic();</span>
<span class="pc bpc" id="L3620" title="1 of 2 branches missed."> boolean hasDeletedDocuments = (r.getLiveDocs() != null);</span>
<span class="pc bpc" id="L3621" title="1 of 2 branches missed."> if (!hasDeletedDocuments) {</span>
<span class="fc" id="L3622"> result.valueSum[0] = termsEnum.totalTermFreq();</span>
<span class="fc" id="L3623"> result.docNumber = termsEnum.docFreq();</span>
<span class="pc bpc" id="L3624" title="1 of 2 branches missed."> if (result.valueSum[0] > -1) {</span>
<span class="fc" id="L3625"> return result;</span>
}
}
<span class="nc" id="L3628"> 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="L3646"> TermvectorNumberBasic result = new TermvectorNumberBasic();</span>
<span class="fc bfc" id="L3647" title="All 2 branches covered."> boolean hasDeletedDocuments = (r.getLiveDocs() != null);</span>
<span class="pc bpc" id="L3648" title="1 of 4 branches missed."> if ((docSet.size() == r.numDocs()) && !hasDeletedDocuments) {</span>
try {
<span class="fc" id="L3650"> return computeTermvectorNumberBasic(termsEnum, r);</span>
<span class="nc" id="L3651"> } catch (IOException e) {</span>
<span class="nc" id="L3652"> log.debug("problem", e);</span>
// problem
}
}
<span class="fc" id="L3656"> result.docNumber = 0;</span>
<span class="fc" id="L3657"> result.valueSum[0] = 0;</span>
<span class="fc" id="L3658"> int localTermDocId = termDocId;</span>
<span class="fc" id="L3659"> Iterator<Integer> docIterator = docSet.iterator();</span>
<span class="fc" id="L3660"> postingsEnum = termsEnum.postings(postingsEnum, PostingsEnum.FREQS);</span>
int docId;
<span class="fc bfc" id="L3662" title="All 2 branches covered."> while (docIterator.hasNext()) {</span>
<span class="fc" id="L3663"> docId = docIterator.next() - lrc.docBase;</span>
<span class="pc bpc" id="L3664" title="2 of 4 branches missed."> if (docId >= localTermDocId && ((docId == localTermDocId)</span>
<span class="fc bfc" id="L3665" title="All 2 branches covered."> || ((localTermDocId = postingsEnum.advance(docId)) == docId))) {</span>
<span class="fc" id="L3666"> result.docNumber++;</span>
<span class="fc" id="L3667"> result.valueSum[0] += postingsEnum.freq();</span>
}
<span class="pc bpc" id="L3669" title="1 of 2 branches missed."> if (localTermDocId == DocIdSetIterator.NO_MORE_DOCS) {</span>
<span class="nc" id="L3670"> break;</span>
}
}
<span class="fc" id="L3673"> 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="L3692"> TermvectorNumberFull result = new TermvectorNumberFull(docSet.size());</span>
<span class="fc" id="L3693"> Iterator<Integer> docIterator = docSet.iterator();</span>
<span class="fc" id="L3694"> int localTermDocId = termDocId;</span>
<span class="fc" id="L3695"> postingsEnum = termsEnum.postings(postingsEnum, PostingsEnum.FREQS);</span>
<span class="fc bfc" id="L3696" title="All 2 branches covered."> while (docIterator.hasNext()) {</span>
<span class="fc" id="L3697"> int docId = docIterator.next() - lrc.docBase;</span>
<span class="fc bfc" id="L3698" title="All 4 branches covered."> if (docId >= localTermDocId && ((docId == localTermDocId)</span>
<span class="fc bfc" id="L3699" title="All 2 branches covered."> || ((localTermDocId = postingsEnum.advance(docId)) == docId))) {</span>
<span class="fc" id="L3700"> result.args[result.docNumber] = postingsEnum.freq();</span>
<span class="pc bpc" id="L3701" title="1 of 2 branches missed."> result.positions[result.docNumber] = (positionsData == null) ? 0</span>
<span class="pc" id="L3702"> : positionsData.get(docId + lrc.docBase);</span>
<span class="fc" id="L3703"> result.docNumber++;</span>
}
<span class="fc" id="L3705"> }</span>
<span class="fc" id="L3706"> 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>