Classes that Hold the Data to Retain Between Iterations - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
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().