Interface IPartitioner
-
- All Known Implementing Classes:
BasePartitioner,ModPartitioner
public interface IPartitionerDefines 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:
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.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.
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.
- 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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IPartitionerclone()Clone.StringgetDescription()Gets the description.StringgetDialogClassName()Gets the dialog class name.StringgetId()Gets the id.IPartitionergetInstance()Gets the single instance of IPartitioner.intgetPartition(IVariables variables, IRowMeta rowMeta, Object[] r)Gets the partition.StringgetXml()Gets the xml.voidloadXml(Node partitioningMethodNode)Load xml.voidsetDescription(String description)Sets the description.voidsetId(String id)Sets the id.voidsetMeta(TransformPartitioningMeta meta)Sets the meta.
-
-
-
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 withrowMeta- the row metar- the r- Returns:
- the partition
- Throws:
HopException- the hop exception
-
setMeta
void setMeta(TransformPartitioningMeta meta)
Sets the meta.- Parameters:
meta- the new meta
-
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
-
-