Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
3.3. Configure the Grouping API
- Enable groups using either the declarative or programmatic method.
- Specify either an intrinsic or extrinsic group. For more information about these group types, see Section 3.1, “Grouping API Operations”
- Register all specified groupers.
3.3.1. Enable Groups Link kopierenLink in die Zwischenablage kopiert!
Example 3.2. Declaratively Enable Groups
<clustering> <hash> <groups enabled="true" /> </hash> </clustering>
<clustering>
<hash>
<groups enabled="true" />
</hash>
</clustering>
Example 3.3. Programmatically Enable Groups
Configuration c = new ConfigurationBuilder().clustering().hash().groups().enabled().build();
Configuration c = new ConfigurationBuilder().clustering().hash().groups().enabled().build();
3.3.2. Specify an Intrinsic Group Link kopierenLink in die Zwischenablage kopiert!
- the key class definition can be altered, that is if it is not part of an unmodifiable library.
- if the key class is not concerned with the determination of a key/value pair group.
@Group
annotation in the relevant method to specify an intrinsic group. The group must always be a String, as illustrated in the example:
Example 3.4. Specifying an Intrinsic Group Example
3.3.3. Specify an Extrinsic Group Link kopierenLink in die Zwischenablage kopiert!
- the key class definition cannot be altered, that is if it is part of an unmodifiable library.
- if the key class is concerned with the determination of a key/value pair group.
Grouper
interface. This interface uses the computeGroup
method to return the group.
Grouper
interface acts as an interceptor by passing the computed value to computeGroup
. If the @Group
annotation is used, the group using it is passed to the first Grouper
. As a result, using an intrinsic group provides even greater control.
Example 3.5. Specifying an Extrinsic Group Example
Grouper
that uses the key class to extract the group from a key using a pattern. Any group information specified on the key class is ignored in such a situation.
3.3.4. Register Groupers Link kopierenLink in die Zwischenablage kopiert!
Example 3.6. Declaratively Register a Grouper
Example 3.7. Programmatically Register a Grouper
Configuration c = new ConfigurationBuilder().clustering().hash().groups().addGrouper(new KXGrouper()).enabled().build();
Configuration c = new ConfigurationBuilder().clustering().hash().groups().addGrouper(new KXGrouper()).enabled().build();