it.unimi.dsi.sux4j.mph
Class HollowTrieDistributor<T>

java.lang.Object
  extended by it.unimi.dsi.fastutil.objects.AbstractObject2LongFunction<T>
      extended by it.unimi.dsi.sux4j.mph.HollowTrieDistributor<T>
All Implemented Interfaces:
Function<T,Long>, Object2LongFunction<T>, Serializable

public class HollowTrieDistributor<T>
extends AbstractObject2LongFunction<T>

A distributor based on a hollow trie.

Implementation details

This class implements a distributor on top of a hollow trie. First, a compacted trie is built from the delimiter set. Then, for each key we compute the node of the trie in which the bucket of the key is established. This gives us, for each node of the trie, a set of paths to which we must associate an action (exit on the left, go through, exit on the right). Overall, the number of such paths is equal to the number of keys plus the number of delimiters, so the mapping from each pair node/path to the respective action takes linear space. Now, from the compacted trie we just retain a hollow trie, as the path-length information is sufficient to rebuild the keys of the above mapping. By sizing the bucket size around the logarithm of the average length, we obtain a distributor that occupies linear space.

See Also:
Serialized Form

Field Summary
protected  double meanSkipLength
          The average skip length in bits (actually, the average length in bits of a skip length increased by one).
 
Fields inherited from class it.unimi.dsi.fastutil.objects.AbstractObject2LongFunction
defRetValue
 
Constructor Summary
HollowTrieDistributor(Iterable<? extends T> elements, int log2BucketSize, TransformationStrategy<? super T> transformationStrategy)
          Creates a partial compacted trie using given elements, bucket size and transformation strategy.
HollowTrieDistributor(Iterable<? extends T> elements, int log2BucketSize, TransformationStrategy<? super T> transformationStrategy, File tempDir)
          Creates a hollow trie distributor.
 
Method Summary
 double bitsPerSkip()
           
 boolean containsKey(Object o)
           
 long getLong(Object o)
           
 long numBits()
           
 int size()
           
 
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractObject2LongFunction
clear, defaultReturnValue, defaultReturnValue, get, put, put, remove, removeLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

meanSkipLength

protected double meanSkipLength
The average skip length in bits (actually, the average length in bits of a skip length increased by one).

Constructor Detail

HollowTrieDistributor

public HollowTrieDistributor(Iterable<? extends T> elements,
                             int log2BucketSize,
                             TransformationStrategy<? super T> transformationStrategy)
                      throws IOException
Creates a partial compacted trie using given elements, bucket size and transformation strategy.

Parameters:
elements - the elements among which the trie must be able to rank.
log2BucketSize - the logarithm of the size of a bucket.
transformationStrategy - a transformation strategy that must turn the elements in elements into a list of distinct, lexicographically increasing (in iteration order) bit vectors.
Throws:
IOException

HollowTrieDistributor

public HollowTrieDistributor(Iterable<? extends T> elements,
                             int log2BucketSize,
                             TransformationStrategy<? super T> transformationStrategy,
                             File tempDir)
                      throws IOException
Creates a hollow trie distributor.

Parameters:
elements - the elements among which the trie must be able to rank.
log2BucketSize - the logarithm of the size of a bucket.
transformationStrategy - a transformation strategy that must turn the elements in elements into a list of distinct, lexicographically increasing (in iteration order) bit vectors.
tempDir - the directory where temporary files will be created, or for the default directory.
Throws:
IOException
Method Detail

getLong

public long getLong(Object o)

numBits

public long numBits()

containsKey

public boolean containsKey(Object o)

size

public int size()

bitsPerSkip

public double bitsPerSkip()