T
- the QueryMatch type returnedpublic class ParallelMatcher<T extends QueryMatch> extends CandidateMatcher<T>
This class delegates the actual matching to separate CandidateMatcher classes, built from a passed in MatcherFactory.
Use this when individual queries can take a long time to run, and you want to minimize latency. The matcher distributes queries amongst its worker threads using a BlockingQueue, and synchronization overhead may affect performance if the individual queries are very fast.
PartitionMatcher
searcher
Modifier and Type | Method and Description |
---|---|
protected void |
doFinish()
Called when all monitoring of a batch of documents is complete
|
static <T extends QueryMatch> |
factory(ExecutorService executor,
MatcherFactory<T> matcherFactory)
Create a new MatcherFactory for a ParallelMatcher
|
static <T extends QueryMatch> |
factory(ExecutorService executor,
MatcherFactory<T> matcherFactory,
int threads)
Create a new MatcherFactory for a ParallelMatcher
|
protected void |
matchQuery(String queryId,
Query matchQuery,
Map<String,String> metadata)
Runs the supplied query against this CandidateMatcher's set of documents, storing any
resulting match, and recording the query in the presearcher hits
|
T |
resolve(T match1,
T match2)
If two matches from the same query are found (for example, two branches of a disjunction),
combine them.
|
addMatch, copyMatches
protected void matchQuery(String queryId, Query matchQuery, Map<String,String> metadata) throws IOException
CandidateMatcher
matchQuery
in class CandidateMatcher<T extends QueryMatch>
queryId
- the query idmatchQuery
- the query to runmetadata
- the query metadataIOException
- on IO errorspublic T resolve(T match1, T match2)
CandidateMatcher
resolve
in class CandidateMatcher<T extends QueryMatch>
match1
- the first match foundmatch2
- the second match foundprotected void doFinish()
CandidateMatcher
doFinish
in class CandidateMatcher<T extends QueryMatch>
public static <T extends QueryMatch> MatcherFactory<T> factory(ExecutorService executor, MatcherFactory<T> matcherFactory, int threads)
T
- the type of QueryMatch generatedexecutor
- the ExecutorService to usematcherFactory
- the MatcherFactory to use to create submatchersthreads
- the number of threads to usepublic static <T extends QueryMatch> MatcherFactory<T> factory(ExecutorService executor, MatcherFactory<T> matcherFactory)
This factory will create a ParallelMatcher that uses as many threads as there are cores available
to the JVM (as determined by Runtime.getRuntime().availableProcessors()
).
T
- the type of QueryMatch generatedexecutor
- the ExecutorService to usematcherFactory
- the MatcherFactory to use to create submatchersCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.