Class UpToTwoPositiveIntOutputs

  • public final class UpToTwoPositiveIntOutputs
    extends Outputs<java.lang.Object>
    An FST Outputs implementation where each output is one or two non-negative long values. If it's a single output, Long is returned; else, TwoLongs. Order is preserved in the TwoLongs case, ie .first is the first input/output added to Builder, and .second is the second. You cannot store 0 output with this (that's reserved to mean "no output")!

    NOTE: the only way to create a TwoLongs output is to add the same input to the FST twice in a row. This is how the FST maps a single input to two outputs (e.g. you cannot pass a TwoLongs to Builder.add(org.apache.lucene.util.IntsRef, T). If you need more than two then use ListOfOutputs, but if you only have at most 2 then this implementation will require fewer bytes as it steals one bit from each long value.

    NOTE: the resulting FST is not guaranteed to be minimal! See Builder.

    • Method Detail

      • get

        public java.lang.Long get​(long v)
      • common

        public java.lang.Long 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.Long subtract​(java.lang.Object _output,
                                       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)
        Description copied from class: Outputs
        Encode an output value into a DataOutput.
        Specified by:
        write in class Outputs<java.lang.Object>
      • 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)
        merge in class Outputs<java.lang.Object>