docs: fix typos (#21503)

This commit is contained in:
Shuduo Sang 2023-05-27 19:28:47 +08:00 committed by GitHub
parent e31d9299cc
commit c91029f92f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 15 deletions

View File

@ -10,7 +10,7 @@ User-defined functions can be scalar functions or aggregate functions. Scalar fu
TDengine supports user-defined functions written in C or Python. This document describes the usage of user-defined functions. TDengine supports user-defined functions written in C or Python. This document describes the usage of user-defined functions.
## Implement a UDF in C ## Implement a UDF in C
When you create a user-defined function, you must implement standard interface functions: When you create a user-defined function, you must implement standard interface functions:
- For scalar functions, implement the `scalarfn` interface function. - For scalar functions, implement the `scalarfn` interface function.
@ -111,13 +111,13 @@ Interface functions return a value that indicates whether the operation was succ
For information about the parameters for interface functions, see Data Model For information about the parameters for interface functions, see Data Model
#### Scalar Interface #### Scalar Interface
`int32_t scalarfn(SUdfDataBlock* inputDataBlock, SUdfColumn *resultColumn)` `int32_t scalarfn(SUdfDataBlock* inputDataBlock, SUdfColumn *resultColumn)`
Replace `scalarfn` with the name of your function. This function performs scalar calculations on data blocks. You can configure a value through the parameters in the `resultColumn` structure. Replace `scalarfn` with the name of your function. This function performs scalar calculations on data blocks. You can configure a value through the parameters in the `resultColumn` structure.
The parameters in the function are defined as follows: The parameters in the function are defined as follows:
- inputDataBlock: The data block to input. - inputDataBlock: The data block to input.
- resultColumn: The column to output. The column to output. - resultColumn: The column to output. The column to output.
#### Aggregate Interface #### Aggregate Interface
@ -197,7 +197,7 @@ The data structure is described as follows:
- The SUdfDataBlock block includes the number of rows (numOfRows) and the number of columns (numCols). udfCols[i] (0 <= i <= numCols-1) indicates that each column is of type SUdfColumn. - The SUdfDataBlock block includes the number of rows (numOfRows) and the number of columns (numCols). udfCols[i] (0 <= i <= numCols-1) indicates that each column is of type SUdfColumn.
- SUdfColumn includes the definition of the data type of the column (colMeta) and the data in the column (colData). - SUdfColumn includes the definition of the data type of the column (colMeta) and the data in the column (colData).
- The member definitions of SUdfColumnMeta are the same as the data type definitions in `taos.h`. - The member definitions of SUdfColumnMeta are the same as the data type definitions in `taos.h`.
- The data in SUdfColumnData can become longer. varLenCol indicates variable-length data, and fixLenCol indicates fixed-length data. - The data in SUdfColumnData can become longer. varLenCol indicates variable-length data, and fixLenCol indicates fixed-length data.
- SUdfInterBuf defines the intermediate structure `buffer` and the number of results in the buffer `numOfResult`. - SUdfInterBuf defines the intermediate structure `buffer` and the number of results in the buffer `numOfResult`.
Additional functions are defined in `taosudf.h` to make it easier to work with these structures. Additional functions are defined in `taosudf.h` to make it easier to work with these structures.
@ -285,9 +285,9 @@ def init():
def destroy(): def destroy():
# destroy # destroy
def process(input: datablock) -> tuple[output_type]: def process(input: datablock) -> tuple[output_type]:
# process input datablock, # process input datablock,
# datablock.data(row, col) is to access the python object in location(row,col) # datablock.data(row, col) is to access the python object in location(row,col)
# return tuple object consisted of object of type outputtype # return tuple object consisted of object of type outputtype
``` ```
### Implement an Aggregate UDF in Python ### Implement an Aggregate UDF in Python
@ -303,12 +303,12 @@ def start() -> bytes:
#return serialize(init_state) #return serialize(init_state)
def reduce(inputs: datablock, buf: bytes) -> bytes def reduce(inputs: datablock, buf: bytes) -> bytes
# deserialize buf to state # deserialize buf to state
# reduce the inputs and state into new_state. # reduce the inputs and state into new_state.
# use inputs.data(i,j) to access python ojbect of location(i,j) # use inputs.data(i,j) to access python object of location(i,j)
# serialize new_state into new_state_bytes # serialize new_state into new_state_bytes
return new_state_bytes return new_state_bytes
def finish(buf: bytes) -> output_type: def finish(buf: bytes) -> output_type:
#return obj of type outputtype #return obj of type outputtype
``` ```
### Python UDF Interface Definition ### Python UDF Interface Definition
@ -328,7 +328,7 @@ def finish(buf: bytes) -> output_type:
``` ```
- first `start()` is called to return the initial result in type `bytes` - first `start()` is called to return the initial result in type `bytes`
- then the input data are divided into multiple data blocks and for each block `input`, `reduce` is called with the data block `input` and the current result `buf` bytes and generates a new intermediate result buffer. - then the input data are divided into multiple data blocks and for each block `input`, `reduce` is called with the data block `input` and the current result `buf` bytes and generates a new intermediate result buffer.
- finally, the `finish` function is called on the intermediate result `buf` and outputs 0 or 1 data of type `output_type` - finally, the `finish` function is called on the intermediate result `buf` and outputs 0 or 1 data of type `output_type`
@ -337,7 +337,7 @@ def finish(buf: bytes) -> output_type:
def init() def init()
def destroy() def destroy()
``` ```
Implement `init` for initialization and `destroy` for termination. Implement `init` for initialization and `destroy` for termination.
### Data Mapping between TDengine SQL and Python UDF ### Data Mapping between TDengine SQL and Python UDF
@ -360,7 +360,7 @@ sudo pip install taospyudf
ldconfig ldconfig
``` ```
2. If PYTHONPATH is needed to find Python packages when the Python UDF executes, include the PYTHONPATH contents into the udfdLdLibPath variable of the taos.cfg configuration file 2. If PYTHONPATH is needed to find Python packages when the Python UDF executes, include the PYTHONPATH contents into the udfdLdLibPath variable of the taos.cfg configuration file
### Python UDF Sample Code ### Python UDF Sample Code
#### Scalar Function [pybitand](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/pybitand.py) #### Scalar Function [pybitand](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/pybitand.py)

View File

@ -111,7 +111,7 @@ The parameters described in this document by the effect that they have on the sy
| Attribute | Description | | Attribute | Description |
| ------------- | ---------------------------------------------- | | ------------- | ---------------------------------------------- |
| Applicable | Client/Server | | Applicable | Client/Server |
| Meaning | The maximum waiting time to get avaliable conn | | Meaning | The maximum waiting time to get available conn |
| Value Range | 10-50000000(ms) | | Value Range | 10-50000000(ms) |
| Default Value | 500000 | | Default Value | 500000 |