jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r694208 - in /jackrabbit/branches/1.4/jackrabbit-core: ./ src/main/java/org/apache/jackrabbit/core/query/lucene/
Date Thu, 11 Sep 2008 10:30:44 GMT
Author: mreutegg
Date: Thu Sep 11 03:30:41 2008
New Revision: 694208

URL: http://svn.apache.org/viewvc?rev=694208&view=rev
Log:
JCR-1730: Background text extraction not possible when supportHighlighting is set true

Added:
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyTextExtractorField.java
      - copied, changed from r694164, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyTextExtractorField.java
Modified:
    jackrabbit/branches/1.4/jackrabbit-core/   (props changed)
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractIndex.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
    jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java

Propchange: jackrabbit/branches/1.4/jackrabbit-core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 11 03:30:41 2008
@@ -1 +1 @@
-/jackrabbit/trunk/jackrabbit-core:653417,654078,654514,655917,656240,656655,656664,658583,679389,680135
+/jackrabbit/trunk/jackrabbit-core:653417,654078,654514,655917,656240,656655,656664,658583,679389,680135,694164

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java?rev=694208&r1=694207&r2=694208&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
Thu Sep 11 03:30:41 2008
@@ -26,7 +26,7 @@
 import org.apache.lucene.index.TermPositionVector;
 import org.apache.lucene.index.TermVectorOffsetInfo;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.Token;
 import org.apache.jackrabbit.core.NodeId;
@@ -98,7 +98,7 @@
             } finally {
                 tDocs.close();
             }
