SOLR-14544: Fix or suppress warnings in solr/client/solrj/io/eval

This commit is contained in:
Erick Erickson 2020-06-07 21:31:51 -04:00
parent 04ba04c29d
commit 7bf59a16bd
111 changed files with 254 additions and 94 deletions

View File

@ -304,7 +304,9 @@ Other Changes
* SOLR-13492: Ensure explicit GCs are concurrent by adding '+ExplicitGCInvokesConcurrent'.
(Guna Sekhar Dora, Shawn Heisey, Munendra S N)
* SOLR-14542: Fix or suppress warnings in solr/handler/dataimport (Erick Erickson)
* SOLR-14542: Fix or suppress warnings in solr/handler/dataimport (Erick Erickson)
* SOLR-14544: Fix or suppress warnings in solr/client/solrj/io/eval (Erick Erickson)
* SOLR-14543: Fix or suppress warnings in apache/solr/search (Erick Erickson)

View File

@ -33,6 +33,7 @@ public class AkimaEvaluator extends RecursiveNumericEvaluator implements ManyVal
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... objects) throws IOException{
Object first = objects[0];
@ -56,7 +57,7 @@ public class AkimaEvaluator extends RecursiveNumericEvaluator implements ManyVal
AkimaSplineInterpolator interpolator = new AkimaSplineInterpolator();
PolynomialSplineFunction spline = interpolator.interpolate(x, y);
List<Number> list = new ArrayList();
List<Number> list = new ArrayList<>();
for(double xvalue : x) {
list.add(spline.value(xvalue));
}

View File

@ -45,6 +45,7 @@ public class AnovaEvaluator extends RecursiveNumericListEvaluator implements Man
// at this point we know every incoming value is an array of BigDecimals
@SuppressWarnings({"unchecked"})
List<double[]> anovaInput = Arrays.stream(values)
// for each List, convert to double[]
.map(value -> ((List<Number>)value).stream().mapToDouble(Number::doubleValue).toArray())

View File

@ -31,8 +31,10 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
public class ArrayEvaluator extends RecursiveObjectEvaluator implements ManyValueWorker {
protected static final long serialVersionUID = 1L;
@SuppressWarnings({"rawtypes"})
private Comparator<Comparable> sortComparator;
@SuppressWarnings({"unchecked"})
public ArrayEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
super(expression, factory, Arrays.asList("sort"));

View File

@ -32,6 +32,7 @@ public class AscEvaluator extends RecursiveObjectEvaluator implements OneValueWo
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object value) throws IOException {
if(null == value){
return value;

View File

@ -22,5 +22,6 @@ import java.util.Map;
public interface Attributes {
Object getAttribute(String key);
void setAttribute(String key, Object value);
@SuppressWarnings({"rawtypes"})
Map getAttributes();
}

View File

@ -47,6 +47,7 @@ public class BicubicSplineEvaluator extends RecursiveObjectEvaluator implements
double[][] grid = null;
if(first instanceof List && second instanceof List && third instanceof Matrix) {
@SuppressWarnings({"unchecked"})
List<Number> xlist = (List<Number>) first;
x = new double[xlist.size()];
@ -54,6 +55,7 @@ public class BicubicSplineEvaluator extends RecursiveObjectEvaluator implements
x[i]=xlist.get(i).doubleValue();
}
@SuppressWarnings({"unchecked"})
List<Number> ylist = (List<Number>) second;
y = new double[ylist.size()];

View File

@ -33,6 +33,7 @@ public class ChebyshevDistanceEvaluator extends RecursiveNumericEvaluator implem
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object first, Object second) throws IOException{
if(null == first){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));

View File

@ -38,7 +38,9 @@ public class ChiSquareDataSetEvaluator extends RecursiveNumericListEvaluator imp
@Override
public Object doWork(Object value1, Object value2) throws IOException {
@SuppressWarnings({"unchecked"})
List<Number> listA = (List<Number>) value1;
@SuppressWarnings({"unchecked"})
List<Number> listB = (List<Number>) value2;
long[] sampleA = new long[listA.size()];

View File

@ -43,7 +43,7 @@ public class ColumnAtEvaluator extends RecursiveObjectEvaluator implements TwoVa
Matrix matrix = (Matrix) value1;
Number index = (Number) value2;
double[][] data = matrix.getData();
List<Number> list = new ArrayList();
List<Number> list = new ArrayList<>();
for(double[] row : data) {
list.add(row[index.intValue()]);
}

View File

@ -45,7 +45,7 @@ public class ConvexHullEvaluator extends RecursiveObjectEvaluator implements Man
public static ConvexHull2D getConvexHull(Matrix matrix) throws IOException {
double[][] data = matrix.getData();
List<Vector2D> points = new ArrayList(data.length);
List<Vector2D> points = new ArrayList<>(data.length);
if(data[0].length == 2) {
for(double[] row : data) {
points.add(new Vector2D(row[0], row[1]));

View File

@ -34,6 +34,7 @@ public class ConvolutionEvaluator extends RecursiveNumericEvaluator implements T
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object first, Object second) throws IOException{
if(null == first){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));

View File

@ -60,6 +60,7 @@ public class CorrelationEvaluator extends RecursiveObjectEvaluator implements Ma
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object ... values) throws IOException{
if(values.length == 2) {
@ -150,7 +151,7 @@ public class CorrelationEvaluator extends RecursiveObjectEvaluator implements Ma
if(labels != null) {
return labels;
} else {
List<String> l = new ArrayList();
List<String> l = new ArrayList<>();
for(int i=0; i<length; i++) {
String label = "col"+ ZplotStream.pad(Integer.toString(i), length);
l.add(label);

View File

@ -46,7 +46,9 @@ public class CosineSimilarityEvaluator extends RecursiveNumericEvaluator impleme
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()));
}
@SuppressWarnings({"unchecked"})
double[] d1 = ((List) first).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray();
@SuppressWarnings({"unchecked"})
double[] d2 = ((List) second).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray();
return cosineSimilarity(d1, d2);

View File

@ -32,6 +32,7 @@ public class CovarianceEvaluator extends RecursiveObjectEvaluator implements Man
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object ... values) throws IOException{
if(values.length == 2) {

View File

@ -41,6 +41,7 @@ public class DbscanEvaluator extends RecursiveObjectEvaluator implements ManyVal
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... values) throws IOException {
Matrix matrix = null;
@ -74,8 +75,9 @@ public class DbscanEvaluator extends RecursiveObjectEvaluator implements ManyVal
distanceMeasure = (DistanceMeasure)values[3];
}
@SuppressWarnings({"rawtypes"})
DBSCANClusterer<ClusterPoint> dbscan = new DBSCANClusterer(e, minPoints, distanceMeasure);
List<ClusterPoint> points = new ArrayList();
List<ClusterPoint> points = new ArrayList<>();
double[][] data = matrix.getData();
List<String> ids = matrix.getRowLabels();
@ -88,6 +90,7 @@ public class DbscanEvaluator extends RecursiveObjectEvaluator implements ManyVal
}
}
@SuppressWarnings({"rawtypes"})
Map fields = new HashMap();
fields.put("e", e);
@ -121,7 +124,7 @@ public class DbscanEvaluator extends RecursiveObjectEvaluator implements ManyVal
private List<String> columnLabels;
private List<Cluster<ClusterPoint>> clusters;
public ClusterTuple(Map fields,
public ClusterTuple(@SuppressWarnings({"rawtypes"})Map fields,
List<Cluster<ClusterPoint>> clusters,
List<String> columnLabels) {
super(fields);

View File

@ -42,6 +42,7 @@ public class DensityEvaluator extends RecursiveObjectEvaluator implements TwoVal
}
MultivariateRealDistribution multivariateRealDistribution = (MultivariateRealDistribution) first;
@SuppressWarnings({"unchecked"})
List<Number> nums = (List<Number>) second;
double[] vec = new double[nums.size()];

View File

@ -38,6 +38,7 @@ public class DistanceEvaluator extends RecursiveObjectEvaluator implements ManyV
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object ... values) throws IOException{
if(values.length == 1) {

View File

@ -48,7 +48,9 @@ public class DotProductEvaluator extends RecursiveNumericEvaluator implements Tw
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()));
}
@SuppressWarnings({"unchecked", "rawtypes"})
RealVector v = new ArrayRealVector(((List) first).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray());
@SuppressWarnings({"unchecked", "rawtypes"})
RealVector v2 = new ArrayRealVector(((List) second).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray());
return v.dotProduct(v2);

View File

@ -34,6 +34,7 @@ public class EBEAddEvaluator extends RecursiveObjectEvaluator implements TwoValu
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object first, Object second) throws IOException{
if(null == first){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));
@ -48,7 +49,7 @@ public class EBEAddEvaluator extends RecursiveObjectEvaluator implements TwoValu
((List) second).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray()
);
List<Number> numbers = new ArrayList();
List<Number> numbers = new ArrayList<>();
for (double d : result) {
numbers.add(d);
}

