Class ListOfOutputs<T>


  • public final class ListOfOutputs<T>
    extends Outputs<java.lang.Object>
    Wraps another Outputs implementation and encodes one or more of its output values. You can use this when a single input may need to map to more than one output, maintaining order: pass the same input with a different output by calling FSTCompiler.add(IntsRef,Object) multiple times. The builder will then combine the outputs using the Outputs.merge(Object,Object) method.

    The resulting FST may not be minimal when an input has more than one output, as this requires pushing all multi-output values to a final state.

    NOTE: the only way to create multiple outputs is to add the same input to the FST multiple times in a row. This is how the FST maps a single input to multiple outputs (e.g. you cannot pass a List<Object> to FSTCompiler.add(org.apache.lucene.util.IntsRef, T)). If your outputs are longs, and you need at most 2, then use UpToTwoPositiveIntOutputs instead since it stores the outputs more compactly (by stealing a bit from each long value).

    NOTE: this cannot wrap itself (ie you cannot make an FST with List<List<Object>> outputs using this).

    • Field Detail

      • outputs

        private final Outputs<T> outputs
      • BASE_LIST_NUM_BYTES

        private static final long BASE_LIST_NUM_BYTES
    • Constructor Detail

      • ListOfOutputs

        public ListOfOutputs​(Outputs<T> outputs)
    • Method Detail

      • common

        public java.lang.Object common​(java.lang.Object output1,
                                       java.lang.Object output2)
        Description copied from class: Outputs
        Eg common("foobar", "food") -> "foo"
        Specified by:
        common in class Outputs<java.lang.Object>
      • subtract

        public java.lang.Object subtract​(java.lang.Object object,
                                         java.lang.Object inc)
        Description copied from class: Outputs
        Eg subtract("foobar", "foo") -> "bar"
        Specified by:
        subtract in class Outputs<java.lang.Object>
      • add

        public java.lang.Object add​(java.lang.Object prefix,
                                    java.lang.Object output)
        Description copied from class: Outputs
        Eg add("foo", "bar") -> "foobar"
        Specified by:
        add in class Outputs<java.lang.Object>
      • write

        public void write​(java.lang.Object output,
                          DataOutput out)
                   throws java.io.IOException
        Description copied from class: Outputs
        Encode an output value into a DataOutput.
        Specified by:
        write in class Outputs<java.lang.Object>
        Throws:
        java.io.IOException
      • getNoOutput

        public java.lang.Object getNoOutput()
        Description copied from class: Outputs
        NOTE: this output is compared with == so you must ensure that all methods return the single object if it's really no output
        Specified by:
        getNoOutput in class Outputs<java.lang.Object>
      • outputToString

        public java.lang.String outputToString​(java.lang.Object output)
        Specified by:
        outputToString in class Outputs<java.lang.Object>
      • merge

        public java.lang.Object merge​(java.lang.Object first,
                                      java.lang.Object second)
        Overrides:
        merge in class Outputs<java.lang.Object>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • asList

        public java.util.List<T> asList​(java.lang.Object output)
      • ramBytesUsed

        public long ramBytesUsed​(java.lang.Object output)
        Description copied from class: Outputs
        Return memory usage for the provided output.
        Specified by:
        ramBytesUsed in class Outputs<java.lang.Object>
        See Also:
        Accountable