jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1185735 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Date Tue, 18 Oct 2011 16:10:41 GMT
Author: alexparvulescu
Date: Tue Oct 18 16:10:41 2011
New Revision: 1185735

URL: http://svn.apache.org/viewvc?rev=1185735&view=rev
Log:
JCR-3119 Improve aggregate node indexing code

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=1185735&r1=1185734&r2=1185735&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Tue Oct 18 16:10:41 2011
@@ -1466,13 +1466,10 @@ public class SearchIndex extends Abstrac
                         }
                         // make sure that fulltext fields are aligned properly
                         // first all stored fields, then remaining
-                        List<Fieldable> fulltextFields = new ArrayList<Fieldable>();
-                        fulltextFields.addAll(removeFields(doc, FieldNames.FULLTEXT));
-                        Collections.sort(fulltextFields, new Comparator<Fieldable>()
{
-                            public int compare(Fieldable o1, Fieldable o2) {
-                                return Boolean.valueOf(o2.isStored()).compareTo(o1.isStored());
-                            }
-                        });
+                        Fieldable[] fulltextFields = doc
+                                .getFieldables(FieldNames.FULLTEXT);
+                        doc.removeFields(FieldNames.FULLTEXT);
+                        Arrays.sort(fulltextFields, FIELDS_COMPARATOR_STORED);
                         for (Fieldable f : fulltextFields) {
                             doc.add(f);
                         }
@@ -1537,21 +1534,11 @@ public class SearchIndex extends Abstrac
         }
     }
 
-    /**
-     * Removes the fields with the given <code>name</code> from the
-     * <code>document</code> and returns them in a collection.
-     *
-     * @param document the document.
-     * @param name     the name of the fields to remove.
-     * @return the removed fields.
-     */
-    protected final Collection<Fieldable> removeFields(Document document,
-                                                 String name) {
-        List<Fieldable> fields = new ArrayList<Fieldable>();
-        fields.addAll(Arrays.asList(document.getFieldables(name)));
-        document.removeFields(FieldNames.FULLTEXT);
-        return fields;
-    }
+    private static final Comparator<Fieldable> FIELDS_COMPARATOR_STORED = new Comparator<Fieldable>()
{
+        public int compare(Fieldable o1, Fieldable o2) {
+            return Boolean.valueOf(o2.isStored()).compareTo(o1.isStored());
+        }
+    };
 
     /**
      * Returns the relative path from <code>nodeState</code> to



Mime
View raw message