Closed GoogleCodeExporter closed 9 years ago
Even though zero values for empty collections might help with the negative
cacheing, I still feel that it would be more realistic for the collection
itself to be weighted. After all, it is still an object, and still takes up
heap space. If you had a huge map filled with empty lists, it should still have
weight.
Hence, my vote would go for list.size() + 1
Original comment by vermeule...@gmail.com
on 3 Sep 2010 at 2:23
Thinking about this, I could argue that the current behavior is correct. The
intent was to allow someone to implement a Google Guava Multimap abstraction.
A Multimap replaces all null cases with empty collections and never stores
empty collections in the backing map. Thus, there would never be a value with
weight zero.
This failure is partially due to not having a Multimap abstraction, which would
remove the need for the Weighers class, and that the negative caching is being
used. Thus, null and empty collection have distinctly different meanings.
Perhaps the best resolution would be to implement a Multimap cache and remove
the Weighers utility class. Grails would still need a custom weigher, but the
behavior wouldn't be surprising.
Original comment by Ben.Manes@gmail.com
on 15 Sep 2010 at 5:37
Clarified JavaDoc in r475 to warn clients of the behavior if the weight is
zero. I've concluded that the default behavior is the most appropriate, with
the action taken the responsibility of the client. If a zero-weight is not
allowed, then it should be decorated in a Multimap form to automatically remove
the value instead of updating it. If a zero weight is allowed, then a custom
weigher should be used to account for the negative caching. As the default
behavior can't assume what is expected, the JavaDoc tries to clarify the
failure case so clients can determine if it may occur in their usage.
Original comment by Ben.Manes@gmail.com
on 1 Nov 2010 at 2:33
Original issue reported on code.google.com by
Ben.Manes@gmail.com
on 2 Sep 2010 at 6:07