Permalink
Browse files

MINDEXER-69 reuse rewritten query for all artifacts

Invoking Query#rewrite(IndexReader) for each
ArtifactInfo/MatchHighlightRequest is redundant and results in
significant unnecessary cpu and/or io utilization.

Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Signed-off-by: Tamás Cservenák <cstamas@apache.org>

git-svn-id: https://svn.apache.org/repos/asf/maven/indexer/trunk@1411588 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent a65af8e commit 44f045b124b004dd0235272e064f48697b63e0ff @cstamas cstamas committed Nov 20, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 indexer-core/src/main/java/org/apache/maven/index/DefaultIteratorResultSet.java
@@ -110,6 +110,13 @@ protected DefaultIteratorResultSet( final IteratorSearchRequest request,
this.matchHighlightRequests = request.getMatchHighlightRequests();
+ List<MatchHighlightRequest> matchHighlightRequests = new ArrayList<MatchHighlightRequest>();
+ for ( MatchHighlightRequest hr : request.getMatchHighlightRequests() )
+ {
+ Query rewrittenQuery = hr.getQuery().rewrite( indexSearcher.getIndexReader() );
+ matchHighlightRequests.add( new MatchHighlightRequest( hr.getField(), rewrittenQuery, hr.getHighlightMode() ) );
+ }
+
this.hits = hits;
this.from = request.getStart();
@@ -358,8 +365,6 @@ protected IndexerField selectStoredIndexerField( Field field )
text = text.replace( '/', '.' ).replaceAll( "^\\.", "" ).replaceAll( "\n\\.", "\n" );
}
- Query rewrittenQuery = hr.getQuery().rewrite( indexSearcher.getIndexReader() );
-
CachingTokenFilter tokenStream =
new CachingTokenFilter( context.getAnalyzer().tokenStream( field.getKey(), new StringReader( text ) ) );
@@ -376,7 +381,7 @@ protected IndexerField selectStoredIndexerField( Field field )
+ "\" is not supported!" );
}
- return getBestFragments( rewrittenQuery, formatter, tokenStream, text, 3 );
+ return getBestFragments( hr.getQuery(), formatter, tokenStream, text, 3 );
}
protected final List<String> getBestFragments( Query query, Formatter formatter, TokenStream tokenStream,

0 comments on commit 44f045b

Please sign in to comment.