Class RecordToIDMap


  • public final class RecordToIDMap
    extends Object
    Provides a mapping between records and integer ids. The keys are maintained in a space-efficient data structure in order to minimize the per-entry object overhead. By providing a mapping from record to IDs, this can be used as a building-block for a number of data structures and operator. The ids returned are from a zero-based, strictly monotonically increasing sequence such that they can be used as indexes into arrays that wish to associate additional information with the keys.
    • Constructor Detail

      • RecordToIDMap

        public RecordToIDMap​(RecordTokenType keyType,
                             int initialCapacity)
        Create a new RecordToIDMap
        Parameters:
        keyType - The record token type that corresponds to the keys that we are selecting. Must be a subset of values from the record input from which we are building/looking up.
        initialCapacity - The initial capacity ( in records ) to use for the internal data structures of this mapping.
    • Method Detail

      • newReadAccessor

        public RecordToIDMap.ReadAccessor newReadAccessor​(RecordValued value)
        Creates an accessor for performing lookup operations.

        NOTE: From a thread safety standpoint, it is safe to have multiple ReadAccessors in different threads that reference a single RecordToIDMap. However, each thread must have its own ReadAccessor instance.

        Parameters:
        value - The record valued object for which we are performing lookup operations. Typically will be a RecordInput.
        Returns:
        the newly-created ReadAccessor
      • getKeyType

        public RecordTokenType getKeyType()
        Returns the type of keys contained within this map.
        Returns:
        the type of keys contained within this map.
      • newWriteAccessor

        public RecordToIDMap.WriteAccessor newWriteAccessor​(RecordValued value)
        Creates an accessor for building the map.

        NOTE: From a thread safety standpoint, it is unsafe to have multiple WriteAccessors in different threads that reference a single RecordToIDMap.

        Parameters:
        value - The record valued object from which we are building the map. Typically will be a RecordInput.
        Returns:
        the newly-created WriteAccessor
      • newLRUWriteAccessor

        public RecordToIDMap.WriteAccessor newLRUWriteAccessor​(RecordValued value,
                                                               int maxSize)
        Creates an accessor for building the map.

        NOTE: From a thread safety standpoint, it is unsafe to have multiple WriteAccessors in different threads that reference a single RecordToIDMap.

        Parameters:
        value - The record valued object from which we are building the map. Typically will be a RecordInput.
        maxSize - The maximum number of items to keep in the map
        Returns:
        the newly-created WriteAccessor
      • newIterator

        public RecordValuedIterator newIterator()
        Creates an iterator to iterate over keys within the map. Keys will be returned in order by their associated ID. Moreover, the absolute index of the iterator will be equivalent to the ID.
        Returns:
        an iterator to iterate over keys within the map.
      • size

        public int size()
        Creates the number of entries in the map.
        Returns:
        the number of entries in the map.