Tabulators -- a catalog (original) (raw)

Remi Forax forax at univ-mlv.fr
Sun Dec 30 05:12:39 PST 2012


On 12/28/2012 05:29 PM, Raab, Donald wrote:

This is the route we went.

interface PartitionCollection { Collection getPositive(); Collection getNegative(); } More specific than Pair. Less mutative, flexible and annoying than Collection[].

yes, but because Tabulators also do a reduce when partitioning, we also need something which is conceptually a pair of value (pair of reduced value) and not only a pair of collections.

Tabulators has a lot of method that are just a composition of several simple methods (map/reduce) that already exist, so I think we should remove them and only kept the ones that allow to chain groupBy and maybe reduceBy.

Rémi

-----Original Message----- From: lambda-libs-spec-experts-bounces at openjdk.java.net [mailto:lambda-libs-_ _spec-experts-bounces at openjdk.java.net] On Behalf Of Brian Goetz Sent: Friday, December 28, 2012 10:50 AM To: Remi Forax Cc: lambda-libs-spec-experts at openjdk.java.net Subject: Re: Tabulators -- a catalog

Seems like overkill :( On 12/28/2012 10:46 AM, Remi Forax wrote: On 12/28/2012 04:28 PM, Brian Goetz wrote: So the thing to do here is return Object[] instead of T[] / D[]. Sad, but not terrible. Not important enough to have the user pass in a factory. For want of a Pair... The other solution is to send a j.u.List with a specific non mutable implementation able to store only two elements.

Rémi

On 12/28/2012 9:39 AM, Remi Forax wrote: On 12/28/2012 03:23 AM, Brian Goetz wrote: Here's a catalog of the currently implemented Tabulators. [...]

3. Partition. Partitions a stream according to a predicate. Results always are a two-element array of something. Five forms:

// Basic Tabulator<T, Collection[]> partition(Predicate predicate) // Explicit factory <T, C extends Collection> Tabulator<T, C[]> partition(Predicate predicate, Supplier rowFactory) // Partitioned mutable reduce <T, D> Tabulator<T, D[]> partition(Predicate predicate, MutableReducer<T,D> downstream) // Partitioned functional reduce Tabulator<T, T[]> partition(Predicate predicate, T zero, BinaryOperator reducer) // Partitioned functional map-reduce Tabulator<T, T[]> partition(Predicate predicate, T zero, Function<T, U> mapper, BinaryOperator reducer) You can't create an array of T (C, D) safely, so casting an array of Object to an array of T is maybe acceptable if you control all the access to that array like in collections, but here you export it. Rémi



More information about the lambda-libs-spec-experts mailing list