lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject lucene-solr:master: SOLR-12233: QParserPlugin's static registry of builtins can be optimized to avoid needless ClassLoader activity on SolrCore load.
Date Tue, 05 Jun 2018 19:11:39 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master cf6339218 -> 0c6f38a31


SOLR-12233: QParserPlugin's static registry of builtins can be optimized
 to avoid needless ClassLoader activity on SolrCore load.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/0c6f38a3
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/0c6f38a3
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/0c6f38a3

Branch: refs/heads/master
Commit: 0c6f38a315d0df5abd01e7d4efe481bc53444a49
Parents: cf63392
Author: Jeff <jeff.miller@salesforce.com>
Authored: Tue Jun 5 15:11:32 2018 -0400
Committer: David Smiley <dsmiley@apache.org>
Committed: Tue Jun 5 15:11:32 2018 -0400

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  6 +-
 .../src/java/org/apache/solr/core/SolrCore.java |  2 +-
 .../org/apache/solr/search/QParserPlugin.java   | 80 ++++++++++----------
 .../solr/search/TestStandardQParsers.java       | 10 +--
 4 files changed, 51 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0c6f38a3/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 479406f..5adc677 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -155,7 +155,7 @@ New Features
 * SOLR-12389: support deeply nested json objects in clusterprops.json (noble)
 
 * SOLR-12376: Added the TaggerRequestHandler (AKA SolrTextTagger) for tagging text.  It's
