madrob commented on a change in pull request #230:
URL: https://github.com/apache/solr/pull/230#discussion_r674457589



##########
File path: solr/core/src/java/org/apache/solr/search/SolrCache.java
##########
@@ -106,8 +107,23 @@
    * @return existing or newly computed value, null if there was no existing 
value and
    * it was not possible to compute a new value (in which case the new mapping 
won't be created).
    */
+  // Can we deprecate/remove this in favor of the other signature?
   public V computeIfAbsent(K key, Function<? super K, ? extends V> 
mappingFunction);
 
+  default V computeIfAbsent(K key, IOFunction<? super K, ? extends V> 
mappingFunction) throws IOException {
+    try {
+      return computeIfAbsent(key, (Function<? super K, ? extends V>) k -> {
+        try {
+          return mappingFunction.apply(k);
+        } catch (IOException e) {
+          throw new WrappingException(e);

Review comment:
       Can also pass this along via an AtomicReference or possible via Lucene's 
Rethrows class if people would prefer to see that.

##########
File path: solr/core/src/test/org/apache/solr/search/TestRangeQuery.java
##########
@@ -357,7 +371,42 @@ public void process(SolrInputDocument doc) {
       }
     }
   }
-  
+
+  @Test
+  public void testRangeQueryWithFilterCache() throws Exception {
+    TestInjection.delayBeforeCreatingNewDocSet = 500;
+
+    // sometimes a very small index, sometimes a very large index
+    // final int numDocs = random().nextBoolean() ? random().nextInt(50) : 
atLeast(1000);
+    final int numDocs = 99;
+    createIndex(numDocs, doc -> {
+      addInt(doc, 0, 0, "foo_i");
+    });
+
+    ExecutorService queryService = ExecutorUtil.newMDCAwareFixedThreadPool(4, 
new SolrNamedThreadFactory("TestRangeQuery"));
+    try (SolrCore core = h.getCoreInc()) {
+      SolrRequestHandler defaultHandler = core.getRequestHandler("");
+
+      ModifiableSolrParams params = new ModifiableSolrParams();
+      params.set("q", "*:*");
+      params.add("fq", "id:[0 TO 222]"); // These should all come from 
FilterCache
+
+      // 10 threads with 4 executors would be enough for 3 waves, or 
approximately 1500ms of delay
+      for (int i = 0; i < 10; i++) {
+        queryService.submit(() -> {
+          try (SolrQueryRequest req = req(params)) {
+            core.execute(defaultHandler, req, new SolrQueryResponse());
+          }
+        });
+      }
+

Review comment:
       TODO: assert that createDocSet was only called once here instead of 4 
times.




-- 
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: issues-unsubscr...@solr.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to