lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [09/50] [abbrv] lucene-solr:jira/solr-11285-sim: LUCENE-8017: Use List rather than array
Date Thu, 09 Nov 2017 21:19:15 GMT
LUCENE-8017: Use List rather than array


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

Branch: refs/heads/jira/solr-11285-sim
Commit: 08f3a64dee8737020d0e65fea6f09799a018f92a
Parents: a886a00
Author: Alan Woodward <romseygeek@apache.org>
Authored: Fri Nov 3 10:59:04 2017 +0000
Committer: Alan Woodward <romseygeek@apache.org>
Committed: Fri Nov 3 11:08:39 2017 +0000

----------------------------------------------------------------------
 .../src/java/org/apache/lucene/search/BooleanWeight.java |  2 +-
 .../org/apache/lucene/search/DisjunctionMaxQuery.java    |  2 +-
 .../core/src/java/org/apache/lucene/search/Weight.java   | 11 ++++++-----
 .../apache/lucene/search/spans/SpanContainingQuery.java  |  3 ++-
 .../org/apache/lucene/search/spans/SpanNearQuery.java    |  3 +--
 .../org/apache/lucene/search/spans/SpanNotQuery.java     |  3 ++-
 .../java/org/apache/lucene/search/spans/SpanOrQuery.java |  3 +--
 .../org/apache/lucene/search/spans/SpanWithinQuery.java  |  3 ++-
 .../java/org/apache/lucene/facet/DrillSidewaysQuery.java |  8 +++++---
 .../java/org/apache/lucene/queries/BoostingQuery.java    |  3 ++-
 .../java/org/apache/lucene/queries/CustomScoreQuery.java |  8 +++++---
 11 files changed, 28 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java b/lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java
index 047a1b1..cb1c194 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java
@@ -302,7 +302,7 @@ final class BooleanWeight extends Weight {
 
   @Override
   public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-    return getCacheHelper(context, weights.toArray(new Weight[0]));
+    return getCacheHelper(context, weights);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
index c40c25d..38f74ad 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
@@ -139,7 +139,7 @@ public final class DisjunctionMaxQuery extends Query implements Iterable<Query>
 
     @Override
     public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-      return getCacheHelper(context, weights.toArray(new Weight[0]));
+      return getCacheHelper(context, weights);
     }
 
     /** Explain the score we computed for doc */

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/core/src/java/org/apache/lucene/search/Weight.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/Weight.java b/lucene/core/src/java/org/apache/lucene/search/Weight.java
index 0d3ce03..e87dd3f 100644
--- a/lucene/core/src/java/org/apache/lucene/search/Weight.java
+++ b/lucene/core/src/java/org/apache/lucene/search/Weight.java
@@ -18,6 +18,7 @@ package org.apache.lucene.search;
 
 
 import java.io.IOException;
+import java.util.List;
 import java.util.Set;
 
 import org.apache.lucene.index.FieldInfo;
