Enum Class ConcurrencyStrategy

java.lang.Object
java.lang.Enum<ConcurrencyStrategy>
org.forgerock.bloomfilter.ConcurrencyStrategy
All Implemented Interfaces:
Serializable, Comparable<ConcurrencyStrategy>, java.lang.constant.Constable

public enum ConcurrencyStrategy extends Enum<ConcurrencyStrategy>
Strategy that determines how thread-safety of bloom filters should be managed. Different strategies have different trade-offs in terms of memory usage and read or write performance.
  • Enum Constant Details

    • COPY_ON_WRITE

      public static final ConcurrencyStrategy COPY_ON_WRITE
      Treats Bloom Filters as effectively immutable objects and creates a copy when applying updates before atomically swapping with the original. This strategy optimises read (mightContain) performance at the cost of significantly more expensive write (add/addAll) times and increased garbage collection pressure due to the temporary copies that are created. This is the recommended strategy if read performance is critical. Writing batching can be used to mitigate the poor write performance (even exceeding the synchronized strategy) and somewhat mitigate the additional garbage creation.
    • SYNCHRONIZED

      public static final ConcurrencyStrategy SYNCHRONIZED
      Fully synchronizes all accesses to the bloom filter. For scalable and rolling bloom filters, each bucket in the chain is synchronized individually, allowing a finer level of locking. This strategy provides a reasonable compromise between read and write performance when read performance is not critical. Additionally, this strategy creates significantly less garbage collection pressure than the copy-on-write strategy as it modifies bloom filters in-place.
    • ATOMIC

      public static final ConcurrencyStrategy ATOMIC
      Uses atomic compare-and-set (CAS) instructions to implement BloomFilter operations over AtomicLongArrays. This strategy offers excellent performance for reads and writes with less garbage collection pressure than the Copy on Write strategy and comparable performance to that strategy even with write batching.
  • Method Details

    • values

      public static ConcurrencyStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ConcurrencyStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null