Package org.apache.lucene.util.fst
Class ListOfOutputs<T>
- java.lang.Object
-
- org.apache.lucene.util.fst.Outputs<Object>
-
- org.apache.lucene.util.fst.ListOfOutputs<T>
-
public final class ListOfOutputs<T> extends Outputs<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 useUpToTwoPositiveIntOutputs
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).
-
-
Constructor Summary
Constructors Constructor Description ListOfOutputs(Outputs<T> outputs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
add(Object prefix, Object output)
Eg add("foo", "bar") -> "foobar"List<T>
asList(Object output)
Object
common(Object output1, Object output2)
Eg common("foobar", "food") -> "foo"Object
getNoOutput()
NOTE: this output is compared with == so you must ensure that all methods return the single object if it's really no outputObject
merge(Object first, Object second)
String
outputToString(Object output)
Object
read(DataInput in)
Decode an output value previously written withOutputs.write(Object, DataOutput)
.Object
readFinalOutput(DataInput in)
Decode an output value previously written withOutputs.writeFinalOutput(Object, DataOutput)
.Object
subtract(Object object, Object inc)
Eg subtract("foobar", "foo") -> "bar"String
toString()
void
write(Object output, DataOutput out)
Encode an output value into aDataOutput
.void
writeFinalOutput(Object output, DataOutput out)
Encode an final node output value into aDataOutput
.
-
-
-
Method Detail
-
common
public Object common(Object output1, Object output2)
Description copied from class:Outputs
Eg common("foobar", "food") -> "foo"
-
subtract
public Object subtract(Object object, Object inc)
Description copied from class:Outputs
Eg subtract("foobar", "foo") -> "bar"
-
add
public Object add(Object prefix, Object output)
Description copied from class:Outputs
Eg add("foo", "bar") -> "foobar"
-
write
public void write(Object output, DataOutput out) throws IOException
Description copied from class:Outputs
Encode an output value into aDataOutput
.- Specified by:
write
in classOutputs<Object>
- Throws:
IOException
-
writeFinalOutput
public void writeFinalOutput(Object output, DataOutput out) throws IOException
Description copied from class:Outputs
Encode an final node output value into aDataOutput
. By default this just callsOutputs.write(Object, DataOutput)
.- Overrides:
writeFinalOutput
in classOutputs<Object>
- Throws:
IOException
-
read
public Object read(DataInput in) throws IOException
Description copied from class:Outputs
Decode an output value previously written withOutputs.write(Object, DataOutput)
.- Specified by:
read
in classOutputs<Object>
- Throws:
IOException
-
readFinalOutput
public Object readFinalOutput(DataInput in) throws IOException
Description copied from class:Outputs
Decode an output value previously written withOutputs.writeFinalOutput(Object, DataOutput)
. By default this just callsOutputs.read(DataInput)
.- Overrides:
readFinalOutput
in classOutputs<Object>
- Throws:
IOException
-
getNoOutput
public 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 classOutputs<Object>
-
outputToString
public String outputToString(Object output)
- Specified by:
outputToString
in classOutputs<Object>
-
-