From: Wolfgang M. M. <wol...@us...> - 2004-08-15 20:29:19
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage/store In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18976/src/org/exist/storage/store Modified Files: BFile.java DOMFile.java ItemId.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: DOMFile.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/store/DOMFile.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** DOMFile.java 12 Aug 2004 19:43:00 -0000 1.49 --- DOMFile.java 15 Aug 2004 20:29:10 -0000 1.50 *************** *** 47,52 **** import org.exist.storage.cache.Cache; import org.exist.storage.cache.Cacheable; - import org.exist.storage.cache.ClockCache; - import org.exist.storage.cache.LRDCache; import org.exist.storage.cache.LRUCache; import org.exist.util.ByteConversion; --- 47,50 ---- *************** *** 108,115 **** public final static short OVERFLOW = 0; ! public final static long DATA_SYNC_PERIOD = 1000; private final Cache dataCache; ! private DOMFileHeader fileHeader; --- 106,113 ---- public final static short OVERFLOW = 0; ! public final static long DATA_SYNC_PERIOD = 4200; private final Cache dataCache; ! private DOMFileHeader fileHeader; *************** *** 129,133 **** fileHeader.setPageCount(0); fileHeader.setTotalCount(0); ! dataCache = new LRDCache(dataBuffers); dataCache.setFileName("dom.dbx"); --- 127,131 ---- fileHeader.setPageCount(0); fileHeader.setTotalCount(0); ! dataCache = new LRUCache(dataBuffers); dataCache.setFileName("dom.dbx"); *************** *** 852,867 **** } - public void sync() throws DBException { - super.flush(); - dataCache.flush(); - // pages.remove(owner); - closeDocument(); - try { - if (fileHeader.isDirty()) fileHeader.write(); - } catch (IOException ioe) { - LOG.warn("sync failed", ioe); - } - } - public void printStatistics() { super.printStatistics(); --- 850,853 ---- *************** *** 1691,1713 **** short vlen; RecordPos rec = null; for (int pos = 0; pos < dlen;) { currentId = ByteConversion.byteToShort(data, pos); ! if (ItemId.isLink(currentId)) { ! if (ItemId.matches(currentId, targetId)) { rec = new RecordPos(pos + 2, this, currentId); rec.isLink = true; - break; } else { ! pos += 10; } ! } else if (ItemId.matches(currentId, targetId)) { ! rec = new RecordPos(pos + 2, this, currentId); ! break; } else { vlen = ByteConversion.byteToShort(data, pos + 2); ! if (ItemId.isRelocated(currentId)) { ! pos += vlen == OVERFLOW ? 20 : vlen + 12; ! } else ! pos += vlen == OVERFLOW ? 12 : vlen + 4; } } --- 1677,1703 ---- short vlen; RecordPos rec = null; + byte flags; for (int pos = 0; pos < dlen;) { currentId = ByteConversion.byteToShort(data, pos); ! flags = ItemId.getFlags(currentId); ! if (ItemId.matches(currentId, targetId)) { ! if ((flags & ItemId.LINK_FLAG) != 0) { rec = new RecordPos(pos + 2, this, currentId); rec.isLink = true; } else { ! rec = new RecordPos(pos + 2, this, currentId); } ! break; ! } else if ((flags & ItemId.LINK_FLAG) != 0){ ! pos += 10; } else { vlen = ByteConversion.byteToShort(data, pos + 2); ! if ((flags & ItemId.RELOCATED_FLAG) != 0) { ! pos += vlen + 12; ! } else { ! pos += vlen + 4; ! } ! if(vlen == OVERFLOW) ! pos += 8; } } Index: BFile.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/store/BFile.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** BFile.java 12 Aug 2004 18:54:21 -0000 1.32 --- BFile.java 15 Aug 2004 20:29:10 -0000 1.33 *************** *** 40,44 **** import org.exist.storage.cache.Cache; import org.exist.storage.cache.Cacheable; ! import org.exist.storage.cache.LRDCache; import org.exist.storage.io.VariableByteArrayInput; import org.exist.storage.io.VariableByteInput; --- 40,44 ---- import org.exist.storage.cache.Cache; import org.exist.storage.cache.Cacheable; ! import org.exist.storage.cache.LRUCache; import org.exist.storage.io.VariableByteArrayInput; import org.exist.storage.io.VariableByteInput; *************** *** 99,103 **** protected Cache dataCache = null; ! protected Lock lock = null; --- 99,103 ---- protected Cache dataCache = null; ! protected Lock lock = null; *************** *** 107,111 **** super(pool, file, btreeBuffers); fileHeader = (BFileHeader) getFileHeader(); ! dataCache = new LRDCache(dataBuffers); dataCache.setFileName(getFile().getName()); minFree = PAGE_MIN_FREE; --- 107,111 ---- super(pool, file, btreeBuffers); fileHeader = (BFileHeader) getFileHeader(); ! dataCache = new LRUCache(dataBuffers); dataCache.setFileName(getFile().getName()); minFree = PAGE_MIN_FREE; *************** *** 119,123 **** dataCache.flush(); } catch (LockException e) { ! LOG.warn("Failed to acquire lock on dom.dbx"); } finally { lock.release(); --- 119,123 ---- dataCache.flush(); } catch (LockException e) { ! LOG.warn("Failed to acquire lock on " + getFile().getName()); } finally { lock.release(); *************** *** 206,210 **** System.arraycopy(data, offset + 4, newData, 0, l); value.copyTo(newData, l); ! p = update(p, page, key, new FixedByteArray(newData)); } return p; --- 206,210 ---- System.arraycopy(data, offset + 4, newData, 0, l); value.copyTo(newData, l); ! p = update(p, page, key, new FixedByteArray(newData, 0, newData.length)); } return p; *************** *** 742,746 **** // save data value.copyTo(data, len); - //System.arraycopy(value, 0, data, len, vlen); len += vlen; page.getPageHeader().setDataLength(len); --- 742,745 ---- Index: ItemId.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/store/ItemId.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ItemId.java 11 Aug 2004 12:47:01 -0000 1.4 --- ItemId.java 15 Aug 2004 20:29:10 -0000 1.5 *************** *** 37,40 **** --- 37,47 ---- public static final short LINK_OR_RELOCATED_MASK = (short) 0xC000; + public static final byte LINK_FLAG = (byte) 0x1; + public static final byte RELOCATED_FLAG = (byte) 0x2; + + public final static byte getFlags(short id) { + return (byte)((id & LINK_OR_RELOCATED_MASK) >>> 14); + } + public final static short getId(short id) { return (short) (id & ID_MASK); |