mirror of https://github.com/apache/lucene.git
Merge pull request #717 from KoenDG/SOLR-13542
SOLR-13542: Code cleanup - Avoid using stream filter count where possible
This commit is contained in:
commit
00f4bbe6fc
|
@ -69,6 +69,8 @@ Other Changes
|
|||
|
||||
* SOLR-13655:Upgrade Collections.unModifiableSet to Set.of and Set.copyOf (Atri Sharma via Tomás Fernández Löbbe)
|
||||
|
||||
* SOLR-13542: Code cleanup - Avoid using stream filter count where possible
|
||||
|
||||
================== 8.3.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -53,7 +53,7 @@ public class ColumnEvaluator extends RecursiveEvaluator {
|
|||
|
||||
Object firstLevel = containedEvaluators.get(0).evaluate(tuple);
|
||||
|
||||
if(!(firstLevel instanceof List<?>) || 0 != ((List<?>)firstLevel).stream().filter(value -> !(value instanceof Tuple)).count()){
|
||||
if(!(firstLevel instanceof List<?>) || ((List<?>) firstLevel).stream().anyMatch(value -> !(value instanceof Tuple))){
|
||||
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting a list of tuples but found %s", toExpression(constructingFactory), firstLevel.getClass().getSimpleName()));
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ConversionEvaluator extends RecursiveNumericEvaluator implements On
|
|||
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting exactly 3 parameters but found %d", super.toExpression(constructingFactory), containedEvaluators.size()));
|
||||
}
|
||||
|
||||
if(0 != containedEvaluators.subList(0, 2).stream().filter(item -> !(item instanceof RawValueEvaluator) && !(item instanceof FieldValueEvaluator)).count()){
|
||||
if(containedEvaluators.subList(0, 2).stream().anyMatch(item -> !(item instanceof RawValueEvaluator) && !(item instanceof FieldValueEvaluator))){
|
||||
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - first two parameters must be strings", super.toExpression(constructingFactory)));
|
||||
}
|
||||
|
||||
|
|
|
@ -38,13 +38,13 @@ public class KolmogorovSmirnovEvaluator extends RecursiveObjectEvaluator impleme
|
|||
|
||||
@Override
|
||||
public Object doWork(Object first, Object second) throws IOException{
|
||||
if(null == first || (first instanceof List<?> && 0 != ((List<?>)first).stream().filter(item -> null == item).count())){
|
||||
if(null == first || (first instanceof List<?> && ((List<?>) first).stream().anyMatch(item -> null == item))){
|
||||
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));
|
||||
}
|
||||
if(null == second || (second instanceof List<?> && 0 != ((List<?>)second).stream().filter(item -> null == item).count())){
|
||||
if(null == second || (second instanceof List<?> && ((List<?>) second).stream().anyMatch(item -> null == item))){
|
||||
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the second value",toExpression(constructingFactory)));
|
||||
}
|
||||
if(!(second instanceof List<?>) || 0 != ((List<?>)second).stream().filter(item -> !(item instanceof Number)).count()){
|
||||
if(!(second instanceof List<?>) || ((List<?>) second).stream().anyMatch(item -> !(item instanceof Number))){
|
||||
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for the second value, expecting a List of numbers",toExpression(constructingFactory), first.getClass().getSimpleName()));
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class KolmogorovSmirnovEvaluator extends RecursiveObjectEvaluator impleme
|
|||
m.put("d-statistic", ks.kolmogorovSmirnovStatistic(realDistribution, data));
|
||||
return new Tuple(m);
|
||||
}
|
||||
else if(first instanceof List<?> && 0 == ((List<?>)first).stream().filter(item -> !(item instanceof Number)).count()){
|
||||
else if(first instanceof List<?> && ((List<?>) first).stream().noneMatch(item -> !(item instanceof Number))){
|
||||
double[] data2 = ((List<?>)first).stream().mapToDouble(item -> ((Number)item).doubleValue()).toArray();
|
||||
|
||||
Map<String,Double> m = new HashMap<>();
|
||||
|
|
Loading…
Reference in New Issue