From: Wolfgang M. M. <wol...@us...> - 2004-06-29 14:26:59
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30306/src/org/exist/storage Modified Files: NativeBroker.java Log Message: Fixed bug in automatic defragmentation method leading to random exceptions (like "node not found", "not implemented" etc.). Index: NativeBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeBroker.java,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** NativeBroker.java 23 Jun 2004 12:45:12 -0000 1.83 --- NativeBroker.java 29 Jun 2004 14:26:48 -0000 1.84 *************** *** 1190,1202 **** } flush(); LOG.debug("Copy took " + (System.currentTimeMillis() - start) + "ms."); } public void defrag(final DocumentImpl doc) { ! LOG.debug("--------------------> Defragmenting document " + doc.getFileName()); final long start = System.currentTimeMillis(); try { ! // dropping old index elementIndex.dropIndex(doc); // dropping dom index NodeRef ref = new NodeRef(doc.getDocId()); --- 1190,1207 ---- } flush(); + closeDocument(); LOG.debug("Copy took " + (System.currentTimeMillis() - start) + "ms."); } public void defrag(final DocumentImpl doc) { ! LOG.debug("============> Defragmenting document " + ! doc.getCollection().getName() + '/' + doc.getFileName()); final long start = System.currentTimeMillis(); try { ! final NodeImpl firstChild = (NodeImpl)doc.getFirstChild(); ! ! // dropping old structure index elementIndex.dropIndex(doc); + // dropping dom index NodeRef ref = new NodeRef(doc.getDocId()); *************** *** 1221,1228 **** --- 1226,1235 ---- .run(); + // create a copy of the old doc to copy the nodes into it DocumentImpl tempDoc = new DocumentImpl(this, doc.getFileName(), doc.getCollection()); tempDoc.copyOf(doc); tempDoc.setDocId(doc.getDocId()); + // copy the nodes Iterator iterator; NodeList nodes = doc.getChildNodes(); *************** *** 1238,1245 **** flush(); new DOMTransaction(this, domDb) { public Object start() { ! NodeImpl node = (NodeImpl)doc.getFirstChild(); ! domDb.removeAll(node.getInternalAddress()); return null; } --- 1245,1253 ---- flush(); + // remove the old nodes new DOMTransaction(this, domDb) { public Object start() { ! domDb.remove(doc.getAddress()); ! domDb.removeAll(firstChild.getInternalAddress()); return null; } *************** *** 1251,1256 **** doc.setAddress(-1); doc.setPageCount(tempDoc.getPageCount()); - LOG.debug("New doc size: " + doc.getContentLength()); storeDocument(doc); saveCollection(doc.getCollection()); --- 1259,1264 ---- doc.setAddress(-1); doc.setPageCount(tempDoc.getPageCount()); storeDocument(doc); + closeDocument(); saveCollection(doc.getCollection()); *************** *** 1490,1494 **** Value val = domDb.get(p.getInternalAddress()); if (val == null) { ! LOG.debug("node " + p.gid + " not found!"); Thread.dumpStack(); return null; --- 1498,1503 ---- Value val = domDb.get(p.getInternalAddress()); if (val == null) { ! LOG.debug("node " + p.gid + " not found in document " + ! p.doc.getCollection().getName() + '/' + p.doc.getFileName()); Thread.dumpStack(); return null; |