LUCENE-9437: make DocValuesOrdinalsReader.decode public

This commit is contained in:
Mike McCandless 2020-07-22 09:57:04 -04:00
parent 8ebf2d0b21
commit 03a03b34a4
2 changed files with 17 additions and 2 deletions

View File

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

View File

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