Structure of your Java program

Your Java™ program must implement a subclass of the Stage class. The Stage class consists of methods for manipulating rows and querying metadata.

The Stage class is the root of all classes that implement a Java Client or Java Transformer stage in your jobs.

  • Initialization is achieved by overriding the Stage.initialize() method. This is optional.
  • Processing is achieved by overriding the Stage.process() method.
  • Termination is achieved by overriding the Stage.terminate() method. This is optional.

The following example shows the skeleton of a simple program. In a single call of the process() method, one input row is consumed and processed, and one output row is produced.

public class Mytransformer extends Stage
{
   public void initialize()
      {
         //          ...initialize logic
      }
   public void terminate()
      {
         //         ...terminate logic
      }
   public int process()
      {
         Row inputRow = readRow();
         //         ...process input row...
         Row outputRow = createOutputRow();
         //         ...fill output row...
         writeRow(outputRow);
         return OUTPUT_STATUS_READY;
      }
}