Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-730: use read-only IndexReaders

Yonik Seeley82c3334f9fb9
diff --git a/CHANGES.txt b/CHANGES.txt
index 64fc7bf1bfc..697fe09c00d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -399,6 +399,11 @@ Optimizations
9. SOLR-587: Delete by Query performance greatly improved by using
new underlying Lucene IndexWriter implementation. (yonik)
+10. SOLR-730: Use read-only IndexReaders that don't synchronize
+ isDeleted(). This will speed up function queries and *:* queries
+ as well as improve their scalability on multi-CPU systems.
+ (Mark Miller via yonik)
+
Bug Fixes
1. Make TextField respect sortMissingFirst and sortMissingLast fields.
(J.J. Larrea via yonik)
diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java
index ebea931a690..49b084bbadd 100644
--- a/src/java/org/apache/solr/core/SolrCore.java
+++ b/src/java/org/apache/solr/core/SolrCore.java
@@ -260,7 +260,12 @@ public final class SolrCore implements SolrInfoMBean {
// gets a non-caching searcher
public SolrIndexSearcher newSearcher(String name) throws IOException {
- return new SolrIndexSearcher(this, schema, name,getIndexDir(),false);
+ return newSearcher(name, false);
+ }
+
+ // gets a non-caching searcher
+ public SolrIndexSearcher newSearcher(String name, boolean readOnly) throws IOException {
+ return new SolrIndexSearcher(this, schema, "main", IndexReader.open(FSDirectory.getDirectory(getIndexDir()), readOnly), true, false);
}
@@ -852,6 +857,10 @@ public final class SolrCore implements SolrInfoMBean {
* be registered before running the event handlers (a slow searcher is better than no searcher).
*
* <p>
+ * These searchers contain read-only IndexReaders. To access a non read-only IndexReader,
+ * see newSearcher(String name, boolean readOnly).
+ *
+ * <p>
* If <tt>forceNew==true</tt> then
* A new searcher will be opened and registered regardless of whether there is already
* a registered searcher or other searchers in the process of being created.
@@ -935,7 +944,7 @@ public final class SolrCore implements SolrInfoMBean {
// if this fails, we need to decrement onDeckSearchers again.
SolrIndexSearcher tmp;
try {
- tmp = new SolrIndexSearcher(this, schema, "main", getIndexDir(), true);
+ tmp = new SolrIndexSearcher(this, schema, "main", IndexReader.open(FSDirectory.getDirectory(getIndexDir()), true), true, true);
} catch (Throwable th) {
synchronized(searcherLock) {
onDeckSearchers--;
diff --git a/src/java/org/apache/solr/search/SolrIndexSearcher.java b/src/java/org/apache/solr/search/SolrIndexSearcher.java
index e730b2f5418..0b2cb8a760f 100644
--- a/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -104,7 +104,7 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean {
this(core, schema,name,r, false, enableCache);
}
- private SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, IndexReader r, boolean closeReader, boolean enableCache) {
+ public SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, IndexReader r, boolean closeReader, boolean enableCache) {
this.core = core;
this.schema = schema;
this.name = "Searcher@" + Integer.toHexString(hashCode()) + (name!=null ? " "+name : "");