krickert commented on code in PR #1003:
URL: https://github.com/apache/opennlp/pull/1003#discussion_r3058651052


##########
opennlp-core/opennlp-ml/opennlp-ml-commons/src/main/java/opennlp/tools/ml/BeamSearch.java:
##########
@@ -63,92 +84,82 @@ public BeamSearch(int size, MaxentModel model) {
   }
 
   /**
-   * Initializes a {@link BeamSearch} instance.
+   * Initializes a {@link BeamSearch} instance with an optional per-thread 
contexts cache.
    *
    * @param size The size of the beam (k).
    * @param model The {@link MaxentModel} for assigning probabilities to the 
sequence outcomes.
-   * @param cacheSize The capacity of the {@link Cache} to use.
+   * @param cacheSize The capacity of the per-thread contexts cache. Use 
{@code 0} to disable caching.

Review Comment:
   Thanks for the catch. The wording was unclear.
   
   `cacheSize == 0` turns off the optional contexts cache (`CacheState` builds 
no `Cache` in that case). We still keep per-thread state because 
`model.eval(..., probs)` needs a per-thread outcome buffer for safe concurrent 
use, so ThreadLocal is not removed when the cache is disabled.
   
   I updated the `@param cacheSize` text on the 3-arg constructor to say that. 
Pushed in the latest commit.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to