sort new objects according to MOFID - this greatly improves hits/miss ratio in FileCache since there is a lots of cases where objects are read sequentially
1.1 --- a/mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreestorage/MDRCache.java Sat Apr 09 19:32:54 2005 +0000
1.2 +++ b/mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreestorage/MDRCache.java Wed Apr 13 15:32:26 2005 +0000
1.3 @@ -436,11 +436,23 @@
1.4 }
1.5 }
1.6
1.7 + private static final Comparator mofidComparator = new Comparator() {
1.8 + public int compare(Object o1, Object o2) {
1.9 + Map.Entry e1=(Map.Entry)o1;
1.10 + Map.Entry e2=(Map.Entry)o2;
1.11 + MOFID id1=(MOFID)e1.getKey();
1.12 + MOFID id2=(MOFID)e2.getKey();
1.13 +
1.14 + return (int)(id1.getSerialNumber()-id2.getSerialNumber());
1.15 + }
1.16 + };
1.17 +
1.18 /** Get all of the new objects
1.19 * @return the keys of the new objects
1.20 */
1.21 public synchronized Collection getNew() {
1.22 - ArrayList result = new ArrayList(newOnes.entrySet());
1.23 + Collection result = new TreeSet(mofidComparator);
1.24 + result.addAll(newOnes.entrySet());
1.25 newOnes.clear();
1.26 return result;
1.27 }