lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject lucene-solr:branch_6x: SOLR-9485:Indexfingerprint.fromObject() returns wrong values if object passed was itself of type IndexFingerprint
Date Tue, 13 Sep 2016 11:51:29 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x ba085d4c8 -> da358bafd


SOLR-9485:Indexfingerprint.fromObject() returns wrong values if object passed was itself of
type IndexFingerprint


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

Branch: refs/heads/branch_6x
Commit: da358bafd6a123d3bb9382447befb315e59de450
Parents: ba085d4
Author: Noble Paul <noble@apache.org>
Authored: Tue Sep 13 17:19:12 2016 +0530
Committer: Noble Paul <noble@apache.org>
Committed: Tue Sep 13 17:21:12 2016 +0530

----------------------------------------------------------------------
 .../apache/solr/update/IndexFingerprint.java    | 36 +++++++++++---------
 1 file changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/da358baf/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java b/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java
index b85b224..a299017 100644
--- a/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java
+++ b/solr/core/src/java/org/apache/solr/update/IndexFingerprint.java
@@ -26,6 +26,7 @@ import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.queries.function.FunctionValues;
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.util.Bits;
+import org.apache.solr.common.SolrException;
 import org.apache.solr.common.util.Hash;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
@@ -168,16 +169,8 @@ public class IndexFingerprint {
     return map;
   }
 
-  private static long getLong(Object o, String key, long def) {
-    long v = def;
-
-    Object oval = null;
-    if (o instanceof Map) {
-      oval = ((Map)o).get(key);
-    } else if (o instanceof NamedList) {
-      oval = ((NamedList)o).get(key);
-    }
-
+  private static long getLong(Map m, String key, long def) {
+    Object oval = m.get(key);
     return oval != null ? ((Number)oval).longValue() : def;
   }
 
@@ -185,14 +178,23 @@ public class IndexFingerprint {
    * Create an IndexFingerprint object from a deserialized generic object (Map or NamedList)
    */
   public static IndexFingerprint fromObject(Object o) {
+    if (o instanceof IndexFingerprint) return (IndexFingerprint) o;
+    Map map = null;
+    if (o instanceof Map) {
+      map = (Map) o;
+    } else if (o instanceof NamedList) {
+      map = ((NamedList) o).asShallowMap();
+    } else {
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type " + o);
+    }
     IndexFingerprint f = new IndexFingerprint();
-    f.maxVersionSpecified = getLong(o, "maxVersionSpecified", Long.MAX_VALUE);
-    f.maxVersionEncountered = getLong(o, "maxVersionEncountered", -1);
-    f.maxInHash = getLong(o, "maxInHash", -1);
-    f.versionsHash = getLong(o, "versionsHash", -1);
-    f.numVersions = getLong(o, "numVersions", -1);
-    f.numDocs = getLong(o, "numDocs", -1);
-    f.maxDoc = getLong(o, "maxDoc", -1);
+    f.maxVersionSpecified = getLong(map, "maxVersionSpecified", Long.MAX_VALUE);
+    f.maxVersionEncountered = getLong(map, "maxVersionEncountered", -1);
+    f.maxInHash = getLong(map, "maxInHash", -1);
+    f.versionsHash = getLong(map, "versionsHash", -1);
+    f.numVersions = getLong(map, "numVersions", -1);
+    f.numDocs = getLong(map, "numDocs", -1);
+    f.maxDoc = getLong(map, "maxDoc", -1);
     return f;
   }
 


Mime
View raw message