stratosphere/stratosphere — pull request #438 by uce (2014-01-25 13:10:11+00:00)
Title: Discussion: Allow Anonymous Classes for Functions in Plan

**This PR is just for discussion.**

I've been thinking about our Java API and @StephanEwen is also prototyping a new API, which will bring the Java and Scala APIs closer together (among other things) by moving the Java API to the distributed DataSet abstraction instead of operator wiring (which is imho super important and will be a big plus).

With the upcoming support for Lambda expressions in Java 8, the upcoming API will be very concise. Since this will only be supported in Java 8, I assume that we will provide separate Java 6/7 and Java 8 APIs. For the Java 6/7 API, I thought that it might be worthwhile to support anonymous classes as function implementations.

`AnonymousWordCount` of this PR shows the default `WordCount` implementation with anonymous classes instead of static nested classes, which makes it imho more readable.

But there is a problem with serializability. With anonymous classes you can only implement a single interface (e.g. `MapFunction`), but we also need to implement `Serializable` (and make sure that everything is indeed serializable). For this discussion I've declared `AbstractFunction` as `Serializable` as a work around, but it has problems (see #147). One way around this would be to provide something like `SerializableMapFunction`. But I find it somehow ugly and inconvenient in terms of usability for newcomers.

So the questions for discussions are:
- What do you think about supporting this?
- What is the best solution if we want it?