From: Wolfgang M. M. <wol...@us...> - 2004-08-15 20:29:18
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util/hashtable In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18976/src/org/exist/util/hashtable Modified Files: SequencedLongHashMap.java Long2ObjectHashMap.java Log Message: Fixed class LRUCache. LRUCache is now used for the data pages in DOMFile + BFile. LRU seems to be a better strategy for the data pages than LRD. It produces less page failures. Index: SequencedLongHashMap.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/hashtable/SequencedLongHashMap.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SequencedLongHashMap.java 12 Aug 2004 18:54:20 -0000 1.1 --- SequencedLongHashMap.java 15 Aug 2004 20:29:10 -0000 1.2 *************** *** 32,36 **** public class SequencedLongHashMap extends Long2ObjectHashMap { ! private static class Entry { long key; --- 32,36 ---- public class SequencedLongHashMap extends Long2ObjectHashMap { ! public final static class Entry { long key; *************** *** 44,47 **** --- 44,59 ---- this.value = value; } + + public Entry getNext() { + return next; + } + + public long getKey() { + return key; + } + + public Object getValue() { + return value; + } } *************** *** 61,82 **** Entry duplicate = null; try { ! duplicate = (Entry)insert(key, entry); } catch (HashtableOverflowException e) { ! long[] copyKeys = keys; ! Object[] copyValues = values; ! // enlarge the table with a prime value ! tabSize = (int) nextPrime(tabSize + tabSize / 2); ! keys = new long[tabSize]; ! values = new Object[tabSize]; ! items = 0; ! ! try { ! for (int k = 0; k < copyValues.length; k++) { ! if (copyValues[k] != null && copyValues[k] != REMOVED) ! insert(copyKeys[k], copyValues[k]); ! } ! duplicate = (Entry)insert(key, entry); ! } catch (HashtableOverflowException e1) { ! } } if(duplicate != null) --- 73,98 ---- Entry duplicate = null; try { ! Object old = insert(key, entry); ! if(old != null && !(old instanceof Entry)) ! throw new RuntimeException("Found old object: " + old.getClass().getName()); ! duplicate = (Entry)old; } catch (HashtableOverflowException e) { ! throw new RuntimeException(e); ! // long[] copyKeys = keys; ! // Object[] copyValues = values; ! // // enlarge the table with a prime value ! // tabSize = (int) nextPrime(tabSize + tabSize / 2); ! // keys = new long[tabSize]; ! // values = new Object[tabSize]; ! // items = 0; ! // ! // try { ! // for (int k = 0; k < copyValues.length; k++) { ! // if (copyValues[k] != null && copyValues[k] != REMOVED) ! // insert(copyKeys[k], copyValues[k]); ! // } ! // duplicate = (Entry)insert(key, entry); ! // } catch (HashtableOverflowException e1) { ! // } } if(duplicate != null) *************** *** 97,100 **** --- 113,120 ---- } + public Entry getFirstEntry() { + return first; + } + public Object remove(long key) { Entry entry = (Entry) super.remove(key); *************** *** 122,126 **** } ! private void removeEntry(Entry entry) { if(entry.prev == null) { if(entry.next == null) { --- 142,146 ---- } ! public void removeEntry(Entry entry) { if(entry.prev == null) { if(entry.next == null) { Index: Long2ObjectHashMap.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/hashtable/Long2ObjectHashMap.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Long2ObjectHashMap.java 12 Aug 2004 18:54:20 -0000 1.4 --- Long2ObjectHashMap.java 15 Aug 2004 20:29:10 -0000 1.5 *************** *** 167,172 **** for (int i = 0; i < tabSize; i++) { idx = (idx + rehashVal) % tabSize; ! if(values[idx] == REMOVED && bucket == -1) { ! bucket = idx; } else if (values[idx] == null) { if(bucket > -1) { --- 167,173 ---- for (int i = 0; i < tabSize; i++) { idx = (idx + rehashVal) % tabSize; ! if(values[idx] == REMOVED) { ! if(bucket == -1) ! bucket = idx; } else if (values[idx] == null) { if(bucket > -1) { |