Interface IPartitioner

  • All Known Implementing Classes:
    BasePartitioner, ModPartitioner

    public interface IPartitioner
    Defines methods needed for partitioner plugins. The main responsibilities are:
    • Maintain partitioner settings
      The implementing class typically keeps track of partitioner settings using private fields with corresponding getters and setters. The dialog class implementing ITransformDialog is using the getters and setters to copy the user supplied configuration in and out of the dialog.

      The following interface method also falls into the area of maintaining settings:

      public Object clone()

      This method is called when a transform containing partitioning configuration is duplicated in HopGui. It needs to return a deep copy of this partitioner object. It is essential that the implementing class creates proper deep copies if the configuration is stored in modifiable objects, such as lists or custom helper objects. The copy is created by first calling super.clone(), and deep-copying any fields the partitioner may have declared.

      public IPartitioner getInstance()

      This method is required to return a new instance of the partitioner class, with the plugin id and plugin description inherited from the instance this function is called on.

    • Serialize partitioner settings
      The plugin needs to be able to serialize its settings to XML. The interface methods are as follows.

      public String getXml()

      This method is called by Apache Hop whenever the plugin needs to serialize its settings to XML. It is called when saving a pipeline in HopGui. The method returns an XML string, containing the serialized settings. The string contains a series of XML tags, typically one tag per setting. The helper class org.apache.hop.core.xml.XmlHandler is typically used to construct the XML string.

      public void loadXml(...)

      This method is called by Apache Hop whenever a plugin needs to read its settings from XML. The XML node containing the plugin's settings is passed in as an argument. Again, the helper class org.apache.hop.core.xml.XmlHandler is typically used to conveniently read the settings from the XML node.

      public String getDialogClassName()

    • Partition incoming rows during runtime
      The class implementing IPartitioner executes the actual logic that distributes the rows to available partitions.

      This method is called with the row structure and the actual row as arguments. It must return the partition this row will be sent to. The total number of partitions is available in the inherited field nrPartitions, and the return value must be between 0 and nrPartitions-1.

      public int getPartition(...)

    • Method Detail

      • getInstance

        IPartitioner getInstance()
        Gets the single instance of IPartitioner.
        Returns:
        single instance of IPartitioner
      • getPartition

        int getPartition​(IVariables variables,
                         IRowMeta rowMeta,
                         Object[] r)
                  throws HopException
        Gets the partition.
        Parameters:
        variables - the variables to resolve variable expressions with
        rowMeta - the row meta
        r - the r
        Returns:
        the partition
        Throws:
        HopException - the hop exception
      • getId

        String getId()
        Gets the id.
        Returns:
        the id
      • getDescription

        String getDescription()
        Gets the description.
        Returns:
        the description
      • setId

        void setId​(String id)
        Sets the id.
        Parameters:
        id - the new id
      • setDescription

        void setDescription​(String description)
        Sets the description.
        Parameters:
        description - the new description
      • getDialogClassName

        String getDialogClassName()
        Gets the dialog class name.
        Returns:
        the dialog class name
      • clone

        IPartitioner clone()
        Clone.
        Returns:
        the partitioner
      • getXml

        String getXml()
        Gets the xml.
        Returns:
        the xml
      • loadXml

        void loadXml​(Node partitioningMethodNode)
              throws HopXmlException
        Load xml.
        Parameters:
        partitioningMethodNode - the partitioning method node
        Throws:
        HopXmlException - the hop xml exception