Hi folks, On 13.10.16 16:25, t...@apache.org wrote: > Author: tv > Date: Thu Oct 13 14:25:04 2016 > New Revision: 1764695 > > URL: http://svn.apache.org/viewvc?rev=1764695&view=rev > Log: > Fix SortedPreferentialArray to actually do what was is supposed to do > > Modified: > > commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskElementDescriptor.java > > commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/SortedPreferentialArray.java > > commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/SortedPrefArrayUnitTest.java
When I looked into the tests of SortedPreferentialArray to see whether this could be replaced with some JDK standard stuff, I found that it has a number of severe problems. IMHO, it simply doesn't work. It doesn't even sort correctly. Now this class is used as a recycle bin in the IndexedDiskCache which, to my knowledge, is a quite popular component within JCS. Am I completely mistaken or is this functionality so unimportant that it doesn't make any difference? I replaced a lot of code with a reference to a ConcurrentSkipListSet and managed to get all tests to pass again. Could some kind soul please take a few cycles to review this commit and the related code in IndexedDiskCache? I would like some help with answering the following questions: - The recycle bin contains elements of type IndexedDiskElementDescriptor. Obviously, these elements were compared by their size (len field) only, not their offset (pos field), so that storage chunks of identical size are considered equal. Nevertheless, this somehow seemed to work, even in the unit test where all elements are of the same size. But why? - The old implementation uses a fixed size array to store the elements. If more elements were added, the smallest elements were discarded. Does this actually make any sense? - After my changes, the disk cache should recycle used storage chunks more effectively. Can someone with a real-world application confirm this? - Do I miss some other sophisticated feature in the code I removed? Thank you in advance for any time you may be able to donate. Bye, Thomas. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org