SOLR-7876: exit ExitableDirectoryReader wrapper if timeout is not enabled

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1700276 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2015-08-31 16:43:57 +00:00
parent c2484192de
commit 330907bf11
5 changed files with 26 additions and 1 deletions

View File

@ -27,6 +27,10 @@ New Features
length computations, to avoid skew from documents that don't have the field. length computations, to avoid skew from documents that don't have the field.
(Ahmet Arslan via Robert Muir) (Ahmet Arslan via Robert Muir)
* SOLR-7876: The QueryTimeout interface now has a isTimeoutEnabled method
that can return false to exit from ExitableDirectoryReader wrapping at
the point fields() is called. (yonik)
API Changes API Changes
* LUCENE-3312: The API of oal.document was restructured to * LUCENE-3312: The API of oal.document was restructured to

View File

@ -80,7 +80,13 @@ public class ExitableDirectoryReader extends FilterDirectoryReader {
@Override @Override
public Fields fields() throws IOException { public Fields fields() throws IOException {
return new ExitableFields(super.fields(), queryTimeout); Fields fields = super.fields();
if (queryTimeout.isTimeoutEnabled()) {
return new ExitableFields(fields, queryTimeout);
}
else {
return fields; // break out of wrapper as soon as possible
}
} }
@Override @Override

View File

@ -29,5 +29,10 @@ public interface QueryTimeout {
*/ */
public abstract boolean shouldExit(); public abstract boolean shouldExit();
/** Returns true if timeouts are enabled for this query (i.e. if shouldExit would ever return true) */
public default boolean isTimeoutEnabled() {
return true;
}
} }

View File

@ -65,6 +65,11 @@ New Features
* SOLR-7707: Add StreamExpression Support to RollupStream (Dennis Gove, Joel Bernstein) * SOLR-7707: Add StreamExpression Support to RollupStream (Dennis Gove, Joel Bernstein)
Optimizations
----------------------
* SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been
specified. Speedups of up to 8% were observed. (yonik)
Other Changes Other Changes
---------------------- ----------------------

View File

@ -49,6 +49,11 @@ public class SolrQueryTimeoutImpl implements QueryTimeout {
return timeoutAt.get(); return timeoutAt.get();
} }
@Override
public boolean isTimeoutEnabled() {
return get() != null;
}
/** /**
* Return true if a timeoutAt value is set and the current time has exceeded the set timeOut. * Return true if a timeoutAt value is set and the current time has exceeded the set timeOut.
*/ */