Package org.apache.lucene.sandbox.facet.cutters

# Class LongValueFacetCutter

java.lang.Object
org.apache.lucene.sandbox.facet.cutters.LongValueFacetCutter

All Implemented Interfaces:
  `FacetCutter`, `OrdToLabel`

public final class LongValueFacetCutter extends Object implements FacetCutter, OrdToLabel
`FacetCutter` and `OrdToLabel` for distinct long values.

TODO: This class is quite inefficient. Will optimise later.

TODO: add support for other value sources e.g: LongValues

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LongValueFacetCutter(String field)`
  Constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `LeafFacetCutter`
  `createLeafCutter(LeafReaderContext context)`
  Get cutter for the leaf.
  `FacetLabel`
  `getLabel(int ordinal)`
  get label of one ord TODO: what do we return when ordinal is not valid? null?
  `FacetLabel[]`
  `getLabels(int[] ordinals)`
  get labels for multiple ords
  `long`
  `getValue(int ordinal)`
  Get value by ordinal.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.apache.lucene.sandbox.facet.cutters.FacetCutter

  `getChildrenOrds, getOrdinalsToRollup`

- ## Constructor Details

  - ### LongValueFacetCutter

    public LongValueFacetCutter(String field)
    Constructor.
    Parameters:
      `field` - field name to read long values from.

- ## Method Details

  - ### createLeafCutter

    public LeafFacetCutter createLeafCutter(LeafReaderContext context) throws IOException
    Description copied from interface: `FacetCutter`
    Get cutter for the leaf.
    Specified by:
      `createLeafCutter` in interface `FacetCutter`
    Throws:
      `IOException`

  - ### getLabel

    public FacetLabel getLabel(int ordinal)
    Description copied from interface: `OrdToLabel`
    get label of one ord TODO: what do we return when ordinal is not valid? null?
    Specified by:
      `getLabel` in interface `OrdToLabel`

  - ### getValue

    public long getValue(int ordinal)
    Get value by ordinal. Should only be called after collection phase.

    TODO: we need it to tie break sort by value. Alternatively we can sort by label (then we don't need this method), but we would have to convert FacetLabel to "long" to have the same order... Overall, it is probably not important to tie break by value, and we can tie break by ord same as for other facets; but for now we don't want to change results order just in case.

    Parameters:
      `ordinal` - facet ordinal.
    Returns:
      long value

  - ### getLabels

    public FacetLabel[] getLabels(int[] ordinals) throws IOException
    Description copied from interface: `OrdToLabel`
    get labels for multiple ords
    Specified by:
      `getLabels` in interface `OrdToLabel`
    Throws:
      `IOException`