MultiDoubleValuesSource (Lucene 10.5.1 facet API)
Description: declaration: package: org.apache.lucene.facet, class: MultiDoubleValuesSource

Package org.apache.lucene.facet

# Class MultiDoubleValuesSource

java.lang.Object
org.apache.lucene.facet.MultiDoubleValuesSource

All Implemented Interfaces:
  `SegmentCacheable`

public abstract class MultiDoubleValuesSource extends Object implements SegmentCacheable
Base class for producing `MultiDoubleValues`. See also `DoubleValuesSource` for a single-valued version.

MultiDoubleValuesSource objects for NumericDocValues/SortedNumericDocValues fields can be obtained by calling `fromFloatField(String)`, `fromDoubleField(String)`, `fromIntField(String)`, or `fromLongField(String)`. If custom long-to-double logic is required, `fromField(String, LongToDoubleFunction)` can be used. This is valid for both multi-valued and single-valued fields.

To obtain a MultiDoubleValuesSource from an existing `DoubleValuesSource`, see `fromSingleValued(DoubleValuesSource)`. Instances created in this way can be "unwrapped" using `unwrapSingleton(MultiDoubleValuesSource)` if necessary. Note that scores are never provided to the underlying `DoubleValuesSource`. `DoubleValuesSource.rewrite(IndexSearcher)` will also never be called. The user should be aware of this if using a `DoubleValuesSource` that relies on rewriting or scores. The faceting use-cases don't call rewrite or provide scores, which is why this simplification was made.

Currently meant only for use within the faceting module. Could be further generalized and made available for more use-cases outside faceting if there is a desire to do so.

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

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MultiDoubleValuesSource()`
  Instantiates a new MultiDoubleValuesSource

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract boolean`
  `equals(Object o)`
  `static MultiDoubleValuesSource`
  `fromDoubleField(String field)`
  Creates a MultiDoubleValuesSource that wraps a double-valued field
  `static MultiDoubleValuesSource`
  `fromField(String field, LongToDoubleFunction decoder)`
  Creates a MultiDoubleValuesSource that wraps a generic NumericDocValues/SortedNumericDocValues field.
  `static MultiDoubleValuesSource`
  `fromFloatField(String field)`
  Creates a MultiDoubleValuesSource that wraps a float-valued field
  `static MultiDoubleValuesSource`
  `fromIntField(String field)`
  Creates a MultiDoubleValuesSource that wraps an int-valued field
  `static MultiDoubleValuesSource`
  `fromLongField(String field)`
  Creates a MultiDoubleValuesSource that wraps a long-valued field
  `static MultiDoubleValuesSource`
  `fromSingleValued(DoubleValuesSource singleValued)`
  Creates a MultiDoubleValuesSource that wraps a single-valued `DoubleValuesSource`
  `abstract MultiDoubleValues`
  `getValues(LeafReaderContext ctx)`
  Returns a `MultiDoubleValues` instance for the passed-in LeafReaderContext
  `abstract int`
  `hashCode()`
  `final MultiLongValuesSource`
  `toMultiLongValuesSource()`
  Convert to a MultiLongValuesSource by casting the double values to longs
  `final MultiLongValuesSource`
  `toSortableMultiLongValuesSource()`
  Convert to a `MultiLongValuesSource` using `NumericUtils.doubleToSortableLong(double)`
  `abstract String`
  `toString()`
  `static DoubleValuesSource`
  `unwrapSingleton(MultiDoubleValuesSource in)`
  Returns a single-valued view of the `MultiDoubleValuesSource` if it was previously wrapped with `fromSingleValued(DoubleValuesSource)`, or null.

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.apache.lucene.search.SegmentCacheable

  `isCacheable`

- ## Constructor Details

  - ### MultiDoubleValuesSource

    public MultiDoubleValuesSource()
    Instantiates a new MultiDoubleValuesSource

- ## Method Details

  - ### getValues

    public abstract MultiDoubleValues getValues(LeafReaderContext ctx) throws IOException
    Returns a `MultiDoubleValues` instance for the passed-in LeafReaderContext
    Throws:
      `IOException`

  - ### hashCode

    public abstract int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public abstract boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### toString

    public abstract String toString()
    Overrides:
      `toString` in class `Object`

  - ### fromField

    public static MultiDoubleValuesSource fromField(String field, LongToDoubleFunction decoder)
    Creates a MultiDoubleValuesSource that wraps a generic NumericDocValues/SortedNumericDocValues field. Uses the long-to-double decoding logic specified in `decoder` for converting the stored value to a double.

  - ### fromDoubleField

    public static MultiDoubleValuesSource fromDoubleField(String field)
    Creates a MultiDoubleValuesSource that wraps a double-valued field

  - ### fromFloatField

    public static MultiDoubleValuesSource fromFloatField(String field)
    Creates a MultiDoubleValuesSource that wraps a float-valued field

  - ### fromLongField

    public static MultiDoubleValuesSource fromLongField(String field)
    Creates a MultiDoubleValuesSource that wraps a long-valued field

  - ### fromIntField

    public static MultiDoubleValuesSource fromIntField(String field)
    Creates a MultiDoubleValuesSource that wraps an int-valued field

  - ### fromSingleValued

    public static MultiDoubleValuesSource fromSingleValued(DoubleValuesSource singleValued)
    Creates a MultiDoubleValuesSource that wraps a single-valued `DoubleValuesSource`

  - ### unwrapSingleton

    public static DoubleValuesSource unwrapSingleton(MultiDoubleValuesSource in)
    Returns a single-valued view of the `MultiDoubleValuesSource` if it was previously wrapped with `fromSingleValued(DoubleValuesSource)`, or null.

  - ### toMultiLongValuesSource

    public final MultiLongValuesSource toMultiLongValuesSource()
    Convert to a MultiLongValuesSource by casting the double values to longs

  - ### toSortableMultiLongValuesSource

    public final MultiLongValuesSource toSortableMultiLongValuesSource()
    Convert to a `MultiLongValuesSource` using `NumericUtils.doubleToSortableLong(double)`