Classes that Hold the Data to Retain Between Iterations - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

To enable Tbl.allocCtx() to serialize a class object into a binary stream and allocate storage for it, the class that the Java table UDF uses to hold the intermediate data must implement the java.io.Serializable interface. (The class must be serializable.) The size of the serialized binary stream determines the size of the allocated intermediate storage and it should be big enough to hold all the data of the object.

In Java, a serializable class overwrites the default methods writeObject(java.io.ObjectOutputStream out) and readObject(java.io.ObjectInputStream in) with its own customized implementation. An object of such a class automatically calls writeObject() during its serialization and readObject() during its deserialization.

If the object that the Java table UDF uses to hold intermediate data has object type fields, the UDF must initialize those fields to non-null values before calling Tbl.allocCtx(). One way to do this is to implement the writeObject() method to check the fields for nulls and initialize them if needed.

Similarly, if the object has array type fields, the UDF must initialize the array itself and each element of the array to non-null values before calling Tbl.allocCtx().