Skip navigation links

Overview | Package | Class | Tree | Index | Help
| Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.net.partition
Class BroadKeyPartitioningStrategy

`java.lang.Object
com.tangosol.util.Base
com.tangosol.util.BitHelper
com.tangosol.util.ExternalizableHelper
com.tangosol.net.partition.DefaultKeyPartitioningStrategy
com.tangosol.net.partition.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 probaility they will. <p/> If an application semantic allows to dynamically determine 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

Field Summary

Fields inherited from class com.tangosol.net.partition.DefaultKeyPartitioningStrategy
`m_service`

Constructor Summary
`BroadKeyPartitioningStrategy(int nSpan)` Construct the BroadKeyPartitioningStrategy based on the specified span.

Method Summary
`PartitionSet` | `getAssociatedPartitions(Object oKey)` Determine the set of partitions that all keys associated with the specified key are assigned to. Most commonly, this method returns a partition set containing a single partition returned by the `getKeyPartition` method.
`int` | `getKeyPartition(Object oKey)` Determine the partition to which a particular key should be assigned. <p/> In general, the implementations are expected to respect the associations provided by the service's KeyAssociator in such a way that keys that return the same `associated key` would be assigned to the same partition. <p/> The resulting partition must be in the range `[0..N-1]`, where `N` is the value returned from `PartitionedService.getPartitionCount()`.
`protected int` | `getSpan(Object oBaseKey)` Caculate the partition span for a logical group of keys represented by the speficified "base" key.
`void` | `init(PartitionedService service)` Initialize the KeyPartitioningStrategy and bind it to the specified PartitionedService.

Methods inherited from class com.tangosol.net.partition.DefaultKeyPartitioningStrategy
`calculateKeyPartition`

Methods inherited from class com.tangosol.util.BitHelper
`countBits, countBits, countBits, indexOfLSB, indexOfLSB, indexOfLSB, indexOfMSB, indexOfMSB, indexOfMSB, rotateLeft, rotateLeft, rotateLeft, rotateRight, rotateRight, rotateRight, toBitString, toBitString, toBitString`

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

### init

    public void init(PartitionedService service)

  Initialize the KeyPartitioningStrategy and bind it to the specified PartitionedService.
  Specified by:
    `init` in interface `KeyPartitioningStrategy`
  Overrides:
    `init` in class `DefaultKeyPartitioningStrategy`
  Parameters:
    `service` - the PartitionedService that this strategy is being bound to

### getKeyPartition

    public int getKeyPartition(Object oKey)

  Determine the partition to which a particular key should be assigned. <p/> In general, the implementations are expected to respect the associations provided by the service's KeyAssociator in such a way that keys that return the same `associated key` would be assigned to the same partition. <p/> The resulting partition must be in the range `[0..N-1]`, where `N` is the value returned from `PartitionedService.getPartitionCount()`.
  Specified by:
    `getKeyPartition` in interface `KeyPartitioningStrategy`
  Overrides:
    `getKeyPartition` in class `DefaultKeyPartitioningStrategy`
  Parameters:
    `oKey` - a key in its Object form
  Returns:
    the partition ID that the specified key is assigned to
  See Also:
    `PartitionAssignmentStrategy.getPartitionOwner(int)`

### getAssociatedPartitions

    public PartitionSet getAssociatedPartitions(Object oKey)

  Determine the set of partitions that all keys associated with the specified key are assigned to. Most commonly, this method returns a partition set containing a single partition returned by the `getKeyPartition` method.
  Specified by:
    `getAssociatedPartitions` in interface `KeyPartitioningStrategy`
  Overrides:
    `getAssociatedPartitions` in class `DefaultKeyPartitioningStrategy`
  Parameters:
    `oKey` - a key in its Object form
  Returns:
    the PartitionSet associated with the specified key

### getSpan

    protected int getSpan(Object oBaseKey)

  Caculate the partition span for a logical group of keys represented by the speficified "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`. <p/> The default implementation just returns the constant span value, but subclasses could implement this method based on additional application level sematics 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

Skip navigation links

Overview | Package | Class | Tree | Index | Help
| Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.