You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/02/22 12:35:28 UTC

[GitHub] [lucene-solr] donnerpeter commented on a change in pull request #2414: LUCENE-9800: Hunspell: put a time limit on suggestion calculation

donnerpeter commented on a change in pull request #2414:
URL: https://github.com/apache/lucene-solr/pull/2414#discussion_r580215786



##########
File path: lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.java
##########
@@ -540,7 +566,36 @@ boolean acceptsStem(int formID) {
     if (word.contains("-") && suggestions.stream().noneMatch(s -> s.contains("-"))) {
       suggestions.addAll(modifyChunksBetweenDashes(word));
     }
+  }
+
+  private Runnable checkTimeLimit(String word, WordCase wordCase, Set<String> suggestions) {
+    return new Runnable() {
+      final long limit = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(SUGGEST_TIME_LIMIT);
+      int invocationCounter = 100;
+
+      @Override
+      public void run() {
+        checkCanceled.run();
+        if (--invocationCounter <= 0) {
+          if (System.nanoTime() > limit) {

Review comment:
       We get system time only on each 100th call, like Hunspell does




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org