org.apache.spark.util.collection

OpenHashSet

class OpenHashSet[T] extends Serializable

A simple, fast hash set optimized for non-null insertion-only use case, where keys are never removed.

The underlying implementation uses Scala compiler's specialization to generate optimized storage for two primitive types (Long and Int). It is much faster than Java's standard HashSet while incurring much less memory overhead. This can serve as building blocks for higher level data structures such as an optimized HashMap.

This OpenHashSet is designed to serve as building blocks for higher level data structures such as an optimized hash map. Compared with standard hash set implementations, this class provides its various callbacks interfaces (e.g. allocateFunc, moveFunc) and interfaces to retrieve the position of a key in the underlying array.

It uses quadratic probing with a power-of-2 hash table size, which is guaranteed to explore all spaces for each key (see http://en.wikipedia.org/wiki/Quadratic_probing).

Annotations
@Private()
Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. OpenHashSet
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new OpenHashSet()(implicit arg0: ClassTag[T])

  2. new OpenHashSet(initialCapacity: Int)(implicit arg0: ClassTag[T])

  3. new OpenHashSet(initialCapacity: Int, loadFactor: Double)(implicit arg0: ClassTag[T])

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. var _bitset: BitSet

    Attributes
    protected
  7. var _capacity: Int

    Attributes
    protected
  8. var _data: Array[T]

    Attributes
    protected
  9. var _growThreshold: Int

    Attributes
    protected
  10. var _mask: Int

    Attributes
    protected
  11. var _size: Int

    Attributes
    protected
  12. def add(k: T): Unit

    Add an element to the set.

    Add an element to the set. If the set is over capacity after the insertion, grow the set and rehash all elements.

  13. def addWithoutResize(k: T): Int

    Add an element to the set.

    Add an element to the set. This one differs from add in that it doesn't trigger rehashing. The caller is responsible for calling rehashIfNeeded.

    Use (retval & POSITION_MASK) to get the actual position, and (retval & NONEXISTENCE_MASK) == 0 for prior existence.

    returns

    The position where the key is placed, plus the highest order bit is set if the key does not exists previously.

  14. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  15. def capacity: Int

    The capacity of the set (i.

    The capacity of the set (i.e. size of the underlying array).

  16. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  17. def contains(k: T): Boolean

    Return true if this set contains the specified element.

  18. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  20. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. def getBitSet: BitSet

  22. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  23. def getPos(k: T): Int

    Return the position of the element in the underlying array, or INVALID_POS if it is not found.

  24. def getValue(pos: Int): T

    Return the value at the specified position.

  25. def getValueSafe(pos: Int): T

    Return the value at the specified position.

  26. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  27. val hasher: Hasher[T]

    Attributes
    protected
  28. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  29. def iterator: Iterator[T]

  30. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  31. def nextPos(fromPos: Int): Int

    Return the next position with an element stored, starting from the given position inclusively.

  32. final def notify(): Unit

    Definition Classes
    AnyRef
  33. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  34. def rehashIfNeeded(k: T, allocateFunc: (Int) ⇒ Unit, moveFunc: (Int, Int) ⇒ Unit): Unit

    Rehash the set if it is overloaded.

    Rehash the set if it is overloaded.

    k

    A parameter unused in the function, but to force the Scala compiler to specialize this method.

    allocateFunc

    Callback invoked when we are allocating a new, larger array.

    moveFunc

    Callback invoked when we move the key from one position (in the old data array) to a new position (in the new data array).

  35. def size: Int

    Number of elements in the set.

  36. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  37. def toString(): String

    Definition Classes
    AnyRef → Any
  38. def union(other: OpenHashSet[T]): OpenHashSet[T]

  39. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped