You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2021/06/23 20:31:40 UTC

[lucene-solr] branch branch_8x updated: Backport LUCENE-9902 Minor fixes to the faceting API (#62) (#2516)

This is an automated email from the ASF dual-hosted git repository.

mikemccand pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 2056d61  Backport LUCENE-9902 Minor fixes to the faceting API (#62) (#2516)
2056d61 is described below

commit 2056d61c6f4546cd1086f6314c27aac1747d43a5
Author: Gautam Worah <wo...@gmail.com>
AuthorDate: Wed Jun 23 13:31:16 2021 -0700

    Backport LUCENE-9902 Minor fixes to the faceting API (#62) (#2516)
    
    Co-authored-by: Gautam Worah <ga...@amazon.com>
---
 lucene/CHANGES.txt                                                   | 5 ++++-
 .../src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java | 3 ++-
 .../src/java/org/apache/lucene/facet/taxonomy/TaxonomyReader.java    | 4 ++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index e9c1057..47b41b7 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -7,7 +7,10 @@ http://s.apache.org/luceneversions
 
 API Changes
 ---------------------
-(No changes)
+
+* LUCENE-9902: Change the getValue method from IntTaxonomyFacets to be protected instead of private.
+  Users can now access the count of an ordinal directly without constructing an extra FacetLabel.
+  Also use variable length arguments for the getOrdinal call in TaxonomyReader. (Gautam Worah)
 
 New Features
 ---------------------
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java
index 71b628c..c7d69b3 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java
@@ -89,7 +89,8 @@ public abstract class IntTaxonomyFacets extends TaxonomyFacets {
     }
   }
 
-  private int getValue(int ordinal) {
+  /** Get the count for this ordinal. */
+  protected int getValue(int ordinal) {
     if (sparseValues != null) {
       return sparseValues.get(ordinal);
     } else {
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyReader.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyReader.java
index f631d3b..687e0ea 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyReader.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyReader.java
@@ -221,8 +221,8 @@ public abstract class TaxonomyReader implements Closeable {
   public abstract int getOrdinal(FacetLabel categoryPath) throws IOException;
 
   /** Returns ordinal for the dim + path. */
-  public int getOrdinal(String dim, String[] path) throws IOException {
-    String[] fullPath = new String[path.length+1];
+  public int getOrdinal(String dim, String... path) throws IOException {
+    String[] fullPath = new String[path.length + 1];
     fullPath[0] = dim;
     System.arraycopy(path, 0, fullPath, 1, path.length);
     return getOrdinal(new FacetLabel(fullPath));