Package org.forgerock.bloomfilter
Enum ConcurrencyStrategy
- java.lang.Object
-
- java.lang.Enum<ConcurrencyStrategy>
-
- org.forgerock.bloomfilter.ConcurrencyStrategy
-
- All Implemented Interfaces:
Serializable
,Comparable<ConcurrencyStrategy>
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 Summary
Enum Constants Enum Constant Description ATOMIC
Uses atomic compare-and-set (CAS) instructions to implement BloomFilter operations over AtomicLongArrays.COPY_ON_WRITE
Treats Bloom Filters as effectively immutable objects and creates a copy when applying updates before atomically swapping with the original.SYNCHRONIZED
Fully synchronizes all accesses to the bloom filter.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ConcurrencyStrategy
valueOf(String name)
Returns the enum constant of this type with the specified name.static ConcurrencyStrategy[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
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 Detail
-
values
public static ConcurrencyStrategy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ConcurrencyStrategy c : ConcurrencyStrategy.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ConcurrencyStrategy valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
-