You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/11/17 08:33:44 UTC
[23/40] lucene-solr:jira/solr-11285-sim: SOLR-11595: optimize
SolrIndexSearcher.collectionStatistics
SOLR-11595: optimize SolrIndexSearcher.collectionStatistics
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/3923e9fb
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/3923e9fb
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/3923e9fb
Branch: refs/heads/jira/solr-11285-sim
Commit: 3923e9fba3ebb9e6e0526dc4a511d4e33b366c90
Parents: d77d54b
Author: David Smiley <ds...@apache.org>
Authored: Tue Nov 14 16:58:49 2017 -0500
Committer: David Smiley <ds...@apache.org>
Committed: Tue Nov 14 16:58:49 2017 -0500
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
.../java/org/apache/solr/search/SolrIndexSearcher.java | 10 +++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3923e9fb/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index fe85f18..e603456 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -123,6 +123,9 @@ Optimizations
* SOLR-11641: Change `frange` to default to `cost=100` so default behavior is to PostFilter if user specifies
`cache=false` (hossman)
+* SOLR-11595: SolrIndexSearcher.localCollectionStatistics is now faster by leveraging an existing
+ cached MultiFields. Noticeable when many fields are searched. (David Smiley)
+
Other Changes
----------------------
* SOLR-11478: Solr should remove itself from live_nodes in zk immediately on shutdown. (Cao Manh Dat)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3923e9fb/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 6a178cb..0e8c022 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -367,7 +367,15 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
}
public CollectionStatistics localCollectionStatistics(String field) throws IOException {
- return super.collectionStatistics(field);
+ // Could call super.collectionStatistics(field); but we can use a cached MultiTerms
+ assert field != null;
+ // SlowAtomicReader has a cache of MultiTerms
+ Terms terms = getSlowAtomicReader().terms(field);
+ if (terms == null) {
+ return null;
+ }
+ return new CollectionStatistics(field, reader.maxDoc(),
+ terms.getDocCount(), terms.getSumTotalTermFreq(), terms.getSumDocFreq());
}
public boolean isCachingEnabled() {