Package org.apache.lucene.misc.util.fst
Class ListOfOutputs<T>
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEg add("foo", "bar") -> "foobar"Eg common("foobar", "food") -> "foo"NOTE: this output is compared with == so you must ensure that all methods return the single object if it's really no outputoutputToString
(Object output) long
ramBytesUsed
(Object output) Return memory usage for the provided output.Decode an output value previously written withOutputs.write(Object, DataOutput)
.Decode an output value previously written withOutputs.writeFinalOutput(Object, DataOutput)
.void
Skip the output previously written withOutputs.writeFinalOutput(T, org.apache.lucene.store.DataOutput)
; defaults to just callingOutputs.readFinalOutput(org.apache.lucene.store.DataInput)
and discarding the result.void
skipOutput
(DataInput in) Skip the output; defaults to just callingOutputs.read(org.apache.lucene.store.DataInput)
and discarding the result.Eg subtract("foobar", "foo") -> "bar"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
.
-
Field Details
-
outputs
-
BASE_LIST_NUM_BYTES
private static final long BASE_LIST_NUM_BYTES
-
-
Constructor Details
-
ListOfOutputs
-
-
Method Details
-
common
Description copied from class:Outputs
Eg common("foobar", "food") -> "foo" -
subtract
Description copied from class:Outputs
Eg subtract("foobar", "foo") -> "bar" -
add
Description copied from class:Outputs
Eg add("foo", "bar") -> "foobar" -
write
Description copied from class:Outputs
Encode an output value into aDataOutput
.- Specified by:
write
in classOutputs<Object>
- Throws:
IOException
-
writeFinalOutput
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
Description copied from class:Outputs
Decode an output value previously written withOutputs.write(Object, DataOutput)
.- Specified by:
read
in classOutputs<Object>
- Throws:
IOException
-
skipOutput
Description copied from class:Outputs
Skip the output; defaults to just callingOutputs.read(org.apache.lucene.store.DataInput)
and discarding the result.- Overrides:
skipOutput
in classOutputs<Object>
- Throws:
IOException
-
readFinalOutput
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
-
skipFinalOutput
Description copied from class:Outputs
Skip the output previously written withOutputs.writeFinalOutput(T, org.apache.lucene.store.DataOutput)
; defaults to just callingOutputs.readFinalOutput(org.apache.lucene.store.DataInput)
and discarding the result.- Overrides:
skipFinalOutput
in classOutputs<Object>
- Throws:
IOException
-
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
- Specified by:
outputToString
in classOutputs<Object>
-
merge
-
toString
-
asList
-
ramBytesUsed
Description copied from class:Outputs
Return memory usage for the provided output.- Specified by:
ramBytesUsed
in classOutputs<Object>
- See Also:
-