- java.lang.Object
-
- com.pervasive.datarush.tokens.record.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RecordToIDMap.ReadAccessor
An accessor for performing lookup operations.static class
RecordToIDMap.WriteAccessor
An accessor for building the map.
-
Constructor Summary
Constructors Constructor Description RecordToIDMap(RecordTokenType keyType, int initialCapacity)
Create a new RecordToIDMap
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RecordTokenType
getKeyType()
Returns the type of keys contained within this map.RecordValuedIterator
newIterator()
Creates an iterator to iterate over keys within the map.RecordToIDMap.WriteAccessor
newLRUWriteAccessor(RecordValued value, int maxSize)
Creates an accessor for building the map.RecordToIDMap.ReadAccessor
newReadAccessor(RecordValued value)
Creates an accessor for performing lookup operations.RecordToIDMap.WriteAccessor
newWriteAccessor(RecordValued value)
Creates an accessor for building the map.int
size()
Creates the number of entries in the map.
-
-
-
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 singleRecordToIDMap
. However, each thread must have its ownReadAccessor
instance.- Parameters:
value
- The record valued object for which we are performing lookup operations. Typically will be aRecordInput
.- 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 singleRecordToIDMap
.- Parameters:
value
- The record valued object from which we are building the map. Typically will be aRecordInput
.- 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 singleRecordToIDMap
.- Parameters:
value
- The record valued object from which we are building the map. Typically will be aRecordInput
.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, theabsolute 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.
-
-