MtasSolrSearchComponent.java.html
43.7 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
<?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>MtasSolrSearchComponent.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.solr.handler.component</a> > <span class="el_source">MtasSolrSearchComponent.java</span></div><h1>MtasSolrSearchComponent.java</h1><pre class="source lang-java linenums">package mtas.solr.handler.component;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import mtas.codec.MtasCodecPostingsFormat;
import mtas.codec.util.CodecComponent.ComponentDocument;
import mtas.codec.util.CodecComponent.ComponentFacet;
import mtas.codec.util.CodecComponent.ComponentFields;
import mtas.codec.util.CodecComponent.ComponentGroup;
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.CodecUtil;
import mtas.solr.handler.component.util.MtasSolrResultMerge;
import mtas.solr.search.MtasSolrJoinCache;
import mtas.solr.handler.component.util.MtasSolrComponentDocument;
import mtas.solr.handler.component.util.MtasSolrComponentFacet;
import mtas.solr.handler.component.util.MtasSolrComponentGroup;
import mtas.solr.handler.component.util.MtasSolrComponentJoin;
import mtas.solr.handler.component.util.MtasSolrComponentKwic;
import mtas.solr.handler.component.util.MtasSolrComponentList;
import mtas.solr.handler.component.util.MtasSolrComponentPrefix;
import mtas.solr.handler.component.util.MtasSolrComponentStats;
import mtas.solr.handler.component.util.MtasSolrComponentTermvector;
import mtas.solr.handler.component.util.MtasSolrMtasResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.handler.component.ResponseBuilder;
import org.apache.solr.handler.component.SearchComponent;
import org.apache.solr.handler.component.ShardRequest;
import org.apache.solr.handler.component.ShardResponse;
import org.apache.solr.search.DocList;
import org.apache.solr.search.DocSet;
import org.apache.solr.search.SolrIndexSearcher;
/**
* The Class MtasSolrSearchComponent.
*/
<span class="fc" id="L49">public class MtasSolrSearchComponent extends SearchComponent {</span>
/** The log. */
<span class="fc" id="L52"> private static Log log = LogFactory.getLog(MtasSolrSearchComponent.class);</span>
/** The search component. */
MtasSolrSearchComponent searchComponent;
/** The Constant CONFIG_JOIN_CACHE_DIRECTORY. */
public static final String CONFIG_JOIN_CACHE_DIRECTORY = "joinCacheDirectory";
/** The Constant CONFIG_JOIN_LIFETIME. */
public static final String CONFIG_JOIN_LIFETIME = "joinLifetime";
/** The Constant CONFIG_JOIN_MAXIMUM_NUMBER. */
public static final String CONFIG_JOIN_MAXIMUM_NUMBER = "joinMaximumNumber";
/** The Constant CONFIG_JOIN_MAXIMUM_OVERFLOW. */
public static final String CONFIG_JOIN_MAXIMUM_OVERFLOW = "joinMaximumOverflow";
/** The Constant PARAM_MTAS. */
public static final String PARAM_MTAS = "mtas";
/** The Constant STAGE_TERMVECTOR_MISSING_TOP. */
<span class="fc" id="L73"> public static final int STAGE_TERMVECTOR_MISSING_TOP = ResponseBuilder.STAGE_EXECUTE_QUERY</span>
+ 10;
/** The Constant STAGE_TERMVECTOR_MISSING_KEY. */
<span class="fc" id="L77"> public static final int STAGE_TERMVECTOR_MISSING_KEY = ResponseBuilder.STAGE_EXECUTE_QUERY</span>
+ 11;
/** The Constant STAGE_TERMVECTOR_FINISH. */
<span class="fc" id="L81"> public static final int STAGE_TERMVECTOR_FINISH = ResponseBuilder.STAGE_EXECUTE_QUERY</span>
+ 12;
/** The Constant STAGE_LIST. */
<span class="fc" id="L85"> public static final int STAGE_LIST = ResponseBuilder.STAGE_EXECUTE_QUERY + 20;</span>
/** The Constant STAGE_PREFIX. */
<span class="fc" id="L88"> public static final int STAGE_PREFIX = ResponseBuilder.STAGE_EXECUTE_QUERY</span>
+ 30;
/** The Constant STAGE_STATS. */
<span class="fc" id="L92"> public static final int STAGE_STATS = ResponseBuilder.STAGE_EXECUTE_QUERY</span>
+ 40;
/** The Constant STAGE_FACET. */
<span class="fc" id="L96"> public static final int STAGE_FACET = ResponseBuilder.STAGE_EXECUTE_QUERY</span>
+ 50;
/** The Constant STAGE_GROUP. */
<span class="fc" id="L100"> public static final int STAGE_GROUP = ResponseBuilder.STAGE_EXECUTE_QUERY</span>
+ 60;
/** The Constant STAGE_JOIN. */
<span class="fc" id="L104"> public static final int STAGE_JOIN = ResponseBuilder.STAGE_EXECUTE_QUERY + 70;</span>
/** The Constant STAGE_DOCUMENT. */
<span class="fc" id="L107"> public static final int STAGE_DOCUMENT = ResponseBuilder.STAGE_GET_FIELDS</span>
+ 10;
/** The mtas solr result merge. */
private MtasSolrResultMerge mtasSolrResultMerge;
/** The search stats. */
private MtasSolrComponentStats searchStats;
/** The search termvector. */
private MtasSolrComponentTermvector searchTermvector;
/** The search prefix. */
private MtasSolrComponentPrefix searchPrefix;
/** The search facet. */
private MtasSolrComponentFacet searchFacet;
/** The search group. */
private MtasSolrComponentGroup searchGroup;
/** The search list. */
private MtasSolrComponentList searchList;
/** The search kwic. */
private MtasSolrComponentKwic searchKwic;
/** The search document. */
private MtasSolrComponentDocument searchDocument;
/** The search join. */
private MtasSolrComponentJoin searchJoin;
/** The join cache. */
<span class="fc" id="L141"> private MtasSolrJoinCache joinCache = null;</span>
/*
* (non-Javadoc)
*
* @see
* org.apache.solr.handler.component.SearchComponent#init(org.apache.solr.
* common.util.NamedList)
*/
@Override
public void init(NamedList args) {
<span class="fc" id="L152"> super.init(args);</span>
// init components
<span class="fc" id="L154"> searchDocument = new MtasSolrComponentDocument();</span>
<span class="fc" id="L155"> searchKwic = new MtasSolrComponentKwic(this);</span>
<span class="fc" id="L156"> searchList = new MtasSolrComponentList(this);</span>
<span class="fc" id="L157"> searchGroup = new MtasSolrComponentGroup(this);</span>
<span class="fc" id="L158"> searchTermvector = new MtasSolrComponentTermvector(this);</span>
<span class="fc" id="L159"> searchPrefix = new MtasSolrComponentPrefix(this);</span>
<span class="fc" id="L160"> searchStats = new MtasSolrComponentStats(this);</span>
<span class="fc" id="L161"> searchFacet = new MtasSolrComponentFacet(this);</span>
<span class="fc" id="L162"> searchJoin = new MtasSolrComponentJoin(this);</span>
// init join
<span class="fc" id="L164"> String joinCacheDirectory = null;</span>
<span class="fc" id="L165"> Long joinLifetime = null;</span>
<span class="fc" id="L166"> Integer joinMaximumNumber = null;</span>
<span class="fc" id="L167"> Integer joinMaximumOverflow = null;</span>
<span class="pc bpc" id="L168" title="1 of 2 branches missed."> if (args.get(CONFIG_JOIN_CACHE_DIRECTORY) != null</span>
<span class="nc bnc" id="L169" title="All 2 branches missed."> && args.get(CONFIG_JOIN_CACHE_DIRECTORY) instanceof String) {</span>
<span class="nc" id="L170"> joinCacheDirectory = (String) args.get(CONFIG_JOIN_CACHE_DIRECTORY);</span>
}
<span class="pc bpc" id="L172" title="1 of 2 branches missed."> if (args.get(CONFIG_JOIN_LIFETIME) != null</span>
<span class="nc bnc" id="L173" title="All 2 branches missed."> && args.get(CONFIG_JOIN_LIFETIME) instanceof Long) {</span>
<span class="nc" id="L174"> joinLifetime = (Long) args.get(CONFIG_JOIN_LIFETIME);</span>
}
<span class="pc bpc" id="L176" title="1 of 2 branches missed."> if (args.get(CONFIG_JOIN_MAXIMUM_NUMBER) != null</span>
<span class="nc bnc" id="L177" title="All 2 branches missed."> && args.get(CONFIG_JOIN_MAXIMUM_NUMBER) instanceof Integer) {</span>
<span class="nc" id="L178"> joinMaximumNumber = (Integer) args.get(CONFIG_JOIN_MAXIMUM_NUMBER);</span>
}
<span class="pc bpc" id="L180" title="1 of 2 branches missed."> if (args.get(CONFIG_JOIN_MAXIMUM_OVERFLOW) != null</span>
<span class="nc bnc" id="L181" title="All 2 branches missed."> && args.get(CONFIG_JOIN_MAXIMUM_OVERFLOW) instanceof Integer) {</span>
<span class="nc" id="L182"> joinMaximumNumber = (Integer) args.get(CONFIG_JOIN_MAXIMUM_OVERFLOW);</span>
}
<span class="fc" id="L184"> joinCache = new MtasSolrJoinCache(joinCacheDirectory, joinLifetime,</span>
joinMaximumNumber, joinMaximumOverflow);
<span class="fc" id="L186"> }</span>
/*
* (non-Javadoc)
*
* @see org.apache.solr.handler.component.SearchComponent#getVersion()
*/
@Override
public String getVersion() {
<span class="nc" id="L195"> return String.valueOf(MtasCodecPostingsFormat.VERSION_CURRENT);</span>
}
/*
* (non-Javadoc)
*
* @see org.apache.solr.handler.component.SearchComponent#getDescription()
*/
@Override
public String getDescription() {
<span class="fc" id="L205"> return "Mtas";</span>
}
/*
* (non-Javadoc)
*
* @see
* org.apache.solr.handler.component.SearchComponent#prepare(org.apache.solr.
* handler.component.ResponseBuilder)
*/
@Override
public void prepare(ResponseBuilder rb) throws IOException {
//System.out
// .println(System.nanoTime() + " - " + Thread.currentThread().getId()
// + " - " + rb.req.getParams().getBool("isShard", false) + " PREPARE "
// + rb.stage + " " + rb.req.getParamString());
<span class="fc bfc" id="L221" title="All 2 branches covered."> if (rb.req.getParams().getBool(PARAM_MTAS, false)) {</span>
<span class="fc" id="L222"> mtasSolrResultMerge = new MtasSolrResultMerge();</span>
<span class="fc" id="L223"> ComponentFields mtasFields = new ComponentFields();</span>
// get settings document
<span class="fc" id="L225"> if (rb.req.getParams()</span>
<span class="pc bpc" id="L226" title="1 of 2 branches missed."> .getBool(MtasSolrComponentDocument.PARAM_MTAS_DOCUMENT, false)) {</span>
<span class="nc" id="L227"> searchDocument.prepare(rb, mtasFields);</span>
}
// get settings kwic
<span class="pc bpc" id="L230" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentKwic.PARAM_MTAS_KWIC,</span>
false)) {
<span class="nc" id="L232"> searchKwic.prepare(rb, mtasFields);</span>
}
// get settings list
<span class="pc bpc" id="L235" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentList.PARAM_MTAS_LIST,</span>
false)) {
<span class="nc" id="L237"> searchList.prepare(rb, mtasFields);</span>
}
// get settings group
<span class="pc bpc" id="L240" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentGroup.PARAM_MTAS_GROUP,</span>
false)) {
<span class="nc" id="L242"> searchGroup.prepare(rb, mtasFields);</span>
}
// get settings termvector
<span class="fc" id="L245"> if (rb.req.getParams()</span>
<span class="fc bfc" id="L246" title="All 2 branches covered."> .getBool(MtasSolrComponentTermvector.PARAM_MTAS_TERMVECTOR, false)) {</span>
<span class="fc" id="L247"> searchTermvector.prepare(rb, mtasFields);</span>
}
// get settings prefix
<span class="pc bpc" id="L250" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentPrefix.PARAM_MTAS_PREFIX,</span>
false)) {
<span class="nc" id="L252"> searchPrefix.prepare(rb, mtasFields);</span>
}
// get settings stats
<span class="fc bfc" id="L255" title="All 2 branches covered."> if (rb.req.getParams().getBool(MtasSolrComponentStats.PARAM_MTAS_STATS,</span>
false)) {
<span class="fc" id="L257"> searchStats.prepare(rb, mtasFields);</span>
}
// get settings facet
<span class="pc bpc" id="L260" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentFacet.PARAM_MTAS_FACET,</span>
false)) {
<span class="nc" id="L262"> searchFacet.prepare(rb, mtasFields);</span>
}
// get settings join
<span class="pc bpc" id="L265" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentJoin.PARAM_MTAS_JOIN,</span>
false)) {
<span class="nc" id="L267"> searchJoin.prepare(rb, mtasFields);</span>
}
<span class="fc" id="L269"> rb.req.getContext().put(ComponentFields.class, mtasFields);</span>
}
<span class="fc" id="L271"> }</span>
/*
* (non-Javadoc)
*
* @see
* org.apache.solr.handler.component.SearchComponent#process(org.apache.solr.
* handler.component.ResponseBuilder)
*/
@Override
public void process(ResponseBuilder rb) throws IOException {
//System.out
//.println(System.nanoTime() + " - " + Thread.currentThread().getId()
//+ " - " + rb.req.getParams().getBool("isShard", false) + " PROCESS "
//+ rb.stage + " " + rb.req.getParamString());
<span class="fc" id="L286"> ComponentFields mtasFields = getMtasFields(rb);</span>
<span class="fc bfc" id="L287" title="All 2 branches covered."> if (mtasFields != null) {</span>
<span class="fc" id="L288"> DocSet docSet = rb.getResults().docSet;</span>
<span class="fc" id="L289"> DocList docList = rb.getResults().docList;</span>
<span class="pc bpc" id="L290" title="9 of 18 branches missed."> if (mtasFields.doStats || mtasFields.doDocument || mtasFields.doKwic</span>
|| mtasFields.doList || mtasFields.doGroup || mtasFields.doFacet
|| mtasFields.doJoin || mtasFields.doTermVector
|| mtasFields.doPrefix) {
<span class="fc" id="L294"> SolrIndexSearcher searcher = rb.req.getSearcher();</span>
<span class="fc" id="L295"> ArrayList<Integer> docSetList = null;</span>
<span class="fc" id="L296"> ArrayList<Integer> docListList = null;</span>
<span class="pc bpc" id="L297" title="1 of 2 branches missed."> if (docSet != null) {</span>
<span class="fc" id="L298"> docSetList = new ArrayList<>();</span>
<span class="fc" id="L299"> Iterator<Integer> docSetIterator = docSet.iterator();</span>
<span class="fc bfc" id="L300" title="All 2 branches covered."> while (docSetIterator.hasNext()) {</span>
<span class="fc" id="L301"> docSetList.add(docSetIterator.next());</span>
}
<span class="fc" id="L303"> Collections.sort(docSetList);</span>
}
<span class="pc bpc" id="L305" title="1 of 2 branches missed."> if (docList != null) {</span>
<span class="fc" id="L306"> docListList = new ArrayList<>();</span>
<span class="fc" id="L307"> Iterator<Integer> docListIterator = docList.iterator();</span>
<span class="pc bpc" id="L308" title="1 of 2 branches missed."> while (docListIterator.hasNext()) {</span>
<span class="nc" id="L309"> docListList.add(docListIterator.next());</span>
}
<span class="fc" id="L311"> Collections.sort(docListList);</span>
}
<span class="fc bfc" id="L313" title="All 2 branches covered."> for (String field : mtasFields.list.keySet()) {</span>
try {
<span class="fc" id="L315"> CodecUtil.collectField(field, searcher, searcher.getRawReader(),</span>
<span class="fc" id="L316"> docListList, docSetList, mtasFields.list.get(field));</span>
<span class="nc" id="L317"> } catch (IllegalAccessException | IllegalArgumentException</span>
| InvocationTargetException e) {
<span class="nc" id="L319"> log.error(e);</span>
<span class="nc" id="L320"> throw new IOException(e);</span>
<span class="fc" id="L321"> }</span>
<span class="fc" id="L322"> }</span>
<span class="fc" id="L323"> CodecUtil.collectJoin(searcher.getRawReader(), docSetList,</span>
mtasFields.join);
<span class="fc" id="L325"> NamedList<Object> mtasResponse = new SimpleOrderedMap<>();</span>
<span class="pc bpc" id="L326" title="1 of 2 branches missed."> if (mtasFields.doDocument) {</span>
<span class="nc" id="L327"> ArrayList<NamedList<?>> mtasDocumentResponses = new ArrayList<>();</span>
<span class="nc bnc" id="L328" title="All 2 branches missed."> for (String field : mtasFields.list.keySet()) {</span>
for (ComponentDocument document : mtasFields.list
<span class="nc bnc" id="L330" title="All 2 branches missed."> .get(field).documentList) {</span>
<span class="nc" id="L331"> mtasDocumentResponses.add(searchDocument.create(document, false));</span>
<span class="nc" id="L332"> }</span>
<span class="nc" id="L333"> }</span>
// add to response
<span class="nc" id="L335"> mtasResponse.add("document", mtasDocumentResponses);</span>
}
<span class="pc bpc" id="L337" title="1 of 2 branches missed."> if (mtasFields.doKwic) {</span>
<span class="nc" id="L338"> ArrayList<NamedList<?>> mtasKwicResponses = new ArrayList<>();</span>
<span class="nc bnc" id="L339" title="All 2 branches missed."> for (String field : mtasFields.list.keySet()) {</span>
<span class="nc bnc" id="L340" title="All 2 branches missed."> for (ComponentKwic kwic : mtasFields.list.get(field).kwicList) {</span>
<span class="nc" id="L341"> mtasKwicResponses.add(searchKwic.create(kwic, false));</span>
<span class="nc" id="L342"> }</span>
<span class="nc" id="L343"> }</span>
// add to response
<span class="nc" id="L345"> mtasResponse.add("kwic", mtasKwicResponses);</span>
}
<span class="pc bpc" id="L347" title="1 of 2 branches missed."> if (mtasFields.doFacet) {</span>
<span class="nc" id="L348"> ArrayList<NamedList<?>> mtasFacetResponses = new ArrayList<>();</span>
<span class="nc bnc" id="L349" title="All 2 branches missed."> for (String field : mtasFields.list.keySet()) {</span>
<span class="nc bnc" id="L350" title="All 2 branches missed."> for (ComponentFacet facet : mtasFields.list.get(field).facetList) {</span>
<span class="nc bnc" id="L351" title="All 2 branches missed."> if (rb.req.getParams().getBool("isShard", false)) {</span>
<span class="nc" id="L352"> mtasFacetResponses.add(searchFacet.create(facet, true));</span>
} else {
<span class="nc" id="L354"> mtasFacetResponses.add(searchFacet.create(facet, false));</span>
}
<span class="nc" id="L356"> }</span>
<span class="nc" id="L357"> }</span>
// add to response
<span class="nc" id="L359"> mtasResponse.add("facet", mtasFacetResponses);</span>
}
<span class="pc bpc" id="L361" title="1 of 2 branches missed."> if (mtasFields.doJoin) {</span>
// add to response
<span class="nc bnc" id="L363" title="All 2 branches missed."> if (rb.req.getParams().getBool("isShard", false)) {</span>
<span class="nc" id="L364"> mtasResponse.add("join", searchJoin.create(mtasFields.join, true));</span>
} else {
<span class="nc" id="L366"> mtasResponse.add("join", searchJoin.create(mtasFields.join, false));</span>
}
}
<span class="pc bpc" id="L369" title="1 of 2 branches missed."> if (mtasFields.doList) {</span>
<span class="nc" id="L370"> ArrayList<NamedList<?>> mtasListResponses = new ArrayList<>();</span>
<span class="nc bnc" id="L371" title="All 2 branches missed."> for (String field : mtasFields.list.keySet()) {</span>
<span class="nc bnc" id="L372" title="All 2 branches missed."> for (ComponentList list : mtasFields.list.get(field).listList) {</span>
<span class="nc" id="L373"> mtasListResponses.add(searchList.create(list, false));</span>
<span class="nc" id="L374"> }</span>
<span class="nc" id="L375"> }</span>
// add to response
<span class="nc" id="L377"> mtasResponse.add("list", mtasListResponses);</span>
}
<span class="pc bpc" id="L379" title="1 of 2 branches missed."> if (mtasFields.doGroup) {</span>
<span class="nc" id="L380"> ArrayList<NamedList<?>> mtasGroupResponses = new ArrayList<>();</span>
<span class="nc bnc" id="L381" title="All 2 branches missed."> for (String field : mtasFields.list.keySet()) {</span>
<span class="nc bnc" id="L382" title="All 2 branches missed."> for (ComponentGroup group : mtasFields.list.get(field).groupList) {</span>
<span class="nc bnc" id="L383" title="All 2 branches missed."> if (rb.req.getParams().getBool("isShard", false)) {</span>
<span class="nc" id="L384"> mtasGroupResponses.add(searchGroup.create(group, true));</span>
} else {
<span class="nc" id="L386"> mtasGroupResponses.add(searchGroup.create(group, false));</span>
}
<span class="nc" id="L388"> }</span>
<span class="nc" id="L389"> }</span>
// add to response
<span class="nc" id="L391"> mtasResponse.add("group", mtasGroupResponses);</span>
}
<span class="fc bfc" id="L393" title="All 2 branches covered."> if (mtasFields.doTermVector) {</span>
<span class="fc" id="L394"> ArrayList<NamedList<?>> mtasTermVectorResponses = new ArrayList<>();</span>
<span class="fc bfc" id="L395" title="All 2 branches covered."> for (String field : mtasFields.list.keySet()) {</span>
for (ComponentTermVector termVector : mtasFields.list
<span class="fc bfc" id="L397" title="All 2 branches covered."> .get(field).termVectorList) {</span>
<span class="fc bfc" id="L398" title="All 2 branches covered."> if (rb.req.getParams().getBool("isShard", false)) {</span>
<span class="fc" id="L399"> mtasTermVectorResponses</span>
<span class="fc" id="L400"> .add(searchTermvector.create(termVector, true));</span>
} else {
<span class="fc" id="L402"> mtasTermVectorResponses</span>
<span class="fc" id="L403"> .add(searchTermvector.create(termVector, false));</span>
}
<span class="fc" id="L405"> }</span>
<span class="fc" id="L406"> }</span>
// add to response
<span class="fc" id="L408"> mtasResponse.add("termvector", mtasTermVectorResponses);</span>
}
<span class="pc bpc" id="L410" title="1 of 2 branches missed."> if (mtasFields.doPrefix) {</span>
<span class="nc" id="L411"> ArrayList<NamedList<?>> mtasPrefixResponses = new ArrayList<>();</span>
<span class="nc bnc" id="L412" title="All 2 branches missed."> for (String field : mtasFields.list.keySet()) {</span>
<span class="nc bnc" id="L413" title="All 2 branches missed."> if (mtasFields.list.get(field).prefix != null) {</span>
<span class="nc bnc" id="L414" title="All 2 branches missed."> if (rb.req.getParams().getBool("isShard", false)) {</span>
<span class="nc" id="L415"> mtasPrefixResponses.add(searchPrefix</span>
<span class="nc" id="L416"> .create(mtasFields.list.get(field).prefix, true));</span>
} else {
<span class="nc" id="L418"> mtasPrefixResponses.add(searchPrefix</span>
<span class="nc" id="L419"> .create(mtasFields.list.get(field).prefix, false));</span>
}
}
<span class="nc" id="L422"> }</span>
<span class="nc" id="L423"> mtasResponse.add("prefix", mtasPrefixResponses);</span>
}
<span class="fc bfc" id="L425" title="All 2 branches covered."> if (mtasFields.doStats) {</span>
<span class="fc" id="L426"> NamedList<Object> mtasStatsResponse = new SimpleOrderedMap<>();</span>
<span class="pc bpc" id="L427" title="1 of 6 branches missed."> if (mtasFields.doStatsPositions || mtasFields.doStatsTokens</span>
|| mtasFields.doStatsSpans) {
<span class="fc bfc" id="L429" title="All 2 branches covered."> if (mtasFields.doStatsTokens) {</span>
<span class="fc" id="L430"> ArrayList<Object> mtasStatsTokensResponses = new ArrayList<>();</span>
<span class="fc bfc" id="L431" title="All 2 branches covered."> for (String field : mtasFields.list.keySet()) {</span>
for (ComponentToken token : mtasFields.list
<span class="fc bfc" id="L433" title="All 2 branches covered."> .get(field).statsTokenList) {</span>
<span class="fc bfc" id="L434" title="All 2 branches covered."> if (rb.req.getParams().getBool("isShard", false)) {</span>
<span class="fc" id="L435"> mtasStatsTokensResponses</span>
<span class="fc" id="L436"> .add(searchStats.create(token, true));</span>
} else {
<span class="fc" id="L438"> mtasStatsTokensResponses</span>
<span class="fc" id="L439"> .add(searchStats.create(token, false));</span>
}
<span class="fc" id="L441"> }</span>
<span class="fc" id="L442"> }</span>
<span class="fc" id="L443"> mtasStatsResponse.add("tokens", mtasStatsTokensResponses);</span>
}
<span class="fc bfc" id="L445" title="All 2 branches covered."> if (mtasFields.doStatsPositions) {</span>
<span class="fc" id="L446"> ArrayList<Object> mtasStatsPositionsResponses = new ArrayList<>();</span>
<span class="fc bfc" id="L447" title="All 2 branches covered."> for (String field : mtasFields.list.keySet()) {</span>
for (ComponentPosition position : mtasFields.list
<span class="fc bfc" id="L449" title="All 2 branches covered."> .get(field).statsPositionList) {</span>
<span class="fc bfc" id="L450" title="All 2 branches covered."> if (rb.req.getParams().getBool("isShard", false)) {</span>
<span class="fc" id="L451"> mtasStatsPositionsResponses</span>
<span class="fc" id="L452"> .add(searchStats.create(position, true));</span>
} else {
<span class="fc" id="L454"> mtasStatsPositionsResponses</span>
<span class="fc" id="L455"> .add(searchStats.create(position, false));</span>
}
<span class="fc" id="L457"> }</span>
<span class="fc" id="L458"> }</span>
<span class="fc" id="L459"> mtasStatsResponse.add("positions", mtasStatsPositionsResponses);</span>
}
<span class="fc bfc" id="L461" title="All 2 branches covered."> if (mtasFields.doStatsSpans) {</span>
<span class="fc" id="L462"> ArrayList<Object> mtasStatsSpansResponses = new ArrayList<>();</span>
<span class="fc bfc" id="L463" title="All 2 branches covered."> for (String field : mtasFields.list.keySet()) {</span>
for (ComponentSpan span : mtasFields.list
<span class="fc bfc" id="L465" title="All 2 branches covered."> .get(field).statsSpanList) {</span>
<span class="fc bfc" id="L466" title="All 2 branches covered."> if (rb.req.getParams().getBool("isShard", false)) {</span>
<span class="fc" id="L467"> mtasStatsSpansResponses.add(searchStats.create(span, true));</span>
} else {
<span class="fc" id="L469"> mtasStatsSpansResponses</span>
<span class="fc" id="L470"> .add(searchStats.create(span, false));</span>
}
<span class="fc" id="L472"> }</span>
<span class="fc" id="L473"> }</span>
<span class="fc" id="L474"> mtasStatsResponse.add("spans", mtasStatsSpansResponses);</span>
}
// add to response
<span class="fc" id="L477"> mtasResponse.add("stats", mtasStatsResponse);</span>
}
}
// add to response
<span class="fc" id="L481"> rb.rsp.add("mtas", mtasResponse);</span>
}
}
<span class="fc" id="L484"> }</span>
/*
* (non-Javadoc)
*
* @see
* org.apache.solr.handler.component.SearchComponent#modifyRequest(org.apache.
* solr.handler.component.ResponseBuilder,
* org.apache.solr.handler.component.SearchComponent,
* org.apache.solr.handler.component.ShardRequest)
*/
@Override
public void modifyRequest(ResponseBuilder rb, SearchComponent who,
ShardRequest sreq) {
//System.out.println(Thread.currentThread().getId() + " - "
//+ rb.req.getParams().getBool("isShard", false) + " MODIFY REQUEST "
//+ rb.stage + " " + rb.req.getParamString());
<span class="fc bfc" id="L501" title="All 2 branches covered."> if (sreq.params.getBool(PARAM_MTAS, false)) {</span>
<span class="fc bfc" id="L502" title="All 2 branches covered."> if (sreq.params.getBool(MtasSolrComponentStats.PARAM_MTAS_STATS, false)) {</span>
<span class="fc" id="L503"> searchStats.modifyRequest(rb, who, sreq);</span>
}
<span class="fc bfc" id="L505" title="All 2 branches covered."> if (sreq.params.getBool(MtasSolrComponentTermvector.PARAM_MTAS_TERMVECTOR,</span>
false)) {
<span class="fc" id="L507"> searchTermvector.modifyRequest(rb, who, sreq);</span>
}
<span class="pc bpc" id="L509" title="1 of 2 branches missed."> if (sreq.params.getBool(MtasSolrComponentPrefix.PARAM_MTAS_PREFIX,</span>
false)) {
<span class="nc" id="L511"> searchPrefix.modifyRequest(rb, who, sreq);</span>
}
<span class="pc bpc" id="L513" title="1 of 2 branches missed."> if (sreq.params.getBool(MtasSolrComponentFacet.PARAM_MTAS_FACET, false)) {</span>
<span class="nc" id="L514"> searchFacet.modifyRequest(rb, who, sreq);</span>
}
<span class="pc bpc" id="L516" title="1 of 2 branches missed."> if (sreq.params.getBool(MtasSolrComponentJoin.PARAM_MTAS_JOIN, false)) {</span>
<span class="nc" id="L517"> searchJoin.modifyRequest(rb, who, sreq);</span>
}
<span class="pc bpc" id="L519" title="1 of 2 branches missed."> if (sreq.params.getBool(MtasSolrComponentGroup.PARAM_MTAS_GROUP, false)) {</span>
<span class="nc" id="L520"> searchGroup.modifyRequest(rb, who, sreq);</span>
}
<span class="pc bpc" id="L522" title="1 of 2 branches missed."> if (sreq.params.getBool(MtasSolrComponentList.PARAM_MTAS_LIST, false)) {</span>
<span class="nc" id="L523"> searchList.modifyRequest(rb, who, sreq);</span>
}
<span class="pc bpc" id="L525" title="1 of 2 branches missed."> if (sreq.params.getBool(MtasSolrComponentDocument.PARAM_MTAS_DOCUMENT,</span>
false)) {
<span class="nc" id="L527"> searchDocument.modifyRequest(rb, who, sreq);</span>
}
<span class="pc bpc" id="L529" title="1 of 2 branches missed."> if (sreq.params.getBool(MtasSolrComponentKwic.PARAM_MTAS_KWIC, false)) {</span>
<span class="nc" id="L530"> searchKwic.modifyRequest(rb, who, sreq);</span>
}
}
<span class="fc" id="L533"> }</span>
/*
* (non-Javadoc)
*
* @see org.apache.solr.handler.component.SearchComponent#handleResponses(org.
* apache.solr.handler.component.ResponseBuilder,
* org.apache.solr.handler.component.ShardRequest)
*/
@Override
public void handleResponses(ResponseBuilder rb, ShardRequest sreq) {
//System.out
//.println(System.nanoTime() + " - " + Thread.currentThread().getId()
//+ " - " + rb.req.getParams().getBool("isShard", false)
//+ " HANDLERESPONSES " + rb.stage + " " + rb.req.getParamString());
<span class="fc" id="L548"> }</span>
/*
* (non-Javadoc)
*
* @see
* org.apache.solr.handler.component.SearchComponent#distributedProcess(org.
* apache.solr.handler.component.ResponseBuilder)
*/
@Override
public void finishStage(ResponseBuilder rb) {
//System.out
//.println(System.nanoTime() + " - " + Thread.currentThread().getId()
//+ " - " + rb.req.getParams().getBool("isShard", false)
//+ " FINISHRESPONSES " + rb.stage + " " + rb.req.getParamString());
<span class="fc bfc" id="L563" title="All 2 branches covered."> if (rb.req.getParams().getBool(PARAM_MTAS, false)) {</span>
<span class="fc bfc" id="L564" title="All 2 branches covered."> if (rb.req.getParams().getBool(MtasSolrComponentStats.PARAM_MTAS_STATS,</span>
false)) {
<span class="fc" id="L566"> searchStats.finishStage(rb);</span>
}
<span class="fc" id="L568"> if (rb.req.getParams()</span>
<span class="fc bfc" id="L569" title="All 2 branches covered."> .getBool(MtasSolrComponentTermvector.PARAM_MTAS_TERMVECTOR, false)) {</span>
<span class="fc" id="L570"> searchTermvector.finishStage(rb);</span>
}
<span class="pc bpc" id="L572" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentPrefix.PARAM_MTAS_PREFIX,</span>
false)) {
<span class="nc" id="L574"> searchPrefix.finishStage(rb);</span>
}
<span class="pc bpc" id="L576" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentFacet.PARAM_MTAS_FACET,</span>
false)) {
<span class="nc" id="L578"> searchFacet.finishStage(rb);</span>
}
<span class="pc bpc" id="L580" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentJoin.PARAM_MTAS_JOIN,</span>
false)) {
<span class="nc" id="L582"> searchJoin.finishStage(rb);</span>
}
<span class="pc bpc" id="L584" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentGroup.PARAM_MTAS_GROUP,</span>
false)) {
<span class="nc" id="L586"> searchGroup.finishStage(rb);</span>
}
<span class="pc bpc" id="L588" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentList.PARAM_MTAS_LIST,</span>
false)) {
<span class="nc" id="L590"> searchList.finishStage(rb);</span>
}
<span class="fc" id="L592"> if (rb.req.getParams()</span>
<span class="pc bpc" id="L593" title="1 of 2 branches missed."> .getBool(MtasSolrComponentDocument.PARAM_MTAS_DOCUMENT, false)) {</span>
<span class="nc" id="L594"> searchDocument.finishStage(rb);</span>
}
<span class="pc bpc" id="L596" title="1 of 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrComponentKwic.PARAM_MTAS_KWIC,</span>
false)) {
<span class="nc" id="L598"> searchKwic.finishStage(rb);</span>
}
<span class="fc" id="L600"> mtasSolrResultMerge.merge(rb);</span>
}
<span class="fc" id="L602"> }</span>
/*
* (non-Javadoc)
*
* @see
* org.apache.solr.handler.component.SearchComponent#distributedProcess(org.
* apache.solr.handler.component.ResponseBuilder)
*/
@Override
public int distributedProcess(ResponseBuilder rb) throws IOException {
// System.out.println(System.nanoTime() + " - " + Thread.currentThread().getId() + " - "
// + rb.req.getParams().getBool("isShard", false) + " DISTIRBUTEDPROCESS "
// + rb.stage + " " + rb.req.getParamString());
// distributed processes
<span class="fc bfc" id="L617" title="All 2 branches covered."> if (rb.req.getParams().getBool(PARAM_MTAS, false)) {</span>
<span class="fc bfc" id="L618" title="All 6 branches covered."> if (rb.stage == STAGE_TERMVECTOR_MISSING_TOP</span>
|| rb.stage == STAGE_TERMVECTOR_MISSING_KEY
|| rb.stage == STAGE_TERMVECTOR_FINISH) {
<span class="fc" id="L621"> ComponentFields mtasFields = getMtasFields(rb);</span>
<span class="fc" id="L622"> searchTermvector.distributedProcess(rb, mtasFields);</span>
<span class="pc bpc" id="L623" title="1 of 2 branches missed."> } else if (rb.stage == STAGE_LIST) {</span>
<span class="nc" id="L624"> ComponentFields mtasFields = getMtasFields(rb);</span>
<span class="nc" id="L625"> searchList.distributedProcess(rb, mtasFields);</span>
<span class="pc bpc" id="L626" title="1 of 2 branches missed."> } else if (rb.stage == STAGE_PREFIX) {</span>
<span class="nc" id="L627"> ComponentFields mtasFields = getMtasFields(rb);</span>
<span class="nc" id="L628"> searchPrefix.distributedProcess(rb, mtasFields);</span>
<span class="pc bfc" id="L629" title="All 2 branches covered."> } else if (rb.stage == STAGE_STATS) {</span>
<span class="fc" id="L630"> ComponentFields mtasFields = getMtasFields(rb);</span>
<span class="fc" id="L631"> searchStats.distributedProcess(rb, mtasFields);</span>
<span class="pc bpc" id="L632" title="1 of 2 branches missed."> } else if (rb.stage == STAGE_FACET) {</span>
<span class="nc" id="L633"> ComponentFields mtasFields = getMtasFields(rb);</span>
<span class="nc" id="L634"> searchFacet.distributedProcess(rb, mtasFields);</span>
<span class="pc bpc" id="L635" title="1 of 2 branches missed."> } else if (rb.stage == STAGE_JOIN) {</span>
<span class="nc" id="L636"> ComponentFields mtasFields = getMtasFields(rb);</span>
<span class="nc" id="L637"> searchJoin.distributedProcess(rb, mtasFields);</span>
<span class="pc bpc" id="L638" title="1 of 2 branches missed."> } else if (rb.stage == STAGE_GROUP) {</span>
<span class="nc" id="L639"> ComponentFields mtasFields = getMtasFields(rb);</span>
<span class="nc" id="L640"> searchGroup.distributedProcess(rb, mtasFields);</span>
<span class="pc bpc" id="L641" title="1 of 2 branches missed."> } else if (rb.stage == STAGE_DOCUMENT) {</span>
<span class="nc" id="L642"> ComponentFields mtasFields = getMtasFields(rb);</span>
<span class="nc" id="L643"> searchDocument.distributedProcess(rb, mtasFields);</span>
}
// compute new stage and return if not finished
<span class="fc bfc" id="L646" title="All 4 branches covered."> if (rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY</span>
&& rb.stage < ResponseBuilder.STAGE_GET_FIELDS) {
<span class="fc bfc" id="L648" title="All 2 branches covered."> if (rb.stage < STAGE_TERMVECTOR_MISSING_TOP</span>
<span class="fc bfc" id="L649" title="All 2 branches covered."> && rb.req.getParams().getBool(</span>
MtasSolrComponentTermvector.PARAM_MTAS_TERMVECTOR, false)) {
<span class="fc" id="L651"> return STAGE_TERMVECTOR_MISSING_TOP;</span>
<span class="fc bfc" id="L652" title="All 2 branches covered."> } else if (rb.stage < STAGE_TERMVECTOR_MISSING_KEY</span>
<span class="fc bfc" id="L653" title="All 2 branches covered."> && rb.req.getParams().getBool(</span>
MtasSolrComponentTermvector.PARAM_MTAS_TERMVECTOR, false)) {
<span class="fc" id="L655"> return STAGE_TERMVECTOR_MISSING_KEY;</span>
<span class="fc bfc" id="L656" title="All 2 branches covered."> } else if (rb.stage < STAGE_TERMVECTOR_FINISH</span>
<span class="fc bfc" id="L657" title="All 2 branches covered."> && rb.req.getParams().getBool(</span>
MtasSolrComponentTermvector.PARAM_MTAS_TERMVECTOR, false)) {
<span class="fc" id="L659"> return STAGE_TERMVECTOR_FINISH;</span>
<span class="fc bfc" id="L660" title="All 2 branches covered."> } else if (rb.stage < STAGE_LIST && rb.req.getParams()</span>
<span class="pc bpc" id="L661" title="1 of 2 branches missed."> .getBool(MtasSolrComponentList.PARAM_MTAS_LIST, false)) {</span>
<span class="nc" id="L662"> return STAGE_LIST;</span>
<span class="fc bfc" id="L663" title="All 2 branches covered."> } else if (rb.stage < STAGE_PREFIX && rb.req.getParams()</span>
<span class="pc bpc" id="L664" title="1 of 2 branches missed."> .getBool(MtasSolrComponentPrefix.PARAM_MTAS_PREFIX, false)) {</span>
<span class="nc" id="L665"> return STAGE_PREFIX;</span>
<span class="fc bfc" id="L666" title="All 2 branches covered."> } else if (rb.stage < STAGE_STATS && rb.req.getParams()</span>
<span class="fc bfc" id="L667" title="All 2 branches covered."> .getBool(MtasSolrComponentStats.PARAM_MTAS_STATS, false)) {</span>
<span class="fc" id="L668"> return STAGE_STATS;</span>
<span class="pc bpc" id="L669" title="1 of 2 branches missed."> } else if (rb.stage < STAGE_FACET && rb.req.getParams()</span>
<span class="pc bpc" id="L670" title="1 of 2 branches missed."> .getBool(MtasSolrComponentFacet.PARAM_MTAS_FACET, false)) {</span>
<span class="nc" id="L671"> return STAGE_FACET;</span>
<span class="pc bpc" id="L672" title="1 of 2 branches missed."> } else if (rb.stage < STAGE_GROUP && rb.req.getParams()</span>
<span class="pc bpc" id="L673" title="1 of 2 branches missed."> .getBool(MtasSolrComponentGroup.PARAM_MTAS_GROUP, false)) {</span>
<span class="nc" id="L674"> return STAGE_GROUP;</span>
<span class="pc bpc" id="L675" title="1 of 2 branches missed."> } else if (rb.stage < STAGE_JOIN && rb.req.getParams()</span>
<span class="pc bpc" id="L676" title="1 of 2 branches missed."> .getBool(MtasSolrComponentJoin.PARAM_MTAS_JOIN, false)) {</span>
<span class="nc" id="L677"> return STAGE_JOIN;</span>
}
<span class="pc bpc" id="L679" title="1 of 4 branches missed."> } else if (rb.stage >= ResponseBuilder.STAGE_GET_FIELDS</span>
&& rb.stage < ResponseBuilder.STAGE_DONE) {
<span class="pc bpc" id="L681" title="1 of 2 branches missed."> if (rb.stage < STAGE_DOCUMENT && rb.req.getParams()</span>
<span class="pc bpc" id="L682" title="1 of 2 branches missed."> .getBool(MtasSolrComponentDocument.PARAM_MTAS_DOCUMENT, false)) {</span>
<span class="nc" id="L683"> return STAGE_DOCUMENT;</span>
}
}
}
<span class="fc" id="L687"> return ResponseBuilder.STAGE_DONE;</span>
}
/**
* Gets the mtas fields.
*
* @param rb
* the rb
* @return the mtas fields
*/
private ComponentFields getMtasFields(ResponseBuilder rb) {
<span class="fc" id="L699"> return (ComponentFields) rb.req.getContext().get(ComponentFields.class);</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>