Class GOV3Function.Builder<T>

  • Enclosing class:
    GOV3Function<T>

    public static class GOV3Function.Builder<T>
    extends java.lang.Object
    A builder class for GOV3Function.
    • Field Detail

      • keys

        protected java.lang.Iterable<? extends T> keys
      • transform

        protected it.unimi.dsi.bits.TransformationStrategy<? super T> transform
      • signatureWidth

        protected int signatureWidth
      • tempDir

        protected java.io.File tempDir
      • values

        protected it.unimi.dsi.fastutil.longs.LongIterable values
      • outputWidth

        protected int outputWidth
      • indirect

        protected boolean indirect
      • compacted

        protected boolean compacted
      • built

        protected boolean built
        Whether build() has already been called.
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • keys

        public GOV3Function.Builder<T> keys​(java.lang.Iterable<? extends T> keys)
        Specifies the keys of the function; if you have specified a BucketedHashStore, it can be null.
        Parameters:
        keys - the keys of the function.
        Returns:
        this builder.
      • transform

        public GOV3Function.Builder<T> transform​(it.unimi.dsi.bits.TransformationStrategy<? super T> transform)
        Specifies the transformation strategy for the keys of the function; the strategy can be raw.
        Parameters:
        transform - a transformation strategy for the keys of the function.
        Returns:
        this builder.
      • signed

        public GOV3Function.Builder<T> signed​(int signatureWidth)
        Specifies that the resulting GOV3Function should be signed using a given number of bits per element; in this case, you cannot specify values.
        Parameters:
        signatureWidth - a signature width, or 0 for no signature (a negative value will have the same effect of dictionary(int) with the opposite argument).
        Returns:
        this builder.
      • dictionary

        public GOV3Function.Builder<T> dictionary​(int signatureWidth)
        Specifies that the resulting GOV3Function should be an approximate dictionary: the output value will be a signature, and GOV3Function.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.

        Parameters:
        signatureWidth - a signature width, or 0 for no signature (a negative value will have the same effect of signed(int) with the opposite argument).
        Returns:
        this builder.
      • tempDir

        public GOV3Function.Builder<T> tempDir​(java.io.File tempDir)
        Specifies a temporary directory for the BucketedHashStore.
        Parameters:
        tempDir - a temporary directory for the BucketedHashStore files, or null for the standard temporary directory.
        Returns:
        this builder.
      • store

        public GOV3Function.Builder<T> store​(BucketedHashStore<T> bucketedHashStore)
        Specifies a bucketed hash store containing the keys.

        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.

        Parameters:
        bucketedHashStore - a bucketed 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).
        Returns:
        this builder.
      • store

        public GOV3Function.Builder<T> store​(BucketedHashStore<T> bucketedHashStore,
                                             int outputWidth)
        Specifies a bucketed hash store containing keys and values, and an output width.

        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.

        Parameters:
        bucketedHashStore - a bucketed 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.
        Returns:
        this builder.
      • values

        public GOV3Function.Builder<T> values​(it.unimi.dsi.fastutil.longs.LongIterable values,
                                              int outputWidth)
        Specifies the values assigned to the keys.

        Contrarily to values(LongIterable), this method does not require a complete scan of the value to determine the output width.

        Parameters:
        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.
        Returns:
        this builder.
        See Also:
        values(LongIterable)
      • values

        public GOV3Function.Builder<T> values​(it.unimi.dsi.fastutil.longs.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.

        Contrarily to values(LongIterable, int), this method requires a complete scan of the value to determine the output width.

        Parameters:
        values - values to be assigned to each element, in the same order of the keys.
        Returns:
        this builder.
        See Also:
        values(LongIterable,int)
      • indirect

        public GOV3Function.Builder<T> indirect()
        Specifies that the function construction must be indirect: a provided store contains indices that must be used to access the values.

        If you specify this option, the provided values must be a LongList or a LongBigList.

        Returns:
        this builder.
      • compacted

        public GOV3Function.Builder<T> compacted()
        Specifies that the function must be compacted.
        Returns:
        this builder.
      • build

        public GOV3Function<T> build()
                              throws java.io.IOException
        Builds a new function.
        Returns:
        a GOV3Function instance with the specified parameters.
        Throws:
        java.lang.IllegalStateException - if called more than once.
        java.io.IOException