You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2017/06/16 06:39:41 UTC

lucene-solr:master: SOLR-9565: The name of TemplateUpdateRequestProcessorFactory' is changed to 'template' from 'Template' and the name of 'AtomicUpdateProcessorFactory' is changed to 'atomic' from 'Atomic'

Repository: lucene-solr
Updated Branches:
  refs/heads/master d953488e9 -> e1d4ec798


SOLR-9565: The name of TemplateUpdateRequestProcessorFactory' is changed to 'template' from 'Template' and the
  name of 'AtomicUpdateProcessorFactory' is changed to 'atomic' from 'Atomic'


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

Branch: refs/heads/master
Commit: e1d4ec798732b30a3bd87f72beb98465a8735376
Parents: d953488
Author: Noble Paul <no...@apache.org>
Authored: Fri Jun 16 16:09:27 2017 +0930
Committer: Noble Paul <no...@apache.org>
Committed: Fri Jun 16 16:09:27 2017 +0930

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  3 ++
 .../processor/AtomicUpdateProcessorFactory.java |  3 +-
 .../processor/SimpleUpdateProcessorFactory.java | 18 +++++++---
 .../TemplateUpdateProcessorFactory.java         |  5 +++
 .../processor/UpdateRequestProcessorChain.java  | 20 +++++++----
 .../AtomicUpdateProcessorFactoryTest.java       | 36 ++++++++++----------
 .../processor/TemplateUpdateProcessorTest.java  | 12 +++----
 .../src/update-request-processors.adoc          | 10 +++---
 8 files changed, 66 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e1d4ec79/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7c8f013..c2e0705 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -94,6 +94,9 @@ Upgrading from Solr 6.x
 
 * TemplateUpdateRequestProcessorFactory uses {} instead of ${} for template
 
+* SOLR-9565: The name of TemplateUpdateRequestProcessorFactory' is changed to 'template' from 'Template' and the
+  name of 'AtomicUpdateProcessorFactory' is changed to 'atomic' from 'Atomic'
+
 New Features
 ----------------------
 * SOLR-9857, SOLR-9858: Collect aggregated metrics from nodes and shard leaders in overseer. (ab)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e1d4ec79/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java
index 2292dc8..2135fb7 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateProcessorFactory.java
@@ -61,7 +61,8 @@ public class AtomicUpdateProcessorFactory extends UpdateRequestProcessorFactory
   private final static Set<String> VALID_OPS = new HashSet<>(Arrays.asList(ADD, INC, REMOVE, SET, REMOVEREGEX));
 
   private final static String VERSION = "_version_";
-  private final static String ATOMIC_FIELD_PREFIX = "Atomic.";
+  public static final String NAME = "atomic";
+  public final static String ATOMIC_FIELD_PREFIX = "atomic.";
   private final static int MAX_ATTEMPTS = 5;
 
   private VersionInfo vinfo;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e1d4ec79/solr/core/src/java/org/apache/solr/update/processor/SimpleUpdateProcessorFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/SimpleUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/SimpleUpdateProcessorFactory.java