View File

@ -47,12 +47,13 @@ public class EBEDivideEvaluator extends RecursiveNumericEvaluator implements Two
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()));
}
@SuppressWarnings({"unchecked"})
double[] result = MathArrays.ebeDivide(
((List) first).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray(),
((List) second).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray()
);
List<Number> numbers = new ArrayList();
List<Number> numbers = new ArrayList<>();
for(double d : result) {
numbers.add(d);
}

View File

@ -33,6 +33,7 @@ public class EBEMultiplyEvaluator extends RecursiveNumericEvaluator implements T
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object first, Object second) throws IOException{
if(null == first){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));
@ -52,7 +53,7 @@ public class EBEMultiplyEvaluator extends RecursiveNumericEvaluator implements T
((List) second).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray()
);
List<Number> numbers = new ArrayList();
List<Number> numbers = new ArrayList<>();
for(double d : result) {
numbers.add(d);
}

View File

@ -34,6 +34,7 @@ public class EBESubtractEvaluator extends RecursiveObjectEvaluator implements Tw
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object first, Object second) throws IOException{
if(null == first){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));
@ -47,7 +48,7 @@ public class EBESubtractEvaluator extends RecursiveObjectEvaluator implements Tw
((List) second).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray()
);
List<Number> numbers = new ArrayList();
List<Number> numbers = new ArrayList<>();
for (double d : result) {
numbers.add(d);
}

View File

@ -45,14 +45,17 @@ public class EnclosingDiskEvaluator extends RecursiveObjectEvaluator implements
}
}
@SuppressWarnings({"rawtypes"})
public static EnclosingBall getEnclosingDisk(Matrix matrix) throws IOException {
double[][] data = matrix.getData();
List<Vector2D> points = new ArrayList(data.length);
List<Vector2D> points = new ArrayList<>(data.length);
if(data[0].length == 2) {
for(double[] row : data) {
points.add(new Vector2D(row[0], row[1]));
}
@SuppressWarnings({"unchecked"})
WelzlEncloser<Euclidean2D, Vector2D> welzlEncloser = new WelzlEncloser(.001, new DiskGenerator());
EnclosingBall enclosingBall = welzlEncloser.enclose(points);
return enclosingBall;

View File

@ -39,13 +39,19 @@ public class EnumeratedDistributionEvaluator extends RecursiveNumericEvaluator i
}
if(values.length == 1) {
@SuppressWarnings({"unchecked"})
List<Number> first = (List<Number>)values[0];
@SuppressWarnings({"unchecked", "rawtypes"})
int[] samples = ((List) first).stream().mapToInt(value -> ((Number) value).intValue()).toArray();
return new EnumeratedIntegerDistribution(samples);
} else {
@SuppressWarnings({"unchecked"})
List<Number> first = (List<Number>)values[0];
@SuppressWarnings({"unchecked"})
List<Number> second = (List<Number>)values[1];
@SuppressWarnings({"unchecked", "rawtypes"})
int[] singletons = ((List) first).stream().mapToInt(value -> ((Number) value).intValue()).toArray();
@SuppressWarnings({"unchecked", "rawtypes"})
double[] probs = ((List) second).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray();
return new EnumeratedIntegerDistribution(singletons, probs);
}

View File

@ -33,6 +33,7 @@ public class EuclideanDistanceEvaluator extends RecursiveNumericEvaluator implem
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object first, Object second) throws IOException{
if(null == first){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));

View File

