lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1421890 - in /lucene/dev/branches/branch_4x/lucene: CHANGES.txt highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
Date Fri, 14 Dec 2012 14:27:40 GMT
Author: mvg
Date: Fri Dec 14 14:27:37 2012
New Revision: 1421890

URL: http://svn.apache.org/viewvc?rev=1421890&view=rev
Log:
LUCENE-4608: Handle large number of requested fragments better.

Modified:
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt
    lucene/dev/branches/branch_4x/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1421890&r1=1421889&r2=1421890&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Fri Dec 14 14:27:37 2012
@@ -80,6 +80,9 @@ Changes in backwards compatibility polic
   a setting, you should extend the relevant class.
   Additionally, FacetSearchParams is now immutable, and requires all FacetRequests
   to speified at initialization time. (Shai Erera)
+
+* LUCENE-4608: Handle large number of requested fragments better.
+  (Martijn van Groningen)
   
 New Features
 

Modified: lucene/dev/branches/branch_4x/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java?rev=1421890&r1=1421889&r2=1421890&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
Fri Dec 14 14:27:37 2012
@@ -124,7 +124,6 @@ public abstract class BaseFragmentsBuild
     }
 
     List<WeightedFragInfo> fragInfos = fieldFragList.getFragInfos();
-    List<String> fragments = new ArrayList<String>( maxNumFragments );
     Field[] values = getFields( reader, docId, fieldName );
     if( values.length == 0 ) {
       return null;
@@ -135,9 +134,12 @@ public abstract class BaseFragmentsBuild
     }
 
     fragInfos = getWeightedFragInfoList(fragInfos);
+    int limitFragments = maxNumFragments < fragInfos.size() ? maxNumFragments : fragInfos.size();
+    List<String> fragments = new ArrayList<String>( limitFragments );
+
     StringBuilder buffer = new StringBuilder();
     int[] nextValueIndex = { 0 };
-    for( int n = 0; n < maxNumFragments && n < fragInfos.size(); n++ ){
+    for( int n = 0; n < limitFragments; n++ ){
       WeightedFragInfo fragInfo = fragInfos.get( n );
       fragments.add( makeFragment( buffer, nextValueIndex, values, fragInfo, preTags, postTags,
encoder ) );
     }



Mime
View raw message