Skip to content

Commit 9e02abe

Browse files
committed
fix: generics compile error
1 parent f95633f commit 9e02abe

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

wayang-commons/wayang-basic/src/main/java/org/apache/wayang/basic/operators/ModelTransformOperator.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@
3232
public class ModelTransformOperator<X, Y> extends BinaryToUnaryOperator<Model<X, Y>, X, Tuple2<X, Y>> {
3333

3434
public static ModelTransformOperator<double[], Integer> kMeans() {
35-
return new ModelTransformOperator<>(new TypeReference<>() {}, new TypeReference<>() {});
35+
// The type of TypeReference cannot be omitted, to avoid the following error.
36+
// error: cannot infer type arguments for TypeReference<T>, reason: cannot use '<>' with anonymous inner classes
37+
return new ModelTransformOperator<>(new TypeReference<double[]>() {}, new TypeReference<Tuple2<double[], Integer>>() {});
3638
}
3739

3840
public static ModelTransformOperator<double[], Double> linearRegression() {
39-
return new ModelTransformOperator<>(new TypeReference<>() {}, new TypeReference<>() {});
41+
return new ModelTransformOperator<>(new TypeReference<double[]>() {}, new TypeReference<Tuple2<double[], Double>>() {});
4042
}
4143

4244
public static ModelTransformOperator<double[], Integer> decisionTreeClassification() {
43-
return new ModelTransformOperator<>(new TypeReference<>() {}, new TypeReference<>() {});
45+
return new ModelTransformOperator<>(new TypeReference<double[]>() {}, new TypeReference<Tuple2<double[], Integer>>() {});
4446
}
4547

4648
public ModelTransformOperator(DataSetType<X> inType, DataSetType<Tuple2<X, Y>> outType) {

wayang-platforms/wayang-spark/code/main/java/org/apache/wayang/spark/operators/ml/Attr.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package org.apache.wayang.spark.operators.ml;
220

321
public class Attr {

wayang-platforms/wayang-spark/code/test/java/org/apache/wayang/spark/operators/SparkDecisionTreeClassificationOperatorTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package org.apache.wayang.spark.operators;
220

321
import org.apache.wayang.basic.data.Tuple2;

wayang-platforms/wayang-spark/code/test/java/org/apache/wayang/spark/operators/SparkLinearRegressionOperatorTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
119
package org.apache.wayang.spark.operators;
220

321
import org.apache.wayang.basic.data.Tuple2;

0 commit comments

Comments
 (0)