@ -31,7 +31,7 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
public class FFTEvaluator extends RecursiveNumericEvaluator implements OneValueWorker {
protected static final long serialVersionUID = 1L;
private static List<String> clabels = new ArrayList();
private static List<String> clabels = new ArrayList<>();
static {
clabels.add("real");

View File

@ -44,10 +44,10 @@ public class FeatureSelectEvaluator extends RecursiveObjectEvaluator implements
double[][] data = matrix.getData();
List<String> labels = matrix.getColumnLabels();
Set<String> features = new HashSet();
Set<String> features = new HashSet<>();
loadFeatures(value2, features);
List<String> newColumnLabels = new ArrayList();
List<String> newColumnLabels = new ArrayList<>();
for(String label : labels) {
if(features.contains(label)) {
@ -81,6 +81,7 @@ public class FeatureSelectEvaluator extends RecursiveObjectEvaluator implements
}
private void loadFeatures(Object o, Set<String> features) {
@SuppressWarnings({"rawtypes"})
List list = (List)o;
for(Object v : list) {
if(v instanceof List) {

View File

@ -42,6 +42,7 @@ public class FieldValueEvaluator extends SourceEvaluator {
}
@Override
@SuppressWarnings({"unchecked"})
public Object evaluate(Tuple tuple) throws IOException {
Object value = tuple.get(fieldName);

View File

@ -52,7 +52,9 @@ public class FindDelayEvaluator extends RecursiveNumericEvaluator implements Two
}
// Get first and second lists as arrays, where second is in reverse order
@SuppressWarnings({"unchecked", "rawtypes"})
double[] firstArray = ((List)first).stream().mapToDouble(value -> ((Number)value).doubleValue()).toArray();
@SuppressWarnings({"unchecked", "rawtypes"})
double[] secondArray = StreamSupport.stream(Spliterators.spliteratorUnknownSize(
((LinkedList)((List)second).stream().collect(Collectors.toCollection(LinkedList::new))).descendingIterator(),
Spliterator.ORDERED), false).mapToDouble(value -> ((Number)value).doubleValue()).toArray();

View File

@ -67,6 +67,7 @@ public class FrequencyTableEvaluator extends RecursiveNumericEvaluator implement
List<Tuple> histogramBins = new ArrayList<>();
@SuppressWarnings({"rawtypes"})
Iterator iterator = frequency.valuesIterator();
while(iterator.hasNext()){

View File

@ -56,6 +56,7 @@ public class FuzzyKmeansEvaluator extends RecursiveObjectEvaluator implements Tw
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object value1, Object value2) throws IOException {
@ -75,11 +76,12 @@ public class FuzzyKmeansEvaluator extends RecursiveObjectEvaluator implements Tw
throw new IOException("The second parameter for fuzzyKmeans should be k.");
}
@SuppressWarnings({"rawtypes"})
FuzzyKMeansClusterer<KmeansEvaluator.ClusterPoint> kmeans = new FuzzyKMeansClusterer(k,
fuzziness,
maxIterations,
new EuclideanDistance());
List<KmeansEvaluator.ClusterPoint> points = new ArrayList();
List<KmeansEvaluator.ClusterPoint> points = new ArrayList<>();
double[][] data = matrix.getData();
List<String> ids = matrix.getRowLabels();
@ -89,6 +91,7 @@ public class FuzzyKmeansEvaluator extends RecursiveObjectEvaluator implements Tw
points.add(new KmeansEvaluator.ClusterPoint(ids.get(i), vec));
}
@SuppressWarnings({"rawtypes"})
Map fields = new HashMap();
fields.put("k", k);
@ -101,7 +104,7 @@ public class FuzzyKmeansEvaluator extends RecursiveObjectEvaluator implements Tw
double[][] mmData = realMatrix.getData();
Matrix mmMatrix = new Matrix(mmData);
mmMatrix.setRowLabels(matrix.getRowLabels());
List<String> clusterCols = new ArrayList();
List<String> clusterCols = new ArrayList<>();
for(int i=0; i<clusters.size(); i++) {
clusterCols.add("cluster"+ ZplotStream.pad(Integer.toString(i), clusters.size()));
}

View File

@ -38,7 +38,9 @@ public class GTestDataSetEvaluator extends RecursiveNumericListEvaluator impleme
@Override
public Object doWork(Object value1, Object value2) throws IOException {
@SuppressWarnings({"unchecked"})
List<Number> listA = (List<Number>) value1;
@SuppressWarnings({"unchecked"})
List<Number> listB = (List<Number>) value2;
long[] sampleA = new long[listA.size()];

View File

@ -37,6 +37,7 @@ public class GaussFitEvaluator extends RecursiveNumericEvaluator implements Many
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Object doWork(Object... objects) throws IOException{
if(objects.length >= 3) {

View File

@ -41,7 +41,7 @@ public class GetBaryCenterEvaluator extends RecursiveObjectEvaluator implements
} else {
ConvexHull2D convexHull2D = (ConvexHull2D)value;
Vector2D vector2D = (Vector2D)convexHull2D.createRegion().getBarycenter();
List<Number> vec = new ArrayList();
List<Number> vec = new ArrayList<>();
vec.add(vector2D.getX());
vec.add(vector2D.getY());
return vec;

View File

@ -37,12 +37,14 @@ public class GetCacheEvaluator extends RecursiveObjectEvaluator implements ManyV
@Override
public Object doWork(Object... values) throws IOException {
@SuppressWarnings({"rawtypes"})
ConcurrentMap objectCache = this.streamContext.getObjectCache();
if(values.length == 2) {
String space = (String)values[0];
String key = (String)values[1];
space = space.replace("\"", "");
key = key.replace("\"", "");
@SuppressWarnings({"rawtypes"})
ConcurrentMap spaceCache = (ConcurrentMap)objectCache.get(space);
if(spaceCache != null) {

View File

@ -41,9 +41,10 @@ public class GetCenterEvaluator extends RecursiveObjectEvaluator implements OneV
if(!(value instanceof EnclosingBall)){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an EnclosingBall",toExpression(constructingFactory), value.getClass().getSimpleName()));
} else {
@SuppressWarnings({"rawtypes"})
EnclosingBall enclosingBall = (EnclosingBall)value;
Vector2D vec = (Vector2D)enclosingBall.getCenter();
List<Number> center = new ArrayList();
List<Number> center = new ArrayList<>();
center.add(vec.getX());
center.add(vec.getY());
return center;

View File

@ -44,9 +44,11 @@ public class GetClusterEvaluator extends RecursiveObjectEvaluator implements Two
List<CentroidCluster<KmeansEvaluator.ClusterPoint>> clusters = clusterTuple.getClusters();
Number index = (Number)value2;
@SuppressWarnings({"rawtypes"})
CentroidCluster cluster = clusters.get(index.intValue());
@SuppressWarnings({"rawtypes"})
List points = cluster.getPoints();
List<String> rowLabels = new ArrayList();
List<String> rowLabels = new ArrayList<>();
double[][] data = new double[points.size()][];
for(int i=0; i<points.size(); i++) {

View File

@ -37,6 +37,7 @@ public class GetRadiusEvaluator extends RecursiveObjectEvaluator implements OneV
if(!(value instanceof EnclosingBall)){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an EnclosingBall",toExpression(constructingFactory), value.getClass().getSimpleName()));
} else {
@SuppressWarnings({"rawtypes"})
EnclosingBall enclosingBall = (EnclosingBall)value;
return enclosingBall.getRadius();
}

View File

@ -39,11 +39,13 @@ public class GetSupportPointsEvaluator extends RecursiveObjectEvaluator implemen
if(!(value instanceof EnclosingBall)){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an EnclosingBall",toExpression(constructingFactory), value.getClass().getSimpleName()));
} else {
@SuppressWarnings({"rawtypes"})
EnclosingBall enclosingBall = (EnclosingBall)value;
@SuppressWarnings({"rawtypes"})
Point[] points = enclosingBall.getSupport();
double[][] data = new double[points.length][2];
int i=0;
for(Point point : points) {
for(@SuppressWarnings({"rawtypes"})Point point : points) {
Vector2D eu = (Vector2D)point;
data[i][0] = eu.getX();
data[i][1] = eu.getY();

View File

@ -34,6 +34,7 @@ public class HarmonicFitEvaluator extends RecursiveNumericEvaluator implements M
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... objects) throws IOException{
if(objects.length > 3) {
@ -76,12 +77,14 @@ public class HarmonicFitEvaluator extends RecursiveNumericEvaluator implements M
double[] coef = curveFitter.fit(points.toList());
HarmonicOscillator pf = new HarmonicOscillator(coef[0], coef[1], coef[2]);
@SuppressWarnings({"rawtypes"})
List list = new ArrayList();
for(double xvalue : x) {
double yvalue= pf.value(xvalue);
list.add(yvalue);
}
@SuppressWarnings({"unchecked"})
VectorFunction vectorFunction = new VectorFunction(pf, list);
vectorFunction.addToContext("amplitude", coef[0]);
vectorFunction.addToContext("angularFrequency", coef[1]);

View File

@ -58,7 +58,7 @@ public class IFFTEvaluator extends RecursiveObjectEvaluator implements OneValueW
FastFourierTransformer fastFourierTransformer = new FastFourierTransformer(DftNormalization.STANDARD);
Complex[] result = fastFourierTransformer.transform(complex, TransformType.INVERSE);
List<Number> realResult = new ArrayList();
List<Number> realResult = new ArrayList<>();
for (int i = 0; i < result.length; ++i) {
realResult.add(result[i].getReal());
}

View File

@ -36,6 +36,7 @@ public class IndexOfEvaluator extends RecursiveObjectEvaluator implements TwoVal
if(!(value1 instanceof List)){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an array",toExpression(constructingFactory), value1.getClass().getSimpleName()));
} else {
@SuppressWarnings({"rawtypes"})
List list = (List)value1;
String find = value2.toString().replace("\"","");
for(int i=0; i<list.size(); i++) {

View File

@ -75,7 +75,7 @@ public class IntegrateEvaluator extends RecursiveObjectEvaluator implements Many
double[] x = (double[])vectorFunction.getFromContext("x");
double[] y = (double[])vectorFunction.getFromContext("y");
ArrayList<Number> out = new ArrayList();
ArrayList<Number> out = new ArrayList<>();
out.add(0);
for(int i=1; i<x.length; i++) {
out.add(integrator.integrate(5000, func, x[0], x[i]));

View File

@ -42,6 +42,7 @@ public class IsNullEvaluator extends RecursiveBooleanEvaluator implements ManyVa
if(values[0] instanceof String) {
//Check to see if the this tuple had a null value for that string.
@SuppressWarnings({"rawtypes"})
Map tupleContext = getStreamContext().getTupleContext();
String nullField = (String)tupleContext.get("null");
if(nullField != null && nullField.equals(values[0])) {

View File

@ -52,6 +52,7 @@ public class KmeansEvaluator extends RecursiveObjectEvaluator implements TwoValu
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object value1, Object value2) throws IOException {
Matrix matrix = null;
@ -70,8 +71,9 @@ public class KmeansEvaluator extends RecursiveObjectEvaluator implements TwoValu
}
@SuppressWarnings({"rawtypes"})
KMeansPlusPlusClusterer<ClusterPoint> kmeans = new KMeansPlusPlusClusterer(k, maxIterations);
List<ClusterPoint> points = new ArrayList();
List<ClusterPoint> points = new ArrayList<>();
double[][] data = matrix.getData();
List<String> ids = matrix.getRowLabels();
@ -85,6 +87,7 @@ public class KmeansEvaluator extends RecursiveObjectEvaluator implements TwoValu
}
}
@SuppressWarnings({"rawtypes"})
Map fields = new HashMap();
fields.put("k", k);
@ -119,7 +122,7 @@ public class KmeansEvaluator extends RecursiveObjectEvaluator implements TwoValu
private List<CentroidCluster<ClusterPoint>> clusters;
private Matrix membershipMatrix;
public ClusterTuple(Map fields,
public ClusterTuple(@SuppressWarnings({"rawtypes"})Map fields,
List<CentroidCluster<ClusterPoint>> clusters,
List<String> columnLabels) {
super(fields);
@ -127,7 +130,7 @@ public class KmeansEvaluator extends RecursiveObjectEvaluator implements TwoValu
this.columnLabels = columnLabels;
}
public ClusterTuple(Map fields,
public ClusterTuple(@SuppressWarnings({"rawtypes"})Map fields,
List<CentroidCluster<ClusterPoint>> clusters,
List<String> columnLabels,
Matrix membershipMatrix) {

View File

@ -52,6 +52,7 @@ public class KnnEvaluator extends RecursiveObjectEvaluator implements ManyValueW
}
if(values[1] instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> nums = (List<Number>)values[1];
vec = new double[nums.size()];
for(int i=0; i<nums.size(); i++) {
@ -84,7 +85,7 @@ public class KnnEvaluator extends RecursiveObjectEvaluator implements ManyValueW
DistanceMeasure distanceMeasure) {
double[][] data = observations.getData();
TreeSet<Neighbor> neighbors = new TreeSet();
TreeSet<Neighbor> neighbors = new TreeSet<>();
for(int i=0; i<data.length; i++) {
double distance = distanceMeasure.compute(vec, data[i]);
neighbors.add(new Neighbor(i, distance));
@ -95,9 +96,9 @@ public class KnnEvaluator extends RecursiveObjectEvaluator implements ManyValueW
double[][] out = new double[neighbors.size()][];
List<String> rowLabels = observations.getRowLabels();
List<String> newRowLabels = new ArrayList();
List<Number> indexes = new ArrayList();
List<Number> distances = new ArrayList();
List<String> newRowLabels = new ArrayList<>();
List<Number> indexes = new ArrayList<>();
List<Number> distances = new ArrayList<>();
int i=-1;
while(neighbors.size() > 0) {

View File

@ -54,6 +54,7 @@ public class KnnRegressionEvaluator extends RecursiveObjectEvaluator implements
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object ... values) throws IOException {
if(values.length < 3) {
@ -105,6 +106,7 @@ public class KnnRegressionEvaluator extends RecursiveObjectEvaluator implements
outcomeData[i] = outcomes.get(i).doubleValue();
}
@SuppressWarnings({"rawtypes"})
Map map = new HashMap();
map.put("k", k);
map.put("observations", observations.getRowCount());
@ -222,6 +224,7 @@ public class KnnRegressionEvaluator extends RecursiveObjectEvaluator implements
Matrix obs = scaledObservations != null ? scaledObservations : observations;
Matrix knn = KnnEvaluator.search(obs, values, k, distanceMeasure);
@SuppressWarnings({"unchecked"})
List<Number> indexes = (List<Number>)knn.getAttribute("indexes");
if(robust) {

View File

@ -41,6 +41,7 @@ public class L1NormEvaluator extends RecursiveObjectEvaluator implements OneValu
throw new IOException(String.format(Locale.ROOT, "Unable to find %s(...) because the value is null", constructingFactory.getFunctionName(getClass())));
}
else if(value instanceof List){
@SuppressWarnings({"unchecked"})
List<Number> c = (List<Number>) value;
double[] data = new double[c.size()];
for(int i=0; i< c.size(); i++) {

View File

@ -41,6 +41,7 @@ public class LInfNormEvaluator extends RecursiveObjectEvaluator implements OneVa
throw new IOException(String.format(Locale.ROOT, "Unable to find %s(...) because the value is null", constructingFactory.getFunctionName(getClass())));
}
else if(value instanceof List){
@SuppressWarnings({"unchecked"})
List<Number> c = (List<Number>) value;
double[] data = new double[c.size()];
for(int i=0; i< c.size(); i++) {

View File

@ -67,6 +67,7 @@ public class LatLonVectorsEvaluator extends RecursiveObjectEvaluator implements
if(!(objects[0] instanceof List)) {
throw new IOException("The latlonVectors function expects a list of Tuples as a parameter.");
} else {
@SuppressWarnings({"rawtypes"})
List list = (List)objects[0];
if(list.size() > 0) {
Object o = list.get(0);
@ -78,14 +79,15 @@ public class LatLonVectorsEvaluator extends RecursiveObjectEvaluator implements
}
}
@SuppressWarnings({"unchecked"})
List<Tuple> tuples = (List<Tuple>) objects[0];
double[][] locationVectors = new double[tuples.size()][2];
List<String> features = new ArrayList();
List<String> features = new ArrayList<>();
features.add("lat");
features.add("lon");
List<String> rowLabels = new ArrayList();
List<String> rowLabels = new ArrayList<>();
for(int i=0; i< tuples.size(); i++) {
Tuple tuple = tuples.get(i);

View File

@ -33,6 +33,7 @@ public class LerpEvaluator extends RecursiveNumericEvaluator implements ManyValu
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... objects) throws IOException{
Object first = objects[0];
@ -56,7 +57,7 @@ public class LerpEvaluator extends RecursiveNumericEvaluator implements ManyValu
LinearInterpolator interpolator = new LinearInterpolator();
PolynomialSplineFunction spline = interpolator.interpolate(x, y);
List<Number> list = new ArrayList();
List<Number> list = new ArrayList<>();
for(double xvalue : x) {
list.add(spline.value(xvalue));
}

View File

@ -41,12 +41,17 @@ public class ListCacheEvaluator extends RecursiveObjectEvaluator implements Many
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... values) throws IOException {
@SuppressWarnings({"rawtypes"})
ConcurrentMap objectCache = this.streamContext.getObjectCache();
@SuppressWarnings({"rawtypes"})
List list = new ArrayList();
if(values.length == 0) {
@SuppressWarnings({"rawtypes"})
ConcurrentHashMap m = (ConcurrentHashMap)objectCache;
@SuppressWarnings({"rawtypes"})
Enumeration en = m.keys();
while(en.hasMoreElements()) {
list.add(en.nextElement());
@ -55,9 +60,12 @@ public class ListCacheEvaluator extends RecursiveObjectEvaluator implements Many
} else if(values.length == 1) {
String space = (String)values[0];
space = space.replace("\"", "");
@SuppressWarnings({"rawtypes"})
ConcurrentMap spaceCache = (ConcurrentMap)objectCache.get(space);
if(spaceCache != null) {
@SuppressWarnings({"rawtypes"})
ConcurrentHashMap spaceMap = (ConcurrentHashMap)objectCache.get(space);
@SuppressWarnings({"rawtypes"})
Enumeration en = spaceMap.keys();
while(en.hasMoreElements()) {
list.add(en.nextElement());

View File

@ -52,6 +52,7 @@ public class LoessEvaluator extends RecursiveNumericEvaluator implements ManyVal
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... objects) throws IOException{
Object first = objects[0];
@ -75,7 +76,7 @@ public class LoessEvaluator extends RecursiveNumericEvaluator implements ManyVal
LoessInterpolator interpolator = new LoessInterpolator(bandwidth, robustIterations);
double[] smooth = interpolator.smooth(x, y);
List<Number> list = new ArrayList();
List<Number> list = new ArrayList<>();
for(double yvalue : smooth) {
list.add(yvalue);
}

View File

@ -44,6 +44,7 @@ public class MannWhitneyUEvaluator extends RecursiveNumericListEvaluator impleme
@Override
public Object doWork(Object... values) throws IOException {
@SuppressWarnings({"unchecked"})
List<double[]> mannWhitneyUInput = Arrays.stream(values)
.map(value -> ((List<Number>) value).stream().mapToDouble(Number::doubleValue).toArray())
.collect(Collectors.toList());

View File

@ -23,18 +23,20 @@ import java.util.ArrayList;
import java.util.Iterator;
@SuppressWarnings({"rawtypes"})
public class Matrix implements Iterable, Attributes {
private double[][] data;
private List<String> columnLabels;
private List<String> rowLabels;
private Map<String, Object> attributes = new HashMap();
private Map<String, Object> attributes = new HashMap<>();
public Matrix(double[][] data) {
this.data = data;
}
@SuppressWarnings({"rawtypes"})
public Map getAttributes() {
return this.attributes;
}
@ -75,10 +77,12 @@ public class Matrix implements Iterable, Attributes {
return data[0].length;
}
@SuppressWarnings({"rawtypes"})
public Iterator iterator() {
return new MatrixIterator(data);
}
@SuppressWarnings({"rawtypes"})
private static class MatrixIterator implements Iterator {
private double[][] d;
@ -88,6 +92,7 @@ public class Matrix implements Iterable, Attributes {
d = data;
}
@SuppressWarnings({"unchecked"})
public Object next() {
double[] row = d[index++];
List list = new ArrayList();

View File

@ -39,6 +39,7 @@ public class MatrixEvaluator extends RecursiveNumericListEvaluator implements Ma
public Object doWork(Object... values) throws IOException {
double[][] data = new double[values.length][];
for(int i=0; i<values.length; i++) {
@SuppressWarnings({"unchecked"})
List<Number> vec = (List<Number>)values[i];
double[] array = new double[vec.size()];
for(int j=0; j<array.length; j++) {

View File

@ -52,6 +52,7 @@ public class MatrixMultiplyEvaluator extends RecursiveObjectEvaluator implements
Matrix matrix = (Matrix)o;
return new Array2DRowRealMatrix(matrix.getData(), false);
} else if(o instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> vec = (List<Number>)o;
double[][] data1 = new double[1][vec.size()];
for(int i=0; i<vec.size(); i++) {

View File

@ -32,6 +32,7 @@ public class MeanDifferenceEvaluator extends RecursiveNumericEvaluator implement
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object first, Object second) throws IOException{
if(null == first){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));

View File

@ -41,6 +41,7 @@ public class MeanEvaluator extends RecursiveObjectEvaluator implements OneValueW
throw new IOException(String.format(Locale.ROOT, "Unable to find %s(...) because the value is null", constructingFactory.getFunctionName(getClass())));
}
else if(value instanceof List){
@SuppressWarnings({"unchecked"})
List<Number> c = (List<Number>) value;
double[] data = new double[c.size()];
for(int i=0; i< c.size(); i++) {

View File

@ -119,14 +119,14 @@ public class MemsetEvaluator extends RecursiveEvaluator {
try {
in.setStreamContext(streamContext);
in.open();
Map<String, List<Number>> arrays = new HashMap();
Map<String, List<Number>> arrays = new HashMap<>();
//Initialize the variables
for(String var : vars) {
if(size > -1) {
arrays.put(var, new ArrayList(size));
arrays.put(var, new ArrayList<>(size));
} else {
arrays.put(var, new ArrayList());
arrays.put(var, new ArrayList<>());
}
}

View File

@ -57,6 +57,7 @@ public class MinMaxScaleEvaluator extends RecursiveObjectEvaluator implements Ma
return new Matrix(scaled);
} else if(values[0] instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> vec = (List)values[0];
double[] data = new double[vec.size()];
@ -65,7 +66,7 @@ public class MinMaxScaleEvaluator extends RecursiveObjectEvaluator implements Ma
}
data = scale(data, min, max);
List<Number> scaled = new ArrayList(data.length);
List<Number> scaled = new ArrayList<>(data.length);
for(double d : data) {
scaled.add(d);
}

View File

@ -43,6 +43,7 @@ public class ModeEvaluator extends RecursiveObjectEvaluator implements OneValueW
throw new IOException(String.format(Locale.ROOT, "Unable to find %s(...) because the value is null", constructingFactory.getFunctionName(getClass())));
}
else if(value instanceof List){
@SuppressWarnings({"unchecked"})
List<Number> c = (List<Number>) value;
double[] data = new double[c.size()];
for(int i=0; i< c.size(); i++) {
@ -50,7 +51,7 @@ public class ModeEvaluator extends RecursiveObjectEvaluator implements OneValueW
}
double[] mode = StatUtils.mode(data);
List<Number> l = new ArrayList();
List<Number> l = new ArrayList<>();
for(double d : mode) {
l.add(d);
}

View File

@ -35,8 +35,10 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
public class MonteCarloEvaluator extends RecursiveEvaluator {
protected static final long serialVersionUID = 1L;
@SuppressWarnings({"rawtypes"})
private Map variables = new LinkedHashMap();
@SuppressWarnings({"unchecked"})
public MonteCarloEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
super(expression, factory);
@ -44,11 +46,8 @@ public class MonteCarloEvaluator extends RecursiveEvaluator {
//Get all the named params
Set<String> echo = null;
boolean echoAll = false;
String currentName = null;
for(StreamExpressionParameter np : namedParams) {
String name = ((StreamExpressionNamedParameter)np).getName();
currentName = name;
StreamExpressionParameter param = ((StreamExpressionNamedParameter)np).getParameter();
if(factory.isEvaluator((StreamExpression)param)) {
@ -83,7 +82,7 @@ public class MonteCarloEvaluator extends RecursiveEvaluator {
StreamEvaluator iterationsEvaluator = containedEvaluators.get(1);
Number itNum = (Number)iterationsEvaluator.evaluate(tuple);
int it = itNum.intValue();
List<Number> results = new ArrayList();
List<Number> results = new ArrayList<>();
for(int i=0; i<it; i++) {
populateVariables(tuple);
Number result = (Number)function.evaluate(tuple);
@ -106,13 +105,14 @@ public class MonteCarloEvaluator extends RecursiveEvaluator {
private void populateVariables(Tuple contextTuple) throws IOException {
@SuppressWarnings({"unchecked"})
Set<Map.Entry<String, Object>> entries = variables.entrySet();
for(Map.Entry<String, Object> entry : entries) {
String name = entry.getKey();
Object o = entry.getValue();
if(o instanceof TupleStream) {
List<Tuple> tuples = new ArrayList();
List<Tuple> tuples = new ArrayList<>();
TupleStream tStream = (TupleStream)o;
tStream.setStreamContext(streamContext);
try {

View File

@ -49,6 +49,7 @@ public class MultiKmeansEvaluator extends RecursiveObjectEvaluator implements Ma
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... values) throws IOException {
if(values.length != 3) {
@ -81,10 +82,12 @@ public class MultiKmeansEvaluator extends RecursiveObjectEvaluator implements Ma
throw new IOException("The third parameter for multiKmeans should be trials.");
}
@SuppressWarnings({"rawtypes"})
KMeansPlusPlusClusterer<KmeansEvaluator.ClusterPoint> kmeans = new KMeansPlusPlusClusterer(k, maxIterations);
@SuppressWarnings({"rawtypes"})
MultiKMeansPlusPlusClusterer multiKmeans = new MultiKMeansPlusPlusClusterer(kmeans, trials);
List<KmeansEvaluator.ClusterPoint> points = new ArrayList();
List<KmeansEvaluator.ClusterPoint> points = new ArrayList<>();
double[][] data = matrix.getData();
List<String> ids = matrix.getRowLabels();
@ -94,6 +97,7 @@ public class MultiKmeansEvaluator extends RecursiveObjectEvaluator implements Ma
points.add(new KmeansEvaluator.ClusterPoint(ids.get(i), vec));
}
@SuppressWarnings({"rawtypes"})
Map fields = new HashMap();
fields.put("k", k);

View File

@ -41,6 +41,7 @@ public class MultiVariateNormalDistributionEvaluator extends RecursiveObjectEval
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the second value",toExpression(constructingFactory)));
}
@SuppressWarnings({"unchecked"})
List<Number> means = (List<Number>)first;
Matrix covar = (Matrix)second;

View File

@ -38,7 +38,7 @@ public class NaturalEvaluator extends RecursiveNumericEvaluator implements OneVa
@Override
public Object doWork(Object value){
int natural = ((Number)value).intValue();
List<Number> naturals = new ArrayList();
List<Number> naturals = new ArrayList<>();
for(int i=0; i<natural; i++) {
naturals.add(i);
}

View File

@ -41,6 +41,7 @@ public class NormEvaluator extends RecursiveObjectEvaluator implements OneValueW
throw new IOException(String.format(Locale.ROOT, "Unable to find %s(...) because the value is null", constructingFactory.getFunctionName(getClass())));
}
else if(value instanceof List){
@SuppressWarnings({"unchecked"})
List<Number> c = (List<Number>) value;
double[] data = new double[c.size()];
for(int i=0; i< c.size(); i++) {

View File

@ -67,13 +67,14 @@ public class NormalizeSumEvaluator extends RecursiveObjectEvaluator implements M
m.setColumnLabels(matrix.getColumnLabels());
return m;
} else if(value instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> vals = (List<Number>)value;
double[] doubles = new double[vals.size()];
for(int i=0; i<doubles.length; i++) {
doubles[i] = vals.get(i).doubleValue();
}
List<Number> unitList = new ArrayList(doubles.length);
List<Number> unitList = new ArrayList<>(doubles.length);
double[] unitArray = MathArrays.normalizeArray(doubles, sumTo);
for(double d : unitArray) {
unitList.add(d);

View File

@ -42,6 +42,7 @@ public class NotNullEvaluator extends RecursiveBooleanEvaluator implements ManyV
if(values[0] instanceof String) {
//Check to see if the this tuple had a null value for that string.
@SuppressWarnings({"rawtypes"})
Map tupleContext = getStreamContext().getTupleContext();
String nullField = (String)tupleContext.get("null");
if(nullField != null && nullField.equals(values[0])) {

View File

@ -37,6 +37,7 @@ public class OLSRegressionEvaluator extends RecursiveObjectEvaluator implements
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object ... values) throws IOException {
Matrix observations = null;
@ -62,6 +63,7 @@ public class OLSRegressionEvaluator extends RecursiveObjectEvaluator implements
OLSMultipleLinearRegression multipleLinearRegression = (OLSMultipleLinearRegression)regress(observationData, outcomeData);
@SuppressWarnings({"rawtypes"})
Map map = new HashMap();
map.put("regressandVariance", multipleLinearRegression.estimateRegressandVariance());
@ -80,7 +82,9 @@ public class OLSRegressionEvaluator extends RecursiveObjectEvaluator implements
return new MultipleRegressionTuple(multipleLinearRegression, map);
}
@SuppressWarnings({"unchecked"})
private List<Number> list(double[] values) {
@SuppressWarnings({"rawtypes"})
List list = new ArrayList();
for(double d : values) {
list.add(d);
@ -105,9 +109,10 @@ public class OLSRegressionEvaluator extends RecursiveObjectEvaluator implements
}
public double predict(double[] values) {
@SuppressWarnings({"unchecked"})
List<Number> weights = (List<Number>)get("regressionParameters");
double prediction = 0.0;
List<Number> predictors = new ArrayList();
List<Number> predictors = new ArrayList<>();
predictors.add(1.0D);
for(double d : values) {
predictors.add(d);

View File

@ -38,7 +38,7 @@ public class OnesEvaluator extends RecursiveNumericEvaluator implements OneValue
@Override
public Object doWork(Object value){
int size = ((Number)value).intValue();
List<Number> ones = new ArrayList();
List<Number> ones = new ArrayList<>();
for(int i=0; i<size; i++) {
ones.add(1);
}

View File

@ -32,6 +32,7 @@ public class OscillateEvaluator extends RecursiveNumericEvaluator implements Man
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... objects) throws IOException{
if(objects.length != 3) {
@ -46,6 +47,7 @@ public class OscillateEvaluator extends RecursiveNumericEvaluator implements Man
HarmonicOscillator pf = new HarmonicOscillator(amp, om, phase);
double[] x = new double[128];
@SuppressWarnings({"rawtypes"})
List list = new ArrayList();
for(int i=0; i<128; i++) {
double yvalue= pf.value(i);

View File

@ -35,6 +35,7 @@ public class OutliersEvaluator extends RecursiveObjectEvaluator implements ManyV
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Object doWork(Object... values) throws IOException{
if(values.length < 4) {
@ -74,13 +75,13 @@ public class OutliersEvaluator extends RecursiveObjectEvaluator implements ManyV
throw new IOException("The optional fifth parameter of the outliers function is an array of Tuples that are paired with the numeric array of values to be tested.");
}
} else {
tuples = new ArrayList();
tuples = new ArrayList<>();
for(int i=0; i<vec.size(); i++) {
tuples.add(new Tuple(new HashMap()));
}
}
List<Tuple> outliers = new ArrayList();
List<Tuple> outliers = new ArrayList<>();
if(dist instanceof IntegerDistribution) {

View File

@ -34,6 +34,7 @@ public class PairSortEvaluator extends RecursiveNumericEvaluator implements TwoV
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object first, Object second) throws IOException{
if(null == first){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));
@ -55,7 +56,7 @@ public class PairSortEvaluator extends RecursiveNumericEvaluator implements TwoV
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - first list (%d) has a different size than the second list (%d)",toExpression(constructingFactory), l1.size(), l2.size()));
}
List<double[]> pairs = new ArrayList();
List<double[]> pairs = new ArrayList<>();
for(int idx = 0; idx < l1.size(); ++idx){
double[] pair = new double[2];
pair[0]= l1.get(idx).doubleValue();

View File

@ -42,9 +42,11 @@ public class PairedTTestEvaluator extends RecursiveNumericListEvaluator implemen
public Object doWork(Object value1, Object value2) throws IOException {
TTest tTest = new TTest();
@SuppressWarnings({"rawtypes"})
Map map = new HashMap();
Tuple tuple = new Tuple(map);
if(value1 instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> values1 = (List<Number>)value1;
double[] samples1 = new double[values1.size()];
@ -53,6 +55,7 @@ public class PairedTTestEvaluator extends RecursiveNumericListEvaluator implemen
}
if(value2 instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> values2 = (List<Number>) value2;
double[] samples2 = new double[values2.size()];

View File

@ -50,8 +50,9 @@ public class PercentileEvaluator extends RecursiveNumericEvaluator implements Tw
} else if(second instanceof List){
Percentile percentile = new Percentile();
percentile.setData(((List<?>) first).stream().mapToDouble(value -> ((Number) value).doubleValue()).toArray());
@SuppressWarnings({"unchecked"})
List<Number> values = (List<Number>) second;
List<Number> percentiles = new ArrayList();
List<Number> percentiles = new ArrayList<>();
for(Number value : values) {
percentiles.add(percentile.evaluate(value.doubleValue()));
}

View File

@ -53,6 +53,7 @@ public class PivotEvaluator extends RecursiveObjectEvaluator implements ManyValu
Object value4 = values[3];
if(value1 instanceof List) {
@SuppressWarnings({"unchecked"})
List<Tuple> tuples = (List<Tuple>)value1;
String x = (String)value2;
x = x.replace("\"", "");
@ -62,8 +63,8 @@ public class PivotEvaluator extends RecursiveObjectEvaluator implements ManyValu
String vlabel = (String)value4;
vlabel = vlabel.replace("\"", "");
Set<String> xset = new TreeSet();
Set<String> yset = new TreeSet();
Set<String> xset = new TreeSet<>();
Set<String> yset = new TreeSet<>();
for(int i=0; i<tuples.size(); i++) {
Tuple tuple = tuples.get(i);
@ -73,8 +74,8 @@ public class PivotEvaluator extends RecursiveObjectEvaluator implements ManyValu
double[][] data = new double[xset.size()][yset.size()];
List<String> xlabels = new ArrayList(xset.size());
Map<String, Integer> xindexes = new HashMap();
List<String> xlabels = new ArrayList<>(xset.size());
Map<String, Integer> xindexes = new HashMap<>();
int xindex = 0;
for (String xlabel :xset) {
xlabels.add(xlabel);
@ -82,8 +83,8 @@ public class PivotEvaluator extends RecursiveObjectEvaluator implements ManyValu
++xindex;
}
List<String> ylabels = new ArrayList(yset.size());
Map<String, Integer> yindexes = new HashMap();
List<String> ylabels = new ArrayList<>(yset.size());
Map<String, Integer> yindexes = new HashMap<>();
int yindex = 0;
for (String ylabel : yset) {
ylabels.add(ylabel);

View File

@ -36,6 +36,7 @@ public class PolyFitDerivativeEvaluator extends RecursiveNumericEvaluator implem
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... objects) throws IOException{
if(objects.length > 3) {
@ -92,6 +93,7 @@ public class PolyFitDerivativeEvaluator extends RecursiveNumericEvaluator implem
PolynomialFunction pf = new PolynomialFunction(coef);
UnivariateFunction univariateFunction = pf.derivative();
@SuppressWarnings({"rawtypes"})
List list = new ArrayList();
for(double xvalue : x) {
double yvalue= univariateFunction.value(xvalue);

View File

@ -35,6 +35,7 @@ public class PolyFitEvaluator extends RecursiveNumericEvaluator implements ManyV
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Object doWork(Object... objects) throws IOException{
if(objects.length > 3) {

View File

@ -49,8 +49,9 @@ public class PowerEvaluator extends RecursiveNumericEvaluator implements TwoValu
Number exponent = (Number) second;
return Math.pow(value.doubleValue(), exponent.doubleValue());
} else if(second instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> exponents = (List<Number>) second;
List<Number> pows = new ArrayList();
List<Number> pows = new ArrayList<>();
for(Number exponent : exponents) {
pows.add(Math.pow(value.doubleValue(), exponent.doubleValue()));
}
@ -59,11 +60,12 @@ public class PowerEvaluator extends RecursiveNumericEvaluator implements TwoValu
throw new IOException("The second parameter to the pow function must either be a scalar or list of scalars");
}
} else if(first instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> values = (List<Number>) first;
if(second instanceof Number) {
Number exponent = (Number) second;
List<Number> out = new ArrayList(values.size());
List<Number> out = new ArrayList<>(values.size());
for (Number value : values) {
out.add(Math.pow(value.doubleValue(), exponent.doubleValue()));
}
@ -71,7 +73,8 @@ public class PowerEvaluator extends RecursiveNumericEvaluator implements TwoValu
return out;
} else if(second instanceof List) {
List<Number> out = new ArrayList(values.size());
List<Number> out = new ArrayList<>(values.size());
@SuppressWarnings({"unchecked"})
List<Number> exponents = (List<Number>)second;
if(values.size() != exponents.size()) {
throw new IOException("The pow function requires vectors of equal size if two vectors are provided.");

View File

@ -68,6 +68,7 @@ public class PredictEvaluator extends RecursiveObjectEvaluator implements ManyVa
OLSRegressionEvaluator.MultipleRegressionTuple regressedTuple = (OLSRegressionEvaluator.MultipleRegressionTuple) first;
if (second instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> list = (List<Number>) second;
double[] predictors = new double[list.size()];
@ -80,7 +81,7 @@ public class PredictEvaluator extends RecursiveObjectEvaluator implements ManyVa
Matrix m = (Matrix) second;
double[][] data = m.getData();
List<Number> predictions = new ArrayList();
List<Number> predictions = new ArrayList<>();
for (double[] predictors : data) {
predictions.add(regressedTuple.predict(predictors));
}
@ -97,8 +98,9 @@ public class PredictEvaluator extends RecursiveObjectEvaluator implements ManyVa
predictors[0] = ((Number)second).doubleValue();
return regressedTuple.predict(predictors);
} else if(second instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> vec = (List<Number>)second;
List<Number> predictions = new ArrayList();
List<Number> predictions = new ArrayList<>();
for(Number num : vec) {
double[] predictors = new double[1];
predictors[0] = num.doubleValue();
@ -109,6 +111,7 @@ public class PredictEvaluator extends RecursiveObjectEvaluator implements ManyVa
} else {
//Handle multi-variate regression
if (second instanceof List) {
@SuppressWarnings({"unchecked"})
List<Number> list = (List<Number>) second;
double[] predictors = new double[list.size()];
@ -128,7 +131,7 @@ public class PredictEvaluator extends RecursiveObjectEvaluator implements ManyVa
m = regressedTuple.scale(m);
}
double[][] data = m.getData();
List<Number> predictions = new ArrayList();
List<Number> predictions = new ArrayList<>();
for (double[] predictors : data) {
predictions.add(regressedTuple.predict(predictors));
}
@ -162,7 +165,7 @@ public class PredictEvaluator extends RecursiveObjectEvaluator implements ManyVa
Matrix m = (Matrix) second;
double[][] data = m.getData();
if (data[0].length == 2) {
List<Number> out = new ArrayList();
List<Number> out = new ArrayList<>();
for (double[] row : data) {
out.add(bivariateFunction.value(row[0], row[1]));
}

View File

@ -44,7 +44,7 @@ public class PrimesEvaluator extends RecursiveNumericEvaluator implements ManyVa
int sizeNum = ((Number)values[0]).intValue();
int startNum = ((Number)values[1]).intValue();
List<Number> primes = new ArrayList();
List<Number> primes = new ArrayList<>();
for(int i=0; i< sizeNum; i++) {
int prime = Primes.nextPrime(startNum);

View File

@ -37,6 +37,7 @@ public class PutCacheEvaluator extends RecursiveObjectEvaluator implements ManyV
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Object doWork(Object... values) throws IOException {
ConcurrentMap objectCache = this.streamContext.getObjectCache();
if(values.length == 3) {

View File

@ -76,7 +76,7 @@ public abstract class RecursiveEvaluator implements StreamEvaluator, ValueWorker
//Let's first check to see if we have a List of Strings.
//If we do let's try and convert to a list of doubles and see what happens
try {
List<Number> vector = new ArrayList();
List<Number> vector = new ArrayList<>();
boolean allDoubles = true;
for(Object o : (Collection)value) {
if(o instanceof String) {
@ -119,6 +119,7 @@ public abstract class RecursiveEvaluator implements StreamEvaluator, ValueWorker
}
@SuppressWarnings({"unchecked"})
protected Object normalizeOutputType(Object value) {
if(null == value){
return null;
@ -144,7 +145,9 @@ public abstract class RecursiveEvaluator implements StreamEvaluator, ValueWorker
//If its a tuple and not a inner class that has extended tuple, which is done in a number of cases so that mathematical models
//can be contained within a tuple.
@SuppressWarnings({"rawtypes"})
Tuple tuple = (Tuple)value;
@SuppressWarnings({"rawtypes"})
Map map = new HashMap();
for(Object o : tuple.fields.keySet()) {
Object v = tuple.fields.get(o);

View File

@ -49,7 +49,9 @@ public class RegressionEvaluator extends RecursiveNumericEvaluator implements Tw
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()));
}
@SuppressWarnings({"unchecked"})
List<Number> l1 = (List<Number>)first;
@SuppressWarnings({"unchecked"})
List<Number> l2 = (List<Number>)second;
if(l2.size() < l1.size()){

View File

@ -37,12 +37,14 @@ public class RemoveCacheEvaluator extends RecursiveObjectEvaluator implements Ma
@Override
public Object doWork(Object... values) throws IOException {
@SuppressWarnings({"rawtypes"})
ConcurrentMap objectCache = this.streamContext.getObjectCache();
if(values.length == 2) {
String space = (String)values[0];
String key = (String)values[1];
space = space.replace("\"", "");
key = key.replace("\"", "");
@SuppressWarnings({"rawtypes"})
ConcurrentMap spaceCache = (ConcurrentMap)objectCache.get(space);
if(spaceCache != null) {

View File

@ -39,7 +39,7 @@ public class RepeatEvaluator extends RecursiveNumericEvaluator implements TwoVal
public Object doWork(Object value1, Object value2){
double d = ((Number)value1).doubleValue();
int size = ((Number)value2).intValue();
List<Number> repeated = new ArrayList();
List<Number> repeated = new ArrayList<>();
for(int i=0; i<size; i++) {
repeated.add(d);
}

View File

@ -43,7 +43,7 @@ public class RowAtEvaluator extends RecursiveObjectEvaluator implements TwoValue
Matrix matrix = (Matrix) value1;
Number index = (Number) value2;
double[] row = matrix.getData()[index.intValue()];
List<Number> list = new ArrayList();
List<Number> list = new ArrayList<>();
for(double d : row) {
list.add(d);
}

View File

@ -83,7 +83,7 @@ public class SampleEvaluator extends RecursiveObjectEvaluator implements ManyVal
} else {
MultivariateNormalDistribution multivariateNormalDistribution = (MultivariateNormalDistribution)first;
double[] sample = multivariateNormalDistribution.sample();
List<Number> sampleList = new ArrayList(sample.length);
List<Number> sampleList = new ArrayList<>(sample.length);
for(int i=0; i<sample.length; i++) {
sampleList.add(sample[i]);
}

View File

@ -40,8 +40,9 @@ public class ScalarAddEvaluator extends RecursiveObjectEvaluator implements TwoV
double d = ((Number)value1).doubleValue();
if(value2 instanceof List){
@SuppressWarnings({"unchecked"})
List<Number> nums = (List<Number>)value2;
List<Number> out = new ArrayList();
List<Number> out = new ArrayList<>();
for(Number num : nums) {
out.add(operate(num.doubleValue(), d));
}

View File

@ -51,7 +51,7 @@ public class ScaleEvaluator extends RecursiveNumericEvaluator implements TwoValu
double[] scaleOver;
if(second instanceof Number){
scaleOver = Arrays.asList((Number)second).stream().mapToDouble(value -> ((Number)value).doubleValue()).toArray();
scaleOver = Arrays.asList((Number)second).stream().mapToDouble(value -> (value).doubleValue()).toArray();
}
else{
scaleOver = ((List<?>)second).stream().mapToDouble(value -> ((Number)value).doubleValue()).toArray();

View File

@ -41,9 +41,10 @@ public class SetColumnLabelsEvaluator extends RecursiveObjectEvaluator implement
} else {
Matrix matrix = (Matrix)value1;
@SuppressWarnings({"rawtypes"})
List colLabels = (List)value2;
//Convert numeric labels to strings.
List<String> strLabels = new ArrayList(colLabels.size());
List<String> strLabels = new ArrayList<>(colLabels.size());
for(Object o : colLabels) {
strLabels.add(o.toString());
}

View File

@ -40,11 +40,12 @@ public class SetRowLabelsEvaluator extends RecursiveObjectEvaluator implements T
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an array of labels.",toExpression(constructingFactory), value2.getClass().getSimpleName()));
} else {
Matrix matrix = (Matrix)value1;
@SuppressWarnings({"rawtypes"})
List rowlabels = (List)value2;
//Convert numeric labels to strings.
List<String> strLabels = new ArrayList(rowlabels.size());
List<String> strLabels = new ArrayList<>(rowlabels.size());
for(Object o : rowlabels) {
strLabels.add(o.toString());

View File

@ -38,6 +38,7 @@ public class SetValueEvaluator extends RecursiveObjectEvaluator implements ManyV
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... values) throws IOException {
if(values[0] instanceof Tuple) {
Tuple tuple = (Tuple)values[0];
@ -47,6 +48,7 @@ public class SetValueEvaluator extends RecursiveObjectEvaluator implements ManyV
value = ((String)value).replace("\"", "");
}
key = key.replace("\"", "");
@SuppressWarnings({"rawtypes"})
Map map = new HashMap(tuple.fields);
map.put(key, value);
return new Tuple(map);

View File

@ -33,6 +33,7 @@ public class SplineEvaluator extends RecursiveNumericEvaluator implements ManyVa
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object... objects) throws IOException{
Object first = objects[0];
@ -56,7 +57,7 @@ public class SplineEvaluator extends RecursiveNumericEvaluator implements ManyVa
SplineInterpolator interpolator = new SplineInterpolator();
PolynomialSplineFunction spline = interpolator.interpolate(x, y);
List<Number> list = new ArrayList();
List<Number> list = new ArrayList<>();
for(double xvalue : x) {
list.add(spline.value(xvalue));
}

View File

@ -43,7 +43,7 @@ public class SplitEvaluator extends RecursiveObjectEvaluator implements TwoValue
String s = value1.toString();
String p = value2.toString();
String[] tokens = s.split(p, -1);
List<String> strings = new ArrayList(tokens.length);
List<String> strings = new ArrayList<>(tokens.length);
for(String tok : tokens) {
strings.add(tok);
}

View File

@ -44,6 +44,7 @@ public class StandardDeviationEvaluator extends RecursiveObjectEvaluator impleme
throw new IOException(String.format(Locale.ROOT, "Unable to find %s(...) because the value is null", constructingFactory.getFunctionName(getClass())));
}
else if(value instanceof List){
@SuppressWarnings({"unchecked"})
List<Number> c = (List<Number>) value;
double[] data = new double[c.size()];
for(int i=0; i< c.size(); i++) {

View File

@ -48,7 +48,7 @@ public class SumColumnsEvaluator extends RecursiveObjectEvaluator implements One
double[][] data = matrix.getData();
RealMatrix realMatrix = new Array2DRowRealMatrix(data, false);
List<Number> sums = new ArrayList(data[0].length);
List<Number> sums = new ArrayList<>(data[0].length);
for(int i=0; i<data[0].length; i++) {
double sum = 0;

View File

@ -32,6 +32,7 @@ public class SumDifferenceEvaluator extends RecursiveNumericEvaluator implements
}
@Override
@SuppressWarnings({"unchecked"})
public Object doWork(Object first, Object second) throws IOException{
if(null == first){
throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - null found for the first value",toExpression(constructingFactory)));

Some files were not shown because too many files have changed in this diff Show More