Package it.unimi.dsi.sux4j.mph

Minimal perfect hash functions.

See: Description

Package it.unimi.dsi.sux4j.mph Description

Minimal perfect hash functions.

Package Specification

This package provides a number of state-of-the-art implementations of static (i.e., immutable) minimal perfect hash functions, and, more generally, of static functions from objects to integers. The classes can be gathered in three broad groups:

LcpMonotoneMinimalPerfectHashFunction and ZFastTrieDistributorMonotoneMinimalPerfectHashFunction were introduced by Djamal Belazzougui, Paolo Boldi, Rasmus Pagh and Sebastiano Vigna in “Monotone Minimal Perfect Hashing: Searching a Sorted Table with O(1) Accesses”, Proc. of the 20th Annual ACM–SIAM Symposium On Discrete Mathematics (SODA), ACM Press, 2009. TwoStepsLcpMonotoneMinimalPerfectHashFunction, PaCoTrieDistributorMonotoneMinimalPerfectHashFunction, HollowTrieMonotoneMinimalPerfectHashFunction and HollowTrieDistributorMonotoneMinimalPerfectHashFunction were introduced by the same authors in “Theory and practice of monotone minimal perfect hashing”, ACM Journal of Experimental Algorithmics, 16(3):132−144, 2011 (the class MWHCFunction implements a compacted version therein introduced of the classical 3-hypergraph-based structure).

Usage

Functions in this package implement the Object2LongFunction interface. However, the underlying machinery manipulates bit vectors only. To bring you own data into the bit vector world, each constructor requires to specify a transformation strategy that maps your objects into bit vectors. For instance, TransformationStrategies.utf16(), TransformationStrategies.prefixFreeUtf16(), TransformationStrategies.iso(), and TransformationStrategies.prefixFreeIso() are ready-made strategies that can be used with character sequences.

Note that if you plain to use monotone hashing, you must provide objects in an order such that the corresponding bit vectors are lexicographically ordered. For instance, TransformationStrategies.utf16() obtain this results by concatenating the reversed 16-bit representation of each character.

Signing functions

All functions in this package will return a value in their range for most of the keys that are not in their domain. In other words, they will produce false positives; in the few cases in which it is possible to detect a negative, you will get the default return value.

If you are interested in getting a more precise behaviour (e.g., you are migrating from the deprecated SignedMinimalPerfectHash class that was distributed with MG4J), you can sign a function, that is, you can record a signature for each key and use it to filter false positives. A signing class for character sequences is provided by the DSI utilities class ShiftAddXorSignedStringMap. By creating a function using one of the implementation provided with Sux4J and signing it using the above class, you can obtain the same functionality of the old signed classes, but you can choose the size of the signature, whether to require monotonicity, and also the space/time tradeoff of your function. Alternatively, by signing with LiterallySignedStringMap you will get a two-way function (i.e., a full StringMap implementation).