public class TwoStepsGOV3Function<T> extends AbstractHashFunction<T> implements 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 and Description |
|---|---|
static class |
TwoStepsGOV3Function.Builder<T>
A builder class for
TwoStepsGOV3Function. |
| Modifier and Type | Field and 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 and Description |
|---|---|
protected |
TwoStepsGOV3Function(Iterable<? extends T> keys,
TransformationStrategy<? super T> transform,
LongBigList values,
File tempDir,
ChunkedHashStore<T> chunkedHashStore)
Creates a new two-step function for the given keys and values.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getLong(Object o) |
long |
getLongByTriple(long[] triple) |
static void |
main(String[] arg) |
long |
numBits()
Returns the number of bits used by this structure.
|
long |
size64() |
containsKey, sizeclear, defaultReturnValue, defaultReturnValue, get, put, put, remove, removeLongpublic 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(Iterable<? extends T> keys, TransformationStrategy<? super T> transform, LongBigList values, File tempDir, ChunkedHashStore<T> chunkedHashStore) throws 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 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.IOExceptionpublic long getLong(Object o)
getLong in interface Object2LongFunction<T>public long getLongByTriple(long[] triple)
public long size64()
size64 in interface Size64size64 in class AbstractHashFunction<T>public long numBits()
public static void main(String[] arg) throws NoSuchMethodException, IOException, JSAPException