index b1edea0..e78e3fb 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/SimpleUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/SimpleUpdateProcessorFactory.java
@@ -29,14 +29,12 @@ import org.apache.solr.update.AddUpdateCommand;
  * This is deliberately made to support only the add operation
  */
 public abstract class SimpleUpdateProcessorFactory extends UpdateRequestProcessorFactory {
-  protected final String myName; // if classname==XyzUpdateProcessorFactory  myName=Xyz
+  private String myName; // if classname==XyzUpdateProcessorFactory  myName=Xyz
   protected NamedList initArgs = new NamedList();
   private static ThreadLocal<SolrQueryRequest> REQ = new ThreadLocal<>();
 
   protected SimpleUpdateProcessorFactory() {
-    String simpleName = this.getClass().getSimpleName();
-    int idx = simpleName.indexOf("UpdateProcessorFactory");
-    this.myName = idx == -1 ? simpleName : simpleName.substring(0, idx);
+
   }
 
   @Override
@@ -80,7 +78,17 @@ public abstract class SimpleUpdateProcessorFactory extends UpdateRequestProcesso
   }
 
   private String _param(String name) {
-    return myName + "." + name;
+    return getMyName() + "." + name;
+  }
+
+  protected String getMyName() {
+    String myName = this.myName;
+    if (myName == null) {
+      String simpleName = this.getClass().getSimpleName();
+      int idx = simpleName.indexOf("UpdateProcessorFactory");
+      this.myName = myName = idx == -1 ? simpleName : simpleName.substring(0, idx);
+    }
+    return myName;
   }
 
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e1d4ec79/solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java
index 19c331f..b6e2c8b 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java
@@ -41,6 +41,7 @@ import org.apache.solr.util.ConcurrentLRUCache;
 */
 public class TemplateUpdateProcessorFactory extends SimpleUpdateProcessorFactory {
   private Cache<String, Resolved> templateCache = new ConcurrentLRUCache<>(1000, 800, 900, 10, false, false, null);
+  public static final String NAME = "template";
   @Override
   protected void process(AddUpdateCommand cmd, SolrQueryRequest req, SolrQueryResponse rsp) {
     String[] vals = getParams("field");
@@ -63,6 +64,10 @@ public class TemplateUpdateProcessorFactory extends SimpleUpdateProcessorFactory
 
   }
 
+  @Override
+  protected String getMyName() {
+    return NAME;
+  }
 
   public static Resolved getResolved(String template, Cache<String, Resolved> cache, Pattern pattern) {
     Resolved r = cache == null ? null : cache.get(template);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e1d4ec79/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
index 3db42aa..6bb212c 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
@@ -21,8 +21,10 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
+import com.google.common.collect.ImmutableMap;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.params.SolrParams;
@@ -271,12 +273,13 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized
       if (s.isEmpty()) continue;
       UpdateRequestProcessorFactory p = core.getUpdateProcessors().get(s);
       if (p == null) {
-        PluginInfo pluginInfo = new PluginInfo("updateProcessor",
-            Utils.makeMap("name", s,
-                "class", s + "UpdateProcessorFactory",
-                "runtimeLib", "true"));
-
-        core.getUpdateProcessors().put(s, p = core.getUpdateProcessors().createPlugin(pluginInfo).get());
+        Class<UpdateRequestProcessorFactory> factoryClass = implicits.get(s);
+        if(factoryClass != null) {
+          PluginInfo pluginInfo = new PluginInfo("updateProcessor",
+              Utils.makeMap("name", s,
+                  "class", factoryClass.getName()));
+          core.getUpdateProcessors().put(s, p = core.getUpdateProcessors().createPlugin(pluginInfo).get());
+        }
         if (p == null)
           throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No such processor " + s);
       }
@@ -315,4 +318,9 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized
     }
   }
 
+  public static final Map<String, Class> implicits = new ImmutableMap.Builder()
+      .put(TemplateUpdateProcessorFactory.NAME, TemplateUpdateProcessorFactory.class)
+      .put(AtomicUpdateProcessorFactory.NAME, AtomicUpdateProcessorFactory.class)
+      .build();
+
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e1d4ec79/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java
index f3f833d..4534937 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java
@@ -45,7 +45,7 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
     AddUpdateCommand cmd = new AddUpdateCommand(new LocalSolrQueryRequest(h.getCore(),
         new ModifiableSolrParams()
             .add("processor", "Atomic")
-            .add("Atomic.cat", "delete")
+            .add("atomic.cat", "delete")
             .add("commit","true")
     ));
 
