public static class GOV4Function.Builder<T> extends Object
GOV4Function.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
built
Whether
build() has already been called. |
protected ChunkedHashStore<T> |
chunkedHashStore |
protected boolean |
indirect |
protected Iterable<? extends T> |
keys |
protected int |
outputWidth |
protected int |
signatureWidth |
protected File |
tempDir |
protected TransformationStrategy<? super T> |
transform |
protected LongIterable |
values |
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
GOV4Function<T> |
build()
Builds a new function.
|
GOV4Function.Builder<T> |
dictionary(int signatureWidth)
Specifies that the resulting
GOV4Function should be a dictionary: the output value will be a signature,
and GOV4Function.getLong(Object) will return 1 or 0 depending on whether the argument was in the key set or not;
in this case, you cannot specify values. |
GOV4Function.Builder<T> |
indirect()
|
GOV4Function.Builder<T> |
keys(Iterable<? extends T> keys)
Specifies the keys of the function; if you have specified a
ChunkedHashStore, it can be null. |
GOV4Function.Builder<T> |
signed(int signatureWidth)
Specifies that the resulting
GOV4Function should be signed using a given number of bits per element;
in this case, you cannot specify values. |
GOV4Function.Builder<T> |
store(ChunkedHashStore<T> chunkedHashStore)
Specifies a chunked hash store containing the keys.
|
GOV4Function.Builder<T> |
store(ChunkedHashStore<T> chunkedHashStore,
int outputWidth)
Specifies a chunked hash store containing keys and values, and an output width.
|
GOV4Function.Builder<T> |
tempDir(File tempDir)
Specifies a temporary directory for the
ChunkedHashStore. |
GOV4Function.Builder<T> |
transform(TransformationStrategy<? super T> transform)
Specifies the transformation strategy for the keys of the function.
|
GOV4Function.Builder<T> |
values(LongIterable values)
Specifies the values assigned to the keys; the output width of the function will
be the minimum width needed to represent all values.
|
GOV4Function.Builder<T> |
values(LongIterable values,
int outputWidth)
Specifies the values assigned to the keys.
|
protected TransformationStrategy<? super T> transform
protected int signatureWidth
protected File tempDir
protected ChunkedHashStore<T> chunkedHashStore
protected LongIterable values
protected int outputWidth
protected boolean indirect
protected boolean built
build() has already been called.public GOV4Function.Builder<T> keys(Iterable<? extends T> keys)
ChunkedHashStore, it can be null.keys - the keys of the function.public GOV4Function.Builder<T> transform(TransformationStrategy<? super T> transform)
transform - a transformation strategy for the keys of the function.public GOV4Function.Builder<T> signed(int signatureWidth)
GOV4Function should be signed using a given number of bits per element;
in this case, you cannot specify values.signatureWidth - a signature width, or 0 for no signature (a negative value will have the same effect of dictionary(int) with the opposite argument).public GOV4Function.Builder<T> dictionary(int signatureWidth)
GOV4Function should be a dictionary: the output value will be a signature,
and GOV4Function.getLong(Object) will return 1 or 0 depending on whether the argument was in the key set or not;
in this case, you cannot specify values.
Note that checking against a signature has the usual probability of a false positive.
signatureWidth - a signature width, or 0 for no signature (a negative value will have the same effect of signed(int) with the opposite argument).public GOV4Function.Builder<T> tempDir(File tempDir)
ChunkedHashStore.tempDir - a temporary directory for the ChunkedHashStore files, or null for the standard temporary directory.public GOV4Function.Builder<T> store(ChunkedHashStore<T> chunkedHashStore)
Note that if you specify a store, it is your responsibility that it conforms to the rest of the data: it must contain ranks if you do not specify values or if you use the indirect feature, values otherwise.
chunkedHashStore - a chunked hash store containing the keys, or null; the store
can be unchecked, but in this case you must specify keys and a transform
(otherwise, in case of a hash collision in the store an IllegalStateException will be thrown).public GOV4Function.Builder<T> store(ChunkedHashStore<T> chunkedHashStore, int outputWidth)
Note that if you specify a store, it is your responsibility that it conforms to the rest of the data: it must contain ranks if you use the indirect feature, values representable in at most the specified number of bits otherwise.
chunkedHashStore - a chunked hash store containing the keys, or null; the store
can be unchecked, but in this case you must specify keys and a transform
(otherwise, in case of a hash collision in the store an IllegalStateException will be thrown).outputWidth - the bit width of the output of the function, which must be enough to represent all values contained in the store.public GOV4Function.Builder<T> values(LongIterable values, int outputWidth)
Contrarily to values(LongIterable), this method does not require a complete scan of the value
to determine the output width.
values - values to be assigned to each element, in the same order of the keys.outputWidth - the bit width of the output of the function, which must be enough to represent all values.values(LongIterable)public GOV4Function.Builder<T> values(LongIterable values)
Contrarily to values(LongIterable, int), this method requires a complete scan of the value
to determine the output width.
values - values to be assigned to each element, in the same order of the keys.values(LongIterable,int)public GOV4Function.Builder<T> indirect()
If you specify this option, the provided values must be a LongList or a LongBigList.
public GOV4Function<T> build() throws IOException
GOV4Function instance with the specified parameters.IllegalStateException - if called more than once.IOException