From: Wolfgang M. M. <wol...@us...> - 2004-04-14 12:18:01
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20167/src/org/exist/storage Modified Files: NativeTextEngine.java NativeBroker.java Log Message: Improved page organization in dom.dbx to fix known XUpdate issues. Index: NativeBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeBroker.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** NativeBroker.java 29 Mar 2004 14:15:14 -0000 1.61 --- NativeBroker.java 14 Apr 2004 12:17:21 -0000 1.62 *************** *** 109,113 **** /** check available memory after storing MEM_LIMIT_CHECK nodes */ ! protected static int MEM_LIMIT_CHECK = 10000; protected CollectionStore collectionsDb = null; --- 109,113 ---- /** check available memory after storing MEM_LIMIT_CHECK nodes */ ! protected final static int MEM_LIMIT_CHECK = 10000; protected CollectionStore collectionsDb = null; *************** *** 340,344 **** val[1].data(), val[1].start(), ! val[1].length()); try { while (is.available() > 0) { --- 340,344 ---- val[1].data(), val[1].start(), ! val[1].getLength()); try { while (is.available() > 0) { *************** *** 869,872 **** --- 869,878 ---- } + /** + * Index a single node, which has been added through an XUpdate + * operation. This method is only called if inserting the node is possible + * without changing the node identifiers of sibling or parent nodes. In other + * cases, reindex will be called. + */ public void index(final NodeImpl node) { final DocumentImpl doc = (DocumentImpl) node.getOwnerDocument(); *************** *** 938,941 **** --- 944,952 ---- } + /** + * Reindex the nodes in the document. This method will either reindex all + * descendant nodes of the passed node, or all nodes below some level of + * the document if node is null. + */ public void reindex(DocumentImpl oldDoc, DocumentImpl doc, NodeImpl node) { int idxLevel = doc.reindexRequired(); *************** *** 948,952 **** LOG.debug("reindexing level " + idxLevel + " of document " + doc.getDocId()); final long start = System.currentTimeMillis(); ! // remove old dom index Value ref = new NodeRef(doc.getDocId()); final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref); --- 959,963 ---- LOG.debug("reindexing level " + idxLevel + " of document " + doc.getDocId()); final long start = System.currentTimeMillis(); ! // remove all old index keys from the btree Value ref = new NodeRef(doc.getDocId()); final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref); *************** *** 981,985 **** lock.release(); } ! // reindex the nodes Iterator iterator; if (node == null) { --- 992,996 ---- lock.release(); } ! // now reindex the nodes Iterator iterator; if (node == null) { *************** *** 1007,1010 **** --- 1018,1028 ---- } + /** + * Reindex the given node after the DOM tree has been + * modified by an XUpdate. + * + * @param node + * @param currentPath + */ private void reindex(final NodeImpl node, StringBuffer currentPath) { if (node.getGID() < 0) *************** *** 1089,1092 **** --- 1107,1118 ---- } + /** + * Called by reindex to walk through all nodes in the tree and reindex them + * if necessary. + * + * @param iterator + * @param node + * @param currentPath + */ private void scanNodes(Iterator iterator, NodeImpl node, StringBuffer currentPath) { if (node.getNodeType() == Node.ELEMENT_NODE) *************** *** 1107,1112 **** } final long lastChildId = firstChildId + node.getChildCount(); - // ong p; - // Value value; NodeImpl child; for (long gid = firstChildId; gid < lastChildId; gid++) { --- 1133,1136 ---- *************** *** 1859,1866 **** final int percent = (int) (run.freeMemory() / (run.totalMemory() / 100)); if (percent < memMinFree) { ! LOG.info( ! "total memory: " + run.totalMemory() + "; free: " + run.freeMemory()); flush(); ! System.gc(); LOG.info( "total memory: " + run.totalMemory() + "; free: " + run.freeMemory()); --- 1883,1890 ---- final int percent = (int) (run.freeMemory() / (run.totalMemory() / 100)); if (percent < memMinFree) { ! //LOG.info( ! // "total memory: " + run.totalMemory() + "; free: " + run.freeMemory()); flush(); ! //System.gc(); LOG.info( "total memory: " + run.totalMemory() + "; free: " + run.freeMemory()); *************** *** 2041,2045 **** LOG.debug(dbe); } - System.gc(); } --- 2065,2068 ---- *************** *** 2061,2069 **** new DOMTransaction(this, domDb, Lock.WRITE_LOCK) { public Object start() throws ReadOnlyException { - final NodeRef ref = new NodeRef(doc.getDocId(), node.getGID()); if (-1 < internalAddress) ! domDb.update(ref, internalAddress, data); ! else ! domDb.update(ref, data); return null; } --- 2084,2092 ---- new DOMTransaction(this, domDb, Lock.WRITE_LOCK) { public Object start() throws ReadOnlyException { if (-1 < internalAddress) ! domDb.update(internalAddress, data); ! else { ! domDb.update(new NodeRef(doc.getDocId(), node.getGID()), data); ! } return null; } *************** *** 2082,2085 **** --- 2105,2111 ---- } + /** + * Physically insert a node into the DOM storage. + */ public void insertAfter(final NodeImpl previous, final NodeImpl node) { final byte data[] = node.serialize(); Index: NativeTextEngine.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeTextEngine.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** NativeTextEngine.java 5 Mar 2004 16:15:47 -0000 1.42 --- NativeTextEngine.java 14 Apr 2004 12:17:21 -0000 1.43 *************** *** 780,784 **** private DocumentImpl doc = null; - private boolean flushed = false; private Map words[] = new TreeMap[2]; private VariableByteOutputStream os = new VariableByteOutputStream(7); --- 780,783 ---- *************** *** 1098,1109 **** if (data.size() == 0) return; - // if data has already been written to the table, - // we may need to do updates. - final WordRef ref = new WordRef(collectionId, word); Lock lock = dbWords.getLock(); try { lock.acquire(Lock.WRITE_LOCK); try { ! dbWords.append(ref, data); } catch (ReadOnlyException e) { } catch (IOException ioe) { --- 1097,1105 ---- if (data.size() == 0) return; Lock lock = dbWords.getLock(); try { lock.acquire(Lock.WRITE_LOCK); try { ! dbWords.append(new WordRef(collectionId, word), data); } catch (ReadOnlyException e) { } catch (IOException ioe) { |