jpa-streamer icon indicating copy to clipboard operation
jpa-streamer copied to clipboard

Add support for column selection when using .map() (Projection)

Open dekmm opened this issue 5 years ago • 2 comments

dekmm avatar Jun 26 '20 09:06 dekmm

I think projection with map(select("col1", "col2")) could wait until the next release or could be in the enterprise version

minborg avatar Jun 26 '20 09:06 minborg

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.

minborg avatar Nov 30 '20 09:11 minborg