The connectors for go & Grafana and some tools have been moved to separated repositories,
The connectors for go & Grafana and some tools have been moved to separated repositories.
so you should run this command in the TDengine directory to install them:
```bash
git submodule update --init--recursive
```
You can modify the file ~/.gitconfig to use ssh protocol instead of https for better download speed. You need to upload ssh public key to GitHub first. Please refer to GitHub official documentation for detail.
You can modify the file ~/.gitconfig to use ssh protocol instead of https for better download speed. You need to upload ssh public key to GitHub first. Please refer to GitHub official documentation for detail.
...
@@ -191,7 +186,6 @@ You can run the bash script `build.sh` to build both TDengine and taosTools incl
...
@@ -191,7 +186,6 @@ You can run the bash script `build.sh` to build both TDengine and taosTools incl
// initialization function. if no initialization, we can skip definition of it. The initialization function shall be concatenation of the udf name and _init suffix
// @return error number defined in taoserror.h
int32_tscalarfn_init(){
// initialization.
returnTSDB_CODE_SUCCESS;
}
// scalar function main computation function
// @param inputDataBlock, input data block composed of multiple columns with each column defined by SUdfColumn
// read data from inputDataBlock and process, then output to resultColumn.
returnTSDB_CODE_SUCCESS;
}
// cleanup function. if no cleanup related processing, we can skip definition of it. The destroy function shall be concatenation of the udf name and _destroy suffix.
// @return error number defined in taoserror.h
int32_tscalarfn_destroy(){
// clean up
returnTSDB_CODE_SUCCESS;
}
```
scalarfn 为函数名的占位符,需要替换成函数名,如bit_and。
## 实现聚合函数
聚合函数的实现模板如下
```c
#include "taos.h"
#include "taoserror.h"
#include "taosudf.h"
// Initialization function. if no initialization, we can skip definition of it. The initialization function shall be concatenation of the udf name and _init suffix
// @return error number defined in taoserror.h
int32_taggfn_init(){
// initialization.
returnTSDB_CODE_SUCCESS;
}
// aggregate start function. The intermediate value or the state(@interBuf) is initialized in this function. The function name shall be concatenation of udf name and _start suffix
// @param interbuf intermediate value to intialize
// @return error number defined in taoserror.h
int32_taggfn_start(SUdfInterBuf*interBuf){
// initialize intermediate value in interBuf
returnTSDB_CODE_SUCESS;
}
// aggregate reduce function. This function aggregate old state(@interbuf) and one data bock(inputBlock) and output a new state(@newInterBuf).
// read from inputBlock and interBuf and output to newInterBuf
returnTSDB_CODE_SUCCESS;
}
// aggregate function finish function. This function transforms the intermediate value(@interBuf) into the final output(@result). The function name must be concatenation of aggfn and _finish suffix.
// read data from inputDataBlock and process, then output to result
returnTSDB_CODE_SUCCESS;
}
// cleanup function. if no cleanup related processing, we can skip definition of it. The destroy function shall be concatenation of the udf name and _destroy suffix.