You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2016/02/22 19:00:52 UTC
lucene-solr git commit: SOLR-8691: Cache index fingerprints per
searcher
Repository: lucene-solr
Updated Branches:
refs/heads/master f47e6b220 -> 120326464
SOLR-8691: Cache index fingerprints per searcher
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/12032646
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/12032646
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/12032646
Branch: refs/heads/master
Commit: 12032646406239e3d4afb84652cdbf91d0025ea4
Parents: f47e6b2
Author: yonik <yo...@apache.org>
Authored: Mon Feb 22 13:00:38 2016 -0500
Committer: yonik <yo...@apache.org>
Committed: Mon Feb 22 13:00:38 2016 -0500
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
.../org/apache/solr/search/SolrIndexSearcher.java | 18 ++++++++++++++++++
.../org/apache/solr/update/IndexFingerprint.java | 5 +++--
3 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/12032646/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f005ae8..866fdde 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/12032646/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 8057a97..da0c7bf 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -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
/////////////////////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/12032646/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java b/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java
index 1ece092..7b8a731 100644
--- a/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java
+++ b/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java
@@ -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();