VerifyError
Richard Warburton
richard.warburton at gmail.com
Sun Apr 21 01:12:46 PDT 2013
> It's a compiler issue,
> in the following expression, the lambda used as parameter of flatMap
> is not able to create CoBuy::new correctly
>
> // product id -> product id -> frequency purchased together
> Map<Integer, Map<Integer, Long>> productSimilarity =
> buysByUser.values()
> .stream()
> .flatMap(buys -> zip(buys.stream(),
> buys.stream(), CoBuy::new))
> .collect(groupingBy(coBuy -> coBuy.x,
> groupingBy(coBuy -> coBuy.y,
> TreeMap::new, counting())));
>
> so the bug is here:
> buys -> zip(buys.stream(), buys.stream(), CoBuy::new)
>
> CoBuy is declared as a non static inner class
> (BTW, Richard, I think you forget to declare it static)
> so it capture 'this' which is an instance of Java8Recommender.
>
Makes perfect sense, and making CoBuy static fixes the problem.
regards,
Richard Warburton
http://insightfullogic.com
@RichardWarburto <http://twitter.com/richardwarburto>
More information about the lambda-dev
mailing list