Package org.apache.lucene.util.fst
Class ListOfOutputs<T>
- java.lang.Object
-
- org.apache.lucene.util.fst.Outputs<java.lang.Object>
-
- org.apache.lucene.util.fst.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 callingBuilder.add(IntsRef,Object)multiple times. The builder will then combine the outputs using theOutputs.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
Builder.add(org.apache.lucene.util.IntsRef, T)). If your outputs are longs, and you need at most 2, then useUpToTwoPositiveIntOutputsinstead 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).
-
-
Constructor Summary
Constructors Constructor Description ListOfOutputs(Outputs<T> outputs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectadd(java.lang.Object prefix, java.lang.Object output)Eg add("foo", "bar") -> "foobar"java.util.List<T>asList(java.lang.Object output)java.lang.Objectcommon(java.lang.Object output1, java.lang.Object output2)Eg common("foobar", "food") -> "foo"java.lang.ObjectgetNoOutput()NOTE: this output is compared with == so you must ensure that all methods return the single object if it's really no outputjava.lang.Objectmerge(java.lang.Object first, java.lang.Object second)java.lang.StringoutputToString(java.lang.Object output)java.lang.Objectread(DataInput in)Decode an output value previously written withOutputs.write(Object, DataOutput).java.lang.ObjectreadFinalOutput(DataInput in)Decode an output value previously written withOutputs.writeFinalOutput(Object, DataOutput).java.lang.Objectsubtract(java.lang.Object object, java.lang.Object inc)Eg subtract("foobar", "foo") -> "bar"java.lang.StringtoString()voidwrite(java.lang.Object output, DataOutput out)Encode an output value into aDataOutput.voidwriteFinalOutput(java.lang.Object output, DataOutput out)Encode an final node output value into aDataOutput.
-
-
-
Method Detail
-
common
public java.lang.Object common(java.lang.Object output1, java.lang.Object output2)Description copied from class:OutputsEg common("foobar", "food") -> "foo"
-
subtract
public java.lang.Object subtract(java.lang.Object object, java.lang.Object inc)Description copied from class:OutputsEg subtract("foobar", "foo") -> "bar"
-
add
public java.lang.Object add(java.lang.Object prefix, java.lang.Object output)Description copied from class:OutputsEg add("foo", "bar") -> "foobar"
-
write
public void write(java.lang.Object output, DataOutput out) throws java.io.IOExceptionDescription copied from class:OutputsEncode an output value into aDataOutput.
-
writeFinalOutput
public void writeFinalOutput(java.lang.Object output, DataOutput out) throws java.io.IOExceptionDescription copied from class:OutputsEncode an final node output value into aDataOutput. By default this just callsOutputs.write(Object, DataOutput).- Overrides:
writeFinalOutputin classOutputs<java.lang.Object>- Throws:
java.io.IOException
-
read
public java.lang.Object read(DataInput in) throws java.io.IOException
Description copied from class:OutputsDecode an output value previously written withOutputs.write(Object, DataOutput).
-
readFinalOutput
public java.lang.Object readFinalOutput(DataInput in) throws java.io.IOException
Description copied from class:OutputsDecode an output value previously written withOutputs.writeFinalOutput(Object, DataOutput). By default this just callsOutputs.read(DataInput).- Overrides:
readFinalOutputin classOutputs<java.lang.Object>- Throws:
java.io.IOException
-
getNoOutput
public java.lang.Object getNoOutput()
Description copied from class:OutputsNOTE: this output is compared with == so you must ensure that all methods return the single object if it's really no output- Specified by:
getNoOutputin classOutputs<java.lang.Object>
-
outputToString
public java.lang.String outputToString(java.lang.Object output)
- Specified by:
outputToStringin classOutputs<java.lang.Object>
-
merge
public java.lang.Object merge(java.lang.Object first, java.lang.Object second)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
asList
public java.util.List<T> asList(java.lang.Object output)
-
-