T - the type of QueryMatch to returnpublic class PartitionMatcher<T extends QueryMatch> extends CandidateMatcher<T>
This class delegates the matching to separate CandidateMatcher classes, built from a passed in MatcherFactory.
Use this if your query sets contain large numbers of very fast queries, where
the synchronization overhead of ParallelMatcher
can outweigh the benefit of multithreading.
ParallelMatcher| Modifier and Type | Class and Description |
|---|---|
private class |
PartitionMatcher.MatcherWorker |
private static class |
PartitionMatcher.MatchTask |
private static class |
PartitionMatcher.PartitionMatcherFactory<T extends QueryMatch> |
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.ExecutorService |
executor |
private MatcherFactory<T> |
matcherFactory |
private CandidateMatcher<T> |
resolvingMatcher |
private java.util.List<PartitionMatcher.MatchTask> |
tasks |
private int |
threads |
searcher| Modifier | Constructor and Description |
|---|---|
private |
PartitionMatcher(IndexSearcher searcher,
java.util.concurrent.ExecutorService executor,
MatcherFactory<T> matcherFactory,
int threads) |
| 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(java.util.concurrent.ExecutorService executor,
MatcherFactory<T> matcherFactory)
Create a new MatcherFactory for a PartitionMatcher
|
static <T extends QueryMatch> |
factory(java.util.concurrent.ExecutorService executor,
MatcherFactory<T> matcherFactory,
int threads)
Create a new MatcherFactory for a PartitionMatcher
|
protected void |
matchQuery(java.lang.String queryId,
Query matchQuery,
java.util.Map<java.lang.String,java.lang.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
|
(package private) static <T> java.util.List<java.util.List<T>> |
partition(java.util.List<T> items,
int slices) |
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, finish, reportErrorprivate final java.util.concurrent.ExecutorService executor
private final MatcherFactory<T extends QueryMatch> matcherFactory
private final int threads
private final CandidateMatcher<T extends QueryMatch> resolvingMatcher
private final java.util.List<PartitionMatcher.MatchTask> tasks
private PartitionMatcher(IndexSearcher searcher, java.util.concurrent.ExecutorService executor, MatcherFactory<T> matcherFactory, int threads)
protected void matchQuery(java.lang.String queryId,
Query matchQuery,
java.util.Map<java.lang.String,java.lang.String> metadata)
CandidateMatchermatchQuery in class CandidateMatcher<T extends QueryMatch>queryId - the query idmatchQuery - the query to runmetadata - the query metadatapublic T resolve(T match1, T match2)
CandidateMatcherresolve in class CandidateMatcher<T extends QueryMatch>match1 - the first match foundmatch2 - the second match foundprotected void doFinish()
CandidateMatcherdoFinish in class CandidateMatcher<T extends QueryMatch>public static <T extends QueryMatch> MatcherFactory<T> factory(java.util.concurrent.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(java.util.concurrent.ExecutorService executor, MatcherFactory<T> matcherFactory)
This factory will create a PartitionMatcher 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 submatchersstatic <T> java.util.List<java.util.List<T>> partition(java.util.List<T> items,
int slices)