com.netflix.nfgraph.compressed
Class HashSetOrdinalSet

java.lang.Object
  extended by com.netflix.nfgraph.OrdinalSet
      extended by com.netflix.nfgraph.compressed.HashSetOrdinalSet

public class HashSetOrdinalSet
extends OrdinalSet

An implementation of OrdinalSet, returned for connections represented as variable-byte hashed integer arrays in an NFCompressedGraph.

A variable-byte hashed integer array representation contains between one and five bytes per connection. The ordinal for each connection is hashed into a byte array, then represented as a variant on the variable-byte integers used in the CompactOrdinalSet.

The byte array can be thought of as a open-addressed hash table, with each byte representing a single bucket. Because values may be represented in more than one byte, single values may spill over into multiple buckets. The beginning of the value is indicated by an unset sign bit, and will be located at or after the bucket to which it is hashed. If the value's first bit is not located at the hashed position, it will be located in a position after the bucket with no empty buckets in between.

This implementation provides O(1) time for contains(), but is not as memory-efficient as a CompactOrdinalSet.

This representation for a connection set can be configured for an NFPropertySpec using NFPropertySpec.HASH.

See Also:
Compact Representations

Field Summary
 
Fields inherited from class com.netflix.nfgraph.OrdinalSet
EMPTY_SET
 
Constructor Summary
HashSetOrdinalSet(com.netflix.nfgraph.util.ByteArrayReader reader)
           
 
Method Summary
 boolean contains(int value)
          Returns true when the specified value is contained in this set.
 OrdinalIterator iterator()
           
 int size()
           
 
Methods inherited from class com.netflix.nfgraph.OrdinalSet
asArray, containsAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashSetOrdinalSet

public HashSetOrdinalSet(com.netflix.nfgraph.util.ByteArrayReader reader)
Method Detail

iterator

public OrdinalIterator iterator()
Specified by:
iterator in class OrdinalSet
Returns:
an OrdinalIterator over this set.

contains

public boolean contains(int value)
Description copied from class: OrdinalSet
Returns true when the specified value is contained in this set. Depending on the implementation, this operation will have one of two performance characteristics:

O(1) for HashSetOrdinalSet and BitSetOrdinalSet
O(n) for CompactOrdinalSet and NFBuildGraphOrdinalSet

Specified by:
contains in class OrdinalSet

size

public int size()
Specified by:
size in class OrdinalSet
Returns:
the number of ordinals in this set.