lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1421872 - in /lucene/dev/trunk/lucene: CHANGES.txt highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
Date Fri, 14 Dec 2012 14:08:09 GMT
Author: mvg
Date: Fri Dec 14 14:08:07 2012
New Revision: 1421872

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

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

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1421872&r1=1421871&r2=1421872&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Fri Dec 14 14:08:07 2012
@@ -288,6 +288,9 @@ Bug Fixes
   indexed and the Iterator throws an exception. Documents were only rolled back
   if the actual indexing process failed. (Simon Willnauer)
 
+* LUCENE-4608: Handle large number of requested fragments better.
+  (Martijn van Groningen)
+
 Changes in Runtime Behavior
   
 * LUCENE-4586: Change default ResultMode of FacetRequest to PER_NODE_IN_TREE.

Modified: lucene/dev/trunk/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java?rev=1421872&r1=1421871&r2=1421872&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
(original)
+++ lucene/dev/trunk/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/BaseFragmentsBuilder.java
Fri Dec 14 14:08:07 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