mirror of https://github.com/apache/lucene.git
SOLR-8691: Cache index fingerprints per searcher
This commit is contained in:
parent
f47e6b2200
commit
1203264640
|
@ -297,6 +297,8 @@ Other Changes
|
|||
* SOLR-8690: Make peersync fingerprinting optional with solr.disableFingerprint system
|
||||
property. (yonik)
|
||||
|
||||
* SOLR-8691: Cache index fingerprints per searcher. (yonik)
|
||||
|
||||
======================= 5.5.0 =======================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
|
||||
|
|
|
@ -123,6 +123,7 @@ import org.apache.solr.schema.TrieFloatField;
|
|||
import org.apache.solr.schema.TrieIntField;
|
||||
import org.apache.solr.search.facet.UnInvertedField;
|
||||
import org.apache.solr.search.stats.StatsSource;
|
||||
import org.apache.solr.update.IndexFingerprint;
|
||||
import org.apache.solr.update.SolrIndexConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -192,6 +193,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
|
|||
private final String path;
|
||||
private boolean releaseDirectory;
|
||||
|
||||
private volatile IndexFingerprint fingerprint;
|
||||
private final Object fingerprintLock = new Object();
|
||||
|
||||
private static DirectoryReader getReader(SolrCore core, SolrIndexConfig config, DirectoryFactory directoryFactory,
|
||||
String path) throws IOException {
|
||||
final Directory dir = directoryFactory.get(path, DirContext.DEFAULT, config.lockType);
|
||||
|
@ -2398,6 +2402,20 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
|
|||
return super.explain(QueryUtils.makeQueryable(query), doc);
|
||||
}
|
||||
|
||||
/** @lucene.internal
|
||||
* gets a cached version of the IndexFingerprint for this searcher
|
||||
**/
|
||||
public IndexFingerprint getIndexFingerprint(long maxVersion) throws IOException {
|
||||
// possibly expensive, so prevent more than one thread from calculating it for this searcher
|
||||
synchronized (fingerprintLock) {
|
||||
if (fingerprint == null) {
|
||||
fingerprint = IndexFingerprint.getFingerprint(this, maxVersion);
|
||||
}
|
||||
}
|
||||
|
||||
return fingerprint;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// SolrInfoMBean stuff: Statistics and Module Info
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -76,12 +76,12 @@ public class IndexFingerprint {
|
|||
return maxDoc;
|
||||
}
|
||||
|
||||
/** Opens a new realtime searcher and returns it's fingerprint */
|
||||
/** Opens a new realtime searcher and returns it's (possibly cached) fingerprint */
|
||||
public static IndexFingerprint getFingerprint(SolrCore core, long maxVersion) throws IOException {
|
||||
core.getUpdateHandler().getUpdateLog().openRealtimeSearcher();
|
||||
RefCounted<SolrIndexSearcher> newestSearcher = core.getUpdateHandler().getUpdateLog().uhandler.core.getRealtimeSearcher();
|
||||
try {
|
||||
return getFingerprint(newestSearcher.get(), maxVersion);
|
||||
return newestSearcher.get().getIndexFingerprint(maxVersion);
|
||||
} finally {
|
||||
if (newestSearcher != null) {
|
||||
newestSearcher.decref();
|
||||
|
@ -89,6 +89,7 @@ public class IndexFingerprint {
|
|||
}
|
||||
}
|
||||
|
||||
/** Calculates an index fingerprint */
|
||||
public static IndexFingerprint getFingerprint(SolrIndexSearcher searcher, long maxVersion) throws IOException {
|
||||
RTimer timer = new RTimer();
|
||||
|
||||
|
|
Loading…
Reference in New Issue