Adding a JSON File to a Function Archive | Teradata Vantage - Adding a JSON File to a Function Archive - Teradata Vantage

Machine Learning User Guide

Product
Teradata Vantage
Release Number
9.01
1.3
Published
August 2020
Language
English (United States)
Last Update
2020-10-02
dita:mapPath
dci1595445931473.ditamap
dita:ditavalPath
dqp1599597541027.ditaval
dita:id
B700-4004
lifecycle
previous
Product Category
Teradata Vantageā„¢
To add a JSON file into a function archive, provide the JSON file as part of the build process to be included in the function archive. If you already have an archive file, you can add the JSON file into the archive zip or jar file using the Java Archive (jar) tool and zip utility. The following example shows the step-by-step process of adding a JSON file, DTW.json, into a function zip file, DTW.zip, on a Linux-based system. If your function archive is a jar file into which you want to add the JSON file, you need only steps 4 through 8.
  1. Verify the contents of DTW.zip:
    $ jar tf DTW.zip
    DTW.jar
    FastDTW-1.1.0 jar
    sql-mr_utilities.jar
  2. Unzip DTW.zip to extract the three jar files listed in the previous step:
    $ unzip DTW.zip
    Archive:  DTW.zip
      inflating: DTW.jar
      inflating: FastDTW-1.1.0.jar 
      inflating: sql-mr_utilities.jar
  3. Verify the contents of DTW.jar to which you want to add DTW.json:
    $ jar tf DTW.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/asterdata/
    com/asterdata/sqlmr/
    com/asterdata/sqlmr/functions/
    com/asterdata/sqlmr/functions/analytics/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/DTW.class
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/DTWArgs.class
  4. Extract DTW.jar and list the directory:
    $ jar xf DTW.jar
    The jar file gives you compiled code in a directory structure (which in this example is under com/) and a manifest directory under META-INF/.
    $ ls com DTW.jar DTW.json DTW.zip FastDTW-1.1.0.jar META-INF sql-mr_utilities.jar
  5. Delete the DTW.jar and DTW.zip files (because you will create new jar and zip files):
    $ rm DTW.jar
    $ rm DTW.zip
  6. Delete the META-INF directory (because the jar tool generates it when you create a jar file):
    $ rm -r META-INF/
  7. Copy DTW.json into the source code directory structure at the same sub-directory level where the function class resides:
    $ cp DTW.json com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/
  8. Create a new archive DTW.jar file from the source code:
    $ jar cf DTW.jar com/
  9. Verify that the contents of the jar file match the contents of the old jar file, except the JSON file:
    $ jar tf DTW.jar
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/asterdata/
    com/asterdata/sqlmr/
    com/asterdata/sqlmr/functions/
    com/asterdata/sqlmr/functions/analytics/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/DTW.class
    com/asterdata/sqlmr/functions/analytics/timeseries_analysis/dynamic_time_warping/DTWArgs.class
  10. Create a new zip file from the newly created DTW.jar and other libraries in the zip file:
    $ zip -r DTW.zip DTW.jar FastDTW-1.1.0.jar sql-mr_utilities.jar
    adding: DTW.jar (deflated 11%)
      adding: FastDTW-1.1.0.jar (deflated 8%)
      adding: sql-mr_utilities.jar (deflated 11%)
    
  11. Verify the contents of DTW.zip:
    $ jar tf DTW.zip
    DTW.jar
    FastDTW-1.1.0.jar
    sql-mr_utilities.jar
    The archive file DTW.zip is ready to be installed on ML Engine.