Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8015314 Umbrella: Stream API loose ends
  3. JDK-8015318

Extend Collector with 'finish' operation

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • None
    • core-libs

      The Collector API, as initially specified, allows mutable reduction operations to be expressed in terms of three functions:
       - create new result container
       - incorporate one new data element into a result container
       - merge two result containers
       
      This is suitable for many summarization operations, such as simple reductions (e.g., sum, min, max), group-by, partition-by, etc. However, it is constraining that the intermediate type used for accumulation and the final result type must be the same; some problems, such as averaging, require a different internal type than final result type. (When averaging, a sensible intermediate representation is a holder for two mutable accumulators, sum and count, but the user almost always wants a double as the final result.) Additionally, it may be the case that there are invariants that the Collector would like to impose on its result (e.g., immutability, or tree balancing) that cannot be done efficiently by the accumulator.

            henryjen Henry Jen
            briangoetz Brian Goetz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: