jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r219683 - in /incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene: CachingIndexReader.java ConsistencyCheck.java MultiIndex.java
Date Tue, 19 Jul 2005 13:41:58 GMT
Author: mreutegg
Date: Tue Jul 19 06:41:57 2005
New Revision: 219683

URL: http://svn.apache.org/viewcvs?rev=219683&view=rev
Log:
JCR-160: Query index not in sync with workspace
- Log warning if index detects duplicate entries for a node
- Not all multiple entries in index are removed on repair

Modified:
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java?rev=219683&r1=219682&r2=219683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java
Tue Jul 19 06:41:57 2005
@@ -186,7 +186,9 @@
                 if (!in.isDeleted(i)) {
                     Document d = in.document(i);
                     Integer docId = new Integer(i);
-                    ids.put(d.get(FieldNames.UUID), docId);
+                    if (ids.put(d.get(FieldNames.UUID), docId) != null) {
+                        log.warn("Duplicate index entry for node: " + d.get(FieldNames.UUID));
+                    }
                     documents.put(docId, d);
                     String parentUUID = d.get(FieldNames.PARENT);
                     List docIds = (List) parents.get(parentUUID);

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java?rev=219683&r1=219682&r2=219683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java
Tue Jul 19 06:41:57 2005
@@ -98,8 +98,8 @@
 
     /**
      * Repairs detected errors during the consistency check.
-     * @param ignoreFailure if <code>true</code> repair failures are ignored
-     *   the the repair continues without throwing an exception. If
+     * @param ignoreFailure if <code>true</code> repair failures are ignored,
+     *   the repair continues without throwing an exception. If
      *   <code>false</code> the repair procedure is aborted on the first
      *   repair failure.
      * @throws IOException if a repair failure occurs.
@@ -320,9 +320,7 @@
         public void repair() throws IOException {
             // first remove all occurrences
             Term id = new Term(FieldNames.UUID, uuid);
-            while (index.removeDocument(id) > 0) {
-                // removed
-            }
+            index.removeAllDocuments(id);
             // then re-index the node
             try {
                 NodeState node = (NodeState) stateMgr.getItemState(new NodeId(uuid));

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=219683&r1=219682&r2=219683&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
Tue Jul 19 06:41:57 2005
@@ -232,11 +232,11 @@
     }
 
     /**
-     * Deletes documents that match the <code>idTerm</code>.
+     * Deletes the first document that matches the <code>idTerm</code>.
      *
-     * @param idTerm documents that match this term will be deleted.
+     * @param idTerm document that match this term will be deleted.
      * @return the number of deleted documents.
-     * @throws IOException if an error occurs while deleting documents.
+     * @throws IOException if an error occurs while deleting the document.
      */
     synchronized int removeDocument(Term idTerm) throws IOException {
         // flush multi reader if it does not have deletions yet
@@ -258,6 +258,28 @@
             return num;
         }
         return 0;
+    }
+
+    /**
+     * Deletes all documents that match the <code>idTerm</code> and immediately
+     * commits the changes to the persistent indexes.
+     *
+     * @param idTerm documents that match this term will be deleted.
+     * @return the number of deleted documents.
+     * @throws IOException if an error occurs while deleting documents.
+     */
+    synchronized int removeAllDocuments(Term idTerm) throws IOException {
+        // flush multi reader if it does not have deletions yet
+        if (multiReader != null && !multiReader.hasDeletions()) {
+            multiReader = null;
+        }
+        int num = volatileIndex.removeDocument(idTerm);
+        for (int i = 0; i < indexes.size(); i++) {
+            PersistentIndex index = (PersistentIndex) indexes.get(i);
+            num += index.removeDocument(idTerm);
+            index.commit();
+        }
+        return num;
     }
 
     /**



Mime
View raw message