Skip to content

Instantly share code, notes, and snippets.

@andrewpalumbo
Last active April 8, 2016 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewpalumbo/c42d41074410752a8712446dcd1f86dc to your computer and use it in GitHub Desktop.
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.
[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
Copy link

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

@andrewpalumbo
Copy link
Author

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