Using the class APT_HashPartitioner
The class APT_HashPartitioner partitions a data set by performing a hashing function on one or more fields of a record.
APT_HashPartitioner uses a dynamic interface schema that allows you to specify one or more numeric or string fields as input to the partitioner.
The following figure shows an operator using APT_HashPartitioner:

APT_HashPartitioner();
APT_HashPartitioner(const APT_FieldList& fList);
The
first overload creates an APT_HashPartitioner object without specifying
any key fields. You must then use setKey() to specify key fields.The second form of the constructor creates an APT_HashPartitioner object using a list of key fields from the input interface schema for the operator. These fields can be any field type, including raw, date, and timestamp. APT_HashPartitioner determines the data type of each field from the input interface schema.
| Comment | Code |
|---|---|
|
|
- 9
- Use the default constructor to dynamically allocate an APT_HashPartitioner
object.
Partitioner objects must be dynamically allocated within describeOperator(). The framework deletes the partitioner for you when it is no longer needed.
You must call setKey() to specify the key fields for this APT_HashPartitioner object.
- 10
- Use APT_HashPartitioner::setKey() to specify field1 as a key field for this APT_HashPartitioner object.
Use setKey() to specify both a field name and a data type for the field. The order in which key fields are listed is unimportant.
- 11
- Specify field2 as a key field for this APT_HashPartitioner object.
- 12
- Use APT_Operator::setPartitionMethod() to specify hashPart as the partitioner for this operator. After calling this function,
do not delete the partitioner because the framework has claim to its
memory.
Because you do not need to use a view adapter with this partitioner, this function creates and passes a default view adapter.
An application developer using this operator can use adapters to translate the name of a data set field and its data type in the input data set schema to match the input interface schema. In the previous figure, the data set myDS is input to the sort operator. An application developer could translate field a and field b of myDS to field1 and field2 of the operator. Therefore, the hash partitioner would partition the record by fields a and b.