Using a Groovy Script MapReduce Job
-
Create an instance of
DataIntegrationFactory
by using its static methodgetInstance()
. -
Provide the input and output details for the GroovyScript job by creating an
instance of
CustomGroovyScriptDetail
specifying theProcessType
. The instance must use the type MRProcessType. Use these steps to create and configure theCustomGroovyScriptDetail
instance.-
Create an instance of
CustomGroovyScriptDetail
by specifying theProcessType
as MRProcessType. To this instance, set these details:- Input file: Use the
inputPath
fieldNote: For a text input file, create an instance ofFilePath
with the relevant details of the input file by invoking the appropriate constructor. For an ORC input file, create an instance ofOrcFilePath
with the path of the ORC input file as the argument. - Output file: Use the
outputPath
fieldNote: For a text output file, create an instance ofFilePath
with the relevant details of the output file by invoking the appropriate constructor. For an ORC output file, create an instance ofOrcFilePath
with the path of the ORC output file as the argument. - Name of the job: Use the
jobName
field - Date pattern:
M/d/yy
- Date-time pattern:
M/d/yy h:mm a
- Time pattern:
h:mm a
- Input file: Use the
-
Create an instance of
CustomGroovyScriptConfiguration
and set these details to it:- The groovyScriptFile
- InputFields
- OutputFields
-
Create a
configuration
by using thegetScriptTransformerConfiguration()
method, which calls the list ofCustomGroovyScriptConfiguration
instances created and configured above.
-
Create an instance of
-
To create a MapReduce job, use the previously created instance of
DataIntegrationFactory
to invoke its methodcreateJob()
. In this, pass the above instance ofCustomGroovyScriptDetail
as an argument.ThecreateJob()
method creates the job and returns aList
of instances ofControlledJob
. -
Run the created job using an instance of
JobControl
.