Enum MultiValueMode

    • Enum Constant Summary

      Enum Constants

      Enum Constant and Description
      AVG
      Average of all the values.
      MAX
      Pick the highest value.
      MIN
      Pick the lowest value.
      SUM
      Sum of all the values.
    • Method Summary

      Modifier and Type Method and Description
      org.apache.lucene.util.BytesRef apply(org.apache.lucene.util.BytesRef a, org.apache.lucene.util.BytesRef b)
       
      abstract double apply(double a, double b)
      Applies the sort mode and returns the result.
      abstract long apply(long a, long b)
      Applies the sort mode and returns the result.
      int applyOrd(int ord1, int ord2)
       
      static MultiValueMode fromString(String sortMode)
      A case insensitive version of valueOf(String)
      protected int pick(org.apache.lucene.index.RandomAccessOrds values)
       
      protected org.apache.lucene.util.BytesRef pick(SortedBinaryDocValues values, org.apache.lucene.util.BytesRef missingValue)
       
      protected long pick(org.apache.lucene.index.SortedNumericDocValues values, long missingValue)
       
      protected double pick(SortedNumericDoubleValues values, double missingValue)
       
      double reduce(double a, int numValues)
      Returns the aggregated value based on the sort mode.
      long reduce(long a, int numValues)
      Returns the aggregated value based on the sort mode.
      org.apache.lucene.index.SortedDocValues select(org.apache.lucene.index.RandomAccessOrds values)
      Return a SortedDocValues instance that can be used to sort documents with this mode and the provided values.
      org.apache.lucene.index.SortedDocValues select(org.apache.lucene.index.RandomAccessOrds values, org.apache.lucene.util.FixedBitSet rootDocs, org.apache.lucene.util.FixedBitSet innerDocs)
      Return a SortedDocValues instance that can be used to sort root documents with this mode, the provided values and filters for root/inner documents.
      org.apache.lucene.index.BinaryDocValues select(SortedBinaryDocValues values, org.apache.lucene.util.BytesRef missingValue)
      Return a BinaryDocValues instance that can be used to sort documents with this mode and the provided values.
      org.apache.lucene.index.BinaryDocValues select(SortedBinaryDocValues values, org.apache.lucene.util.BytesRef missingValue, org.apache.lucene.util.FixedBitSet rootDocs, org.apache.lucene.util.FixedBitSet innerDocs, int maxDoc)
      Return a BinaryDocValues instance that can be used to sort root documents with this mode, the provided values and filters for root/inner documents.
      org.apache.lucene.index.NumericDocValues select(org.apache.lucene.index.SortedNumericDocValues values, long missingValue)
      Return a NumericDocValues instance that can be used to sort documents with this mode and the provided values.
      org.apache.lucene.index.NumericDocValues select(org.apache.lucene.index.SortedNumericDocValues values, long missingValue, org.apache.lucene.util.FixedBitSet rootDocs, org.apache.lucene.util.FixedBitSet innerDocs, int maxDoc)
      Return a NumericDocValues instance that can be used to sort root documents with this mode, the provided values and filters for root/inner documents.
      NumericDoubleValues select(SortedNumericDoubleValues values, double missingValue)
      Return a NumericDoubleValues instance that can be used to sort documents with this mode and the provided values.
      NumericDoubleValues select(SortedNumericDoubleValues values, double missingValue, org.apache.lucene.util.FixedBitSet rootDocs, org.apache.lucene.util.FixedBitSet innerDocs, int maxDoc)
      Return a NumericDoubleValues instance that can be used to sort root documents with this mode, the provided values and filters for root/inner documents.
      double startDouble()
      Returns an initial value for the sort mode that is guaranteed to have no impact if passed to apply(double, double).
      long startLong()
      Returns an initial value for the sort mode that is guaranteed to have no impact if passed to apply(long, long).
      static MultiValueMode valueOf(String name)
      Returns the enum constant of this type with the specified name.
      static MultiValueMode[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
    • Method Detail

      • values

        public static MultiValueMode[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (MultiValueMode c : MultiValueMode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static MultiValueMode valueOf(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • apply

        public abstract double apply(double a,
                                     double b)
        Applies the sort mode and returns the result. This method is meant to be a binary function that is commonly used in a loop to find the relevant value for the sort mode in a list of values. For instance if the sort mode is MAX this method is equivalent to Math.max(double, double). Note: all implementations are idempotent.
        Parameters:
        a - an argument
        b - another argument
        Returns:
        the result of the function.
      • apply

        public abstract long apply(long a,
                                   long b)
        Applies the sort mode and returns the result. This method is meant to be a binary function that is commonly used in a loop to find the relevant value for the sort mode in a list of values. For instance if the sort mode is MAX this method is equivalent to Math.max(long, long). Note: all implementations are idempotent.
        Parameters:
        a - an argument
        b - another argument
        Returns:
        the result of the function.
      • applyOrd

        public int applyOrd(int ord1,
                            int ord2)
      • apply

        public org.apache.lucene.util.BytesRef apply(org.apache.lucene.util.BytesRef a,
                                                     org.apache.lucene.util.BytesRef b)
      • startDouble

        public double startDouble()
        Returns an initial value for the sort mode that is guaranteed to have no impact if passed to apply(double, double). This value should be used as the initial value if the sort mode is applied to a non-empty list of values. For instance:
             double relevantValue = sortMode.startDouble();
             for (int i = 0; i < array.length; i++) {
                 relevantValue = sortMode.apply(array[i], relevantValue);
             }
         
        Note: This method return 0 by default.
        Returns:
        an initial value for the sort mode.
      • startLong

        public long startLong()
        Returns an initial value for the sort mode that is guaranteed to have no impact if passed to apply(long, long). This value should be used as the initial value if the sort mode is applied to a non-empty list of values. For instance:
             long relevantValue = sortMode.startLong();
             for (int i = 0; i < array.length; i++) {
                 relevantValue = sortMode.apply(array[i], relevantValue);
             }
         
        Note: This method return 0 by default.
        Returns:
        an initial value for the sort mode.
      • reduce

        public double reduce(double a,
                             int numValues)
        Returns the aggregated value based on the sort mode. For instance if AVG is used this method divides the given value by the number of values. The default implementation returns the first argument. Note: all implementations are idempotent.
      • reduce

        public long reduce(long a,
                           int numValues)
        Returns the aggregated value based on the sort mode. For instance if AVG is used this method divides the given value by the number of values. The default implementation returns the first argument. Note: all implementations are idempotent.
      • pick

        protected long pick(org.apache.lucene.index.SortedNumericDocValues values,
                            long missingValue)
      • select

        public org.apache.lucene.index.NumericDocValues select(org.apache.lucene.index.SortedNumericDocValues values,
                                                               long missingValue)
        Return a NumericDocValues instance that can be used to sort documents with this mode and the provided values. When a document has no value, missingValue is returned.
      • select

        public org.apache.lucene.index.NumericDocValues select(org.apache.lucene.index.SortedNumericDocValues values,
                                                               long missingValue,
                                                               org.apache.lucene.util.FixedBitSet rootDocs,
                                                               org.apache.lucene.util.FixedBitSet innerDocs,
                                                               int maxDoc)
        Return a NumericDocValues instance that can be used to sort root documents with this mode, the provided values and filters for root/inner documents. For every root document, the values of its inner documents will be aggregated. If none of the inner documents has a value, then missingValue is returned. NOTE: Calling the returned instance on docs that are not root docs is illegal
      • select

        public NumericDoubleValues select(SortedNumericDoubleValues values,
                                          double missingValue,
                                          org.apache.lucene.util.FixedBitSet rootDocs,
                                          org.apache.lucene.util.FixedBitSet innerDocs,
                                          int maxDoc)
        Return a NumericDoubleValues instance that can be used to sort root documents with this mode, the provided values and filters for root/inner documents. For every root document, the values of its inner documents will be aggregated. If none of the inner documents has a value, then missingValue is returned. NOTE: Calling the returned instance on docs that are not root docs is illegal
      • pick

        protected org.apache.lucene.util.BytesRef pick(SortedBinaryDocValues values,
                                                       org.apache.lucene.util.BytesRef missingValue)
      • select

        public org.apache.lucene.index.BinaryDocValues select(SortedBinaryDocValues values,
                                                              org.apache.lucene.util.BytesRef missingValue)
        Return a BinaryDocValues instance that can be used to sort documents with this mode and the provided values. When a document has no value, missingValue is returned.
      • select

        public org.apache.lucene.index.BinaryDocValues select(SortedBinaryDocValues values,
                                                              org.apache.lucene.util.BytesRef missingValue,
                                                              org.apache.lucene.util.FixedBitSet rootDocs,
                                                              org.apache.lucene.util.FixedBitSet innerDocs,
                                                              int maxDoc)
        Return a BinaryDocValues instance that can be used to sort root documents with this mode, the provided values and filters for root/inner documents. For every root document, the values of its inner documents will be aggregated. If none of the inner documents has a value, then missingValue is returned. NOTE: Calling the returned instance on docs that are not root docs is illegal
      • pick

        protected int pick(org.apache.lucene.index.RandomAccessOrds values)
      • select

        public org.apache.lucene.index.SortedDocValues select(org.apache.lucene.index.RandomAccessOrds values)
        Return a SortedDocValues instance that can be used to sort documents with this mode and the provided values.
      • select

        public org.apache.lucene.index.SortedDocValues select(org.apache.lucene.index.RandomAccessOrds values,
                                                              org.apache.lucene.util.FixedBitSet rootDocs,
                                                              org.apache.lucene.util.FixedBitSet innerDocs)
        Return a SortedDocValues instance that can be used to sort root documents with this mode, the provided values and filters for root/inner documents. For every root document, the values of its inner documents will be aggregated. NOTE: Calling the returned instance on docs that are not root docs is illegal