Function<T,java.lang.Long>
, Object2LongFunction<T>
, Size64
, java.io.Serializable
, java.util.function.Function<T,java.lang.Long>
, java.util.function.ToLongFunction<T>
public class TwoStepsGOV3Function<T> extends AbstractHashFunction<T> implements java.io.Serializable, Size64
TwoStepsLcpMonotoneMinimalPerfectHashFunction
).
To create an instance, we perform a pre-scan of the values to be assigned. If possible, we finds the best possible
r such that the 2r − 1 most frequent values can be stored in a GOV3Function
and suitably remapped when read. The function uses 2r − 1 as an escape symbol for all other
values, which are stored in a separate function.
Warning: during the construction phase, a filter
will be set on the ChunkedHashStore
used to store the keys. If you are passing a store,
you will have to reset it to its previous state.
Modifier and Type | Class | Description |
---|---|---|
static class |
TwoStepsGOV3Function.Builder<T> |
A builder class for
TwoStepsGOV3Function . |
Modifier and Type | Field | Description |
---|---|---|
protected int |
escape |
The escape value returned by
firstFunction to suggest that secondFunction should be queried instead, provided that there is a first function. |
protected GOV3Function<T> |
firstFunction |
The first function, or
null . |
protected long |
n |
The number of keys.
|
protected double |
rankMean |
The mean of the rank distribution.
|
protected long[] |
remap |
A mapping from values of the first function to actual values, provided that there is a first function.
|
protected GOV3Function<T> |
secondFunction |
The second function.
|
protected long |
seed |
The seed to be used when converting keys to triples.
|
static long |
serialVersionUID |
|
protected TransformationStrategy<? super T> |
transform |
The transformation strategy to turn objects of type
T into bit vectors. |
protected int |
width |
The width of the output of this function, in bits.
|
defRetValue
Modifier | Constructor | Description |
---|---|---|
protected |
TwoStepsGOV3Function(java.lang.Iterable<? extends T> keys,
TransformationStrategy<? super T> transform,
LongBigList values,
java.io.File tempDir,
ChunkedHashStore<T> chunkedHashStore) |
Creates a new two-step function for the given keys and values.
|
Modifier and Type | Method | Description |
---|---|---|
long |
getLong(java.lang.Object o) |
|
long |
getLongByTriple(long[] triple) |
|
static void |
main(java.lang.String[] arg) |
|
long |
numBits() |
Returns the number of bits used by this structure.
|
long |
size64() |
containsKey, size
defaultReturnValue, defaultReturnValue
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyAsLong, get, put, put, remove, removeLong
public static final long serialVersionUID
protected final long n
protected final TransformationStrategy<? super T> transform
T
into bit vectors.protected final GOV3Function<T> firstFunction
null
. The special output value escape
denotes that secondFunction
should be queried instead.protected final GOV3Function<T> secondFunction
firstFunction
returns
escape
(or simply all queries, if firstFunction
is null
) will be rerouted here.protected final long[] remap
protected final int escape
firstFunction
to suggest that secondFunction
should be queried instead, provided that there is a first function.protected long seed
protected final int width
protected final double rankMean
protected TwoStepsGOV3Function(java.lang.Iterable<? extends T> keys, TransformationStrategy<? super T> transform, LongBigList values, java.io.File tempDir, ChunkedHashStore<T> chunkedHashStore) throws java.io.IOException
keys
- the keys in the domain of the function.transform
- a transformation strategy for the keys.values
- values to be assigned to each key, in the same order of the iterator returned by keys
; if null
, the
assigned value will the ordinal number of each key.tempDir
- a temporary directory for the store files, or null
for the standard temporary directory.chunkedHashStore
- a chunked hash store containing the keys associated with their rank, or null
; the store
can be unchecked, but in this case keys
and transform
must be non-null
.java.io.IOException
public long getLong(java.lang.Object o)
getLong
in interface Object2LongFunction<T>
public long getLongByTriple(long[] triple)
public long size64()
size64
in interface Size64
size64
in class AbstractHashFunction<T>
public long numBits()
public static void main(java.lang.String[] arg) throws java.lang.NoSuchMethodException, java.io.IOException, JSAPException
java.lang.NoSuchMethodException
java.io.IOException
JSAPException