Create a gist now

Instantly share code, notes, and snippets.

Embed
"Object creation impossible" compiler error when trying to Extend an Abstract java class as an anonymous class in scala.
[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
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)
}
})
@tillrohrmann

This comment has been minimized.

Show comment
Hide comment
@tillrohrmann

tillrohrmann Apr 8, 2016

Maybe you've imported Scala's Iterable instead of Java's Iterable.

Maybe you've imported Scala's Iterable instead of Java's Iterable.

@andrewpalumbo

This comment has been minimized.

Show comment
Hide comment
@andrewpalumbo

andrewpalumbo Apr 8, 2016

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!

Owner

andrewpalumbo commented Apr 8, 2016

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