lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject [44/50] [abbrv] lucene-solr:feature/autoscaling: SOLR-10278: only long and double are used
Date Wed, 07 Jun 2017 14:11:48 GMT
SOLR-10278: only long and double are used


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

Branch: refs/heads/feature/autoscaling
Commit: bd2203df93b528b1eb4a5b0829ee9c052ffeda06
Parents: 790fb19
Author: Noble Paul <noble@apache.org>
Authored: Tue Jun 6 16:06:44 2017 +0930
Committer: Noble Paul <noble@apache.org>
Committed: Tue Jun 6 16:06:44 2017 +0930

----------------------------------------------------------------------
 .../java/org/apache/solr/cloud/autoscaling/Preference.java  | 4 +---
 .../src/java/org/apache/solr/cloud/autoscaling/Row.java     | 9 +++++----
 2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bd2203df/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Preference.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Preference.java b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Preference.java
index 60a6756..0566d25 100644
--- a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Preference.java
+++ b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Preference.java
@@ -56,9 +56,7 @@ class Preference implements MapWriter {
     Object o1 = useApprox ? r1.cells[idx].approxVal : r1.cells[idx].val;
     Object o2 = useApprox ? r2.cells[idx].approxVal : r2.cells[idx].val;
     int result = 0;
-    if (o1 instanceof Integer && o2 instanceof Integer) result = ((Integer) o1).compareTo((Integer)
o2);
-    else if (o1 instanceof Long && o2 instanceof Long) result = ((Long) o1).compareTo((Long)
o2);
-    else if (o1 instanceof Float && o2 instanceof Float) result = ((Float) o1).compareTo((Float)
o2);
+    if (o1 instanceof Long && o2 instanceof Long) result = ((Long) o1).compareTo((Long)
o2);
     else if (o1 instanceof Double && o2 instanceof Double) result = ((Double) o1).compareTo((Double)
o2);
     else if (!o1.getClass().getName().equals(o2.getClass().getName()))  {
       throw new RuntimeException("Unable to compare " + o1 + " of type: " + o1.getClass().getName()
+ " from " + r1.cells[idx].toString() + " and " + o2 + " of type: " + o2.getClass().getName()
+ " from " + r2.cells[idx].toString());

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bd2203df/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Row.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Row.java b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Row.java
index 463d434..f7ab5ca 100644
--- a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Row.java
+++ b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Row.java
@@ -91,10 +91,8 @@ class Row implements MapWriter {
   // this adds a replica to the replica info
   Row addReplica(String coll, String shard) {
     Row row = copy();
-    Map<String, List<ReplicaInfo>> c = row.collectionVsShardVsReplicas.get(coll);
-    if (c == null) row.collectionVsShardVsReplicas.put(coll, c = new HashMap<>());
-    List<ReplicaInfo> replicas = c.get(shard);
-    if (replicas == null) c.put(shard, replicas = new ArrayList<>());
+    Map<String, List<ReplicaInfo>> c = row.collectionVsShardVsReplicas.computeIfAbsent(coll,
k -> new HashMap<>());
+    List<ReplicaInfo> replicas = c.computeIfAbsent(shard, k -> new ArrayList<>());
     replicas.add(new ReplicaInfo("" + new Random().nextInt(1000) + 1000, coll, shard, new
HashMap<>()));
     for (Cell cell : row.cells) {
       if (cell.name.equals("cores")) cell.val = ((Number) cell.val).longValue() + 1;
@@ -109,6 +107,9 @@ class Row implements MapWriter {
     if (c == null) return null;
     List<ReplicaInfo> s = c.get(shard);
     if (s == null || s.isEmpty()) return null;
+    for (Cell cell : row.cells) {
+      if (cell.name.equals("cores")) cell.val = ((Number) cell.val).longValue() -1;
+    }
     return new Pair(row, s.remove(0));
 
   }


Mime
View raw message