User Defined Function/Operation Assembly (

) processes data using Java-based functions defined by the user.
This assembly processes one input record at a time and can emit zero, one, or multiple output records.
It is typically used when built-in transformation functions are not sufficient and custom processing logic is required.
Parameters of User Defined Function / Operation
- UDF Function-class
Java class that extends com.solusi247.function.Function247
- Parameter
Parameter value passed to the UDF class
- Output Fields
List of output field names and their data types
Creating a User Defined Function / Operation
A User Defined Function / Operation is created by:
- Creating a Java class that extends com.solusi247.function.Function247
- Implementing the following abstract method:
void operate(List<Comparable> record)
This method is executed once for every input record.
Methods of com.solusi247.function.Function247
The class com.solusi247.function.Function247 provides the following methods:
- public abstract void operate(List<Comparable> record)
Called for every incoming record.
Contains the core processing logic.
- public String getParameter()
this method returns the received parameter
- public void prepare()
Called after the UDF object is created.
Used for initialization logic.
- public void cleanup()
Called after all records have been processed.
Used for cleanup or resource release.
- public final void addToOutputCollector(List<Comparable> record)
Emits a record to the output stream.
- public List<String> getIncomingFields()
Returns the list of field names from the incoming record.
Example: Java-Based User Defined Function / Operation
Reverse a Specific Field in a Record
package plugins.function;
import com.solusi247.function.Function247;
import java.util.ArrayList;
import java.util.List;
public class Reverse extends Function247{
@Override
public void operate(List<Comparable> record) {
ArrayList<Comparable> list_out=new ArrayList<>();
for (int i=0; i<list.size(); i++){
if (i==5){
StringBuilder sb=new StringBuilder(record.get(i).toString());
list_out.add(sb.reverse().toString());
}else{
list_out.add(list.get(i));
}
}
this.addToOutputCollector(list_out);
}
}
Explanation of the Example
- The input record is received as List<Comparable>
- The field at index 5 is reversed
- All other fields remain unchanged
- The transformed record is emitted using addToOutputCollector()
Deploying the UDF in HGrid247
To make the UDF appear in the HGrid247-3.5 GUI:
Required Dependency
Java-based plug-ins require the following library:
libCommon/HGrid247CommonLib-3.5.jar
Summary
The User Defined Function / Operation Assembly enables developers to:
- Implement advanced or proprietary logic
- Process records programmatically using Java
- Extend the platform beyond built-in assembly
This assembly provides maximum flexibility and is ideal for complex data processing requirements.
Supported Engines
Map Reduce |
Spark 1.x RDD |
Spark 2.x RDD |
Spark 2.x Dataset |
Apache Beam 2.29.0 Batch |
Apache Beam 2.29.0 Streaming |
Apache Flink 1.12.0 Batch |
Apache Flink 1.12.0 Streaming |
Apache Tez 0.9.1 |
PySpark |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |