public final class UpToTwoPositiveIntOutputs extends Outputs<java.lang.Object>
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
.
Modifier and Type | Class and Description |
---|---|
static class |
UpToTwoPositiveIntOutputs.TwoLongs
Holds two long outputs.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
doShare |
private static java.lang.Long |
NO_OUTPUT |
private static UpToTwoPositiveIntOutputs |
singletonNoShare |
private static UpToTwoPositiveIntOutputs |
singletonShare |
private static long |
TWO_LONGS_NUM_BYTES |
Modifier | Constructor and Description |
---|---|
private |
UpToTwoPositiveIntOutputs(boolean doShare) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
add(java.lang.Object _prefix,
java.lang.Object _output)
Eg add("foo", "bar") -> "foobar"
|
java.lang.Long |
common(java.lang.Object _output1,
java.lang.Object _output2)
Eg common("foobar", "food") -> "foo"
|
java.lang.Long |
get(long v) |
UpToTwoPositiveIntOutputs.TwoLongs |
get(long first,
long second) |
java.lang.Object |
getNoOutput()
NOTE: this output is compared with == so you must
ensure that all methods return the single object if
it's really no output
|
static UpToTwoPositiveIntOutputs |
getSingleton(boolean doShare) |
java.lang.Object |
merge(java.lang.Object first,
java.lang.Object second) |
java.lang.String |
outputToString(java.lang.Object output) |
long |
ramBytesUsed(java.lang.Object o)
Return memory usage for the provided output.
|
java.lang.Object |
read(DataInput in)
Decode an output value previously written with
Outputs.write(Object, DataOutput) . |
java.lang.Long |
subtract(java.lang.Object _output,
java.lang.Object _inc)
Eg subtract("foobar", "foo") -> "bar"
|
private boolean |
valid(java.lang.Long o) |
private boolean |
valid(java.lang.Object _o,
boolean allowDouble) |
void |
write(java.lang.Object _output,
DataOutput out)
Encode an output value into a
DataOutput . |
readFinalOutput, skipFinalOutput, skipOutput, writeFinalOutput
private static final java.lang.Long NO_OUTPUT
private final boolean doShare
private static final UpToTwoPositiveIntOutputs singletonShare
private static final UpToTwoPositiveIntOutputs singletonNoShare
private static final long TWO_LONGS_NUM_BYTES
public static UpToTwoPositiveIntOutputs getSingleton(boolean doShare)
public java.lang.Long get(long v)
public UpToTwoPositiveIntOutputs.TwoLongs get(long first, long second)
public java.lang.Long common(java.lang.Object _output1, java.lang.Object _output2)
Outputs
public java.lang.Long subtract(java.lang.Object _output, java.lang.Object _inc)
Outputs
public java.lang.Object add(java.lang.Object _prefix, java.lang.Object _output)
Outputs
public void write(java.lang.Object _output, DataOutput out) throws java.io.IOException
Outputs
DataOutput
.public java.lang.Object read(DataInput in) throws java.io.IOException
Outputs
Outputs.write(Object, DataOutput)
.private boolean valid(java.lang.Long o)
private boolean valid(java.lang.Object _o, boolean allowDouble)
public java.lang.Object getNoOutput()
Outputs
getNoOutput
in class Outputs<java.lang.Object>
public java.lang.String outputToString(java.lang.Object output)
outputToString
in class Outputs<java.lang.Object>
public java.lang.Object merge(java.lang.Object first, java.lang.Object second)
public long ramBytesUsed(java.lang.Object o)
Outputs
ramBytesUsed
in class Outputs<java.lang.Object>
Accountable