Apache Lucene open-source search software
LUCENE-9902 Minor fixes to the faceting API (#62)
Gautam Worahefeea0b8ee72
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 1ab52831a40..638194b2bd8 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -290,7 +290,10 @@ OtherAPI 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.javaindex 434becb6518..7d4e5d6149c 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@@ -88,7 +88,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.javaindex b498466f8ea..4a64a696e03 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@@ -202,7 +202,7 @@ 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 {+ 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);