Sample Files

Sample table UDF files are installed with the server. Use the samples as models when defining your own table UDFs.

Sample files are located in:
File Description
apache_log_reader.cxx

Implementation of a table UDF that reads an Apache log file and presents the rows from the file in table format. This UDF illustrates a real-world example of how you can use a UDF to make computer-generated data available to a SQL query writer in real time.

build.sh / build.bat Script that compiles and links the sample scalar and aggregate UDFs, table UDFs, and TPFs found in the samples/udf directory.
my_md5.cxx

A simple deterministic scalar UDF that calculates the MD5 hash value of an input file (a LOB binary argument).

tpf_agg.cxx

Consumes rows from an input table, performs an aggregation on the input data, and returns rows back to the server.

tpf_blob.cxx

Implementation of a TPF that reads LOB data from an input table and passes the data to the result set, if an even number of the specified character or digit is present. This TPF illustrates how to read LOB data and how a user can pass LOB datatypes through to the result set.

tpf_dt.cxx  
tpf_filt.cxx

Illustrates how a TPF can be used to filter rows. The example uses the row block provided by caller and passes it to the input TABLE parameter. The input table schema must match the output result set of this function.

tpf_oby.cxx

Illustrates how a TPF can generate ordered output and pass it along.

tpf_pby.cxx

Illustrates how a TPF can generate partitioned output and pass it along.

tpf_rg_1.cxx

Similar to the table UDF sample udf_rg_2.cxx. It produces rows of data based on an input parameter.

tpf_rg_2.cxx

Builds upon the sample in tpf_rg_1.cxx, but uses fetch_into instead of fetch_block to read rows from the input table.

udf_main.cxx

This file is linked into all of the examples and includes a common set of required entry points for the v4 API. This allows you to reuse the code rather than including it in each example.

udf_rg_1.cxx

A simple table UDF that generates rows of integer data.

udf_rg_2.cxx

A simple table UDF that generates rows of integer data that uses describes to ensure the schema defined in SQL matches the UDF's implementation. It also describes some optimizer attributes.

udf_rg_3.cxx

A simple table UDF that generates integer data in blocks of 100 using the _fetch_block fetch method.

udf_utils.cxx

A set of utility functions and macros that are useful to UDF/TPF developers. The examples rely on items in this file.

udf_utils.h

A set of utility functions and macros that are useful to UDF/TPF developers. The examples rely on items in this file.