Class FastRenameField

java.lang.Object
com.northconcepts.datapipeline.transform.Transformer
com.northconcepts.datapipeline.transform.FastRenameField

public class FastRenameField extends Transformer
An performant alternative to RenameField that assumes 1) a flat table structure (no nested fields or arrays), 2) columns are always in the same position from row to row 3) no missing fields (nulls field values are okay), and 4) the target name does not already exist (otherwise there will be two fields with the same name).
  • Constructor Details

    • FastRenameField

      public FastRenameField(String oldName, String newName)
      Creates a transformer that renames the field named oldName; its position is looked up in the first record and reused for all later records.
    • FastRenameField

      public FastRenameField(Integer oldIndex, String newName)
      Creates a transformer that renames the field at the given 0-based position.
  • Method Details

    • getOldName

      public String getOldName()
      Returns the name of the field to rename or null if it is identified by position.
    • getOldIndex

      public Integer getOldIndex()
      Returns the 0-based position of the field to rename; when renaming by name it is null until the first record is transformed.
    • getNewName

      public String getNewName()
    • open

      protected void open()
      Description copied from class: Transformer
      Called by TransformingReader or TransformingWriter when their open() method is called (before reading or writing starts).
      Overrides:
      open in class Transformer
    • transform

      public boolean transform(Record record) throws Throwable
      Description copied from class: Transformer
      Applies this transformer to a record on its way through a TransformingReader or TransformingWriter.

      Contract for subclasses (see also docs/authoring/Transformer.md):

      • Mutate record in place as needed.
      • Return true to keep the record in the pipeline.
      • Return false to drop the record (the host routes it to a discard writer if one is configured, otherwise it disappears).
      • Throw to fail (or route to a discard writer, depending on host configuration).
      • Do not call incrementRecordCount() on the host endpoint; the host handles it.
      Specified by:
      transform in class Transformer
      Throws:
      Throwable
    • toString

      public String toString()
      Overrides:
      toString in class Object