Interface Partitioner
-
- All Known Implementing Classes:
BasePartitioner
,ModPartitioner
public interface Partitioner
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 StepDialogInterface 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 step containing partitioning configuration is duplicated in Spoon. 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 Partitioner 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 both XML and a PDI repository. The interface methods are as follows.This method is called by PDI whenever the plugin needs to serialize its settings to XML. It is called when saving a transformation in Spoon. 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.pentaho.di.core.xml.XMLHandler is typically used to construct the XML string.
This method is called by PDI 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.pentaho.di.core.xml.XMLHandler is typically used to conveniently read the settings from the XML node.
This method is called by PDI whenever a plugin needs to save its settings to a PDI repository. The repository object passed in as the first argument provides a convenient set of methods for serializing settings. The transformation id and step id passed in should be used as identifiers when calling the repository serialization methods.
This method is called by PDI whenever a plugin needs to read its configuration from a PDI repository. The step id given in the arguments should be used as the identifier when using the repositories serialization methods.
- Provide access to dialog class PDI needs to know which class will take care of the settings dialog for the plugin. The interface method must return the name of the class implementing the StepDialogInterface for the partitioner.
- Partition incoming rows during runtime
The class implementing Partitioner 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 String getDialogClassName()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Partitioner
clone()
Clone.String
getDescription()
Gets the description.String
getDialogClassName()
Gets the dialog class name.String
getId()
Gets the id.Partitioner
getInstance()
Gets the single instance of Partitioner.int
getPartition(org.pentaho.di.core.row.RowMetaInterface rowMeta, Object[] r)
Gets the partition.String
getXML()
Gets the xml.void
loadRep(Repository rep, org.pentaho.di.repository.ObjectId id_step)
Load rep.void
loadXML(Node partitioningMethodNode)
Load xml.void
saveRep(Repository rep, org.pentaho.di.repository.ObjectId id_transformation, org.pentaho.di.repository.ObjectId id_step)
Saves partitioning properties in the repository for the given step.void
setDescription(String description)
Sets the description.void
setId(String id)
Sets the id.void
setMeta(StepPartitioningMeta meta)
Sets the meta.
-
-
-
Method Detail
-
getInstance
Partitioner getInstance()
Gets the single instance of Partitioner.- Returns:
- single instance of Partitioner
-
getPartition
int getPartition(org.pentaho.di.core.row.RowMetaInterface rowMeta, Object[] r) throws org.pentaho.di.core.exception.KettleException
Gets the partition.- Parameters:
rowMeta
- the row metar
- the r- Returns:
- the partition
- Throws:
org.pentaho.di.core.exception.KettleException
- the kettle exception
-
setMeta
void setMeta(StepPartitioningMeta 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
Partitioner clone()
Clone.- Returns:
- the partitioner
-
getXML
String getXML()
Gets the xml.- Returns:
- the xml
-
loadXML
void loadXML(Node partitioningMethodNode) throws org.pentaho.di.core.exception.KettleXMLException
Load xml.- Parameters:
partitioningMethodNode
- the partitioning method node- Throws:
org.pentaho.di.core.exception.KettleXMLException
- the kettle xml exception
-
saveRep
void saveRep(Repository rep, org.pentaho.di.repository.ObjectId id_transformation, org.pentaho.di.repository.ObjectId id_step) throws org.pentaho.di.core.exception.KettleException
Saves partitioning properties in the repository for the given step.- Parameters:
rep
- the repository to save inid_transformation
- the ID of the transformationid_step
- the ID of the step- Throws:
org.pentaho.di.core.exception.KettleException
- In case anything goes wrong
-
loadRep
void loadRep(Repository rep, org.pentaho.di.repository.ObjectId id_step) throws org.pentaho.di.core.exception.KettleException
Load rep.- Parameters:
rep
- the repid_step
- the id_step- Throws:
org.pentaho.di.core.exception.KettleException
- the kettle exception
-
-