You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/02/12 23:32:03 UTC

[GitHub] [solr] dsmiley commented on a change in pull request #624: SOLR-16002: don't double-cache FilterQuery

dsmiley commented on a change in pull request #624:
URL: https://github.com/apache/solr/pull/624#discussion_r805215814



##########
File path: solr/core/src/test/org/apache/solr/search/TestFiltersQueryCaching.java
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.search;
+
+import java.util.Map;
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.metrics.MetricsMap;
+import org.apache.solr.metrics.SolrMetricManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.apache.solr.common.util.Utils.fromJSONString;
+
+/**
+ * Verify caching impacts of FiltersQParser and FilterQuery
+ */
+public class TestFiltersQueryCaching extends SolrTestCaseJ4 {
+
+  private static final int NUM_DOCS = 20;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    initCore("solrconfig.xml", "schema_latest.xml");
+    createIndex();
+  }
+
+  public static void createIndex() {
+    for (int i = 0; i < NUM_DOCS; i++) {
+      assertU(adoc("id", Integer.toString(i), "field_s", "d" + i));
+      if (random().nextInt(NUM_DOCS) == 0) {
+        assertU(commit());  // sometimes make multiple segments
+      }
+    }
+    assertU(commit());
+  }
+
+  private static final String MATCH_ALL_DOCS_QUERY = "*:*";

Review comment:
       Any Solr engineer knows what a match-all-docs query looks like :-)

##########
File path: solr/core/src/test/org/apache/solr/search/TestFiltersQueryCaching.java
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.search;
+
+import java.util.Map;
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.metrics.MetricsMap;
+import org.apache.solr.metrics.SolrMetricManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.apache.solr.common.util.Utils.fromJSONString;
+
+/**
+ * Verify caching impacts of FiltersQParser and FilterQuery
+ */
+public class TestFiltersQueryCaching extends SolrTestCaseJ4 {
+
+  private static final int NUM_DOCS = 20;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    initCore("solrconfig.xml", "schema_latest.xml");
+    createIndex();
+  }
+
+  public static void createIndex() {
+    for (int i = 0; i < NUM_DOCS; i++) {
+      assertU(adoc("id", Integer.toString(i), "field_s", "d" + i));
+      if (random().nextInt(NUM_DOCS) == 0) {
+        assertU(commit());  // sometimes make multiple segments
+      }
+    }
+    assertU(commit());
+  }
+
+  private static final String MATCH_ALL_DOCS_QUERY = "*:*";
+
+  private static Map<String, Object> coreToFilterCacheMetrics(SolrCore core) {
+    return ((MetricsMap)((SolrMetricManager.GaugeWrapper<?>)core.getCoreMetricManager().getRegistry()
+            .getMetrics().get("CACHE.searcher.filterCache")).getGauge()).getValue();
+  }
+
+  private static long coreToInserts(SolrCore core) {
+    return (long)((MetricsMap)((SolrMetricManager.GaugeWrapper<?>)core
+            .getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.filterCache")).getGauge())
+            .getValue().get("inserts");
+  }
+
+  private static long getNumFound(String response) {

Review comment:
       I don't think this method is needed.  Down below where you look at the response, you could use the `assertJQ` method and add suitable expressions.

##########
File path: solr/core/src/test/org/apache/solr/search/TestFiltersQueryCaching.java
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.search;
+
+import java.util.Map;
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.metrics.MetricsMap;
+import org.apache.solr.metrics.SolrMetricManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.apache.solr.common.util.Utils.fromJSONString;
+
+/**
+ * Verify caching impacts of FiltersQParser and FilterQuery
+ */
+public class TestFiltersQueryCaching extends SolrTestCaseJ4 {
+
+  private static final int NUM_DOCS = 20;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    initCore("solrconfig.xml", "schema_latest.xml");
+    createIndex();
+  }
+
+  public static void createIndex() {
+    for (int i = 0; i < NUM_DOCS; i++) {
+      assertU(adoc("id", Integer.toString(i), "field_s", "d" + i));
+      if (random().nextInt(NUM_DOCS) == 0) {
+        assertU(commit());  // sometimes make multiple segments
+      }
+    }
+    assertU(commit());
+  }
+
+  private static final String MATCH_ALL_DOCS_QUERY = "*:*";
+
+  private static Map<String, Object> coreToFilterCacheMetrics(SolrCore core) {
+    return ((MetricsMap)((SolrMetricManager.GaugeWrapper<?>)core.getCoreMetricManager().getRegistry()
+            .getMetrics().get("CACHE.searcher.filterCache")).getGauge()).getValue();
+  }
+
+  private static long coreToInserts(SolrCore core) {

Review comment:
       To me, this method is named strangely but I think I get it.  I'd just call it something like `lookupFilterCacheInserts`




-- 
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-unsubscribe@solr.apache.org

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



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