<div dir="ltr">So far (b73), I haven't found any uses for -XDuseGraphInference. Most of the times I've tried it, it has thrown an AssertionException.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Jan 16, 2013 at 6:14 PM, Raab, Donald <span dir="ltr"><<a href="mailto:Donald.Raab@gs.com" target="_blank">Donald.Raab@gs.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Tried. No luck.<br>
<br>
What is it possible for this to infer beyond normal levels of inference?<br>
<div class="im HOEnZb"><br>
> -----Original Message-----<br>
> From: Brian Goetz [mailto:<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>]<br>
> Sent: Wednesday, January 16, 2013 8:55 PM<br>
> To: Raab, Donald [Tech]<br>
</div><div class="HOEnZb"><div class="h5">> Cc: 'Joe Bowbeer'; '<a href="mailto:lambda-libs-spec-experts@openjdk.java.net">lambda-libs-spec-experts@openjdk.java.net</a>'; Weir, John<br>
> [Tech]; Motlin, Craig P. [Tech]<br>
> Subject: Re: GS Collections Kata w/ JCF Solutions<br>
><br>
> Try compiling with -XDuseGraphInference.<br>
><br>
> On Jan 16, 2013, at 4:15 PM, Raab, Donald wrote:<br>
><br>
> > Great suggestion. I just gave it a try. Max takes a comparator and returns<br>
> Optional so you have to add a call to get(). I was able to change the example<br>
> to the following:<br>
> ><br>
> > Map<Double, Collection<Customer>> multimap = this.company.getCustomers()<br>
> > .stream()<br>
> > .collect(Collectors.<Customer, Double>groupBy((Customer customer) -><br>
> > customer.getOrders()<br>
> > .stream()<br>
> > .explode((Stream.Downstream<LineItem> downstream, Order order) -><br>
> {<br>
> > downstream.send(order.getLineItems());<br>
> > })<br>
> > .map(LineItem::getValue)<br>
> > .max(Comparators.naturalOrder())<br>
> > .get()));<br>
> ><br>
> > I get an unchecked error on Comparators.naturalOrder() in IntelliJ, but<br>
> adding <Double> there makes it ugly.<br>
> ><br>
> > This is the GS Collections version of the kata, which also used max(), but<br>
> calls this method on a DoubleIterable:<br>
> ><br>
> > MutableListMultimap<Double, Customer> multimap = this.company.getCustomers()<br>
> > .groupBy(customer -> customer.getOrders()<br>
> > .asLazy()<br>
> > .flatCollect(Order::getLineItems)<br>
> > .collectDouble(LineItem::getValue)<br>
> > .max());<br>
> ><br>
> > Unfortunately, the type inference seems to be very successful at thwarting<br>
> me trying to simplify the above example using the stream library features. I<br>
> would like to simplify down to this but can't seem to get it to work:<br>
> ><br>
> > Map<Double, Collection<Customer>> multimap = this.company.getCustomers()<br>
> > .stream()<br>
> > .collect(groupBy((customer) -><br>
> > customer.getOrders()<br>
> > .stream()<br>
> > .explode((downstream, order) -> {<br>
> > downstream.send(order.getLineItems());<br>
> > })<br>
> > .map(LineItem::getValue)<br>
> > .max(Comparators.naturalOrder())<br>
> > .get()));<br>
> ><br>
> ><br>
> > From: Joe Bowbeer [mailto:<a href="mailto:joe.bowbeer@gmail.com">joe.bowbeer@gmail.com</a>]<br>
> > Sent: Wednesday, January 16, 2013 4:21 PM<br>
> > To: Raab, Donald [Tech]<br>
> > Cc: <a href="mailto:lambda-libs-spec-experts@openjdk.java.net">lambda-libs-spec-experts@openjdk.java.net</a>; Motlin, Craig P. [Tech];<br>
> Weir, John [Tech]<br>
> > Subject: Re: GS Collections Kata w/ JCF Solutions<br>
> ><br>
> > Thanks.<br>
> ><br>
> ><br>
> > Would it be better to rewrite the following using Stream.max()?<br>
> ><br>
> ><br>
> > .reduce(0.0, (x, y) -> Math.max(x, y))<br>
> ><br>
> > --Joe<br>
> ><br>
> ><br>
<br>
</div></div></blockquote></div><br></div>