used as a component of
-  NER/ERD systems including query-understanding.  See the ref guide for more info.  (David
Smiley
+  NER/ERD systems including query-understanding.  See the ref guide for more info.  (David
Smiley)
 
 Bug Fixes
 ----------------------
@@ -332,6 +332,10 @@ Optimizations
 
 * SOLR-9922: Write buffering updates to another tlog. (Cao Manh Dat)
 
+* SOLR-12233: QParserPlugin's built-in static registry now holds actual QParserPlugin instances
instead of class
+  references.  This is consistent with other plugin registries and allows a SolrCore to load
faster.
+  (Jeff Miller, David Smiley)
+
 Other Changes
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0c6f38a3/solr/core/src/java/org/apache/solr/core/SolrCore.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 99c0cca..feab22d 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -958,7 +958,7 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer,
Closeab
       initIndex(prev != null, reload);
 
       initWriters();
-      qParserPlugins.init(createInstances(QParserPlugin.standardPlugins), this);
+      qParserPlugins.init(QParserPlugin.standardPlugins, this);
       valueSourceParsers.init(ValueSourceParser.standardValueSourceParsers, this);
       transformerFactories.init(TransformerFactory.defaultFactories, this);
       loadSearchComponents();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0c6f38a3/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/QParserPlugin.java b/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
index f80bc9c..b20c3c8 100644
--- a/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
@@ -37,53 +37,53 @@ public abstract class QParserPlugin implements NamedListInitializedPlugin,
SolrI
   public static final String DEFAULT_QTYPE = LuceneQParserPlugin.NAME;
 
   /**
-   * Internal use - name to class mappings of builtin parsers.
+   * Internal use - name to parser for the builtin parsers.
    * Each query parser plugin extending {@link QParserPlugin} has own instance of standardPlugins.
    * This leads to cyclic dependencies of static fields and to case when NAME field is not
yet initialized.
    * This result to NPE during initialization.
    * For every plugin, listed here, NAME field has to be final and static.
    */
-  public static final Map<String, Class<? extends QParserPlugin>> standardPlugins;
+  public static final Map<String, QParserPlugin> standardPlugins;
 
   static {
-    HashMap<String, Class<? extends QParserPlugin>> map = new HashMap<>(30,
1);
-    map.put(LuceneQParserPlugin.NAME, LuceneQParserPlugin.class);
-    map.put(FunctionQParserPlugin.NAME, FunctionQParserPlugin.class);
-    map.put(PrefixQParserPlugin.NAME, PrefixQParserPlugin.class);
-    map.put(BoostQParserPlugin.NAME, BoostQParserPlugin.class);
-    map.put(DisMaxQParserPlugin.NAME, DisMaxQParserPlugin.class);
-    map.put(ExtendedDismaxQParserPlugin.NAME, ExtendedDismaxQParserPlugin.class);
-    map.put(FieldQParserPlugin.NAME, FieldQParserPlugin.class);
-    map.put(RawQParserPlugin.NAME, RawQParserPlugin.class);
-    map.put(TermQParserPlugin.NAME, TermQParserPlugin.class);
-    map.put(TermsQParserPlugin.NAME, TermsQParserPlugin.class);
-    map.put(NestedQParserPlugin.NAME, NestedQParserPlugin.class);
-    map.put(FunctionRangeQParserPlugin.NAME, FunctionRangeQParserPlugin.class);
-    map.put(SpatialFilterQParserPlugin.NAME, SpatialFilterQParserPlugin.class);
-    map.put(SpatialBoxQParserPlugin.NAME, SpatialBoxQParserPlugin.class);
-    map.put(JoinQParserPlugin.NAME, JoinQParserPlugin.class);
-    map.put(SurroundQParserPlugin.NAME, SurroundQParserPlugin.class);
-    map.put(SwitchQParserPlugin.NAME, SwitchQParserPlugin.class);
-    map.put(MaxScoreQParserPlugin.NAME, MaxScoreQParserPlugin.class);
-    map.put(BlockJoinParentQParserPlugin.NAME, BlockJoinParentQParserPlugin.class);
-    map.put(BlockJoinChildQParserPlugin.NAME, BlockJoinChildQParserPlugin.class);
-    map.put(FiltersQParserPlugin.NAME, FiltersQParserPlugin.class);
-    map.put(CollapsingQParserPlugin.NAME, CollapsingQParserPlugin.class);
-    map.put(SimpleQParserPlugin.NAME, SimpleQParserPlugin.class);
-    map.put(ComplexPhraseQParserPlugin.NAME, ComplexPhraseQParserPlugin.class);
-    map.put(ReRankQParserPlugin.NAME, ReRankQParserPlugin.class);
-    map.put(ExportQParserPlugin.NAME, ExportQParserPlugin.class);
-    map.put(MLTQParserPlugin.NAME, MLTQParserPlugin.class);
-    map.put(HashQParserPlugin.NAME, HashQParserPlugin.class);
-    map.put(GraphQParserPlugin.NAME, GraphQParserPlugin.class);
-    map.put(XmlQParserPlugin.NAME, XmlQParserPlugin.class);
-    map.put(GraphTermsQParserPlugin.NAME, GraphTermsQParserPlugin.class);
-    map.put(IGainTermsQParserPlugin.NAME, IGainTermsQParserPlugin.class);
-    map.put(TextLogisticRegressionQParserPlugin.NAME, TextLogisticRegressionQParserPlugin.class);
-    map.put(SignificantTermsQParserPlugin.NAME, SignificantTermsQParserPlugin.class);
-    map.put(PayloadScoreQParserPlugin.NAME, PayloadScoreQParserPlugin.class);
-    map.put(PayloadCheckQParserPlugin.NAME, PayloadCheckQParserPlugin.class);
-    map.put(BoolQParserPlugin.NAME, BoolQParserPlugin.class);
+    HashMap<String, QParserPlugin> map = new HashMap<>(30, 1);
+    map.put(LuceneQParserPlugin.NAME, new LuceneQParserPlugin());
+    map.put(FunctionQParserPlugin.NAME, new FunctionQParserPlugin());
+    map.put(PrefixQParserPlugin.NAME, new PrefixQParserPlugin());
+    map.put(BoostQParserPlugin.NAME, new BoostQParserPlugin());
+    map.put(DisMaxQParserPlugin.NAME, new DisMaxQParserPlugin());
+    map.put(ExtendedDismaxQParserPlugin.NAME, new ExtendedDismaxQParserPlugin());
+    map.put(FieldQParserPlugin.NAME, new FieldQParserPlugin());
+    map.put(RawQParserPlugin.NAME, new RawQParserPlugin());
+    map.put(TermQParserPlugin.NAME, new TermQParserPlugin());
+    map.put(TermsQParserPlugin.NAME, new TermsQParserPlugin());
+    map.put(NestedQParserPlugin.NAME, new NestedQParserPlugin());
+    map.put(FunctionRangeQParserPlugin.NAME, new FunctionRangeQParserPlugin());
+    map.put(SpatialFilterQParserPlugin.NAME, new SpatialFilterQParserPlugin());
+    map.put(SpatialBoxQParserPlugin.NAME, new SpatialBoxQParserPlugin());
+    map.put(JoinQParserPlugin.NAME, new JoinQParserPlugin());
+    map.put(SurroundQParserPlugin.NAME, new SurroundQParserPlugin());
+    map.put(SwitchQParserPlugin.NAME, new SwitchQParserPlugin());
+    map.put(MaxScoreQParserPlugin.NAME, new MaxScoreQParserPlugin());
+    map.put(BlockJoinParentQParserPlugin.NAME, new BlockJoinParentQParserPlugin());
+    map.put(BlockJoinChildQParserPlugin.NAME, new BlockJoinChildQParserPlugin());
+    map.put(FiltersQParserPlugin.NAME, new FiltersQParserPlugin());
+    map.put(CollapsingQParserPlugin.NAME, new CollapsingQParserPlugin());
+    map.put(SimpleQParserPlugin.NAME, new SimpleQParserPlugin());
+    map.put(ComplexPhraseQParserPlugin.NAME, new ComplexPhraseQParserPlugin());
+    map.put(ReRankQParserPlugin.NAME, new ReRankQParserPlugin());
+    map.put(ExportQParserPlugin.NAME, new ExportQParserPlugin());
+    map.put(MLTQParserPlugin.NAME, new MLTQParserPlugin());
+    map.put(HashQParserPlugin.NAME, new HashQParserPlugin());
+    map.put(GraphQParserPlugin.NAME, new GraphQParserPlugin());
+    map.put(XmlQParserPlugin.NAME, new XmlQParserPlugin());
+    map.put(GraphTermsQParserPlugin.NAME, new GraphTermsQParserPlugin());
+    map.put(IGainTermsQParserPlugin.NAME, new IGainTermsQParserPlugin());
+    map.put(TextLogisticRegressionQParserPlugin.NAME, new TextLogisticRegressionQParserPlugin());
+    map.put(SignificantTermsQParserPlugin.NAME, new SignificantTermsQParserPlugin());
+    map.put(PayloadScoreQParserPlugin.NAME, new PayloadScoreQParserPlugin());
+    map.put(PayloadCheckQParserPlugin.NAME, new PayloadCheckQParserPlugin());
+    map.put(BoolQParserPlugin.NAME, new BoolQParserPlugin());
 
     standardPlugins = Collections.unmodifiableMap(map);
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0c6f38a3/solr/core/src/test/org/apache/solr/search/TestStandardQParsers.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestStandardQParsers.java b/solr/core/src/test/org/apache/solr/search/TestStandardQParsers.java
index ff9ffff..cab9026 100644
--- a/solr/core/src/test/org/apache/solr/search/TestStandardQParsers.java
+++ b/solr/core/src/test/org/apache/solr/search/TestStandardQParsers.java
@@ -16,15 +16,15 @@
  */
 package org.apache.solr.search;
 
-import org.apache.lucene.util.LuceneTestCase;
-import org.junit.Test;
-
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.lucene.util.LuceneTestCase;
+import org.junit.Test;
+
 /**
  * Check standard query parsers for class loading problems during initialization (NAME field
is final and static).
  * Because every query plugin extend {@link org.apache.solr.search.QParserPlugin} and contains
own instance of {@link org.apache.solr.search.QParserPlugin#standardPlugins},
@@ -50,9 +50,9 @@ public class TestStandardQParsers extends LuceneTestCase {
     List<String> notFinal = new ArrayList<>(QParserPlugin.standardPlugins.size());
     List<String> mismatch = new ArrayList<>(QParserPlugin.standardPlugins.size());
 
-    for (Map.Entry<String, Class<? extends QParserPlugin>> pair : QParserPlugin.standardPlugins.entrySet())
{
+    for (Map.Entry<String, QParserPlugin> pair : QParserPlugin.standardPlugins.entrySet())
{
       String regName = pair.getKey();
-      Class<? extends QParserPlugin> clazz = pair.getValue();
+      Class<? extends QParserPlugin> clazz = pair.getValue().getClass();;
 
       Field nameField = clazz.getField(FIELD_NAME);
       int modifiers = nameField.getModifiers();


Mime
View raw message