8
8
import brave .Tracing ;
9
9
import com .google .common .annotations .VisibleForTesting ;
10
10
import com .google .common .base .Stopwatch ;
11
- import com .google .common .util .concurrent .ThreadFactoryBuilder ;
12
11
import com .slack .kaldb .histogram .FixedIntervalHistogramImpl ;
13
12
import com .slack .kaldb .histogram .Histogram ;
14
13
import com .slack .kaldb .histogram .NoOpHistogramImpl ;
23
22
import java .util .Collection ;
24
23
import java .util .Collections ;
25
24
import java .util .List ;
26
- import java .util .concurrent .ExecutorService ;
27
- import java .util .concurrent .Executors ;
28
25
import java .util .concurrent .TimeUnit ;
29
26
import org .apache .lucene .analysis .standard .StandardAnalyzer ;
30
27
import org .apache .lucene .document .LongPoint ;
31
28
import org .apache .lucene .index .DirectoryReader ;
32
- import org .apache .lucene .index .IndexReader ;
33
29
import org .apache .lucene .queryparser .classic .ParseException ;
34
30
import org .apache .lucene .queryparser .classic .QueryParser ;
35
31
import org .apache .lucene .search .BooleanClause .Occur ;
39
35
import org .apache .lucene .search .MultiCollectorManager ;
40
36
import org .apache .lucene .search .Query ;
41
37
import org .apache .lucene .search .ScoreDoc ;
42
- import org .apache .lucene .search .SearcherFactory ;
43
38
import org .apache .lucene .search .SearcherManager ;
44
39
import org .apache .lucene .search .Sort ;
45
40
import org .apache .lucene .search .SortField ;
@@ -63,18 +58,7 @@ public class LogIndexSearcherImpl implements LogIndexSearcher<LogMessage> {
63
58
@ VisibleForTesting
64
59
public static SearcherManager searcherManagerFromPath (Path path ) throws IOException {
65
60
MMapDirectory directory = new MMapDirectory (path );
66
- class CachedThreadPoolSearchFactory extends SearcherFactory {
67
- private final ExecutorService executorService =
68
- Executors .newCachedThreadPool (
69
- new ThreadFactoryBuilder ().setNameFormat ("log-searcher-impl-%d" ).build ());
70
-
71
- @ Override
72
- public IndexSearcher newSearcher (IndexReader reader , IndexReader previousReader ) {
73
- return new IndexSearcher (reader , executorService );
74
- }
75
- }
76
-
77
- return new SearcherManager (directory , new CachedThreadPoolSearchFactory ());
61
+ return new SearcherManager (directory , null );
78
62
}
79
63
80
64
// todo - this is not needed once this data is on the snapshot
@@ -129,19 +113,19 @@ public SearchResult<LogMessage> search(
129
113
// This is a useful optimization for indexes that are static.
130
114
IndexSearcher searcher = searcherManager .acquire ();
131
115
try {
132
- CollectorManager <TopFieldCollector , TopFieldDocs > topFieldCollector =
133
- buildTopFieldCollector (howMany );
116
+ List <LogMessage > results ;
117
+ Histogram histogram = new NoOpHistogramImpl ();
118
+
134
119
CollectorManager <StatsCollector , Histogram > statsCollector =
135
120
buildStatsCollector (bucketCount , startTimeMsEpoch , endTimeMsEpoch );
136
121
137
- MultiCollectorManager collectorManager = new MultiCollectorManager (topFieldCollector );
138
- if (bucketCount > 0 ) {
139
- collectorManager = new MultiCollectorManager (topFieldCollector , statsCollector );
140
- }
141
-
142
- List <LogMessage > results ;
143
- Histogram histogram = new NoOpHistogramImpl ();
144
122
if (howMany > 0 ) {
123
+ CollectorManager <TopFieldCollector , TopFieldDocs > topFieldCollector =
124
+ buildTopFieldCollector (howMany );
125
+ MultiCollectorManager collectorManager = new MultiCollectorManager (topFieldCollector );
126
+ if (bucketCount > 0 ) {
127
+ collectorManager = new MultiCollectorManager (topFieldCollector , statsCollector );
128
+ }
145
129
Object [] collector = searcher .search (query , collectorManager );
146
130
147
131
ScoreDoc [] hits = ((TopFieldDocs ) collector [0 ]).scoreDocs ;
0 commit comments