@@ -123,14 +124,14 @@ public abstract class Weight {
    * @param weights an array of {@link Weight} to be cached
    * @return an {@link org.apache.lucene.index.IndexReader.CacheHelper} indicating the cache
level
    */
-  protected static IndexReader.CacheHelper getCacheHelper(LeafReaderContext context, Weight...
weights) {
-    if (weights.length == 0)
+  protected static IndexReader.CacheHelper getCacheHelper(LeafReaderContext context, List<?
extends Weight> weights) {
+    if (weights.size() == 0)
       return null;
-    IndexReader.CacheHelper helper = weights[0].getCacheHelper(context);
+    IndexReader.CacheHelper helper = weights.get(0).getCacheHelper(context);
     if (helper == null)
       return null;
-    for (int i = 1; i < weights.length; i++) {
-      IndexReader.CacheHelper nextHelper = weights[i].getCacheHelper(context);
+    for (int i = 1; i < weights.size(); i++) {
+      IndexReader.CacheHelper nextHelper = weights.get(i).getCacheHelper(context);
       if (nextHelper == null || nextHelper != helper)
         return null;
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainingQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainingQuery.java
b/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainingQuery.java
index 736d332..0af481f 100644
--- a/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainingQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/spans/SpanContainingQuery.java
@@ -19,6 +19,7 @@ package org.apache.lucene.search.spans;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Map;
 
 import org.apache.lucene.index.IndexReader;
@@ -119,7 +120,7 @@ public final class SpanContainingQuery extends SpanContainQuery {
 
     @Override
     public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-      return getCacheHelper(context, bigWeight, littleWeight);
+      return getCacheHelper(context, Arrays.asList(bigWeight, littleWeight));
     }
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java b/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
index cb3207d..a7c42d6 100644
--- a/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/spans/SpanNearQuery.java
@@ -33,7 +33,6 @@ import org.apache.lucene.index.TermContext;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Weight;
 
 /** Matches spans which are near one another.  One can specify <i>slop</i>, the
  * maximum number of intervening unmatched positions, as well as whether
@@ -233,7 +232,7 @@ public class SpanNearQuery extends SpanQuery implements Cloneable {
 
     @Override
     public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-      return getCacheHelper(context, subWeights.toArray(new Weight[0]));
+      return getCacheHelper(context, subWeights);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java b/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
index a87baf5..154ddfe 100644
--- a/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/spans/SpanNotQuery.java
@@ -18,6 +18,7 @@ package org.apache.lucene.search.spans;
 
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
@@ -194,7 +195,7 @@ public final class SpanNotQuery extends SpanQuery {
 
     @Override
     public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-      return getCacheHelper(context, includeWeight, excludeWeight);
+      return getCacheHelper(context, Arrays.asList(includeWeight, excludeWeight));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java b/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
index fdde9d1..653fc70 100644
--- a/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
@@ -34,7 +34,6 @@ import org.apache.lucene.search.DisjunctionDISIApproximation;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TwoPhaseIterator;
-import org.apache.lucene.search.Weight;
 
 
 /** Matches the union of its clauses.
@@ -141,7 +140,7 @@ public final class SpanOrQuery extends SpanQuery {
 
     @Override
     public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-      return getCacheHelper(context, subWeights.toArray(new Weight[0]));
+      return getCacheHelper(context, subWeights);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/core/src/java/org/apache/lucene/search/spans/SpanWithinQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/spans/SpanWithinQuery.java b/lucene/core/src/java/org/apache/lucene/search/spans/SpanWithinQuery.java
index 23a0499..d29b4dd 100644
--- a/lucene/core/src/java/org/apache/lucene/search/spans/SpanWithinQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/spans/SpanWithinQuery.java
@@ -19,6 +19,7 @@ package org.apache.lucene.search.spans;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Map;
 
 import org.apache.lucene.index.IndexReader;
@@ -120,7 +121,7 @@ public final class SpanWithinQuery extends SpanContainQuery {
 
     @Override
     public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-      return getCacheHelper(context, littleWeight, bigWeight);
+      return getCacheHelper(context, Arrays.asList(littleWeight, bigWeight));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java
----------------------------------------------------------------------
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java b/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java
index ef73316..822eeb4 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java
@@ -17,8 +17,10 @@
 package org.apache.lucene.facet;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
+import java.util.List;
 import java.util.Objects;
 import java.util.Set;
 
@@ -103,9 +105,9 @@ class DrillSidewaysQuery extends Query {
 
       @Override
       public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-        Weight[] weights = new Weight[drillDowns.length + 1];
-        weights[0] = baseWeight;
-        System.arraycopy(drillDowns, 0, weights, 1, drillDowns.length);
+        List<Weight> weights = new ArrayList<>();
+        weights.add(baseWeight);
+        weights.addAll(Arrays.asList(drillDowns));
         return getCacheHelper(context, weights);
       }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/queries/src/java/org/apache/lucene/queries/BoostingQuery.java
----------------------------------------------------------------------
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/BoostingQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/BoostingQuery.java
index 17f8407..1864882 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/BoostingQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/BoostingQuery.java
@@ -17,6 +17,7 @@
 package org.apache.lucene.queries;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Objects;
 import java.util.Set;
 
@@ -124,7 +125,7 @@ public class BoostingQuery extends Query {
 
         @Override
         public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-          return getCacheHelper(context, matchWeight, contextWeight);
+          return getCacheHelper(context, Arrays.asList(matchWeight, contextWeight));
         }
       };
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/08f3a64d/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
----------------------------------------------------------------------
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
index da70725..1fb0d97 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
@@ -17,9 +17,11 @@
 package org.apache.lucene.queries;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 import java.util.Set;
 
 import org.apache.lucene.index.IndexReader;
@@ -209,9 +211,9 @@ public class CustomScoreQuery extends Query implements Cloneable {
 
     @Override
     public IndexReader.CacheHelper getCacheHelper(LeafReaderContext context) {
-      Weight[] weights = new Weight[valSrcWeights.length + 1];
-      weights[0] = subQueryWeight;
-      System.arraycopy(valSrcWeights, 0, weights, 1, valSrcWeights.length);
+      List<Weight> weights = new ArrayList<>();
+      weights.add(subQueryWeight);
+      weights.addAll(Arrays.asList(valSrcWeights));
       return getCacheHelper(context, weights);
     }
 


Mime
View raw message