VMware Tanzu GemFire Native .NET Reference 10.3.0
Apache::Geode::Client::IPartitionResolver< TKey, TValue > Interface Template Reference

Implementers of interface

PartitionResolver

enable custom partitioning on the

PartitionedRegion

. More...

#include <IPartitionResolver.hpp>

Inherited by Apache::Geode::Client::IFixedPartitionResolver< TKey, TValue >.

Public Member Functions

String ^ GetName ()
 Returns the name of the PartitionResolver. More...
 
Object ^ GetRoutingObject (EntryEvent< TKey, TValue >^ key)
 return object associated with entry event which allows the Partitioned Region to store associated data together. More...
 

Detailed Description

template<class TKey, class TValue>
interface Apache::Geode::Client::IPartitionResolver< TKey, TValue >

Implementers of interface

PartitionResolver

enable custom partitioning on the

PartitionedRegion

.

  1. The Key class or callback arg can implement PartitionResolver interface to enable custom partitioning OR
  2. Configure your own PartitionResolver class in partition attributes (For instance when the Key is a primitive type or String) Implement the appropriate equals - For all implementations, you need to be sure to code the class equals method so it properly verifies equality for the PartitionResolver implementation. This might mean verifying that class names are the same or that the returned routing objects are the same etc.. When you initiate the partitioned region on multiple nodes, Geode uses the equals method to ensure you are using the same PartitionResolver implementation for all of the nodes for the region. Geode uses the routing object's hashCode to determine where the data is being managed. Say, for example, you want to colocate all Trades by month and year.The key is implemented by TradeKey class which also implements the PartitionResolver interface. public class TradeKey implements PartitionResolver {
    &nbsp &nbsp private String tradeID;
    &nbsp &nbsp private Month month ;
    &nbsp &nbsp private Year year ;

&nbsp &nbsp public TradingKey(){ }
&nbsp &nbsp public TradingKey(Month month, Year year){
&nbsp &nbsp &nbsp &nbsp this.month = month;
&nbsp &nbsp &nbsp &nbsp this.year = year;
&nbsp &nbsp }
&nbsp &nbsp public Serializable getRoutingObject(EntryOperation key){
&nbsp &nbsp &nbsp &nbsp return this.month + this.year;
&nbsp &nbsp }
}

In the example above, all trade entries with the same month and year are guaranteed to be colocated.

See also
RegionAttributesFactory.SetPartitionResolver, RegionAttributes.PartitionResolver

Member Function Documentation

◆ GetName()

template<class TKey , class TValue >
String ^ Apache::Geode::Client::IPartitionResolver< TKey, TValue >::GetName ( )

Returns the name of the PartitionResolver.

This function does not throw any exception.

Returns
the name of the PartitionResolver

◆ GetRoutingObject()

template<class TKey , class TValue >
Object ^ Apache::Geode::Client::IPartitionResolver< TKey, TValue >::GetRoutingObject ( EntryEvent< TKey, TValue >^  key)

return object associated with entry event which allows the Partitioned Region to store associated data together.

throws RuntimeException - any exception thrown will terminate the operation and the exception will be passed to the calling thread.

Parameters
keykey the detail of the entry event.

Apache Geode C++ Cache .NET API Documentation