Last active
April 8, 2016 19:39
-
-
Save andrewpalumbo/c42d41074410752a8712446dcd1f86dc to your computer and use it in GitHub Desktop.
"Object creation impossible" compiler error when trying to Extend an Abstract java class as an anonymous class in scala.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ERROR] /home/andy/sandbox/mahout/flink/src/main/scala/org/apache/mahout/flinkbindings/blas/FlinkOpABt.scala:137: | |
error: object creation impossible, since method combine in class RichGroupCombineFunction of type | |
(x$1: Iterable[(Int, (Array[K], Array[Int], org.apache.mahout.math.Matrix))], x$2: | |
org.apache.flink.util.Collector[(Array[K], org.apache.mahout.math.Matrix)])Unit is not defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Rich variant of the {@link GroupCombineFunction}. As a {@link RichFunction}, it gives access to the | |
* {@link org.apache.flink.api.common.functions.RuntimeContext} and provides setup and teardown methods: | |
* {@link RichFunction#open(org.apache.flink.configuration.Configuration)} and | |
* {@link RichFunction#close()}. | |
* | |
* @param <IN> The data type of the elements to be combined. | |
* @param <OUT> The resulting data type of the elements to be combined. | |
*/ | |
@Public | |
public abstract class RichGroupCombineFunction<IN, OUT> extends AbstractRichFunction implements GroupCombineFunction<IN, OUT> { | |
private static final long serialVersionUID = 1L; | |
@Override | |
public abstract void combine(Iterable<IN> values, Collector<OUT> out) throws Exception; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit val typeInformation = FlinkEngine.generateTypeInformation[(Int, (Array[K], Array[Int], Matrix))] | |
dataSetToCombine: DataSet[(Int, (Array[K], Array[Int], Matrix))] = {...} | |
.groupBy(0) | |
.combineGroup(new RichGroupCombineFunction[(Int, (Array[K], Array[Int], Matrix)), (Array[K], Matrix)] { | |
override def open(params: Configuration): Unit = { | |
} | |
override def combine(values: Iterable[(Int, (Array[K], Array[Int], Matrix))], | |
out: Collector[(Array[K], Matrix)]): Unit = { | |
val tuple = values.toIterator.next | |
val rowKeys = tuple._2._1 | |
val colKeys = tuple._2._2 | |
val block = tuple._2._3 | |
val comb = new SparseMatrix(prodNCol, block.nrow).t | |
for ((col, i) <- colKeys.zipWithIndex) comb(::, col) := block(::, i) | |
val res = rowKeys -> comb | |
out.collect(res) | |
} | |
}) |
Thanks Till- that did it:
.combineGroup(new RichGroupCombineFunction[(Int, (Array[K], Array[Int], Matrix)), (Array[K], Matrix)] {
def combine(values: java.lang.Iterable[(Int, (Array[K], Array[Int], Matrix))],
out: Collector[(Array[K], Matrix)]): Unit = {
val tuple = values.iterator().next
val rowKeys = tuple._2._1
val colKeys = tuple._2._2
val block = tuple._2._3
val comb = new SparseMatrix(prodNCol, block.nrow).t
for ((col, i) <- colKeys.zipWithIndex) comb(::, col) := block(::, i)
val res = rowKeys -> comb
out.collect(res)
}
})
Does compiles without the error. Appreciate the help!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe you've imported Scala's Iterable instead of Java's Iterable.