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/05/18 13:57:35 UTC

[GitHub] [lucene] gsmiller opened a new pull request #143: LUCENE-9962: Allow DrillSideways sub-classes to provide their own "drill down" facet counting implementation (or null).

gsmiller opened a new pull request #143:
URL: https://github.com/apache/lucene/pull/143


   # Description
   
   This change allows users to sub-class `DrillSideways` and override the logic for creating a "drill down" `FacetsCollector`/`FacetsCollectorManager`. This is useful if the user doesn't want to collect for drill downs (e.g., they can provide `null`), or if they're already collecting for drill downs in a custom `Collector`/`CollectorManager` that's already being provided to `search`. In the latter case, they may want to override these methods to return `null` so they don't wastefully collect for drill downs twice (once in their customer collector and again internally to `DrillSideways`).
   
   # Solution
   
   `DrillSidewaysQuery`/`DrillSidewaysScorer` already support a `null` drill down `FacetsCollector` so this is as simple as modifying `DrillSideways` itself. I added `protected` methods for creation of the drill down collectors, allowing sub-classes to override.
   
   # Tests
   
   Added new tests to test a sub-classed `DrillSideways` that provides `null` collectors.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/lucene/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request title.
   - [x] I have given Lucene maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [x] I have developed this patch against the `main` branch.
   - [x] I have run `./gradlew check`.
   - [x] I have added tests for my changes.
   


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


[GitHub] [lucene] mikemccand commented on a change in pull request #143: LUCENE-9962: Allow DrillSideways sub-classes to provide their own "drill down" facet counting implementation (or null).

Posted by GitBox <gi...@apache.org>.
mikemccand commented on a change in pull request #143:
URL: https://github.com/apache/lucene/pull/143#discussion_r634653074



##########
File path: lucene/facet/src/java/org/apache/lucene/facet/DrillSideways.java
##########
@@ -124,16 +124,34 @@ public DrillSideways(
     this.executor = executor;
   }
 
+  /**
+   * Subclass can override to customize drill down facets collector. Returning {@code null} is valid
+   * if no drill down facet collection is needed.
+   */
+  protected FacetsCollector createDrillDownFacetsCollector() {
+    return new FacetsCollector();
+  }
+
+  /**
+   * Subclass can override to customize drill down facets collector. Returning {@code null} is valid
+   * if no drill down facet collection is needed.
+   */
+  protected FacetsCollectorManager createDrillDownFacetsCollectorManager() {
+    return new FacetsCollectorManager();
+  }
+
   /** Subclass can override to customize per-dim Facets impl. */
   protected Facets buildFacetsResult(
       FacetsCollector drillDowns, FacetsCollector[] drillSideways, String[] drillSidewaysDims)
       throws IOException {
 
-    Facets drillDownFacets;
+    Facets drillDownFacets = null;

Review comment:
       Aha!  OK, tricky :) But makes sense, thanks.




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


[GitHub] [lucene] gsmiller commented on pull request #143: LUCENE-9962: Allow DrillSideways sub-classes to provide their own "drill down" facet counting implementation (or null).

Posted by GitBox <gi...@apache.org>.
gsmiller commented on pull request #143:
URL: https://github.com/apache/lucene/pull/143#issuecomment-844179797


   @mikemccand as for the gradle check, I think something was busted temporarily. I noticed a number of failing workflows during that time. It's now passed for this.


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


[GitHub] [lucene] gsmiller commented on a change in pull request #143: LUCENE-9962: Allow DrillSideways sub-classes to provide their own "drill down" facet counting implementation (or null).

Posted by GitBox <gi...@apache.org>.
gsmiller commented on a change in pull request #143:
URL: https://github.com/apache/lucene/pull/143#discussion_r634644879



##########
File path: lucene/facet/src/java/org/apache/lucene/facet/DrillSideways.java
##########
@@ -124,16 +124,34 @@ public DrillSideways(
     this.executor = executor;
   }
 
+  /**
+   * Subclass can override to customize drill down facets collector. Returning {@code null} is valid
+   * if no drill down facet collection is needed.
+   */
+  protected FacetsCollector createDrillDownFacetsCollector() {
+    return new FacetsCollector();
+  }
+
+  /**
+   * Subclass can override to customize drill down facets collector. Returning {@code null} is valid
+   * if no drill down facet collection is needed.
+   */
+  protected FacetsCollectorManager createDrillDownFacetsCollectorManager() {
+    return new FacetsCollectorManager();
+  }
+
   /** Subclass can override to customize per-dim Facets impl. */
   protected Facets buildFacetsResult(
       FacetsCollector drillDowns, FacetsCollector[] drillSideways, String[] drillSidewaysDims)
       throws IOException {
 
-    Facets drillDownFacets;
+    Facets drillDownFacets = null;

Review comment:
       It's actually possible for this to not get initialized (if omitting the line). With my change, it would only get initialized if `drillDowns` is non-null (because of the new conditional checks I added on lines 152/163). The problem arises down on line 175 in cases where `dillDowns` is null. Hope that makes sense.




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


[GitHub] [lucene] mikemccand commented on pull request #143: LUCENE-9962: Allow DrillSideways sub-classes to provide their own "drill down" facet counting implementation (or null).

Posted by GitBox <gi...@apache.org>.
mikemccand commented on pull request #143:
URL: https://github.com/apache/lucene/pull/143#issuecomment-843414032


   Why is `Gradle precommit` check failing after 0 seconds here?  I tried to poke through and find a log or something but failed.


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


[GitHub] [lucene] gsmiller merged pull request #143: LUCENE-9962: Allow DrillSideways sub-classes to provide their own "drill down" facet counting implementation (or null).

Posted by GitBox <gi...@apache.org>.
gsmiller merged pull request #143:
URL: https://github.com/apache/lucene/pull/143


   


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


[GitHub] [lucene] mikemccand commented on a change in pull request #143: LUCENE-9962: Allow DrillSideways sub-classes to provide their own "drill down" facet counting implementation (or null).

Posted by GitBox <gi...@apache.org>.
mikemccand commented on a change in pull request #143:
URL: https://github.com/apache/lucene/pull/143#discussion_r634636938



##########
File path: lucene/facet/src/java/org/apache/lucene/facet/DrillSideways.java
##########
@@ -124,16 +124,34 @@ public DrillSideways(
     this.executor = executor;
   }
 
+  /**
+   * Subclass can override to customize drill down facets collector. Returning {@code null} is valid
+   * if no drill down facet collection is needed.
+   */
+  protected FacetsCollector createDrillDownFacetsCollector() {
+    return new FacetsCollector();
+  }
+
+  /**
+   * Subclass can override to customize drill down facets collector. Returning {@code null} is valid
+   * if no drill down facet collection is needed.
+   */
+  protected FacetsCollectorManager createDrillDownFacetsCollectorManager() {
+    return new FacetsCollectorManager();
+  }
+
   /** Subclass can override to customize per-dim Facets impl. */
   protected Facets buildFacetsResult(
       FacetsCollector drillDowns, FacetsCollector[] drillSideways, String[] drillSidewaysDims)
       throws IOException {
 
-    Facets drillDownFacets;
+    Facets drillDownFacets = null;

Review comment:
       Hmm, I wonder why you needed to do this?  I would think `javac` would realize this local variable is fully initialized regardless of which way the conditionals go below, both before and after this change.




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