[JBoss JIRA] (DROOLS-5697) Make exec model's groupBy() composable
by Lukáš Petrovický (Jira)
Lukáš Petrovický created DROOLS-5697:
----------------------------------------
Summary: 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: Luca Molteni
In some of the OptaPlanner examples, we have Constraint Streams like this:
{code:java}
.groupBy(ProcessAssignment::getService, count())
.groupBy(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 one with the most count.
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())
)
accumulate(
$tuple: Tuple<Service, Integer> from $tuples,
...
$result: max($tuple._2)
)
then
System.out.println($result);
end
{noformat}
We'd like the new groupBy construct to be capable of composition instead.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)