2.3.31 The PartitionSpec Structure

Abstract

This section describes the PartitionSpec structure.

Parent class.  Ndb

Description.  PartitionSpec is a structure available in MySQL Cluster NDB 6.3.24 and later. A given PartitionSpec is used for describing a table partition in terms of any one of the following criteria:

Attributes.  A PartitionSpec has two attributes, a SpecType and a Spec which is a data structure corresponding to that SpecType, as shown in the following table:

SpecType EnumerationSpecType Value (Uint32)Data StructureDescription
PS_NONE0noneNo partitioning information is provided.
PS_USER_DEFINED1UserDefinedFor a table having user-defined partitioning, a specific partition is identified by its partition ID.
PS_DISTR_KEY_PART_PTR2KeyPartPtrFor a table having native partitioning, an array containing the table's distribution key values is used to identify the partition.
(MySQL Cluster NDB 7.0.4 and later:) PS_DISTR_KEY_RECORD3KeyRecordThe partition is identified using a natively partitioned table's distribution key values, as contained in a row given in NdbRecord format.

UserDefined structure.  This structure is used when the SpecType is PS_USER_DEFINED.

AttributeTypeDescription
partitionIdUint32The partition ID for the desired table.

KeyPartPtr structure.  This structure is used when the SpecType is PS_DISTR_KEY_PART_PTR.

AttributeTypeDescription
tableKeyPartsKey_part_ptrPointer to the distribution key values for a table having native partitioning.
xfrmbufvoid*Pointer to a temporary buffer used for performing calculations.
xfrmbuflenUint32Length of the temporary buffer.

KeyRecord structure.  (MySQL Cluster NDB 7.0.4 and later:) This structure is used when the SpecType is PS_DISTR_KEY_RECORD.

AttributeTypeDescription
keyRecordNdbRecordA row in NdbRecord format, containing a table's distribution keys.
keyRowconst char*The distribution key data.
xfrmbufvoid*Pointer to a temporary buffer used for performing calculations.
xfrmbuflenUint32Length of the temporary buffer.

Definition from Ndb.hpp Because this is a fairly complex structure, we here provide the original source-code definition of PartitionSpec, as given in storage/ndb/include/ndbapi/Ndb.hpp:

struct PartitionSpec
{
  enum SpecType
  {
    PS_NONE                = 0,
    PS_USER_DEFINED        = 1,
    PS_DISTR_KEY_PART_PTR  = 2

    /* MySQL Cluster NDB 7.0.4 and later: */
                              ,
    PS_DISTR_KEY_RECORD    = 3
  };

  Uint32 type;

  union
  {
    struct {
      Uint32 partitionId;
    } UserDefined;

    struct {
      const Key_part_ptr* tableKeyParts;
      void* xfrmbuf;
      Uint32 xfrmbuflen;
    } KeyPartPtr;

    /* MySQL Cluster NDB 7.0.4 and later: */

    struct {
      const NdbRecord* keyRecord;
      const char* keyRow;
      void* xfrmbuf;
      Uint32 xfrmbuflen;
    } KeyRecord;
  };
};