Class BroadKeyPartitioningStrategy

  • All Implemented Interfaces:
    KeyPartitioningStrategy

    public class BroadKeyPartitioningStrategy
    extends DefaultKeyPartitioningStrategy
    The BroadKeyPartitioningStrategy is a strategy that could be used in cases when the standard key association-based strategy produces very uneven partition distribution - some partitions having significantly larger amount of data than others. Another use case is a partitioned cache with relatively small number of logical groups of values, when using the standard association strategy would result in only a small number of partitions containing any data and large number of partitions being completely empty.
    While using the BroadKeyPartitioningStrategy allows to spread data much more evenly across partitions and still have scalable parallel queries (based on the KeyAssociatedFilter), it comes with a trade-off - associated entries can no longer be assume to reside in the same JVM, though with a relatively high probability they will.

    If the semantics of an application allows dynamically determining the desired span for different logically associated groups of entries, it is recommended to extend this strategy and override the getSpan() method.

    Since:
    Coherence 3.6
    Author:
    gg 2010.05.19
    • Constructor Detail

      • BroadKeyPartitioningStrategy

        public BroadKeyPartitioningStrategy​(int nSpan)
        Construct the BroadKeyPartitioningStrategy based on the specified span. Span value of zero means that this strategy will behave identically to the DefaultKeyPartitioningStrategy. Span value of N will place associated entries into no more than (N+1) distinct partitions.
        Parameters:
        nSpan - the default span value
    • Method Detail

      • getSpan

        protected int getSpan​(Object oBaseKey)
        Calculate the partition span for a logical group of keys represented by the specified "base" key. The passed in key no longer needs to be checked for the key association; in fact if there was any association, it is the one that was returned by the service's KeyAssociator.

        The default implementation just returns the constant span value, but subclasses could implement this method based on additional application level semantics or construction-time configuration to dynamically assign greater span values to larger logical groups.

        Parameters:
        oBaseKey - the "base" key in Object format
        Returns:
        the partition span for the given key