public class Monitor
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Class and Description |
|---|---|
private class |
Monitor.PresearcherQueryCollector<T extends QueryMatch> |
static class |
Monitor.QueryCacheStats
Statistics for the query cache and query index
|
private static class |
Monitor.StandardQueryCollector<T extends QueryMatch> |
| Modifier and Type | Field and Description |
|---|---|
private Analyzer |
analyzer |
private long |
commitBatchSize |
private long |
lastPurged |
private java.util.List<MonitorUpdateListener> |
listeners |
protected Presearcher |
presearcher |
private java.util.concurrent.ScheduledExecutorService |
purgeExecutor |
private QueryIndex |
queryIndex |
| Constructor and Description |
|---|
Monitor(Analyzer analyzer)
Create a non-persistent Monitor instance with the default term-filtering Presearcher
|
Monitor(Analyzer analyzer,
MonitorConfiguration config)
Create a new Monitor instance with a specific configuration
|
Monitor(Analyzer analyzer,
Presearcher presearcher)
Create a new non-persistent Monitor instance
|
Monitor(Analyzer analyzer,
Presearcher presearcher,
MonitorConfiguration configuration)
Create a new Monitor instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
addQueryIndexUpdateListener(MonitorUpdateListener listener)
Register a
MonitorUpdateListener that will be notified whenever changes
are made to the Monitor's queryindex |
void |
clear()
Delete all queries from the monitor
|
void |
close() |
private void |
commit(java.util.List<MonitorQuery> updates) |
<T extends QueryMatch> |
debug(Document[] docs,
MatcherFactory<T> factory)
Match a DocumentBatch against the queries stored in the Monitor, also returning information
about which queries were selected by the presearcher, and why.
|
<T extends QueryMatch> |
debug(Document doc,
MatcherFactory<T> factory)
Match a single
Document against the queries stored in the Monitor, also returning information
about which queries were selected by the presearcher, and why. |
void |
deleteById(java.util.List<java.lang.String> queryIds)
Delete queries from the monitor by ID
|
void |
deleteById(java.lang.String... queryIds)
Delete queries from the monitor by ID
|
int |
getDisjunctCount() |
MonitorQuery |
getQuery(java.lang.String queryId)
Get the MonitorQuery for a given query id
|
Monitor.QueryCacheStats |
getQueryCacheStats() |
int |
getQueryCount() |
java.util.Set<java.lang.String> |
getQueryIds() |
<T extends QueryMatch> |
match(Document[] docs,
MatcherFactory<T> factory)
Match an array of
Documents against the queryindex, calling a CandidateMatcher produced by the
supplied MatcherFactory for each possible matching query. |
<T extends QueryMatch> |
match(Document doc,
MatcherFactory<T> factory)
Match a single
Document against the queryindex, calling a CandidateMatcher produced by the
supplied MatcherFactory for each possible matching query. |
void |
purgeCache()
Remove unused queries from the query cache.
|
void |
register(java.lang.Iterable<MonitorQuery> queries)
Add new queries to the monitor
|
void |
register(MonitorQuery... queries)
Add new queries to the monitor
|
protected final Presearcher presearcher
private final Analyzer analyzer
private final QueryIndex queryIndex
private final java.util.List<MonitorUpdateListener> listeners
private final long commitBatchSize
private final java.util.concurrent.ScheduledExecutorService purgeExecutor
private long lastPurged
public Monitor(Analyzer analyzer) throws java.io.IOException
analyzer - to analyze Documents at match timejava.io.IOExceptionpublic Monitor(Analyzer analyzer, Presearcher presearcher) throws java.io.IOException
analyzer - to analyze Documents at match timepresearcher - the presearcher to usejava.io.IOExceptionpublic Monitor(Analyzer analyzer, MonitorConfiguration config) throws java.io.IOException
analyzer - to analyze Documents at match timeconfig - the configurationjava.io.IOExceptionpublic Monitor(Analyzer analyzer, Presearcher presearcher, MonitorConfiguration configuration) throws java.io.IOException
analyzer - to analyze Documents at match timepresearcher - the presearcher to useconfiguration - the configurationjava.io.IOExceptionpublic void addQueryIndexUpdateListener(MonitorUpdateListener listener)
MonitorUpdateListener that will be notified whenever changes
are made to the Monitor's queryindexlistener - listener to registerpublic Monitor.QueryCacheStats getQueryCacheStats()
public void purgeCache()
throws java.io.IOException
This is normally called from a background thread at a rate set by configurePurgeFrequency().
java.io.IOException - on IO errorspublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void register(java.lang.Iterable<MonitorQuery> queries) throws java.io.IOException
queries - the MonitorQueries to addjava.io.IOExceptionprivate void commit(java.util.List<MonitorQuery> updates) throws java.io.IOException
java.io.IOExceptionpublic void register(MonitorQuery... queries) throws java.io.IOException
queries - the MonitorQueries to addjava.io.IOException - on IO errorspublic void deleteById(java.util.List<java.lang.String> queryIds)
throws java.io.IOException
queryIds - the IDs to deletejava.io.IOException - on IO errorspublic void deleteById(java.lang.String... queryIds)
throws java.io.IOException
queryIds - the IDs to deletejava.io.IOException - on IO errorspublic void clear()
throws java.io.IOException
java.io.IOException - on IO errorspublic <T extends QueryMatch> MultiMatchingQueries<T> match(Document[] docs, MatcherFactory<T> factory) throws java.io.IOException
Documents against the queryindex, calling a CandidateMatcher produced by the
supplied MatcherFactory for each possible matching query.T - the type of QueryMatch to returndocs - the DocumentBatch to matchfactory - a MatcherFactory to use to create a CandidateMatcher for the match runMatchingQueries object summarizing the match run.java.io.IOException - on IO errorspublic <T extends QueryMatch> MatchingQueries<T> match(Document doc, MatcherFactory<T> factory) throws java.io.IOException
Document against the queryindex, calling a CandidateMatcher produced by the
supplied MatcherFactory for each possible matching query.T - the type of QueryMatch to returndoc - the InputDocument to matchfactory - a MatcherFactory to use to create a CandidateMatcher for the match runMatchingQueries object summarizing the match run.java.io.IOException - on IO errorspublic MonitorQuery getQuery(java.lang.String queryId) throws java.io.IOException
queryId - the id of the query to getjava.io.IOException - on IO errorsjava.lang.IllegalStateException - if queries are not stored in the queryindexpublic int getDisjunctCount()
public int getQueryCount()
throws java.io.IOException
java.io.IOException - on IO errorspublic java.util.Set<java.lang.String> getQueryIds()
throws java.io.IOException
java.io.IOException - on IO errorspublic <T extends QueryMatch> PresearcherMatches<T> debug(Document[] docs, MatcherFactory<T> factory) throws java.io.IOException
T - the type of QueryMatch produced by the CandidateMatcherdocs - a DocumentBatch to match against the indexfactory - a MatcherFactory to use to create a CandidateMatcher for the match runPresearcherMatches object containing debug informationjava.io.IOException - on IO errorspublic <T extends QueryMatch> PresearcherMatches<T> debug(Document doc, MatcherFactory<T> factory) throws java.io.IOException
Document against the queries stored in the Monitor, also returning information
about which queries were selected by the presearcher, and why.T - the type of QueryMatch produced by the CandidateMatcherdoc - an InputDocument to match against the indexfactory - a MatcherFactory to use to create a CandidateMatcher for the match runPresearcherMatches object containing debug informationjava.io.IOException - on IO errors