com.hazelcast.util

## Class SampleableConcurrentHashMap<K,V>

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - com.hazelcast.util.ConcurrentReferenceHashMap<K,V>
    - - com.hazelcast.util.SampleableConcurrentHashMap<K,V>

- Type Parameters:
    `K` - Type of the key
    `V` - Type of the value
  All Implemented Interfaces:
    IConcurrentMap<K,V>, Serializable, ConcurrentMap<K,V>, Map<K,V>

      public class SampleableConcurrentHashMap<K,V>
      extends ConcurrentReferenceHashMap<K,V>

  ConcurrentHashMap to extend iterator capability.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SampleableConcurrentHashMap.SamplingEntry<K,V>` Entry to define keys and values for sampling.

    - ### Nested classes/interfaces inherited from class com.hazelcast.util.ConcurrentReferenceHashMap

      `ConcurrentReferenceHashMap.Option, ConcurrentReferenceHashMap.ReferenceType, ConcurrentReferenceHashMap.SimpleEntry<K,V>, ConcurrentReferenceHashMap.WriteThroughEntry`

    - ### Nested classes/interfaces inherited from class java.util.AbstractMap

      `AbstractMap.SimpleImmutableEntry<K,V>`

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SampleableConcurrentHashMap(int initialCapacity)`
    `SampleableConcurrentHashMap(int initialCapacity, ConcurrentReferenceHashMap.ReferenceType keyType, ConcurrentReferenceHashMap.ReferenceType valueType)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected <E extends SampleableConcurrentHashMap.SamplingEntry> E` | `createSamplingEntry(K key, V value)`
    `int` | `fetchEntries(int tableIndex, int size, List<Map.Entry<K,V>> entries)` Fetches entries from given `tableIndex` as `size` and puts them into `entries` list.
    `int` | `fetchKeys(int tableIndex, int size, List<K> keys)` Fetches keys from given `tableIndex` as `size` and puts them into `keys` list.
    `<E extends SampleableConcurrentHashMap.SamplingEntry> Iterable<E>` | `getRandomSamples(int sampleCount)` Gets and returns samples as `sampleCount`.
    `protected boolean` | `isValidForFetching(V value, long now)`
    `protected boolean` | `isValidForSampling(K key, V value)`

    - ### Methods inherited from class com.hazelcast.util.ConcurrentReferenceHashMap

      `applyIfAbsent, applyIfPresent, clear, contains, containsKey, containsValue, elements, entrySet, get, isEmpty, keys, keySet, purgeStaleEntries, put, putAll, putIfAbsent, remove, remove, replace, replace, size, values`

    - ### Methods inherited from class java.util.AbstractMap

      `clone, equals, hashCode, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.concurrent.ConcurrentMap

      `compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll`

    - ### Methods inherited from interface java.util.Map

      `equals, hashCode`

- - ### Constructor Detail

    - #### SampleableConcurrentHashMap

          public SampleableConcurrentHashMap(int initialCapacity)

    - #### SampleableConcurrentHashMap

          public SampleableConcurrentHashMap(int initialCapacity,
                                             ConcurrentReferenceHashMap.ReferenceType keyType,
                                             ConcurrentReferenceHashMap.ReferenceType valueType)

  - ### Method Detail

    - #### fetchKeys

          public int fetchKeys(int tableIndex,
                               int size,
                               List<K> keys)

      Fetches keys from given `tableIndex` as `size` and puts them into `keys` list.
      Parameters:
        `tableIndex` - Index (checkpoint) for starting point of fetch operation
        `size` - Count of how many keys will be fetched
        `keys` - List that fetched keys will be put into
      Returns:
        the next index (checkpoint) for later fetches

    - #### fetchEntries

          public int fetchEntries(int tableIndex,
                                  int size,
                                  List<Map.Entry<K,V>> entries)

      Fetches entries from given `tableIndex` as `size` and puts them into `entries` list.
      Parameters:
        `tableIndex` - Index (checkpoint) for starting point of fetch operation
        `size` - Count of how many entries will be fetched
        `entries` - List that fetched entries will be put into
      Returns:
        the next index (checkpoint) for later fetches

    - #### isValidForFetching

          protected boolean isValidForFetching(V value,
                                               long now)

    - #### createSamplingEntry

          protected <E extends SampleableConcurrentHashMap.SamplingEntry> E createSamplingEntry(K key,
                                                                                                V value)

    - #### getRandomSamples

          public <E extends SampleableConcurrentHashMap.SamplingEntry> Iterable<E> getRandomSamples(int sampleCount)

      Gets and returns samples as `sampleCount`.
      Parameters:
        `sampleCount` - Count of samples
      Returns:
        the sampled `SampleableConcurrentHashMap.SamplingEntry` list

    - #### isValidForSampling

          protected boolean isValidForSampling(K key,
                                               V value)

Copyright © 2019. All rights reserved.