I think this is the right idea to eliminate boilerplate code, but it also overlaps with the stream API. There was an earlier discussion/JIRA for making respective underlying operators from that API available for use in other applications as well. I think we should pursue that path and enhance where necessary.
Thomas On Wed, Oct 26, 2016 at 10:20 PM, Chinmay Kolhatkar <[email protected]> wrote: > Hi All, > > With a lot of Apache projects making use of inner class in Java 7 and > Decarative programming feature of Java 8 to define stages in the pipeline, > I would like to propose a small additional to our existing compositional > APIs allowing it to define processing stages inline. > > I've created a public gist of addition and example about it: > https://gist.github.com/chinmaykolhatkar/ad3d25fd9a0343d76ac7fdd7fca59e6f > > Basically, it has an abstract "Process" base operator which has a single > abstract method called "apply" which takes input and returns output. This > method also takes a state variable to allow user to maintain any state if > required for the operator. This way one can create a new operator simply as > follows: > > dag.addOperator("test", new Process<String, String[]>() > { > @Override > public String[] apply(String s, Map<String, Object> state) > { > return s.split(" "); > } > }); > > Using this one need not create a new class for defining simple and up to a > certain level complex functionalities. > > Intention of this is to make app developers life easier. > > Please share your thoughts if this can be a good addition. > > Thanks, > Chinmay. >