@@ -63,8 +63,8 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
   public void testNoUniqueIdPassed() throws Exception { //TODO
     AddUpdateCommand cmd = new AddUpdateCommand(new LocalSolrQueryRequest(h.getCore(),
         new ModifiableSolrParams()
-            .add("processor", "Atomic")
-            .add("Atomic.cat", "add")
+            .add("processor", "atomic")
+            .add("atomic.cat", "add")
             .add("commit","true")
     ));
 
@@ -85,12 +85,12 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
 
     AddUpdateCommand cmd = new AddUpdateCommand(new LocalSolrQueryRequest(h.getCore(),
         new ModifiableSolrParams()
-            .add("processor", "Atomic")
-            .add("Atomic.cat", "add")
-            .add("Atomic.title", "set")
-            .add("Atomic.count_i", "set")
-            .add("Atomic.name_s", "set")
-            .add("Atomic.multiDefault", "set")
+            .add("processor", "atomic")
+            .add("atomic.cat", "add")
+            .add("atomic.title", "set")
+            .add("atomic.count_i", "set")
+            .add("atomic.name_s", "set")
+            .add("atomic.multiDefault", "set")
             .add("commit","true")
     ));
 
@@ -136,12 +136,12 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
 
     cmd = new AddUpdateCommand(new LocalSolrQueryRequest(h.getCore(),
         new ModifiableSolrParams()
-            .add("processor", "Atomic")
-            .add("Atomic.cat", "add")
-            .add("Atomic.title", "set")
-            .add("Atomic.count_i", "inc")
-            .add("Atomic.name_s", "remove")
-            .add("Atomic.multiDefault", "removeregex")
+            .add("processor", "atomic")
+            .add("atomic.cat", "add")
+            .add("atomic.title", "set")
+            .add("atomic.count_i", "inc")
+            .add("atomic.name_s", "remove")
+            .add("atomic.multiDefault", "removeregex")
             .add("commit","true")
     ));
 
@@ -216,9 +216,9 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
         public void run() {
           AddUpdateCommand cmd = new AddUpdateCommand(new LocalSolrQueryRequest(h.getCore(),
               new ModifiableSolrParams()
-                  .add("processor", "Atomic")
-                  .add("Atomic.cat", "add")
-                  .add("Atomic.int_i", "inc")
+                  .add("processor", "atomic")
+                  .add("atomic.cat", "add")
+                  .add("atomic.int_i", "inc")
                   .add("commit","true")
 
           ));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e1d4ec79/solr/core/src/test/org/apache/solr/update/processor/TemplateUpdateProcessorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/processor/TemplateUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/TemplateUpdateProcessorTest.java
index e145219..6eb122a 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/TemplateUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/TemplateUpdateProcessorTest.java
@@ -61,10 +61,10 @@ public class TemplateUpdateProcessorTest extends SolrCloudTestCase {
   public void testSimple() throws Exception {
 
     ModifiableSolrParams params = new ModifiableSolrParams()
-        .add("processor", "Template")
-        .add("Template.field", "id:{firstName}_{lastName}")
-        .add("Template.field", "another:{lastName}_{firstName}")
-        .add("Template.field", "missing:{lastName}_{unKnown}");
+        .add("processor", "template")
+        .add("template.field", "id:{firstName}_{lastName}")
+        .add("template.field", "another:{lastName}_{firstName}")
+        .add("template.field", "missing:{lastName}_{unKnown}");
     AddUpdateCommand cmd = new AddUpdateCommand(new LocalSolrQueryRequest(null,
         params
 
@@ -82,9 +82,9 @@ public class TemplateUpdateProcessorTest extends SolrCloudTestCase {
     solrDoc.addField("id", "1");
 
    params = new ModifiableSolrParams()
-        .add("processor", "Template")
+        .add("processor", "template")
         .add("commit", "true")
-        .add("Template.field", "x_s:key_{id}");
+        .add("template.field", "x_s:key_{id}");
     params.add("commit", "true");
     UpdateRequest add = new UpdateRequest().add(solrDoc);
     add.setParams(params);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e1d4ec79/solr/solr-ref-guide/src/update-request-processors.adoc
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/update-request-processors.adoc b/solr/solr-ref-guide/src/update-request-processors.adoc
index 7942028..37cdebb 100644
--- a/solr/solr-ref-guide/src/update-request-processors.adoc
+++ b/solr/solr-ref-guide/src/update-request-processors.adoc
@@ -386,27 +386,27 @@ These Update processors do not need any configuration is your `solrconfig.xml` .
 
 The `TemplateUpdateProcessorFactory` can be used to add new fields to documents based on a template pattern.
 
-Use the parameter `processor=Template` to use it. The template parameter `Template.field` (multivalued) defines the field to add and the pattern. Templates may contain placeholders which refer to other fields in the document. You can have multiple `Template.field` parameters in a single request.
+Use the parameter `processor=template` to use it. The template parameter `template.field` (multivalued) define the field to add and the pattern. Templates may contain placeholders which refer to other fields in the document. You can have multiple `Template.field` parameters in a single request.
 
 For example:
 
 [source,bash]
 ----
-processor=Template&Template.field=fullName:Mr. {firstName} {lastName}
+processor=template&template.field=fullName:Mr. {firstName} {lastName}
 ----
 
-The above example would add a new field to the document called `fullName`. The fields `firstName` and `lastName` are supplied from the document fields. If either of them is missing, that part is replaced with an empty string. If those fields are multi-valued, only the first value is used.
+The above example would add a new field to the document called `fullName`. The fields `firstName and` `lastName` are supplied from the document fields. If either of them is missing, that part is replaced with an empty string. If those fields are multi-valued, only the first value is used.
 
 ==== AtomicUpdateProcessorFactory
 
 
-Use it to convert your normal `update` operations to atomic update operations. This is particularly useful when you use endpoints such as `/update/csv` or `/update/json/docs` which does not support syntax for atomic operations.
+Name of the processor is `atomic` . Use it to convert your normal `update` operations to atomic update operations. This is particularly useful when you use endpoints such as `/update/csv` or `/update/json/docs` which does not support syntax for atomic operations.
 
 example:
 
 [source,bash]
 ----
-processor=Atomic&Atomic.field1=add&Atomic.field2=set&Atomic.field3=inc&Atomic.field4=remove&Atomic.field4=remove
+processor=atomic&atomic.field1=add&atomic.field2=set&atomic.field3=inc&atomic.field4=remove&atomic.field4=remove
 ----
 
 The above parameters convert a normal `update` operation on