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 2020/07/22 14:02:59 UTC

[lucene-solr] branch master updated: LUCENE-9437: make DocValuesOrdinalsReader.decode public

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 03a03b3  LUCENE-9437: make DocValuesOrdinalsReader.decode public
03a03b3 is described below

commit 03a03b34a468f8095c7f0b87ceeaf4ba0d4aeaec
Author: Mike McCandless <mi...@apache.org>
AuthorDate: Wed Jul 22 09:57:04 2020 -0400

    LUCENE-9437: make DocValuesOrdinalsReader.decode public
---
 lucene/CHANGES.txt                                        |  4 ++++
 .../lucene/facet/taxonomy/DocValuesOrdinalsReader.java    | 15 +++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index ea17066..96f1b25 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -159,6 +159,10 @@ API Changes
 ---------------------
 (No changes)
 
+* LUCENE-9437: Lucene's facet module's DocValuesOrdinalsReader.decode method
+  is now public, making it easier for applications to decode facet
+  ordinals into their corresponding labels (Ankur)
+
 New Features
 ---------------------
 
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/DocValuesOrdinalsReader.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/DocValuesOrdinalsReader.java
index fd48849..f4c31e5 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/DocValuesOrdinalsReader.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/DocValuesOrdinalsReader.java
@@ -78,8 +78,19 @@ public class DocValuesOrdinalsReader extends OrdinalsReader {
     return field;
   }
 
-  /** Subclass and override if you change the encoding. */
-  protected void decode(BytesRef buf, IntsRef ordinals) {
+ /** 
+   * Subclass and override if you change the encoding. 
+   * The method is marked 'public' to allow decoding of binary payload containing ordinals
+   * without instantiating an {@link org.apache.lucene.facet.taxonomy.OrdinalsReader.OrdinalsSegmentReader}.
+   *  
+   * This takes care of use cases where an application instantiates {@link org.apache.lucene.index.BinaryDocValues} 
+   * reader for a facet field outside this class, reads the binary payload for a document and decodes the ordinals
+   * in the payload.
+   *
+   * @param buf binary payload containing encoded ordinals
+   * @param ordinals buffer for decoded ordinals
+   */
+  public void decode(BytesRef buf, IntsRef ordinals) {
 
     // grow the buffer up front, even if by a large number of values (buf.length)
     // that saves the need to check inside the loop for every decoded value if