The segment extends ReentrantReadWriteLock to allow read locking on read operations. In addition to the typical CHM-like methods, this classes additionally supports replacement under a read lock - which is accomplished using an atomic CAS on the associated HashEntry.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class | Segment.HashIterator
An iterator over the HashEntry objects within this Segment. |
| Modifier and Type | Field and Description |
|---|---|
| private final RegisteredEventListeners | |
| private volatile boolean | |
| protected volatile int | count
Count of elements in the map. |
| private final DiskStorageFactory | disk
The primary substitute factory. |
| private final OperationObserver | |
| private static final float | |
| private static final Logger | |
| private static final int | |
| protected int | modCount
Mod-count used to track concurrent modifications when doing size calculations or iterating over the store. |
| private static final HashEntry | |
| private final PoolAccessor | |
| private final PoolAccessor | |
| private volatile HashEntry[] | table
Table of HashEntry linked lists, indexed by the least-significant bits of the spread-hash value. |
| private int | threshold
Size at which the next rehashing of this Segment should occur |
| Access | Constructor and Description |
|---|---|
| public | Segment(int
initial capacity of store initialCapacity, float fraction of capacity at which rehash occurs loadFactor, DiskStorageFactory primary element substitute factory primary, CacheConfiguration the cache configuration cacheConfiguration, PoolAccessor<T extends PoolParticipant> the pool tracking on-heap usage onHeapPoolAccessor, PoolAccessor<T extends PoolParticipant> the pool tracking on-disk usage onDiskPoolAccessor, RegisteredEventListeners cacheEventNotificationService, OperationObserver<CacheOperationOutcomes.Create a Segment with the given initial capacity, load-factor, primary element substitute factory, and identity element substitute factory. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | addRandomSample(ElementSubstituteFilter
filter of substitute types filter, int minimum number of elements to return sampleSize, Collection<DiskStorageFactory.collection in which to place the elements sampled,random seed for the selection seed)Select a random sample of elements generated by the supplied factory. |
| pack-priv boolean | Returns: true if a failed marker was or is still there, false otherwisethe key key, final int the key's hash hash)Will check whether a Placeholder that failed to flush to disk is lying around If so, it'll try to evict it |
| pack-priv void | |
| pack-priv void | |
| pack-priv boolean | Returns: true if there is a mapping for this keykey to check for key, int spread-hash for key hash)Return true if this segment contains a mapping for this key |
| private Element | |
| private Element | |
| private static boolean | |
| pack-priv Element | Returns: true on a successful removekey to match against key, int spread-hash for the key hash, DiskStorageFactory.optional value to match against valueRemove the matching mapping. |
| pack-priv Element | Returns: true on a successful removekey to match against key, int spread-hash for the key hash, DiskStorageFactory.optional value to match against value,whether to notify if we evict something notify)Remove the matching mapping. |
| pack-priv boolean | Returns: true if fault was installedkey to which this element (proxy) is mapped key, int the hash of the key hash, DiskStorageFactory.element (proxy) expected expect,element (proxy) to install fault,Try to atomically switch (CAS) the |
| private boolean | faultInternal(final Object key, final int hash, final DiskStorageFactory.
|
| private boolean | findAndFree(final Object key, final int hash, final DiskStorageFactory.
|
| pack-priv boolean | |
| private void | |
| private void | |
| pack-priv Element | |
| private HashEntry | |
| pack-priv Iterator | Returns: an iterator over the HashEntry objects within this Segment.Creates an iterator over the HashEntry objects within this Segment. |
| public boolean | |
| private void | |
| pack-priv Element | |
| pack-priv boolean | Returns: true if the encoded element was installedkey to map the element to key, int spread-hash for the key hash, DiskStorageFactory.encoded element to store encodedAdd the supplied pre-encoded mapping. |
| private void | |
| pack-priv Element | Returns: removed elementkey to match against key, int spread-hash for the key hash, Element optional value to match against value, ElementValueComparator the comparator to use to compare values comparator)Remove the matching mapping. |
| pack-priv boolean | Returns: true on a successful replacekey to map the element to key, int spread-hash for the key hash, Element expected element oldElement, Element element to add newElement, ElementValueComparator the comparator to use to compare values comparator)Replace the element mapped to this key only if currently mapped to the given element. |
| pack-priv Element | |
| private boolean | |
| public String | toString()
Overrides java. |
| pack-priv Object | Returns: Element or ElementSubstitutekey to lookup key, int spread-hash for the key hash)Return the unretrieved (undecoded) value for this key |
| cacheEventNotificationService | back to summary |
|---|---|
| private final RegisteredEventListeners cacheEventNotificationService | |
| cachePinned | back to summary |
|---|---|
| private volatile boolean cachePinned | |
| count | back to summary |
|---|---|
| protected volatile int count Count of elements in the map. A volatile reference is needed here for the same reasons as in the table reference. | |
| disk | back to summary |
|---|---|
| private final DiskStorageFactory disk The primary substitute factory.
This is the substitute type used to store | |
| evictionObserver | back to summary |
|---|---|
| private final OperationObserver<CacheOperationOutcomes. | |
| LOAD_FACTOR | back to summary |
|---|---|
| private static final float LOAD_FACTOR | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| MAXIMUM_CAPACITY | back to summary |
|---|---|
| private static final int MAXIMUM_CAPACITY | |
| modCount | back to summary |
|---|---|
| protected int modCount Mod-count used to track concurrent modifications when doing size calculations or iterating over the store. Note that we don't actually have any iterators yet... | |
| NULL_HASH_ENTRY | back to summary |
|---|---|
| private static final HashEntry NULL_HASH_ENTRY | |
| onDiskPoolAccessor | back to summary |
|---|---|
| private final PoolAccessor<T extends PoolParticipant> onDiskPoolAccessor | |
| onHeapPoolAccessor | back to summary |
|---|---|
| private final PoolAccessor<T extends PoolParticipant> onHeapPoolAccessor | |
| table | back to summary |
|---|---|
| private volatile HashEntry[] table Table of HashEntry linked lists, indexed by the least-significant bits of the spread-hash value. A volatile reference is needed to ensure the visibility of table changes made during rehash operations to size operations. Key operations are done under read-locks so there is no need for volatility in that regard. Hence if we switched to read-locked size operations, we wouldn't need a volatile reference here. | |
| threshold | back to summary |
|---|---|
| private int threshold Size at which the next rehashing of this Segment should occur | |
| Segment | back to summary |
|---|---|
| public Segment(int initialCapacity, float loadFactor, DiskStorageFactory primary, CacheConfiguration cacheConfiguration, PoolAccessor<T extends PoolParticipant> onHeapPoolAccessor, PoolAccessor<T extends PoolParticipant> onDiskPoolAccessor, RegisteredEventListeners cacheEventNotificationService, OperationObserver<CacheOperationOutcomes. Create a Segment with the given initial capacity, load-factor, primary element substitute factory, and identity element substitute factory.
An identity element substitute factory is specified at construction time because only one subclass of IdentityElementProxyFactory
can be used with a Segment. Without this requirement the mapping between bare
If a
| |
| addRandomSample | back to summary |
|---|---|
| pack-priv void addRandomSample(ElementSubstituteFilter filter, int sampleSize, Collection<DiskStorageFactory. Select a random sample of elements generated by the supplied factory.
| |
| cleanUpFailedMarker | back to summary |
|---|---|
| pack-priv boolean cleanUpFailedMarker(final Serializable key, final int hash) Will check whether a Placeholder that failed to flush to disk is lying around If so, it'll try to evict it
| |
| clear | back to summary |
|---|---|
| pack-priv void clear() Removes all mappings from this segment. | |
| clearFaultedBit | back to summary |
|---|---|
| pack-priv void clearFaultedBit() Clears the faulted but on all entries | |
| containsKey | back to summary |
|---|---|
| pack-priv boolean containsKey(Object key, int hash) Return true if this segment contains a mapping for this key
| |
| decode | back to summary |
|---|---|
| private Element decode(Object object) Decode the possible DiskSubstitute | |
| decodeHit | back to summary |
|---|---|
| private Element decodeHit(Object object) Decode the possible DiskSubstitute, updating the statistics | |
| determineCachePinned | back to summary |
|---|---|
| private static boolean determineCachePinned(CacheConfiguration cacheConfiguration) | |
| evict | back to summary |
|---|---|
| pack-priv Element evict(Object key, int hash, DiskStorageFactory. Remove the matching mapping. Unlike the
| |
| evict | back to summary |
|---|---|
| pack-priv Element evict(Object key, int hash, DiskStorageFactory. Remove the matching mapping. Unlike the
| |
| fault | back to summary |
|---|---|
| pack-priv boolean fault(Object key, int hash, DiskStorageFactory. Try to atomically switch (CAS) the
A successful switch will return
| |
| faultInternal | back to summary |
|---|---|
| private boolean faultInternal(final Object key, final int hash, final DiskStorageFactory. | |
| findAndFree | back to summary |
|---|---|
| private boolean findAndFree(final Object key, final int hash, final DiskStorageFactory. | |
| flush | back to summary |
|---|---|
| pack-priv boolean flush(final Object key, final int hash, final Element element) Marks an entry as flushable to disk (i.e. not faulted in higher tiers) Also updates the access stats | |
| free | back to summary |
|---|---|
| private void free(Object object) Free the DiskSubstitute
| |
| free | back to summary |
|---|---|
| private void free(Object object, boolean faultFailure) Free the DiskSubstitute indicating if it could not be faulted
| |
| get | back to summary |
|---|---|
| pack-priv Element get(Object key, int hash, final boolean markFaulted) Get the element mapped to this key (or null if there is no mapping for this key) | |
| getFirst | back to summary |
|---|---|
| private HashEntry getFirst(int hash) | |
| hashIterator | back to summary |
|---|---|
| pack-priv Iterator Creates an iterator over the HashEntry objects within this Segment. | |
| isFaulted | back to summary |
|---|---|
| public boolean isFaulted(final int hash, final Object key) Verifies if the mapping for a key is marked as faulted
| |
| notifyEviction | back to summary |
|---|---|
| private void notifyEviction(final Element evicted) | |
| put | back to summary |
|---|---|
| pack-priv Element put(Object key, int hash, Element element, boolean onlyIfAbsent, boolean faulted) Add the supplied mapping.
The supplied element is substituted using the primary element proxy factory
before being stored in the cache. If | |
| putRawIfAbsent | back to summary |
|---|---|
| pack-priv boolean putRawIfAbsent(Object key, int hash, DiskStorageFactory. Add the supplied pre-encoded mapping. The supplied encoded element is directly inserted into the segment if there is no other mapping for this key.
| |
| rehash | back to summary |
|---|---|
| private void rehash() | |
| remove | back to summary |
|---|---|
| pack-priv Element remove(Object key, int hash, Element value, ElementValueComparator comparator) Remove the matching mapping.
If
| |
| replace | back to summary |
|---|---|
| pack-priv boolean replace(Object key, int hash, Element oldElement, Element newElement, ElementValueComparator comparator) Replace the element mapped to this key only if currently mapped to the given element.
| |
| replace | back to summary |
|---|---|
| pack-priv Element replace(Object key, int hash, Element newElement) Replace the entry for this key only if currently mapped to some element. | |
| returnSafeDeprecated | back to summary |
|---|---|
| private boolean returnSafeDeprecated(final Object key, final int hash, final Element element)
Deprecated
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string identifying this lock, as well as its lock state.
The state, in brackets, includes the String | |
| unretrievedGet | back to summary |
|---|---|
| pack-priv Object unretrievedGet(Object key, int hash) Return the unretrieved (undecoded) value for this key | |
| Modifier and Type | Field and Description |
|---|---|
| private HashEntry | |
| private HashEntry | |
| private int | |
| private final HashEntry[] |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public boolean | |
| public HashEntry | |
| public void | remove()
Overrides default java. |
| lastReturned | back to summary |
|---|---|
| private HashEntry lastReturned | |
| nextEntry | back to summary |
|---|---|
| private HashEntry nextEntry | |
| nextTableIndex | back to summary |
|---|---|
| private int nextTableIndex | |
| ourTable | back to summary |
|---|---|
| private final HashEntry[] ourTable | |
| HashIterator | back to summary |
|---|---|
| private HashIterator() | |
| advance | back to summary |
|---|---|
| private void advance() | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public HashEntry next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the | |