Help Center/
MapReduce Service/
Developer Guide (LTS)/
IoTDB Development Guide (Security Mode)/
Application IoTDB Development/
IoTDB UDF Sample Program
Updated on 2025-04-14 GMT+08:00
IoTDB UDF Sample Program
Description
This section describes how to implement a simple IoTDB user-defined function (UDF).
For details, see section UDF Sample Code and Operations.
Sample Code
The following is an example code snippet:
package com.huawei.bigdata.iotdb; import org.apache.iotdb.udf.api.UDTF; import org.apache.iotdb.udf.api.access.Row; import org.apache.iotdb.udf.api.collector.PointCollector; import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations; import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters; import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy; import org.apache.iotdb.udf.api.type.Type; import java.io.IOException; public class UDTFExample implements UDTF { @Override public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) { configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.INT32); } @Override public void transform(Row row, PointCollector collector) throws IOException { collector.putInt(row.getTime(), -row.getInt(0)); } }
Parent topic: Application IoTDB Development
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot