From f16af7afc03f6fd155f72a44728c1d26cc35c7f6 Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Thu, 18 Sep 2014 18:45:46 +0000 Subject: [PATCH] SOLR-6365 renamed to git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1626045 13f79535-47bb-0310-9956-ffa450edef68 --- .../core/{ParamSet.java => InitParams.java} | 8 +++--- .../org/apache/solr/core/RequestHandlers.java | 21 +++++++-------- .../java/org/apache/solr/core/SolrConfig.java | 27 ++++++++----------- .../org/apache/solr/util/SolrPluginUtils.java | 18 ++++++------- .../collection1/conf/solrconfig-paramset.xml | 12 ++++----- ...{TestParamSet.java => TestInitParams.java} | 4 +-- .../solr/collection1/conf/solrconfig.xml | 8 +++--- .../solr/collection1/conf/solrconfig.xml | 4 +-- 8 files changed, 48 insertions(+), 54 deletions(-) rename solr/core/src/java/org/apache/solr/core/{ParamSet.java => InitParams.java} (96%) rename solr/core/src/test/org/apache/solr/core/{TestParamSet.java => TestInitParams.java} (97%) diff --git a/solr/core/src/java/org/apache/solr/core/ParamSet.java b/solr/core/src/java/org/apache/solr/core/InitParams.java similarity index 96% rename from solr/core/src/java/org/apache/solr/core/ParamSet.java rename to solr/core/src/java/org/apache/solr/core/InitParams.java index dc5807eb41b..321cc99e2ee 100644 --- a/solr/core/src/java/org/apache/solr/core/ParamSet.java +++ b/solr/core/src/java/org/apache/solr/core/InitParams.java @@ -26,16 +26,16 @@ import java.util.List; import java.util.Map; import java.util.Set; /** - * An Object which represents a paramSet tag + * An Object which represents a tag * */ -public class ParamSet { - public static final String TYPE = "paramSet"; +public class InitParams { + public static final String TYPE = "initParams"; public final String name; public final Set paths; public final NamedList defaults,invariants,appends; - public ParamSet(PluginInfo p) { + public InitParams(PluginInfo p) { this.name = p.attributes.get("name"); Set paths = null; String pathStr = p.attributes.get("path"); diff --git a/solr/core/src/java/org/apache/solr/core/RequestHandlers.java b/solr/core/src/java/org/apache/solr/core/RequestHandlers.java index 8c4cb3ac647..4e8b9d5404b 100644 --- a/solr/core/src/java/org/apache/solr/core/RequestHandlers.java +++ b/solr/core/src/java/org/apache/solr/core/RequestHandlers.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -199,21 +198,21 @@ public final class RequestHandlers { } private PluginInfo applyParamSet(SolrConfig config, PluginInfo info) { - List paramSets= new ArrayList<>(); - String p = info.attributes.get("paramSet"); + List ags = new ArrayList<>(); + String p = info.attributes.get(InitParams.TYPE); if(p!=null) { - for (String paramSet : StrUtils.splitSmart(p, ',')) { - if(config.getParamSets().containsKey(paramSet)) paramSets.add(config.getParamSets().get(paramSet)); - else log.warn("INVALID paramSet {} in requestHandler {}", paramSet, info.toString()); + for (String arg : StrUtils.splitSmart(p, ',')) { + if(config.getInitParams().containsKey(arg)) ags.add(config.getInitParams().get(arg)); + else log.warn("INVALID paramSet {} in requestHandler {}", arg, info.toString()); } } - for (ParamSet paramSet : config.getParamSets().values()) { - if(paramSet.matchPath(info.name)) paramSets.add(paramSet); + for (InitParams args : config.getInitParams().values()) { + if(args.matchPath(info.name)) ags.add(args); } - if(!paramSets.isEmpty()){ + if(!ags.isEmpty()){ info = new PluginInfo(info.type, info.attributes, info.initArgs.clone(), info.children); - for (ParamSet paramSet : paramSets) { - paramSet.apply(info.initArgs); + for (InitParams args : ags) { + args.apply(info.initArgs); } } return info; diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.java index d3be0686437..a3be91294f9 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java +++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java @@ -23,8 +23,6 @@ import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.util.Version; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; -import org.apache.solr.common.util.NamedList; -import org.apache.solr.common.util.StrUtils; import org.apache.solr.handler.component.SearchComponent; import org.apache.solr.request.SolrRequestHandler; import org.apache.solr.response.QueryResponseWriter; @@ -59,13 +57,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -312,24 +307,24 @@ public class SolrConfig extends Config { addHttpRequestToContext = getBool( "requestDispatcher/requestParsers/@addHttpRequestToContext", false ); - loadPluginInfo(ParamSet.class,ParamSet.TYPE, MULTI_OK); - List paramSetInfos = pluginStore.get(ParamSet.class.getName()) ; - if(paramSetInfos!=null){ - Map paramSets = new HashMap<>(); - for (PluginInfo p : paramSetInfos) { - ParamSet paramSet = new ParamSet(p); - paramSets.put(paramSet.name == null ? String.valueOf(paramSet.hashCode()) : paramSet.name , paramSet ); + loadPluginInfo(InitParams.class, InitParams.TYPE, MULTI_OK); + List argsInfos = pluginStore.get(InitParams.class.getName()) ; + if(argsInfos!=null){ + Map argsMap = new HashMap<>(); + for (PluginInfo p : argsInfos) { + InitParams args = new InitParams(p); + argsMap.put(args.name == null ? String.valueOf(args.hashCode()) : args.name, args); } - this.paramSets = Collections.unmodifiableMap(paramSets); + this.initParams = Collections.unmodifiableMap(argsMap); } solrRequestParsers = new SolrRequestParsers(this); Config.log.info("Loaded SolrConfig: " + name); } - private Map paramSets = Collections.emptyMap(); - public Map getParamSets() { - return paramSets; + private Map initParams = Collections.emptyMap(); + public Map getInitParams() { + return initParams; } protected UpdateHandlerInfo loadUpdatehandlerInfo() { return new UpdateHandlerInfo(get("updateHandler/@class",null), diff --git a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java index 18e2ae50a47..82fb6592ba7 100644 --- a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java +++ b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java @@ -48,7 +48,7 @@ import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SimpleOrderedMap; import org.apache.solr.common.util.StrUtils; -import org.apache.solr.core.ParamSet; +import org.apache.solr.core.InitParams; import org.apache.solr.core.SolrCore; import org.apache.solr.handler.component.HighlightComponent; import org.apache.solr.handler.component.ResponseBuilder; @@ -125,14 +125,14 @@ public class SolrPluginUtils { */ public static void setDefaults(SolrQueryRequest req, SolrParams defaults, SolrParams appends, SolrParams invariants) { - String paramSetNames = req.getParams().get(ParamSet.TYPE); - if(paramSetNames !=null){ - for (String name : StrUtils.splitSmart(paramSetNames,',')) { - ParamSet paramSet = req.getCore().getSolrConfig().getParamSets().get(name); - if(paramSet!=null){ - if(paramSet.defaults != null) defaults = SolrParams.wrapDefaults(SolrParams.toSolrParams(paramSet.defaults) , defaults); - if(paramSet.invariants != null) invariants = SolrParams.wrapDefaults(invariants, SolrParams.toSolrParams(paramSet.invariants)); - if(paramSet.appends != null) appends = SolrParams.wrapAppended(appends, SolrParams.toSolrParams(paramSet.appends)); + String useParams = req.getParams().get("useParam"); + if(useParams !=null){ + for (String name : StrUtils.splitSmart(useParams,',')) { + InitParams initParams = req.getCore().getSolrConfig().getInitParams().get(name); + if(initParams !=null){ + if(initParams.defaults != null) defaults = SolrParams.wrapDefaults(SolrParams.toSolrParams(initParams.defaults) , defaults); + if(initParams.invariants != null) invariants = SolrParams.wrapDefaults(invariants, SolrParams.toSolrParams(initParams.invariants)); + if(initParams.appends != null) appends = SolrParams.wrapAppended(appends, SolrParams.toSolrParams(initParams.appends)); } } } diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-paramset.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-paramset.xml index 50f0e3f80ca..3dde8b2cef9 100644 --- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-paramset.xml +++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-paramset.xml @@ -26,7 +26,7 @@ - + A @@ -36,19 +36,19 @@ C - - + + P - + - - + + A1 diff --git a/solr/core/src/test/org/apache/solr/core/TestParamSet.java b/solr/core/src/test/org/apache/solr/core/TestInitParams.java similarity index 97% rename from solr/core/src/test/org/apache/solr/core/TestParamSet.java rename to solr/core/src/test/org/apache/solr/core/TestInitParams.java index 8d62eed3ba5..65279db60bd 100644 --- a/solr/core/src/test/org/apache/solr/core/TestParamSet.java +++ b/solr/core/src/test/org/apache/solr/core/TestInitParams.java @@ -26,7 +26,7 @@ import org.junit.Test; import java.util.Arrays; -public class TestParamSet extends SolrTestCaseJ4 { +public class TestInitParams extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { initCore("solrconfig-paramset.xml","schema.xml"); @@ -69,7 +69,7 @@ public class TestParamSet extends SolrTestCaseJ4 { for (String s : Arrays.asList("/dump4")) { SolrRequestHandler handler = h.getCore().getRequestHandler(s); SolrQueryResponse rsp = new SolrQueryResponse(); - handler.handleRequest(req("param", "a","param","b" ,"param","c", "paramSet","a"), rsp); + handler.handleRequest(req("param", "a","param","b" ,"param","c", "useParam","a"), rsp); NamedList def = (NamedList) rsp.getValues().get("params"); assertEquals("A", def.get("a")); assertEquals("B", def.get("b")); diff --git a/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml b/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml index 2d07fcfc3bd..ce35a876ab2 100755 --- a/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml +++ b/solr/example/example-schemaless/solr/collection1/conf/solrconfig.xml @@ -969,17 +969,17 @@ spellcheck - + _text - + - + add-unknown-fields-to-the-schema - + - + text - +