From: Wolfgang M. M. <wol...@us...> - 2004-05-03 13:09:28
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19067/src/org/exist/storage Modified Files: NativeTextEngine.java DBBroker.java NativeElementIndex.java NativeBroker.java Log Message: Implemented lazy evaluation for XQuery enclosed expressions. Index: NativeBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeBroker.java,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** NativeBroker.java 27 Apr 2004 15:47:02 -0000 1.64 --- NativeBroker.java 3 May 2004 13:08:43 -0000 1.65 *************** *** 26,30 **** import java.io.File; import java.io.IOException; - import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.util.ArrayList; --- 26,29 ---- *************** *** 36,39 **** --- 35,39 ---- import java.util.TreeMap; + import org.apache.log4j.Logger; import org.apache.oro.text.regex.MalformedPatternException; import org.apache.oro.text.regex.Pattern; *************** *** 66,69 **** --- 66,72 ---- import org.exist.security.PermissionDeniedException; import org.exist.security.User; + import org.exist.storage.io.VariableByteArrayInput; + import org.exist.storage.io.VariableByteInput; + import org.exist.storage.io.VariableByteOutputStream; import org.exist.storage.serializers.NativeSerializer; import org.exist.storage.serializers.Serializer; *************** *** 82,87 **** import org.exist.util.Occurrences; import org.exist.util.ReadOnlyException; - import org.exist.util.VariableByteInputStream; - import org.exist.util.VariableByteOutputStream; import org.exist.xquery.Constants; import org.exist.xquery.NodeSelector; --- 85,88 ---- *************** *** 101,104 **** --- 102,109 ---- */ public class NativeBroker extends DBBroker { + /** + * Log4J Logger for this class + */ + private static final Logger LOG = Logger.getLogger(NativeBroker.class); private static final String DATABASE_IS_READ_ONLY = "database is read-only"; *************** *** 306,310 **** collections.add(collection); TreeMap map = new TreeMap(); ! VariableByteInputStream is; int docId; int len; --- 311,315 ---- collections.add(collection); TreeMap map = new TreeMap(); ! VariableByteArrayInput is; int docId; int len; *************** *** 337,341 **** is = ! new VariableByteInputStream( val[1].data(), val[1].start(), --- 342,346 ---- is = ! new VariableByteArrayInput( val[1].data(), val[1].start(), *************** *** 385,391 **** short collectionId; long gid; ! VariableByteInputStream is; ElementValue ref; - InputStream dis = null; short sym, nsSym; Collection collection; --- 390,395 ---- short collectionId; long gid; ! VariableByteInput is = null; ElementValue ref; short sym, nsSym; Collection collection; *************** *** 407,417 **** try { lock.acquire(Lock.READ_LOCK); ! dis = elementsDb.getAsStream(ref); } catch (LockException e) { ! LOG.warn("failed to acquire lock", e); // jmv: dis = null; exceptionOcurred = true; } catch (IOException e) { ! LOG.warn("io exception while reading elements for " + qname, e); // jmv: dis = null; exceptionOcurred = true; --- 411,428 ---- try { lock.acquire(Lock.READ_LOCK); ! is = elementsDb.getAsStream(ref); } catch (LockException e) { ! LOG.warn( ! "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - " ! + "failed to acquire lock", ! e); // jmv: dis = null; exceptionOcurred = true; } catch (IOException e) { ! LOG.warn( ! "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - " ! + "io exception while reading elements for " ! + qname, ! e); // jmv: dis = null; exceptionOcurred = true; *************** *** 421,427 **** // jmv: if (dis == null) // wolf: dis == null if no matching element has been found in the index ! if (dis == null || exceptionOcurred) continue; - is = new VariableByteInputStream(dis); try { while (is.available() > 0) { --- 432,437 ---- // jmv: if (dis == null) // wolf: dis == null if no matching element has been found in the index ! if (is == null || exceptionOcurred) continue; try { while (is.available() > 0) { *************** *** 442,446 **** } catch (EOFException e) { } catch (IOException e) { ! LOG.warn("unexpected io error", e); } } --- 452,459 ---- } catch (EOFException e) { } catch (IOException e) { ! LOG.warn( ! "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - " ! + "unexpected io error", ! e); } } *************** *** 485,496 **** Collection root = getCollection(ROOT_COLLECTION); root.allDocs(this, docs, true); ! LOG.debug( ! "loading " ! + docs.getLength() ! + " documents from " ! + docs.getCollectionCount() ! + "collections took " ! + (System.currentTimeMillis() - start) ! + "ms."); return docs; } --- 498,511 ---- Collection root = getCollection(ROOT_COLLECTION); root.allDocs(this, docs, true); ! if (LOG.isDebugEnabled()) { ! LOG.debug("getAllDocuments(DocumentSet) - end - " ! + "loading " ! + docs.getLength() ! + " documents from " ! + docs.getCollectionCount() ! + "collections took " ! + (System.currentTimeMillis() - start) ! + "ms."); ! } return docs; } *************** *** 540,544 **** } Collection collection = null; ! InputStream dis = null; Lock lock = collectionsDb.getLock(); try { --- 555,559 ---- } Collection collection = null; ! VariableByteInput is = null; Lock lock = collectionsDb.getLock(); try { *************** *** 548,566 **** return collection; } collection = new Collection(collectionsDb, name); try { if (addr < 0) { ! dis = collectionsDb.getAsStream(key); } else { ! dis = collectionsDb.getAsStream(addr); } } catch (IOException ioe) { LOG.warn(ioe.getMessage(), ioe); } ! if (dis == null) return null; ! VariableByteInputStream istream = new VariableByteInputStream(dis); try { ! collection.read(this, istream); } catch (IOException ioe) { LOG.warn(ioe); --- 563,583 ---- return collection; } + if(name.equals("/db/collection-31/collection-31-1")) + LOG.debug("loading collection " + name); collection = new Collection(collectionsDb, name); try { if (addr < 0) { ! is = collectionsDb.getAsStream(key); } else { ! is = collectionsDb.getAsStream(addr); } } catch (IOException ioe) { LOG.warn(ioe.getMessage(), ioe); } ! if (is == null) return null; ! try { ! collection.read(this, is); } catch (IOException ioe) { LOG.warn(ioe); *************** *** 1434,1447 **** } else { NodeImpl node = (NodeImpl)doc.getFirstChild(); ! Iterator k = ! getDOMIterator( ! new NodeProxy( ! doc, ! node.getGID(), ! node.getInternalAddress())); ! while(k.hasNext()) { ! k.next(); ! k.remove(); ! } } return null; --- 1451,1465 ---- } else { NodeImpl node = (NodeImpl)doc.getFirstChild(); ! domDb.removeAll(node.getInternalAddress()); ! // Iterator k = ! // getDOMIterator( ! // new NodeProxy( ! // doc, ! // node.getGID(), ! // node.getInternalAddress())); ! // while(k.hasNext()) { ! // k.next(); ! // k.remove(); ! // } } return null; *************** *** 1489,1496 **** final DocumentImpl doc = (DocumentImpl) getDocument(docName); if (doc == null) { ! LOG.debug("document " + docName + " not found"); return; } ! LOG.info("removing document " + doc.getDocId() + " ..."); // drop element-index --- 1507,1524 ---- final DocumentImpl doc = (DocumentImpl) getDocument(docName); if (doc == null) { ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument(String) - end - " ! + "document " ! + docName ! + " not found"); ! } return; } ! if (LOG.isInfoEnabled()) { ! LOG.info("removeDocument() - " ! + "removing document " ! + doc.getDocId() ! + " ..."); ! } // drop element-index *************** *** 1502,1506 **** lock.acquire(Lock.WRITE_LOCK); ArrayList elements = elementsDb.findKeys(query); ! LOG.debug("found " + elements.size() + " elements."); Value key; --- 1530,1539 ---- lock.acquire(Lock.WRITE_LOCK); ArrayList elements = elementsDb.findKeys(query); ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument() - " ! + "found " ! + elements.size() ! + " elements."); ! } Value key; *************** *** 1508,1512 **** byte[] data; // byte[] ndata; ! VariableByteInputStream is; VariableByteOutputStream os; int len; --- 1541,1545 ---- byte[] data; // byte[] ndata; ! VariableByteArrayInput is; VariableByteOutputStream os; int len; *************** *** 1519,1523 **** value = elementsDb.get(key); data = value.getData(); ! is = new VariableByteInputStream(data); os = new VariableByteOutputStream(); changed = false; --- 1552,1556 ---- value = elementsDb.get(key); data = value.getData(); ! is = new VariableByteArrayInput(data); os = new VariableByteOutputStream(); changed = false; *************** *** 1543,1556 **** } } catch (EOFException e) { ! LOG.debug("eof: " + is.available()); } if (changed) { //ndata = os.toByteArray(); if (elementsDb.put(key, os.data()) < 0) ! LOG.debug("could not save element"); } } } catch (LockException e) { ! LOG.warn("could not acquire lock on elements", e); } finally { lock.release(); --- 1576,1597 ---- } } catch (EOFException e) { ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument(String) - " ! + "eof: " ! + is.available(), e); ! } } if (changed) { //ndata = os.toByteArray(); if (elementsDb.put(key, os.data()) < 0) ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument() - " ! + "could not save element"); ! } } } } catch (LockException e) { ! LOG.warn("removeDocument(String) - " ! + "could not acquire lock on elements", e); } finally { lock.release(); *************** *** 1559,1578 **** ((NativeTextEngine) textEngine).removeDocument(doc); ! LOG.debug("removing dom"); new DOMTransaction(this, domDb) { public Object start() { ! NodeList children = doc.getChildNodes(); ! NodeImpl node; ! for (int i = 0; i < children.getLength(); i++) { ! node = (NodeImpl) children.item(i); ! Iterator j = ! getDOMIterator( ! new NodeProxy( ! doc, ! node.getGID(), ! node.getInternalAddress())); ! removeNodes(j); ! } ! domDb.remove(doc.getAddress()); return null; } --- 1600,1623 ---- ((NativeTextEngine) textEngine).removeDocument(doc); ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument() - " + "removing dom"); ! } new DOMTransaction(this, domDb) { public Object start() { ! NodeImpl node = (NodeImpl)doc.getFirstChild(); ! domDb.removeAll(node.getInternalAddress()); ! // NodeList children = doc.getChildNodes(); ! // NodeImpl node; ! // for (int i = 0; i < children.getLength(); i++) { ! // node = (NodeImpl) children.item(i); ! // Iterator j = ! // getDOMIterator( ! // new NodeProxy( ! // doc, ! // node.getGID(), ! // node.getInternalAddress())); ! // removeNodes(j); ! // } ! // domDb.remove(doc.getAddress()); return null; } *************** *** 1588,1596 **** domDb.flush(); } catch (BTreeException e) { ! LOG.warn("error while removing doc", e); } catch (DBException e) { ! LOG.warn("error while removing doc", e); } catch (IOException e) { ! LOG.warn("error while removing doc", e); } return null; --- 1633,1641 ---- domDb.flush(); } catch (BTreeException e) { ! LOG.warn("start() - " + "error while removing doc", e); } catch (DBException e) { ! LOG.warn("start() - " + "error while removing doc", e); } catch (IOException e) { ! LOG.warn("start() - " + "error while removing doc", e); } return null; *************** *** 1599,1611 **** .run(); freeDocument(doc.getDocId()); - LOG.info("removed document."); } catch (IOException ioe) { ioe.printStackTrace(); ! LOG.warn(ioe); } catch (BTreeException bte) { bte.printStackTrace(); ! LOG.warn(bte); } catch (ReadOnlyException e) { ! LOG.warn(DATABASE_IS_READ_ONLY); } } --- 1644,1655 ---- .run(); freeDocument(doc.getDocId()); } catch (IOException ioe) { ioe.printStackTrace(); ! LOG.warn("removeDocument(String) - " + ioe); } catch (BTreeException bte) { bte.printStackTrace(); ! LOG.warn("removeDocument(String) - " + bte); } catch (ReadOnlyException e) { ! LOG.warn("removeDocument(String) - " + DATABASE_IS_READ_ONLY); } } *************** *** 2139,2142 **** --- 2183,2190 ---- public final static class NodeRef extends Value { + /** + * Log4J Logger for this class + */ + private static final Logger LOG = Logger.getLogger(NodeRef.class); public NodeRef() { Index: NativeElementIndex.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeElementIndex.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** NativeElementIndex.java 29 Jan 2004 15:06:48 -0000 1.23 --- NativeElementIndex.java 3 May 2004 13:08:43 -0000 1.24 *************** *** 23,27 **** import java.io.EOFException; import java.io.IOException; - import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; --- 23,26 ---- *************** *** 37,41 **** import org.exist.dom.QName; import org.exist.dom.XMLUtil; ! import org.exist.storage.store.*; import org.exist.util.Configuration; import org.exist.util.FastQSort; --- 36,44 ---- import org.exist.dom.QName; import org.exist.dom.XMLUtil; ! import org.exist.storage.io.VariableByteArrayInput; ! import org.exist.storage.io.VariableByteInput; ! import org.exist.storage.io.VariableByteOutputStream; ! import org.exist.storage.store.BFile; ! import org.exist.storage.store.StorageAddress; import org.exist.util.Configuration; import org.exist.util.FastQSort; *************** *** 45,50 **** import org.exist.util.ReadOnlyException; //import org.exist.util.StorageAddress; - import org.exist.util.VariableByteInputStream; - import org.exist.util.VariableByteOutputStream; public class NativeElementIndex extends ElementIndex { --- 48,51 ---- *************** *** 83,88 **** List oldList = new ArrayList(), idList; NodeProxy p; ! VariableByteInputStream is = new VariableByteInputStream(); ! InputStream dis = null; int len, docId; byte[] data; --- 84,88 ---- List oldList = new ArrayList(), idList; NodeProxy p; ! VariableByteInput is = null; int len, docId; byte[] data; *************** *** 111,115 **** lock.acquire(Lock.READ_LOCK); //val = dbElement.get(ref); ! dis = dbElement.getAsStream(ref); } catch (LockException e) { LOG.error("could not acquire lock for index on " + qname); --- 111,115 ---- lock.acquire(Lock.READ_LOCK); //val = dbElement.get(ref); ! is = dbElement.getAsStream(ref); } catch (LockException e) { LOG.error("could not acquire lock for index on " + qname); *************** *** 117,121 **** } catch (IOException e) { LOG.error("io error while reindexing " + qname, e); ! dis = null; } finally { lock.release(); --- 117,121 ---- } catch (IOException e) { LOG.error("io error while reindexing " + qname, e); ! is = null; } finally { lock.release(); *************** *** 123,130 **** os.clear(); oldList.clear(); ! if (dis != null) { // add old entries to the new list //data = val.getData(); - is.setInputStream(dis); try { while (is.available() > 0) { --- 123,129 ---- os.clear(); oldList.clear(); ! if (is != null) { // add old entries to the new list //data = val.getData(); try { while (is.available() > 0) { *************** *** 184,191 **** try { lock.acquire(Lock.WRITE_LOCK); ! if (dis == null) dbElement.put(ref, os.data()); else { ! address = ((BFile.PageInputStream) dis).getAddress(); dbElement.update(address, ref, os.data()); //dbElement.update(val.getAddress(), ref, data); --- 183,190 ---- try { lock.acquire(Lock.WRITE_LOCK); ! if (is == null) dbElement.put(ref, os.data()); else { ! address = ((BFile.PageInputStream) is).getAddress(); dbElement.update(address, ref, os.data()); //dbElement.update(val.getAddress(), ref, data); *************** *** 211,215 **** List newList = new ArrayList(), idList; NodeProxy p; ! VariableByteInputStream is; int len, docId; byte[] data; --- 210,214 ---- List newList = new ArrayList(), idList; NodeProxy p; ! VariableByteArrayInput is; int len, docId; byte[] data; *************** *** 250,254 **** // add old entries to the new list data = val.getData(); ! is = new VariableByteInputStream(data); try { while (is.available() > 0) { --- 249,253 ---- // add old entries to the new list data = val.getData(); ! is = new VariableByteArrayInput(data); try { while (is.available() > 0) { Index: DBBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/DBBroker.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** DBBroker.java 23 Apr 2004 13:07:44 -0000 1.24 --- DBBroker.java 3 May 2004 13:08:43 -0000 1.25 *************** *** 44,52 **** import org.exist.security.PermissionDeniedException; import org.exist.security.User; import org.exist.storage.serializers.Serializer; import org.exist.util.Configuration; import org.exist.util.Occurrences; - import org.exist.util.VariableByteInputStream; - import org.exist.util.VariableByteOutputStream; import org.exist.xquery.NodeSelector; import org.w3c.dom.Document; --- 44,53 ---- import org.exist.security.PermissionDeniedException; import org.exist.security.User; + import org.exist.storage.io.VariableByteInput; + import org.exist.storage.io.VariableByteOutputStream; + import org.exist.storage.io.VariableByteInputStream; import org.exist.storage.serializers.Serializer; import org.exist.util.Configuration; import org.exist.util.Occurrences; import org.exist.xquery.NodeSelector; import org.w3c.dom.Document; *************** *** 108,112 **** try { FileInputStream fis = new FileInputStream(symbols.getFile()); ! VariableByteInputStream is = new VariableByteInputStream(fis); symbols.read(is); fis.close(); --- 109,113 ---- try { FileInputStream fis = new FileInputStream(symbols.getFile()); ! VariableByteInput is = new VariableByteInputStream(fis); symbols.read(is); fis.close(); Index: NativeTextEngine.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeTextEngine.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** NativeTextEngine.java 23 Apr 2004 13:07:44 -0000 1.44 --- NativeTextEngine.java 3 May 2004 13:08:43 -0000 1.45 *************** *** 26,30 **** import java.io.File; import java.io.IOException; - import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.util.ArrayList; --- 26,29 ---- *************** *** 36,39 **** --- 35,39 ---- import java.util.TreeMap; import java.util.TreeSet; + import org.apache.oro.text.GlobCompiler; import org.apache.oro.text.regex.MalformedPatternException; *************** *** 65,68 **** --- 65,71 ---- import org.exist.security.User; import org.exist.storage.analysis.TextToken; + import org.exist.storage.io.VariableByteArrayInput; + import org.exist.storage.io.VariableByteInput; + import org.exist.storage.io.VariableByteOutputStream; import org.exist.storage.serializers.Serializer; import org.exist.storage.store.BFile; *************** *** 78,83 **** import org.exist.util.ReadOnlyException; import org.exist.util.UTF8; - import org.exist.util.VariableByteInputStream; - import org.exist.util.VariableByteOutputStream; import org.w3c.dom.Node; import org.w3c.dom.NodeList; --- 81,84 ---- *************** *** 304,309 **** Collection collection; short collectionId; ! VariableByteInputStream is; ! InputStream dis = null; NodeProxy parent, current = new NodeProxy(); NodeSet result; --- 305,309 ---- Collection collection; short collectionId; ! VariableByteInput is = null; NodeProxy parent, current = new NodeProxy(); NodeSet result; *************** *** 322,330 **** try { lock.acquire(); ! dis = dbWords.getAsStream(ref); ! if (dis == null) { continue; } - is = new VariableByteInputStream(dis); while (is.available() > 0) { docId = is.readInt(); --- 322,329 ---- try { lock.acquire(); ! is = dbWords.getAsStream(ref); ! if (is == null) { continue; } while (is.available() > 0) { docId = is.readInt(); *************** *** 508,512 **** TreeMap map = new TreeMap(); Occurrences oc; ! VariableByteInputStream is; int docId; int len; --- 507,511 ---- TreeMap map = new TreeMap(); Occurrences oc; ! VariableByteArrayInput is; int docId; int len; *************** *** 528,532 **** map.put(term, oc); } ! is = new VariableByteInputStream(val[1].getData()); try { while (is.available() > 0) { --- 527,531 ---- map.put(term, oc); } ! is = new VariableByteArrayInput(val[1].getData()); try { while (is.available() > 0) { *************** *** 589,593 **** */ public void removeDocument(DocumentImpl doc) { - LOG.debug("removing text index ..."); try { TreeSet words = new TreeSet(); --- 588,591 ---- *************** *** 603,608 **** Value val; WordRef ref; ! VariableByteInputStream is; ! InputStream dis; VariableByteOutputStream os; int len; --- 601,605 ---- Value val; WordRef ref; ! VariableByteInput is = null; VariableByteOutputStream os; int len; *************** *** 618,634 **** try { lock.acquire(Lock.READ_LOCK); ! dis = dbWords.getAsStream(ref); } catch (LockException e) { ! LOG.warn("could not acquire lock on words db", e); ! dis = null; } catch (IOException e) { ! LOG.error("io error while reading words", e); ! dis = null; } finally { lock.release(); } ! if (dis == null) continue; - is = new VariableByteInputStream(dis); os = new VariableByteOutputStream(); changed = false; --- 615,632 ---- try { lock.acquire(Lock.READ_LOCK); ! is = dbWords.getAsStream(ref); } catch (LockException e) { ! LOG.warn("removeDocument(DocumentImpl) - " ! + "could not acquire lock on words db", e); ! is = null; } catch (IOException e) { ! LOG.error("removeDocument(DocumentImpl) - " ! + "io error while reading words", e); ! is = null; } finally { lock.release(); } ! if (is == null) continue; os = new VariableByteOutputStream(); changed = false; *************** *** 660,667 **** } else { if (dbWords.put(ref, os.data()) < 0) ! LOG.debug("could not remove index for " + word); } } catch (LockException e) { ! LOG.warn("could not acquire lock on words db", e); } finally { lock.release(); --- 658,670 ---- } else { if (dbWords.put(ref, os.data()) < 0) ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument() - " ! + "could not remove index for " ! + word); ! } } } catch (LockException e) { ! LOG.warn("removeDocument(DocumentImpl) - " ! + "could not acquire lock on words db", e); } finally { lock.release(); *************** *** 669,675 **** } } ! LOG.debug(words.size() + " words updated."); } catch (ReadOnlyException e) { ! LOG.warn("database is read-only"); } } --- 672,683 ---- } } ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument() - " ! + words.size() ! + " words updated."); ! } } catch (ReadOnlyException e) { ! LOG.warn("removeDocument(DocumentImpl) - " ! + "database is read-only"); } } *************** *** 814,817 **** --- 822,826 ---- public void remove() { + // TODO: use VariableInputStream if (doc == null) return; *************** *** 830,834 **** LongLinkedList newList; Value val = null; ! VariableByteInputStream is; Lock lock = dbWords.getLock(); for (int k = 0; k < 2; k++) { --- 839,843 ---- LongLinkedList newList; Value val = null; ! VariableByteArrayInput is; Lock lock = dbWords.getLock(); for (int k = 0; k < 2; k++) { *************** *** 852,856 **** // add old entries to the new list data = val.getData(); ! is = new VariableByteInputStream(data); try { while (is.available() > 0) { --- 861,865 ---- // add old entries to the new list data = val.getData(); ! is = new VariableByteArrayInput(data); try { while (is.available() > 0) { *************** *** 937,942 **** NodeProxy p; WordRef ref; ! VariableByteInputStream is = new VariableByteInputStream(); ! InputStream dis = null; Lock lock = dbWords.getLock(); for (int k = 0; k < 2; k++) { --- 946,950 ---- NodeProxy p; WordRef ref; ! VariableByteInput is = null; Lock lock = dbWords.getLock(); for (int k = 0; k < 2; k++) { *************** *** 948,969 **** try { lock.acquire(Lock.READ_LOCK); ! dis = dbWords.getAsStream(ref); } catch (LockException e) { LOG.error("could not acquire lock on index for '" + word + "'"); ! dis = null; } catch (IOException e) { LOG.error("io error while reindexing word '" + word + "'"); ! dis = null; } finally { lock.release(); } os.clear(); ! if (dis != null) { // add old entries to the new list - is.setInputStream(dis); try { ! while (dis.available() > 0) { docId = is.readInt(); section = is.readByte(); --- 956,976 ---- try { lock.acquire(Lock.READ_LOCK); ! is = dbWords.getAsStream(ref); } catch (LockException e) { LOG.error("could not acquire lock on index for '" + word + "'"); ! is = null; } catch (IOException e) { LOG.error("io error while reindexing word '" + word + "'"); ! is = null; } finally { lock.release(); } os.clear(); ! if (is != null) { // add old entries to the new list try { ! while (is.available() > 0) { docId = is.readInt(); section = is.readByte(); *************** *** 1024,1031 **** lock.acquire(Lock.WRITE_LOCK); try { ! if (dis == null) dbWords.put(ref, os.data()); else { ! dbWords.update(((BFile.PageInputStream) dis) .getAddress(), ref, os.data()); } --- 1031,1038 ---- lock.acquire(Lock.WRITE_LOCK); try { ! if (is == null) dbWords.put(ref, os.data()); else { ! dbWords.update(((BFile.PageInputStream) is) .getAddress(), ref, os.data()); } *************** *** 1174,1184 **** } if (matcher.matches(word)) { ! InputStream dis = null; try { ! dis = dbWords.getAsStream(pointer); } catch (IOException ioe) { LOG.warn(ioe.getMessage(), ioe); } ! if (dis == null) return true; int k = 0; --- 1181,1191 ---- } if (matcher.matches(word)) { ! VariableByteInput is = null; try { ! is = dbWords.getAsStream(pointer); } catch (IOException ioe) { LOG.warn(ioe.getMessage(), ioe); } ! if (is == null) return true; int k = 0; *************** *** 1192,1196 **** DocumentImpl doc; NodeProxy parent, proxy; - VariableByteInputStream is = new VariableByteInputStream(dis); try { while (is.available() > 0) { --- 1199,1202 ---- *************** *** 1231,1238 **** LOG.warn("io error while reading index", e); } - try { - dis.close(); - } catch (IOException e1) { - } } if (context != null) --- 1237,1240 ---- |