]
Mario Fusco updated DROOLS-5697:
--------------------------------
Sprint: 2020 Week 49-51 (from Nov 30) (was: 2020 Week 46-48 (from Nov 9))
Make exec model's groupBy() composable
--------------------------------------
Key: DROOLS-5697
URL:
https://issues.redhat.com/browse/DROOLS-5697
Project: Drools
Issue Type: Enhancement
Components: executable model
Affects Versions: 7.44.0.Final
Reporter: Lukáš Petrovický
Assignee: Mario Fusco
Priority: Major
In some of the OptaPlanner examples, we have Constraint Streams like this:
{code:java}
.groupBy(ProcessAssignment::getService, count())
.groupBy(Service::getTag, max((service, count) -> count))
{code}
This will:
- Take all ProcessAssigment instances.
- Count all such instances which run on the same Service.
- Out of all the pairs of (service, count) find the maximum count where the services
share the same Tag.
This is an example of groupBy composition. Currently, we implement it with the old,
inefficient groupBy. That implementation looks something like this:
{noformat}
when
$tuples: List<Tuple<Service, Integer>> from accumulate(
$p: ProcessAssignment(),
...
groupBy(ProcessAssignment::getService, count())
)
$tuples2: List<Tuple<String, Integer>> from accumulate(
$tuple: Tuple<Service, Integer> from $tuples,
...
groupBy(Service::getTag, max($tuple._2))
)
$result: Tuple<String, Integer> from $tuples2
then
System.out.println($result);
end
{noformat}
We'd like the new groupBy construct to be capable of composition instead.