jpa-streamer
jpa-streamer copied to clipboard
Add support for column selection when using .map() (Projection)
I think projection with map(select("col1", "col2")) could wait until the next release or could be in the enterprise version
Projection should be provided according to the example below:
jpaStreamer.stream(sc)
.sorted(Film$.length.reversed())
.limit(15)
.map(Projection.select(Film$.filmId, Film$.title))
.map((Tuple t) -> String.format("filmId: %d, title: %s ", t.get(0), t.get(1, String.class)))
.forEach(System.out::println);
Thus, Projection.select(...) would return a Function<Film, Tuple> containing sufficient meta-data to be able to extract the columns needed.
This work item only involves pure columns and thus no expressions with columns.
The mapping of columns could take place in several places in the example above: Before or after limit(). It cannot, however, take place before sorted because Tuple it not of type Film wich the sorted(Film$.length.reversed()) statement assumes.
mapToInt() etc. is in a separate issue #44.