Github user mikemccand commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/497#discussion_r232662145
--- Diff:
lucene/core/src/java/org/apache/lucene/index/ExitableDirectoryReader.java ---
@@ -100,13 +109,97 @@ public CacheHelper getCoreCacheHelper() {
}
+ /**
+ * Wrapper class for another PointValues implementation that is used by
ExitableFields.
+ */
+ public static class ExitablePointValues extends PointValues {
+
+ private final PointValues in;
+ private final QueryTimeout queryTimeout;
+
+ public ExitablePointValues(PointValues in, QueryTimeout queryTimeout) {
+ this.in = in;
+ this.queryTimeout = queryTimeout;
+ checkAndThrow();
+ }
+
+ /**
+ * Throws {@link ExitingReaderException} if {@link
QueryTimeout#shouldExit()} returns true,
+ * or if {@link Thread#interrupted()} returns true.
+ */
+ private void checkAndThrow() {
+ if (queryTimeout.shouldExit()) {
+ throw new ExitingReaderException("The request took too long to
iterate over terms. Timeout: "
+ + queryTimeout.toString()
+ + ", PointValues=" + in
+ );
+ } else if (Thread.interrupted()) {
+ throw new ExitingReaderException("Interrupted while iterating over
terms. PointValues=" + in);
+ }
+ }
+
+ @Override
+ public void intersect(IntersectVisitor visitor) throws IOException {
+ checkAndThrow();
+ in.intersect(visitor);
--- End diff --
A lot of time/effort can be spent in this (recursive) intersect call --
should we also wrap the `IntersectVisitor` and sometimes check for timeout?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]