mirror of
https://github.com/apache/lucene.git
synced 2025-02-09 19:45:22 +00:00
LUCENE-8017: Use List rather than array
This commit is contained in:
parent
a886a001a4
commit
08f3a64dee
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user