Class FastRenameField
java.lang.Object
com.northconcepts.datapipeline.transform.Transformer
com.northconcepts.datapipeline.transform.FastRenameField
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 Summary
ConstructorsConstructorDescriptionFastRenameField(Integer oldIndex, String newName) Creates a transformer that renames the field at the given 0-based position.FastRenameField(String oldName, String newName) Creates a transformer that renames the field namedoldName; its position is looked up in the first record and reused for all later records. -
Method Summary
Modifier and TypeMethodDescriptionReturns the 0-based position of the field to rename; when renaming by name it is null until the first record is transformed.Returns the name of the field to rename or null if it is identified by position.protected voidopen()Called byTransformingReaderorTransformingWriterwhen theiropen()method is called (before reading or writing starts).toString()booleanApplies this transformer to a record on its way through aTransformingReaderorTransformingWriter.Methods inherited from class com.northconcepts.datapipeline.transform.Transformer
addExceptionProperties, close, geEndpoint, getEndpoint, getReader, getWriter, of, setWriter
-
Constructor Details
-
FastRenameField
Creates a transformer that renames the field namedoldName; its position is looked up in the first record and reused for all later records. -
FastRenameField
Creates a transformer that renames the field at the given 0-based position.
-
-
Method Details
-
getOldName
Returns the name of the field to rename or null if it is identified by position. -
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
-
open
protected void open()Description copied from class:TransformerCalled byTransformingReaderorTransformingWriterwhen theiropen()method is called (before reading or writing starts).- Overrides:
openin classTransformer
-
transform
Description copied from class:TransformerApplies this transformer to a record on its way through aTransformingReaderorTransformingWriter.Contract for subclasses (see also
docs/authoring/Transformer.md):- Mutate
recordin place as needed. - Return
trueto keep the record in the pipeline. - Return
falseto 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:
transformin classTransformer- Throws:
Throwable
- Mutate
-
toString
-