JDK-8015318 : Extend Collector with 'finish' operation
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.util.stream
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-05-23
  • Updated: 2017-05-17
  • Resolved: 2013-08-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b103Fixed
Related Reports
Blocks :  
Duplicate :  
Relates :  
Relates :  
Description
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.