You can codify a partitioning scheme for instances of a partitioned class by defining a partition method. Partition methods have two main usage contexts, as follows.
Enabling an application to determine the partition in which an object is stored when the transaction that created it commits.
Converting a non-partitioned database file containing instances of a single class to partitioned format. (This is achieved by executing a
In the first case, you can reimplement the
A partition method enables you to implement partitioning algorithms based on the values of one or more attributes of the object being created.
Two common single-attribute partitioning strategies are:
List (or value) partitioning
Range partitioning
With list partitioning, there is a one-to-one correspondence between an attribute value and a partition. An example might be partitioning sales by region, where the region attribute determines the partition.
With range partitioning, a range of values are mapped to a partition. A simple example might be to use the month part of a date or timestamp attribute to map sales data to one of 12 monthly sales partitions.
The partition method is evaluated during the execution of the commitTransaction instruction for each object created in the transaction with a zero partition index. When the returned value is outside the partition modulus range, an exception is raised.
Changes to the property values used in a partition method that occur after the creating transaction commits do not trigger the partition method or cause the object to be relocated.
For more details about partition methods, see "partitionMethod Option", in Chapter 1.