Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5697

Make exec model's groupBy() composable

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Done
    • Major
    • None
    • 7.44.0.Final
    • executable model
    • None
    • 2020 Week 52-03 (from Dec 21)
    • Undefined
    • NEW
    • NEW
    • ---
    • ---

    Description

      In some of the OptaPlanner examples, we have Constraint Streams like this:

                      .groupBy(ProcessAssignment::getService, count())
                      .groupBy(Service::getTag, max((service, count) -> count))
      

      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:

      	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
      

      We'd like the new groupBy construct to be capable of composition instead.

      Attachments

        Issue Links

          Activity

            People

              mfusco@redhat.com Mario Fusco
              lpetrovi@redhat.com Lukáš Petrovický (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: