All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pentaho.di.trans.Partitioner Maven / Gradle / Ivy

The newest version!
/*! ******************************************************************************
 *
 * Pentaho Data Integration
 *
 * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

package org.pentaho.di.trans;

import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.exception.KettleXMLException;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.repository.ObjectId;
import org.pentaho.di.repository.Repository;
import org.pentaho.di.trans.step.StepPartitioningMeta;
import org.w3c.dom.Node;

/**
 * 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: *

    * public Object clone() *

    * 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. *

    * public String getXML() *

    * 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. *

    * public void loadXML(...) *

    * 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. *

    * public void saveRep(...) *

    * 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. *

    * public void * loadRep(...) *

    * 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. *

    * public String getDialogClassName() *

  • 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 int getPartition(...)

  • *
*/ public interface Partitioner { /** * Gets the single instance of Partitioner. * * @return single instance of Partitioner */ public abstract Partitioner getInstance(); /** * Gets the partition. * * @param rowMeta * the row meta * @param r * the r * @return the partition * @throws KettleException * the kettle exception */ public int getPartition( RowMetaInterface rowMeta, Object[] r ) throws KettleException; /** * Sets the meta. * * @param meta * the new meta */ public void setMeta( StepPartitioningMeta meta ); /** * Gets the id. * * @return the id */ public String getId(); /** * Gets the description. * * @return the description */ public String getDescription(); /** * Sets the id. * * @param id * the new id */ public void setId( String id ); /** * Sets the description. * * @param description * the new description */ public void setDescription( String description ); /** * Gets the dialog class name. * * @return the dialog class name */ public String getDialogClassName(); /** * Clone. * * @return the partitioner */ public Partitioner clone(); /** * Gets the xml. * * @return the xml */ public String getXML(); /** * Load xml. * * @param partitioningMethodNode * the partitioning method node * @throws KettleXMLException * the kettle xml exception */ public void loadXML( Node partitioningMethodNode ) throws KettleXMLException; /** * Saves partitioning properties in the repository for the given step. * * @param rep * the repository to save in * @param id_transformation * the ID of the transformation * @param id_step * the ID of the step * @throws KettleException * In case anything goes wrong */ public void saveRep( Repository rep, ObjectId id_transformation, ObjectId id_step ) throws KettleException; /** * Load rep. * * @param rep * the rep * @param id_step * the id_step * @throws KettleException * the kettle exception */ public void loadRep( Repository rep, ObjectId id_step ) throws KettleException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy