lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [42/46] lucene-solr:jira/solr-9959: SOLR-6615: use constants for 'id', '_route_', '_version_'
Date Thu, 23 Mar 2017 11:50:29 GMT
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb587772/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
index 7776a13..afa746e 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
@@ -30,6 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.ShardParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.DataInputInputStream;
 import org.apache.solr.common.util.JavaBinCodec;
@@ -226,8 +227,8 @@ public class JavaBinUpdateRequestCodec {
         Map<String,Object> params = entry.getValue();
         if (params != null) {
           Long version = (Long) params.get(UpdateRequest.VER);
-          if (params.containsKey(UpdateRequest.ROUTE))
-            updateRequest.deleteById(entry.getKey(), (String) params.get(UpdateRequest.ROUTE));
+          if (params.containsKey(ShardParams._ROUTE_))
+            updateRequest.deleteById(entry.getKey(), (String) params.get(ShardParams._ROUTE_));
           else
           updateRequest.deleteById(entry.getKey(), version);
         } else {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb587772/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
index e7ca0fa..142710a 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
@@ -44,6 +44,8 @@ import org.apache.solr.common.params.UpdateParams;
 import org.apache.solr.common.util.ContentStream;
 import org.apache.solr.common.util.XML;
 
+import static org.apache.solr.common.params.ShardParams._ROUTE_;
+
 /**
  * 
  * 
@@ -54,7 +56,6 @@ public class UpdateRequest extends AbstractUpdateRequest {
   public static final String REPFACT = "rf";
   public static final String MIN_REPFACT = "min_rf";
   public static final String VER = "ver";
-  public static final String ROUTE = "_route_";
   public static final String OVERWRITE = "ow";
   public static final String COMMIT_WITHIN = "cw";
   private Map<SolrInputDocument,Map<String,Object>> documents = null;
@@ -188,7 +189,7 @@ public class UpdateRequest extends AbstractUpdateRequest {
     if (version != null)
       params.put(VER, version);
     if (route != null)
-      params.put(ROUTE, route);
+      params.put(_ROUTE_, route);
     deleteById.put(id, params);
     return this;
   }
@@ -221,7 +222,7 @@ public class UpdateRequest extends AbstractUpdateRequest {
   public UpdateRequest withRoute(String route) {
     if (params == null)
       params = new ModifiableSolrParams();
-    params.set(ROUTE, route);
+    params.set(_ROUTE_, route);
     return this;
   }
 
@@ -461,7 +462,7 @@ public class UpdateRequest extends AbstractUpdateRequest {
           Map<String,Object> map = entry.getValue();
           if (map != null) {
             Long version = (Long) map.get(VER);
-            String route = (String)map.get(ROUTE);
+            String route = (String)map.get(_ROUTE_);
             if (version != null) {
               writer.append(" version=\"" + version + "\"");
             }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb587772/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java b/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java
index 55b9b8c..9c4ac9a 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java
@@ -18,9 +18,11 @@ package org.apache.solr.common;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.common.SolrException;
+
 import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.util.SimpleOrderedMap;
+
+import static org.apache.solr.common.params.CommonParams.ID;
 
 /**
  * Models the basic information related to a single "tolerated" error that occured during
updates.  
@@ -74,7 +76,7 @@ public final class ToleratedUpdateError {
    * @see #getSimpleMap
    */
   public static ToleratedUpdateError parseMap(SimpleOrderedMap<String> data) {
-    final String id = data.get("id");
+    final String id = data.get(ID);
     final String message = data.get("message");
     final String t = data.get("type");
     if (null == t || null == id || null == message) {
@@ -156,7 +158,7 @@ public final class ToleratedUpdateError {
   public SimpleOrderedMap<String> getSimpleMap() {
     SimpleOrderedMap<String> entry = new SimpleOrderedMap<String>();
     entry.add("type", type.toString());
-    entry.add("id", id);
+    entry.add(ID, id);
     entry.add("message", message);
     return entry;
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb587772/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java b/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java
index f9ab5d4..5e19d38 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/HashBasedRouter.java
@@ -16,13 +16,15 @@
  */
 package org.apache.solr.common.cloud;
 
+import java.util.Collection;
+import java.util.Collections;
+
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.Hash;
 
-import java.util.Collection;
-import java.util.Collections;
+import static org.apache.solr.common.params.CommonParams.ID;
 
 public abstract class HashBasedRouter extends DocRouter {
 
@@ -51,7 +53,7 @@ public abstract class HashBasedRouter extends DocRouter {
   }
 
   protected String getId(SolrInputDocument sdoc, SolrParams params) {
-    Object  idObj = sdoc.getFieldValue("id");  // blech
+    Object  idObj = sdoc.getFieldValue(ID);  // blech
     String id = idObj != null ? idObj.toString() : "null";  // should only happen on client
side
     return id;
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb587772/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java b/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
index 7cf27d2..589ef7e 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
@@ -259,5 +259,9 @@ public interface CommonParams {
 
   String NAME = "name";
   String VALUE_LONG = "val";
+
+  String VERSION_FIELD="_version_";
+
+  String ID = "id";
 }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb587772/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java b/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java
index 2686573..cbc33f4 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java
@@ -25,35 +25,35 @@ package org.apache.solr.common.params;
  */
 public interface ShardParams {
   /** the shards to use (distributed configuration) */
-  public static final String SHARDS = "shards";
+  String SHARDS = "shards";
   
   /** per-shard start and rows */
-  public static final String SHARDS_ROWS = "shards.rows";
-  public static final String SHARDS_START = "shards.start";
+  String SHARDS_ROWS = "shards.rows";
+  String SHARDS_START = "shards.start";
   
   /** IDs of the shard documents */
-  public static final String IDS = "ids";
+  String IDS = "ids";
   
   /** whether the request goes to a shard */
-  public static final String IS_SHARD = "isShard";
+  String IS_SHARD = "isShard";
   
   /** The requested URL for this shard */
-  public static final String SHARD_URL = "shard.url";
+  String SHARD_URL = "shard.url";
   
   /** The Request Handler for shard requests */
-  public static final String SHARDS_QT = "shards.qt";
+  String SHARDS_QT = "shards.qt";
   
   /** Request detailed match info for each shard (true/false) */
-  public static final String SHARDS_INFO = "shards.info";
+  String SHARDS_INFO = "shards.info";
 
   /** Should things fail if there is an error? (true/false) */
-  public static final String SHARDS_TOLERANT = "shards.tolerant";
+  String SHARDS_TOLERANT = "shards.tolerant";
   
   /** query purpose for shard requests */
-  public static final String SHARDS_PURPOSE = "shards.purpose";
+  String SHARDS_PURPOSE = "shards.purpose";
 
-  public static final String _ROUTE_ = "_route_";
+  String _ROUTE_ = "_route_";
 
   /** Force a single-pass distributed query? (true/false) */
-  public static final String DISTRIB_SINGLE_PASS = "distrib.singlePass";
+  String DISTRIB_SINGLE_PASS = "distrib.singlePass";
 }


Mime
View raw message