-            Field[] fields = doc.getFields(FieldNames.FULLTEXT);
+            Fieldable[] fields = doc.getFieldables(FieldNames.FULLTEXT);
             if (fields == null) {
                 log.debug("Fulltext field not stored, using {}",
                         SimpleExcerptProvider.class.getName());

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractIndex.java?rev=694208&r1=694207&r2=694208&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractIndex.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractIndex.java
Thu Sep 11 03:30:41 2008
@@ -23,6 +23,7 @@
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -410,12 +411,12 @@
         if (!Util.isDocumentReady(doc)) {
             Document copy = new Document();
             for (Iterator fields = doc.getFields().iterator(); fields.hasNext(); ) {
-                Field f = (Field) fields.next();
-                Field field = null;
+                Fieldable f = (Fieldable) fields.next();
+                Fieldable field = null;
                 Field.TermVector tv = getTermVectorParameter(f);
                 Field.Store stored = getStoreParameter(f);
                 Field.Index indexed = getIndexParameter(f);
-                if (f.readerValue() != null) {
+                if (f instanceof LazyTextExtractorField || f.readerValue() != null) {
                     // replace all readers with empty string reader
                     field = new Field(f.name(), new StringReader(""), tv);
                 } else if (f.stringValue() != null) {
@@ -503,7 +504,7 @@
      * @param f a lucene field.
      * @return the index parameter on <code>f</code>.
      */
-    private Field.Index getIndexParameter(Field f) {
+    private Field.Index getIndexParameter(Fieldable f) {
         if (!f.isIndexed()) {
             return Field.Index.NO;
         } else if (f.isTokenized()) {
@@ -519,7 +520,7 @@
      * @param f a lucene field.
      * @return the store parameter on <code>f</code>.
      */
-    private Field.Store getStoreParameter(Field f) {
+    private Field.Store getStoreParameter(Fieldable f) {
         if (f.isCompressed()) {
             return Field.Store.COMPRESS;
         } else if (f.isStored()) {
@@ -535,7 +536,7 @@
      * @param f a lucene field.
      * @return the term vector parameter on <code>f</code>.
      */
-    private Field.TermVector getTermVectorParameter(Field f) {
+    private Field.TermVector getTermVectorParameter(Fieldable f) {
         if (f.isStorePositionWithTermVector() && f.isStoreOffsetWithTermVector())
{
             return Field.TermVector.WITH_POSITIONS_OFFSETS;
         } else if (f.isStorePositionWithTermVector()) {

Copied: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyTextExtractorField.java
(from r694164, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyTextExtractorField.java)
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyTextExtractorField.java?p2=jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyTextExtractorField.java&p1=jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyTextExtractorField.java&r1=694164&r2=694208&rev=694208&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyTextExtractorField.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LazyTextExtractorField.java
Thu Sep 11 03:30:41 2008
@@ -19,7 +19,6 @@
 import org.apache.lucene.document.AbstractField;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.analysis.TokenStream;
-import org.apache.commons.io.IOUtils;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -95,7 +94,11 @@
                         + e.getMessage());
                 log.debug("Dump:", e);
             } finally {
-                IOUtils.closeQuietly(reader);
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                    // ignore
+                }
             }
             extract = textExtract.toString();
         }

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java?rev=694208&r1=694207&r2=694208&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
Thu Sep 11 03:30:41 2008
@@ -35,6 +35,7 @@
 import org.slf4j.LoggerFactory;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.PropertyType;
@@ -42,7 +43,6 @@
 
 import java.io.InputStream;
 import java.io.Reader;
-import java.io.IOException;
 import java.util.Calendar;
 import java.util.Iterator;
 import java.util.Set;
@@ -661,30 +661,11 @@
      * @param value the reader value.
      * @return a lucene field.
      */
-    protected Field createFulltextField(Reader value) {
+    protected Fieldable createFulltextField(Reader value) {
         if (supportHighlighting) {
-            // need to create a string value
-            StringBuffer textExtract = new StringBuffer();
-            char[] buffer = new char[1024];
-            int len;
-            try {
-                while ((len = value.read(buffer)) > -1) {
-                    textExtract.append(buffer, 0, len);
-                }
-            } catch (IOException e) {
-                log.warn("Exception reading value for fulltext field: " +
-                        e.getMessage());
-                log.debug("Dump:", e);
-            } finally {
-                try {
-                    value.close();
-                } catch (IOException e) {
-                    // ignore
-                }
-            }
-            return createFulltextField(textExtract.toString());
+            return new LazyTextExtractorField(FieldNames.FULLTEXT, value, true, true);
         } else {
-            return new Field(FieldNames.FULLTEXT, value);
+            return new LazyTextExtractorField(FieldNames.FULLTEXT, value, false, false);
         }
     }
 

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=694208&r1=694207&r2=694208&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Thu Sep 11 03:30:41 2008
@@ -57,6 +57,7 @@
 import org.apache.lucene.search.SortField;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
 import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
 import org.xml.sax.SAXException;
 import org.w3c.dom.Element;
@@ -1088,7 +1089,7 @@
                                 getNamespaceMappings(),
                                 index.getIndexFormatVersion());
                         // transfer fields to doc if there are any
-                        Field[] fulltextFields = aDoc.getFields(FieldNames.FULLTEXT);
+                        Fieldable[] fulltextFields = aDoc.getFieldables(FieldNames.FULLTEXT);
                         if (fulltextFields != null) {
                             for (int k = 0; k < fulltextFields.length; k++) {
                                 doc.add(fulltextFields[k]);

Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java?rev=694208&r1=694207&r2=694208&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Util.java
Thu Sep 11 03:30:41 2008
@@ -17,11 +17,11 @@
 package org.apache.jackrabbit.core.query.lucene;
 
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
-import java.util.Enumeration;
+import java.util.Iterator;
 import java.io.IOException;
 
 /**
@@ -41,14 +41,17 @@
      * @param old the document to dispose.
      */
     public static void disposeDocument(Document old) {
-        for (Enumeration e = old.fields(); e.hasMoreElements();) {
-            Field f = (Field) e.nextElement();
-            if (f.readerValue() != null) {
-                try {
+        for (Iterator it = old.getFields().iterator(); it.hasNext(); ) {
+            Fieldable f = (Fieldable) it.next();
+            try {
+                if (f.readerValue() != null) {
                     f.readerValue().close();
-                } catch (IOException ex) {
-                    log.warn("Exception while disposing index document: " + ex);
+                } else if (f instanceof LazyTextExtractorField) {
+                    LazyTextExtractorField field = (LazyTextExtractorField) f;
+                    field.dispose();
                 }
+            } catch (IOException ex) {
+                log.warn("Exception while disposing index document: " + ex);
             }
         }
     }
@@ -62,11 +65,11 @@
      *         otherwise.
      */
     public static boolean isDocumentReady(Document doc) {
-        for (Enumeration fields = doc.fields(); fields.hasMoreElements(); ) {
-            Field f = (Field) fields.nextElement();
-            if (f.readerValue() instanceof TextExtractorReader) {
-                TextExtractorReader r = (TextExtractorReader) f.readerValue();
-                if (!r.isExtractorFinished()) {
+        for (Iterator it = doc.getFields().iterator(); it.hasNext(); ) {
+            Fieldable f = (Fieldable) it.next();
+            if (f instanceof LazyTextExtractorField) {
+                LazyTextExtractorField field = (LazyTextExtractorField) f;
+                if (!field.isExtractorFinished()) {
                     return false;
                 }
             }



Mime
View raw message